diff --git a/binaries/aarch64/tpws b/binaries/aarch64/tpws index 61209ec..521c6de 100755 Binary files a/binaries/aarch64/tpws and b/binaries/aarch64/tpws differ diff --git a/binaries/arm/tpws b/binaries/arm/tpws index 2e1a020..86ec918 100755 Binary files a/binaries/arm/tpws and b/binaries/arm/tpws differ diff --git a/binaries/mips32r1-lsb/tpws b/binaries/mips32r1-lsb/tpws index 2f3c4ae..cf587d9 100755 Binary files a/binaries/mips32r1-lsb/tpws and b/binaries/mips32r1-lsb/tpws differ diff --git a/binaries/mips32r1-msb/tpws b/binaries/mips32r1-msb/tpws index bcef5b6..a556014 100755 Binary files a/binaries/mips32r1-msb/tpws and b/binaries/mips32r1-msb/tpws differ diff --git a/binaries/mips64r2-msb/tpws b/binaries/mips64r2-msb/tpws index 84e5c2a..c17a507 100755 Binary files a/binaries/mips64r2-msb/tpws and b/binaries/mips64r2-msb/tpws differ diff --git a/binaries/ppc/tpws b/binaries/ppc/tpws index 9ccd3a3..145e7de 100755 Binary files a/binaries/ppc/tpws and b/binaries/ppc/tpws differ diff --git a/binaries/x86/tpws b/binaries/x86/tpws index 4cf32a9..6d13951 100755 Binary files a/binaries/x86/tpws and b/binaries/x86/tpws differ diff --git a/binaries/x86_64/tpws b/binaries/x86_64/tpws index 56637ac..0ca7eb9 100755 Binary files a/binaries/x86_64/tpws and b/binaries/x86_64/tpws differ diff --git a/binaries/x86_64/tpws_wsl.tgz b/binaries/x86_64/tpws_wsl.tgz index f5d5298..a84eb17 100644 Binary files a/binaries/x86_64/tpws_wsl.tgz and b/binaries/x86_64/tpws_wsl.tgz differ diff --git a/tpws/helpers.c b/tpws/helpers.c index c034fa6..18c34af 100644 --- a/tpws/helpers.c +++ b/tpws/helpers.c @@ -75,7 +75,10 @@ void print_sockaddr(const struct sockaddr *sa) bool check_local_ip(const struct sockaddr *saddr) { struct ifaddrs *addrs,*a; - + + if (saddr->sa_family==AF_INET && is_localnet((struct sockaddr_in *)saddr)) + return true; + if (getifaddrs(&addrs)<0) return false; a = addrs; @@ -150,7 +153,11 @@ bool saconvmapped(struct sockaddr_storage *a) return false; } -bool is_linklocal(const struct sockaddr_in6* a) +bool is_localnet(const struct sockaddr_in *a) +{ + return (htonl(a->sin_addr.s_addr)>>24)==127; +} +bool is_linklocal(const struct sockaddr_in6 *a) { // fe80::/10 return a->sin6_addr.s6_addr[0]==0xFE && (a->sin6_addr.s6_addr[1] & 0xC0)==0x80; diff --git a/tpws/helpers.h b/tpws/helpers.h index bbe323d..4bd1091 100644 --- a/tpws/helpers.h +++ b/tpws/helpers.h @@ -21,6 +21,7 @@ uint16_t saport(const struct sockaddr *sa); // true = was converted bool saconvmapped(struct sockaddr_storage *a); +bool is_localnet(const struct sockaddr_in *a); bool is_linklocal(const struct sockaddr_in6* a); bool is_private6(const struct sockaddr_in6* a);