Skip to content

Commit

Permalink
fprint2
Browse files Browse the repository at this point in the history
  • Loading branch information
laduke committed Mar 14, 2024
1 parent 5eb6c0d commit 223061c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions node/InetAddress.cpp
Expand Up @@ -28,10 +28,13 @@ const InetAddress InetAddress::LO6((const void *)("\x00\x00\x00\x00\x00\x00\x00\

InetAddress::IpScope InetAddress::ipScope() const
{
char buf[255];
fprintf(stderr, "scope for %s \t", this->toString(buf));
switch(ss_family) {

case AF_INET: {
const uint32_t ip = Utils::ntoh((uint32_t)reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr);
fprintf(stderr, "AF_INET\n");
switch(ip >> 24) {
case 0x00:
return IP_SCOPE_NONE; // 0.0.0.0/8 (reserved, never used)
Expand Down Expand Up @@ -112,6 +115,7 @@ InetAddress::IpScope InetAddress::ipScope() const
} break;

case AF_INET6: {
fprintf(stderr, "AF_INET6\n");
const unsigned char *ip = reinterpret_cast<const unsigned char *>(reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr);
if ((ip[0] & 0xf0) == 0xf0) {
if (ip[0] == 0xff) {
Expand Down
2 changes: 1 addition & 1 deletion service/OneService.cpp
Expand Up @@ -1698,7 +1698,7 @@ class OneServiceImpl : public OneService
bool isAuth = false;
// If localhost, allow
char buf[255];
fprintf(stderr, "remote Addr: %s\n", remoteAddr.toIpString(buf));
fprintf(stderr, "scope: %d, remote Addr: %s\n", remoteAddr.ipScope(),remoteAddr.toIpString(buf));
if (remoteAddr.ipScope() == InetAddress::IP_SCOPE_LOOPBACK) {
ipAllowed = true;
}
Expand Down

0 comments on commit 223061c

Please sign in to comment.