From 1f46e913421bd1b5cba59db21a4628566b8853fa Mon Sep 17 00:00:00 2001 From: bol-van Date: Fri, 2 Jan 2026 22:12:20 +0300 Subject: [PATCH 1/5] blockcheck: fix tpws test regression --- blockcheck.sh | 5 +++++ docs/changes.txt | 1 + 2 files changed, 6 insertions(+) diff --git a/blockcheck.sh b/blockcheck.sh index bf937423..ed0ed243 100755 --- a/blockcheck.sh +++ b/blockcheck.sh @@ -1776,6 +1776,11 @@ check_domain_http_tcp() [ "$SKIP_IPBLOCK" = 1 ] || check_dpi_ip_block $1 $4 + [ "$SKIP_TPWS" = 1 ] || { + echo + tpws_check_domain_http_bypass $1 $3 $4 + } + [ "$SKIP_PKTWS" = 1 ] || { echo echo preparing $PKTWSD redirection diff --git a/docs/changes.txt b/docs/changes.txt index 0e50ac51..26ef4d94 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -585,3 +585,4 @@ nfqws: backport from nfqws2 nl80211 ssid discovery fix for newer kernels 73.6 ipset: remove zapret-info based scripts because it's gone +blockcheck: fix tpws test regression From b17da98fc49a28698555e4b2639087bf438e9d23 Mon Sep 17 00:00:00 2001 From: bol-van Date: Sat, 3 Jan 2026 00:44:29 +0300 Subject: [PATCH 2/5] install_bin: fix and --- install_bin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_bin.sh b/install_bin.sh index cc50127f..4afa50bd 100755 --- a/install_bin.sh +++ b/install_bin.sh @@ -31,7 +31,7 @@ select_test_method() elif exists zsh && [ "$UNAME" != CYGWIN ] ; then TEST=zsh elif [ "$UNAME" != Darwin -a "$UNAME" != CYGWIN ]; then - if exists hexdump and exists dd; then + if exists hexdump && exists dd; then # macos does not use ELF TEST=elf ELF= From 3e35fb9025551eb208db40b2c4363fc44e9140e0 Mon Sep 17 00:00:00 2001 From: bol-van Date: Wed, 7 Jan 2026 13:21:30 +0300 Subject: [PATCH 3/5] nfqws: memleak fix --- nfq/pools.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nfq/pools.c b/nfq/pools.c index 54689e33..a704ff48 100644 --- a/nfq/pools.c +++ b/nfq/pools.c @@ -98,6 +98,7 @@ hostfail_pool *HostFailPoolFind(hostfail_pool *p,const char *s) } void HostFailPoolDel(hostfail_pool **p, hostfail_pool *elem) { + free(elem->str); HASH_DEL(*p, elem); free(elem); } @@ -108,11 +109,7 @@ void HostFailPoolPurge(hostfail_pool **pp) HASH_ITER(hh, *pp, elem, tmp) { if (now >= elem->expire) - { - free(elem->str); - HASH_DEL(*pp, elem); - free(elem); - } + HostFailPoolDel(pp, elem); } } static time_t host_fail_purge_prev=0; From 6ac8ed4c3f74a02696817b074170eb885cf985ad Mon Sep 17 00:00:00 2001 From: bol-van Date: Wed, 7 Jan 2026 13:41:17 +0300 Subject: [PATCH 4/5] AI inspired fixes --- mdig/mdig.c | 2 +- nfq/helpers.c | 34 ++-------------------------------- nfq/helpers.h | 12 ------------ nfq/nfqws.c | 1 - nfq/params.c | 4 ++-- tpws/helpers.c | 30 +----------------------------- tpws/helpers.h | 12 ------------ tpws/params.c | 4 ++-- tpws/tpws.c | 1 - 9 files changed, 8 insertions(+), 92 deletions(-) diff --git a/mdig/mdig.c b/mdig/mdig.c index b2447f69..847f2831 100644 --- a/mdig/mdig.c +++ b/mdig/mdig.c @@ -87,7 +87,7 @@ static bool dom_valid(char *dom) static void invalid_domain_beautify(char *dom) { for (int i = 0; *dom && i < 64; i++, dom++) - if (*dom < 0x20 || *dom>0x7F) *dom = '?'; + if (*dom < 0x20 || *dom<0) *dom = '?'; if (*dom) *dom = 0; } diff --git a/nfq/helpers.c b/nfq/helpers.c index bbc74fa2..13d74286 100644 --- a/nfq/helpers.c +++ b/nfq/helpers.c @@ -13,7 +13,7 @@ int unique_size_t(size_t *pu, int ct) { - int i, j, u; + size_t i, j, u; for (i = j = 0; j < ct; i++) { u = pu[j++]; @@ -477,43 +477,13 @@ bool set_env_exedir(const char *argv0) if ((s = strdup(argv0))) { if ((d = dirname(s))) - setenv("EXEDIR",s,1); + bOK = !setenv("EXEDIR",d,1); free(s); } return bOK; } -static void mask_from_preflen6_make(uint8_t plen, struct in6_addr *a) -{ - if (plen >= 128) - memset(a->s6_addr,0xFF,16); - else - { - uint8_t n = plen >> 3; - memset(a->s6_addr,0xFF,n); - memset(a->s6_addr+n,0x00,16-n); - a->s6_addr[n] = (uint8_t)(0xFF00 >> (plen & 7)); - } -} -struct in6_addr ip6_mask[129]; -void mask_from_preflen6_prepare(void) -{ - for (int plen=0;plen<=128;plen++) mask_from_preflen6_make(plen, ip6_mask+plen); -} - -#if defined(__GNUC__) && !defined(__llvm__) -__attribute__((optimize ("no-strict-aliasing"))) -#endif -void ip6_and(const struct in6_addr * restrict a, const struct in6_addr * restrict b, struct in6_addr * restrict result) -{ - // int128 requires 16-bit alignment. in struct sockaddr_in6.sin6_addr is 8-byte aligned. - // it causes segfault on x64 arch with latest compiler. it can cause misalign slowdown on other archs - // use 64-bit AND - ((uint64_t*)result->s6_addr)[0] = ((uint64_t*)a->s6_addr)[0] & ((uint64_t*)b->s6_addr)[0]; - ((uint64_t*)result->s6_addr)[1] = ((uint64_t*)a->s6_addr)[1] & ((uint64_t*)b->s6_addr)[1]; -} - void str_cidr4(char *s, size_t s_len, const struct cidr4 *cidr) { char s_ip[16]; diff --git a/nfq/helpers.h b/nfq/helpers.h index 31f24bad..6e7a8329 100644 --- a/nfq/helpers.h +++ b/nfq/helpers.h @@ -118,15 +118,3 @@ void str_cidr6(char *s, size_t s_len, const struct cidr6 *cidr); void print_cidr6(const struct cidr6 *cidr); bool parse_cidr4(char *s, struct cidr4 *cidr); bool parse_cidr6(char *s, struct cidr6 *cidr); - -static inline uint32_t mask_from_preflen(uint32_t preflen) -{ - return preflen ? preflen<32 ? ~((1 << (32-preflen)) - 1) : 0xFFFFFFFF : 0; -} -void ip6_and(const struct in6_addr * restrict a, const struct in6_addr * restrict b, struct in6_addr * restrict result); -extern struct in6_addr ip6_mask[129]; -void mask_from_preflen6_prepare(void); -static inline const struct in6_addr *mask_from_preflen6(uint8_t preflen) -{ - return ip6_mask+preflen; -} diff --git a/nfq/nfqws.c b/nfq/nfqws.c index 5eaa48b7..a24c1489 100644 --- a/nfq/nfqws.c +++ b/nfq/nfqws.c @@ -2304,7 +2304,6 @@ int main(int argc, char **argv) #endif srandom(time(NULL)); - mask_from_preflen6_prepare(); PRINT_VER; diff --git a/nfq/params.c b/nfq/params.c index ec8d4b92..a59a810f 100644 --- a/nfq/params.c +++ b/nfq/params.c @@ -289,14 +289,14 @@ struct desync_profile_list *dp_list_add(struct desync_profile_list_head *head) dp_init(&entry->dp); // add to the tail - struct desync_profile_list *dpn,*dpl=LIST_FIRST(¶ms.desync_profiles); + struct desync_profile_list *dpn,*dpl=LIST_FIRST(head); if (dpl) { while ((dpn=LIST_NEXT(dpl,next))) dpl = dpn; LIST_INSERT_AFTER(dpl, entry, next); } else - LIST_INSERT_HEAD(¶ms.desync_profiles, entry, next); + LIST_INSERT_HEAD(head, entry, next); return entry; } diff --git a/tpws/helpers.c b/tpws/helpers.c index 8171c68e..64461ac1 100644 --- a/tpws/helpers.c +++ b/tpws/helpers.c @@ -27,7 +27,7 @@ int unique_size_t(size_t *pu, int ct) { - int i, j, u; + size_t i, j, u; for (i = j = 0; j < ct; i++) { u = pu[j++]; @@ -476,34 +476,6 @@ bool set_env_exedir(const char *argv0) } -static void mask_from_preflen6_make(uint8_t plen, struct in6_addr *a) -{ - if (plen >= 128) - memset(a->s6_addr, 0xFF, 16); - else - { - uint8_t n = plen >> 3; - memset(a->s6_addr, 0xFF, n); - memset(a->s6_addr + n, 0x00, 16 - n); - a->s6_addr[n] = (uint8_t)(0xFF00 >> (plen & 7)); - } -} -struct in6_addr ip6_mask[129]; -void mask_from_preflen6_prepare(void) -{ - for (int plen = 0; plen <= 128; plen++) mask_from_preflen6_make(plen, ip6_mask + plen); -} - -#if defined(__GNUC__) && !defined(__llvm__) -__attribute__((optimize("no-strict-aliasing"))) -#endif -void ip6_and(const struct in6_addr * restrict a, const struct in6_addr * restrict b, struct in6_addr * restrict result) -{ - // int 128 can cause alignment segfaults because sin6_addr in struct sockaddr_in6 is 8-byte aligned, not 16-byte - ((uint64_t*)result->s6_addr)[0] = ((uint64_t*)a->s6_addr)[0] & ((uint64_t*)b->s6_addr)[0]; - ((uint64_t*)result->s6_addr)[1] = ((uint64_t*)a->s6_addr)[1] & ((uint64_t*)b->s6_addr)[1]; -} - void str_cidr4(char *s, size_t s_len, const struct cidr4 *cidr) { char s_ip[16]; diff --git a/tpws/helpers.h b/tpws/helpers.h index c61a9744..271c3aea 100644 --- a/tpws/helpers.h +++ b/tpws/helpers.h @@ -124,18 +124,6 @@ void print_cidr6(const struct cidr6 *cidr); bool parse_cidr4(char *s, struct cidr4 *cidr); bool parse_cidr6(char *s, struct cidr6 *cidr); -static inline uint32_t mask_from_preflen(uint32_t preflen) -{ - return preflen ? preflen<32 ? ~((1 << (32-preflen)) - 1) : 0xFFFFFFFF : 0; -} -void ip6_and(const struct in6_addr * restrict a, const struct in6_addr * restrict b, struct in6_addr * restrict result); -extern struct in6_addr ip6_mask[129]; -void mask_from_preflen6_prepare(void); -static inline const struct in6_addr *mask_from_preflen6(uint8_t preflen) -{ - return ip6_mask+preflen; -} - void msleep(unsigned int ms); #ifdef __linux__ bool socket_supports_notsent(); diff --git a/tpws/params.c b/tpws/params.c index c6a9670b..0690e68f 100644 --- a/tpws/params.c +++ b/tpws/params.c @@ -219,14 +219,14 @@ struct desync_profile_list *dp_list_add(struct desync_profile_list_head *head) dp_init(&entry->dp); // add to the tail - struct desync_profile_list *dpn,*dpl=LIST_FIRST(¶ms.desync_profiles); + struct desync_profile_list *dpn,*dpl=LIST_FIRST(head); if (dpl) { while ((dpn=LIST_NEXT(dpl,next))) dpl = dpn; LIST_INSERT_AFTER(dpl, entry, next); } else - LIST_INSERT_HEAD(¶ms.desync_profiles, entry, next); + LIST_INSERT_HEAD(head, entry, next); return entry; } diff --git a/tpws/tpws.c b/tpws/tpws.c index 4d86ee23..a205e7f1 100644 --- a/tpws/tpws.c +++ b/tpws/tpws.c @@ -1897,7 +1897,6 @@ int main(int argc, char *argv[]) set_console_io_buffering(); set_env_exedir(argv[0]); srand(time(NULL)); - mask_from_preflen6_prepare(); PRINT_VER; From 409579512c00b615d99e396392c58de267c9a36b Mon Sep 17 00:00:00 2001 From: bol-van Date: Wed, 7 Jan 2026 13:45:53 +0300 Subject: [PATCH 5/5] AI inspired fixes --- ip2net/ip2net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ip2net/ip2net.c b/ip2net/ip2net.c index 77d7139d..9badb080 100644 --- a/ip2net/ip2net.c +++ b/ip2net/ip2net.c @@ -49,7 +49,7 @@ static int ucmp(const void * a, const void * b, void *arg) } static uint32_t mask_from_bitcount(uint32_t zct) { - return zct<32 ? ~((1 << zct) - 1) : 0; + return zct<32 ? ~((1u << zct) - 1) : 0; } // make presorted array unique. return number of unique items. // 1,1,2,3,3,0,0,0 (ct=8) => 1,2,3,0 (ct=4) @@ -138,7 +138,7 @@ static void mask_from_bitcount6_make(uint32_t zct, struct in6_addr *a) int32_t n = (127 - zct) >> 3; memset(a->s6_addr,0xFF,n); memset(a->s6_addr+n,0x00,16-n); - a->s6_addr[n] = ~((1 << (zct & 7)) - 1); + a->s6_addr[n] = ~((1u << (zct & 7)) - 1); } } static struct in6_addr ip6_mask[129];