diff --git a/binaries/aarch64/tpws b/binaries/aarch64/tpws index 521c6de..e9e6d49 100755 Binary files a/binaries/aarch64/tpws and b/binaries/aarch64/tpws differ diff --git a/binaries/arm/tpws b/binaries/arm/tpws index 86ec918..bb33839 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 cf587d9..f5b1297 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 a556014..da1ec64 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 c17a507..4f69718 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 145e7de..473b121 100755 Binary files a/binaries/ppc/tpws and b/binaries/ppc/tpws differ diff --git a/binaries/x86/tpws b/binaries/x86/tpws index 6d13951..cea40a9 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 0ca7eb9..f001a7b 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 a84eb17..6cbf857 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 18c34af..eb2936e 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 4bd1091..5e15d74 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);