diff --git a/binaries/aarch64/tpws b/binaries/aarch64/tpws index 521c6de7..e9e6d498 100755 Binary files a/binaries/aarch64/tpws and b/binaries/aarch64/tpws differ diff --git a/binaries/arm/tpws b/binaries/arm/tpws index 86ec9187..bb33839c 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 cf587d9c..f5b1297d 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 a5560145..da1ec648 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 c17a507a..4f697180 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 145e7dee..473b1212 100755 Binary files a/binaries/ppc/tpws and b/binaries/ppc/tpws differ diff --git a/binaries/x86/tpws b/binaries/x86/tpws index 6d139519..cea40a96 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 0ca7eb9e..f001a7b4 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 a84eb178..6cbf8574 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 18c34af9..eb2936e1 100644 --- a/tpws/helpers.c +++ b/tpws/helpers.c @@ -76,7 +76,7 @@ bool check_local_ip(const struct sockaddr *saddr) { struct ifaddrs *addrs,*a; - if (saddr->sa_family==AF_INET && is_localnet((struct sockaddr_in *)saddr)) + if (is_localnet(saddr)) return true; if (getifaddrs(&addrs)<0) return false; @@ -153,9 +153,10 @@ bool saconvmapped(struct sockaddr_storage *a) return false; } -bool is_localnet(const struct sockaddr_in *a) +bool is_localnet(const struct sockaddr *a) { - return (htonl(a->sin_addr.s_addr)>>24)==127; + return a->sa_family==AF_INET && *(char*)&((struct sockaddr_in *)a)->sin_addr.s_addr==127 || + a->sa_family==AF_INET6 && saismapped((struct sockaddr_in6 *)a) && ((struct sockaddr_in6 *)a)->sin6_addr.s6_addr[12]==127; } bool is_linklocal(const struct sockaddr_in6 *a) { diff --git a/tpws/helpers.h b/tpws/helpers.h index 4bd10914..5e15d746 100644 --- a/tpws/helpers.h +++ b/tpws/helpers.h @@ -21,7 +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_localnet(const struct sockaddr *a); bool is_linklocal(const struct sockaddr_in6* a); bool is_private6(const struct sockaddr_in6* a);