Compare commits

...

22 Commits

Author SHA1 Message Date
bol-van 87e058624c update docs 2026-07-21 09:17:51 +03:00
bol-van 906665d9a5 nfqws: fix minor compile warning 2026-07-21 09:14:01 +03:00
bol-van f97c22e96f init.d: discord media add port range 2026-07-21 09:10:49 +03:00
bol-van 9fb1f24808 init.d: remove KillMode=none in systemd unit 2026-07-21 09:08:52 +03:00
bol-van 1a1fc38c8e minor static analyzer fixes 2026-06-06 10:09:35 +03:00
bol-van 42a9b8e330 update docs 2026-05-09 08:14:30 +03:00
bol-van 363fbe6943 github: remove sdiv crash on old armv7 2026-03-12 20:55:17 +03:00
bol-van 5cc46a9815 update changes.txt 2026-03-12 14:36:58 +03:00
bol-van ef637c482c github: use 16K page size for android arm64 build 2026-03-05 19:37:57 +03:00
bol-van acccfc75e9 nfqws: backport QUICDefragCrypto 2026-03-05 10:32:26 +03:00
bol-van a92b4a543e nfqws: backport QUICDefragCrypto 2026-03-04 22:49:53 +03:00
bol-van 24e3b53165 github: move arm to armv6 2026-03-01 20:35:00 +03:00
bol-van 63e6215be0 github: use thumb in android armv7 build 2026-03-01 18:32:26 +03:00
bol-van cb382036f4 winws: -Wl,--gc-sections 2026-03-01 14:38:11 +03:00
bol-van 928134ca36 update docs 2026-03-01 14:15:36 +03:00
bol-van e5c3e4c706 optimize binaries size 2026-03-01 14:14:28 +03:00
bol-van 378411443f minor fixes 2026-03-01 09:50:52 +03:00
bol-van 74c5b58a1b AI fixes 2026-02-28 10:10:12 +03:00
bol-van 934903dfdf nfqws: cosmetic 2026-02-27 14:35:38 +03:00
bol-van 6cb394de4d Merge pull request #2096 from a1batross/master
Fix build on e2k
2026-02-26 16:30:36 +03:00
Alibek Omarov 003c540f24 tpws: fix building on e2k 2026-02-26 13:33:30 +00:00
Alibek Omarov 0870120cce nfqws: fix building on e2k 2026-02-26 13:33:08 +00:00
20 changed files with 147 additions and 87 deletions
+26 -22
View File
@@ -25,27 +25,13 @@ jobs:
- arch: arm64 - arch: arm64
tool: aarch64-unknown-linux-musl tool: aarch64-unknown-linux-musl
- arch: arm - arch: arm
tool: arm-unknown-linux-musleabi tool: armv6-unknown-linux-musleabi
# - arch: armhf
# tool: arm-unknown-linux-musleabihf
# - arch: armv7
# tool: armv7-unknown-linux-musleabi
# - arch: armv7hf
# tool: armv7-unknown-linux-musleabihf
# - arch: mips64el
# tool: mips64el-unknown-linux-musl
- arch: mips64 - arch: mips64
tool: mips64-unknown-linux-musl tool: mips64-unknown-linux-musl
# - arch: mipsel
# tool: mipsel-unknown-linux-musl
- arch: mipselsf - arch: mipselsf
tool: mipsel-unknown-linux-muslsf tool: mipsel-unknown-linux-muslsf
# - arch: mips
# tool: mips-unknown-linux-musl
- arch: mipssf - arch: mipssf
tool: mips-unknown-linux-muslsf tool: mips-unknown-linux-muslsf
# - arch: ppc64
# tool: powerpc64-unknown-linux-musl
- arch: ppc - arch: ppc
tool: powerpc-unknown-linux-musl tool: powerpc-unknown-linux-musl
- arch: x86 - arch: x86
@@ -69,7 +55,7 @@ jobs:
env: env:
ARCH: ${{ matrix.arch }} ARCH: ${{ matrix.arch }}
TOOL: ${{ matrix.tool }} TOOL: ${{ matrix.tool }}
REPO: ${{ matrix.arch == 'lexra' && matrix.repo || 'spvkgn/musl-cross' }} REPO: ${{ matrix.arch == 'lexra' && matrix.repo || 'bol-van/musl-cross' }}
DIR: ${{ matrix.arch == 'lexra' && matrix.dir || matrix.tool }} DIR: ${{ matrix.arch == 'lexra' && matrix.dir || matrix.tool }}
run: | run: |
if [[ "$ARCH" == lexra ]]; then if [[ "$ARCH" == lexra ]]; then
@@ -102,6 +88,15 @@ jobs:
export STRIP=$TARGET-strip export STRIP=$TARGET-strip
export PKG_CONFIG_PATH=$DEPS_DIR/lib/pkgconfig export PKG_CONFIG_PATH=$DEPS_DIR/lib/pkgconfig
export STAGING_DIR=$RUNNER_TEMP export STAGING_DIR=$RUNNER_TEMP
OPTIMIZE=-Oz
case "$ARCH" in
lexra)
OPTIMIZE=-Os
;;
arm)
CPU="-mcpu=arm1176jzf-s -mthumb"
;;
esac
# netfilter libs # netfilter libs
wget -qO- https://www.netfilter.org/pub/libnfnetlink/libnfnetlink-1.0.2.tar.bz2 | tar -xj wget -qO- https://www.netfilter.org/pub/libnfnetlink/libnfnetlink-1.0.2.tar.bz2 | tar -xj
@@ -111,7 +106,7 @@ jobs:
for i in libmnl libnfnetlink libnetfilter_queue ; do for i in libmnl libnfnetlink libnetfilter_queue ; do
( (
cd $i-* cd $i-*
CFLAGS="-Os -flto=auto $CFLAGS" \ CFLAGS="$OPTIMIZE $CPU -flto=auto $CFLAGS" \
./configure --prefix= --host=$TARGET --enable-static --disable-shared --disable-dependency-tracking ./configure --prefix= --host=$TARGET --enable-static --disable-shared --disable-dependency-tracking
make install -j$(nproc) DESTDIR=$DEPS_DIR make install -j$(nproc) DESTDIR=$DEPS_DIR
) )
@@ -123,7 +118,7 @@ jobs:
xargs -I{} wget -qO- https://github.com/madler/zlib/archive/refs/tags/{}.tar.gz | tar -xz xargs -I{} wget -qO- https://github.com/madler/zlib/archive/refs/tags/{}.tar.gz | tar -xz
( (
cd zlib-* cd zlib-*
CFLAGS="-Os -flto=auto $CFLAGS" \ CFLAGS="$OPTIMIZE $CPU -flto=auto $CFLAGS" \
./configure --prefix= --static ./configure --prefix= --static
make install -j$(nproc) DESTDIR=$DEPS_DIR make install -j$(nproc) DESTDIR=$DEPS_DIR
) )
@@ -134,7 +129,8 @@ jobs:
install -Dm644 -t $DEPS_DIR/include/sys /usr/include/x86_64-linux-gnu/sys/queue.h /usr/include/sys/capability.h install -Dm644 -t $DEPS_DIR/include/sys /usr/include/x86_64-linux-gnu/sys/queue.h /usr/include/sys/capability.h
# zapret # zapret
CFLAGS="-DZAPRET_GH_VER=${{ github.ref_name }} -DZAPRET_GH_HASH=${{ github.sha }} -static-libgcc -static -I$DEPS_DIR/include $CFLAGS" \ OPTIMIZE=$OPTIMIZE \
CFLAGS="-DZAPRET_GH_VER=${{ github.ref_name }} -DZAPRET_GH_HASH=${{ github.sha }} -static-libgcc -static $CPU -I$DEPS_DIR/include $CFLAGS" \
LDFLAGS="-L$DEPS_DIR/lib $LDFLAGS" \ LDFLAGS="-L$DEPS_DIR/lib $LDFLAGS" \
make -C zapret -j$(nproc) make -C zapret -j$(nproc)
tar -C zapret/binaries/my -cJf zapret-linux-$ARCH.tar.xz . tar -C zapret/binaries/my -cJf zapret-linux-$ARCH.tar.xz .
@@ -340,6 +336,14 @@ jobs:
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
export STRIP=$TOOLCHAIN/bin/llvm-strip export STRIP=$TOOLCHAIN/bin/llvm-strip
export PKG_CONFIG_PATH=$DEPS_DIR/lib/pkgconfig export PKG_CONFIG_PATH=$DEPS_DIR/lib/pkgconfig
case "$ABI" in
armeabi-v7a)
CPU="-mthumb"
;;
arm64-v8a)
PAGESIZE="-Wl,-z,max-page-size=16384"
;;
esac
# netfilter libs # netfilter libs
wget -qO- https://www.netfilter.org/pub/libnfnetlink/libnfnetlink-1.0.2.tar.bz2 | tar -xj wget -qO- https://www.netfilter.org/pub/libnfnetlink/libnfnetlink-1.0.2.tar.bz2 | tar -xj
@@ -350,7 +354,7 @@ jobs:
for i in libmnl libnfnetlink libnetfilter_queue ; do for i in libmnl libnfnetlink libnetfilter_queue ; do
( (
cd $i-* cd $i-*
CFLAGS="-Os -flto=auto -Wno-implicit-function-declaration" \ CFLAGS="$CPU -Os -flto=auto -Wno-implicit-function-declaration" \
./configure --prefix= --host=$TARGET --enable-static --disable-shared --disable-dependency-tracking ./configure --prefix= --host=$TARGET --enable-static --disable-shared --disable-dependency-tracking
make install -j$(nproc) DESTDIR=$DEPS_DIR make install -j$(nproc) DESTDIR=$DEPS_DIR
) )
@@ -358,8 +362,8 @@ jobs:
done done
# zapret # zapret
CFLAGS="-DZAPRET_GH_VER=${{ github.ref_name }} -DZAPRET_GH_HASH=${{ github.sha }} -I$DEPS_DIR/include" \ CFLAGS="$CPU -DZAPRET_GH_VER=${{ github.ref_name }} -DZAPRET_GH_HASH=${{ github.sha }} -I$DEPS_DIR/include" \
LDFLAGS="-L$DEPS_DIR/lib" \ LDFLAGS="-L$DEPS_DIR/lib $PAGESIZE" \
make -C zapret android -j$(nproc) make -C zapret android -j$(nproc)
# strip unwanted ELF sections to prevent warnings on old Android versions # strip unwanted ELF sections to prevent warnings on old Android versions
+25 -7
View File
@@ -568,35 +568,53 @@ nfqws: --wssize-forced-cutoff
nfqws: --orig-tcp-flags, --dup-tcp-flags, --dpi-desync-tcp-flags nfqws: --orig-tcp-flags, --dup-tcp-flags, --dpi-desync-tcp-flags
nfqws: --dup-ip-id nfqws: --dup-ip-id
73.3 72.3
blockcheck: support URIs blockcheck: support URIs
blockcheck: CURL_HTTPS_GET=1 suppresses -I curl option for https (HEAD -> GET) blockcheck: CURL_HTTPS_GET=1 suppresses -I curl option for https (HEAD -> GET)
73.4 72.4
blockcheck: fix broken dns cache blockcheck: fix broken dns cache
73.5 72.5
nfqws: fix broken l7proto profile rediscovery nfqws: fix broken l7proto profile rediscovery
nfqws: backport from nfqws2 nl80211 ssid discovery fix for newer kernels nfqws: backport from nfqws2 nl80211 ssid discovery fix for newer kernels
73.6 72.6
ipset: remove zapret-info based scripts because it's gone ipset: remove zapret-info based scripts because it's gone
blockcheck: fix tpws test regression blockcheck: fix tpws test regression
73.7 72.7
nfqws,tpws: memleak fix nfqws,tpws: memleak fix
mdig: --eagain, --eagain-delay mdig: --eagain, --eagain-delay
73.8 72.8
nfqws: fix breaking tcp if ts fooling is enabled but no timestamps present nfqws: fix breaking tcp if ts fooling is enabled but no timestamps present
73.9 72.9
blockcheck: fix detection of http redirection if domain/URI specified blockcheck: fix detection of http redirection if domain/URI specified
install_easy: fix writing of ask_list variables install_easy: fix writing of ask_list variables
72.10
* nfqws2: fix broken wifi ssid update
* minor AI fixes
72.12
* github: reduce binaries size
* github: use 16K page size for android arm64 build
* nfqws: join fragments in quic CRYPTO reconstruction. allow intersections.
72.13
* github: compile armv6. fix idiv illegal instruction on early armv7
* init.d: add port range for discord media
* init.d: remove KillMode=none in systemd unit
+5
View File
@@ -4,6 +4,11 @@ This software is free and open source under [MIT license](./LICENSE.txt).
If anyone demands you to download this software only from their webpage, telegram channel, forces you to delete links, videos, makes copyright claims, you are dealing with scammers. If anyone demands you to download this software only from their webpage, telegram channel, forces you to delete links, videos, makes copyright claims, you are dealing with scammers.
However, [donations](#donations) are welcome. However, [donations](#donations) are welcome.
# zapret2
zapret 1 is EOL (End-Of-Life). Will be no more new features, no PR will be accepted.
Current version is [zapret2](https://github.com/bol-van/zapret2).
# Multilanguage/Мультиязычный README # Multilanguage/Мультиязычный README
___ ___
[![en](https://img.shields.io/badge/lang-en-red.svg)](https://github.com/bol-van/zapret/tree/master/docs/readme.en.md) [![en](https://img.shields.io/badge/lang-en-red.svg)](https://github.com/bol-van/zapret/tree/master/docs/readme.en.md)
+1 -1
View File
@@ -6,7 +6,7 @@ zapret является свободным и open source.
# zapret2 # zapret2
Эта версия zapret более не развивается и находится в режиме EOL (End-Of-Life). Никаких новых функций больше не будет. Только багфиксы. Эта версия zapret более не развивается и находится в режиме EOL (End-Of-Life). Никаких новых функций больше не будет. Только багфиксы. Pull реквесты с новыми фичами не принимаются.
[Актуальная версия - zapret 2](https://github.com/bol-van/zapret2) [Актуальная версия - zapret 2](https://github.com/bol-van/zapret2)
@@ -3,7 +3,7 @@
# can override in config : # can override in config :
NFQWS_OPT_DESYNC_DISCORD_MEDIA="${NFQWS_OPT_DESYNC_DISCORD_MEDIA:---dpi-desync=fake --dpi-desync-repeats=2}" NFQWS_OPT_DESYNC_DISCORD_MEDIA="${NFQWS_OPT_DESYNC_DISCORD_MEDIA:---dpi-desync=fake --dpi-desync-repeats=2}"
DISCORD_MEDIA_PORT_RANGE="${DISCORD_MEDIA_PORT_RANGE:-50000-50099}" DISCORD_MEDIA_PORT_RANGE="${DISCORD_MEDIA_PORT_RANGE:-50000-50099,19294-19344}"
alloc_dnum DNUM_DISCORD_MEDIA alloc_dnum DNUM_DISCORD_MEDIA
alloc_qnum QNUM_DISCORD_MEDIA alloc_qnum QNUM_DISCORD_MEDIA
@@ -21,7 +21,7 @@ zapret_custom_firewall()
local DISABLE_IPV6=1 local DISABLE_IPV6=1
local port_range=$(replace_char - : $DISCORD_MEDIA_PORT_RANGE) local port_range=$(replace_char - : $DISCORD_MEDIA_PORT_RANGE)
local f="-p udp --dport $port_range -m u32 --u32" local f="-p udp -m multiport --dports $port_range -m u32 --u32"
# this is simplified test to skip writing monstrous rule. instead of checking 64 bytes for zeroes only check 2 dwords for zero # this is simplified test to skip writing monstrous rule. instead of checking 64 bytes for zeroes only check 2 dwords for zero
fw_nfqws_post $1 "$f 0>>22&0x3C@4>>16=0x52&&0>>22&0x3C@8=0x00010046&&0>>22&0x3C@16=0&&0>>22&0x3C@76=0" '' $QNUM_DISCORD_MEDIA fw_nfqws_post $1 "$f 0>>22&0x3C@4>>16=0x52&&0>>22&0x3C@8=0x00010046&&0>>22&0x3C@16=0&&0>>22&0x3C@76=0" '' $QNUM_DISCORD_MEDIA
} }
@@ -30,6 +30,7 @@ zapret_custom_firewall_nft()
# stop logic is not required # stop logic is not required
local DISABLE_IPV6=1 local DISABLE_IPV6=1
local f="udp dport $DISCORD_MEDIA_PORT_RANGE udp length == 82 @ih,0,32 0x00010046 @ih,64,128 0x00000000000000000000000000000000 @ih,192,128 0x00000000000000000000000000000000 @ih,320,128 0x00000000000000000000000000000000 @ih,448,128 0x00000000000000000000000000000000" local f="udp dport {$DISCORD_MEDIA_PORT_RANGE} udp length == 82 @ih,0,32 0x00010046 @ih,64,128 0x00000000000000000000000000000000 @ih,192,128 0x00000000000000000000000000000000 @ih,320,128 0x00000000000000000000000000000000 @ih,448,128 0x00000000000000000000000000000000"
nft_fw_nfqws_post "$f" '' $QNUM_DISCORD_MEDIA nft_fw_nfqws_post "$f" '' $QNUM_DISCORD_MEDIA
} }
-1
View File
@@ -7,7 +7,6 @@ Type=forking
Restart=no Restart=no
TimeoutSec=30sec TimeoutSec=30sec
IgnoreSIGPIPE=no IgnoreSIGPIPE=no
KillMode=none
GuessMainPID=no GuessMainPID=no
RemainAfterExit=no RemainAfterExit=no
ExecStart=/opt/zapret/init.d/sysv/zapret start ExecStart=/opt/zapret/init.d/sysv/zapret start
@@ -1,5 +1,5 @@
outbound and ip and outbound and ip and
udp.DstPort>=50000 and udp.DstPort<=50099 and (udp.DstPort>=50000 and udp.DstPort<=50099 or udp.DstPort>=19294 and udp.DstPort<=19344) and
udp.PayloadLength=74 and udp.PayloadLength=74 and
udp.Payload32[0]=0x00010046 and udp.Payload32[0]=0x00010046 and
udp.Payload32[2]=0 and udp.Payload32[2]=0 and
+14 -9
View File
@@ -1,10 +1,15 @@
CC ?= cc CC ?= cc
OPTIMIZE ?= -Os OPTIMIZE ?= -Os
CFLAGS += -std=gnu99 $(OPTIMIZE) -flto=auto CFLAGS += -std=gnu99 $(OPTIMIZE) -flto=auto -ffunction-sections -fdata-sections
CFLAGS_SYSTEMD = -DUSE_SYSTEMD CFLAGS_SYSTEMD = -DUSE_SYSTEMD
CFLAGS_BSD = -Wno-address-of-packed-member CFLAGS_BSD = -Wno-address-of-packed-member
CFLAGS_CYGWIN = -Wno-address-of-packed-member -static CFLAGS_CYGWIN = -Wno-address-of-packed-member -static
LDFLAGS_ANDROID = -llog LDFLAGS += -flto=auto
LDFLAGS_ANDROID = -Wl,--gc-sections -llog
LDFLAGS_BSD = -Wl,--gc-sections
LDFLAGS_LINUX = -Wl,--gc-sections
LDFLAGS_MAC = -Wl,-dead_strip
LDFLAGS_WIN = -Wl,--gc-sections
LIBS_LINUX = -lz -lnetfilter_queue -lnfnetlink -lmnl LIBS_LINUX = -lz -lnetfilter_queue -lnfnetlink -lmnl
LIBS_SYSTEMD = -lsystemd LIBS_SYSTEMD = -lsystemd
LIBS_BSD = -lz LIBS_BSD = -lz
@@ -18,28 +23,28 @@ SRC_FILES = *.c crypto/*.c
all: nfqws all: nfqws
nfqws: $(SRC_FILES) nfqws: $(SRC_FILES)
$(CC) -s $(CFLAGS) -o nfqws $(SRC_FILES) $(LIBS_LINUX) $(LDFLAGS) $(CC) -s $(CFLAGS) -o nfqws $(SRC_FILES) $(LIBS_LINUX) $(LDFLAGS) $(LDFLAGS_LINUX)
systemd: $(SRC_FILES) systemd: $(SRC_FILES)
$(CC) -s $(CFLAGS) $(CFLAGS_SYSTEMD) -o nfqws $(SRC_FILES) $(LIBS_LINUX) $(LIBS_SYSTEMD) $(LDFLAGS) $(CC) -s $(CFLAGS) $(CFLAGS_SYSTEMD) -o nfqws $(SRC_FILES) $(LIBS_LINUX) $(LIBS_SYSTEMD) $(LDFLAGS) $(LDFLAGS_LINUX)
android: $(SRC_FILES) android: $(SRC_FILES)
$(CC) -s $(CFLAGS) -o nfqws $(SRC_FILES) $(LIBS_LINUX) $(LDFLAGS) $(LDFLAGS_ANDROID) $(CC) -s $(CFLAGS) -o nfqws $(SRC_FILES) $(LIBS_LINUX) $(LDFLAGS) $(LDFLAGS_ANDROID)
bsd: $(SRC_FILES) bsd: $(SRC_FILES)
$(CC) -s $(CFLAGS) $(CFLAGS_BSD) -o dvtws $(SRC_FILES) $(LIBS_BSD) $(LDFLAGS) $(CC) -s $(CFLAGS) $(CFLAGS_BSD) -o dvtws $(SRC_FILES) $(LIBS_BSD) $(LDFLAGS) $(LDFLAGS_BSD)
mac: $(SRC_FILES) mac: $(SRC_FILES)
$(CC) $(CFLAGS) $(CFLAGS_BSD) -o dvtwsa $(SRC_FILES) -target arm64-apple-macos10.8 $(LIBS_BSD) $(LDFLAGS) $(CC) $(CFLAGS) $(CFLAGS_BSD) -o dvtwsa $(SRC_FILES) -target arm64-apple-macos10.8 $(LIBS_BSD) $(LDFLAGS) $(LDFLAGS_MAC)
$(CC) $(CFLAGS) $(CFLAGS_BSD) -o dvtwsx $(SRC_FILES) -target x86_64-apple-macos10.8 $(LIBS_BSD) $(LDFLAGS) $(CC) $(CFLAGS) $(CFLAGS_BSD) -o dvtwsx $(SRC_FILES) -target x86_64-apple-macos10.8 $(LIBS_BSD) $(LDFLAGS) $(LDFLAGS_MAC)
strip dvtwsa dvtwsx strip dvtwsa dvtwsx
lipo -create -output dvtws dvtwsx dvtwsa lipo -create -output dvtws dvtwsx dvtwsa
rm -f dvtwsx dvtwsa rm -f dvtwsx dvtwsa
cygwin64: cygwin64:
$(CC) -s $(CFLAGS) $(CFLAGS_CYGWIN) -o winws $(SRC_FILES) $(LIBS_CYGWIN) $(LIBS_CYGWIN64) $(RES_CYGWIN64) $(LDFLAGS) $(CC) -s $(CFLAGS) $(CFLAGS_CYGWIN) -o winws $(SRC_FILES) $(LIBS_CYGWIN) $(LIBS_CYGWIN64) $(RES_CYGWIN64) $(LDFLAGS) $(LDFLAGS_WIN)
cygwin32: cygwin32:
$(CC) -s $(CFLAGS) $(CFLAGS_CYGWIN) -o winws $(SRC_FILES) $(LIBS_CYGWIN) $(LIBS_CYGWIN32) $(RES_CYGWIN32) $(LDFLAGS) $(CC) -s $(CFLAGS) $(CFLAGS_CYGWIN) -o winws $(SRC_FILES) $(LIBS_CYGWIN) $(LIBS_CYGWIN32) $(RES_CYGWIN32) $(LDFLAGS) $(LDFLAGS_WIN)
cygwin: cygwin64 cygwin: cygwin64
clean: clean:
-1
View File
@@ -29,7 +29,6 @@
#if defined(_MSC_VER) #if defined(_MSC_VER)
#include <basetsd.h> #include <basetsd.h>
typedef unsigned int size_t;// use the right type for length declarations
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
typedef UINT64 uint64_t; typedef UINT64 uint64_t;
#else #else
+4 -2
View File
@@ -221,7 +221,8 @@ void print_sockaddr(const struct sockaddr *sa)
bool pton4_port(const char *s, struct sockaddr_in *sa) bool pton4_port(const char *s, struct sockaddr_in *sa)
{ {
char ip[16],*p; char ip[16];
const char *p;
size_t l; size_t l;
unsigned int u; unsigned int u;
@@ -241,7 +242,8 @@ bool pton4_port(const char *s, struct sockaddr_in *sa)
} }
bool pton6_port(const char *s, struct sockaddr_in6 *sa) bool pton6_port(const char *s, struct sockaddr_in6 *sa)
{ {
char ip[40],*p; char ip[40];
const char *p;
size_t l; size_t l;
unsigned int u; unsigned int u;
+3 -3
View File
@@ -3169,7 +3169,7 @@ int main(int argc, char **argv)
} }
break; break;
case IDX_HOSTLIST_AUTO_FAIL_THRESHOLD: case IDX_HOSTLIST_AUTO_FAIL_THRESHOLD:
dp->hostlist_auto_fail_threshold = (uint8_t)atoi(optarg); dp->hostlist_auto_fail_threshold = atoi(optarg);
if (dp->hostlist_auto_fail_threshold < 1 || dp->hostlist_auto_fail_threshold>20) if (dp->hostlist_auto_fail_threshold < 1 || dp->hostlist_auto_fail_threshold>20)
{ {
DLOG_ERR("auto hostlist fail threshold must be within 1..20\n"); DLOG_ERR("auto hostlist fail threshold must be within 1..20\n");
@@ -3177,7 +3177,7 @@ int main(int argc, char **argv)
} }
break; break;
case IDX_HOSTLIST_AUTO_FAIL_TIME: case IDX_HOSTLIST_AUTO_FAIL_TIME:
dp->hostlist_auto_fail_time = (uint8_t)atoi(optarg); dp->hostlist_auto_fail_time = atoi(optarg);
if (dp->hostlist_auto_fail_time < 1) if (dp->hostlist_auto_fail_time < 1)
{ {
DLOG_ERR("auto hostlist fail time is not valid\n"); DLOG_ERR("auto hostlist fail time is not valid\n");
@@ -3185,7 +3185,7 @@ int main(int argc, char **argv)
} }
break; break;
case IDX_HOSTLIST_AUTO_RETRANS_THRESHOLD: case IDX_HOSTLIST_AUTO_RETRANS_THRESHOLD:
dp->hostlist_auto_retrans_threshold = (uint8_t)atoi(optarg); dp->hostlist_auto_retrans_threshold = atoi(optarg);
if (dp->hostlist_auto_retrans_threshold < 2 || dp->hostlist_auto_retrans_threshold>10) if (dp->hostlist_auto_retrans_threshold < 2 || dp->hostlist_auto_retrans_threshold>10)
{ {
DLOG_ERR("auto hostlist fail threshold must be within 2..10\n"); DLOG_ERR("auto hostlist fail threshold must be within 2..10\n");
+1 -1
View File
@@ -50,7 +50,7 @@ static char log_buf[1024];
static size_t log_buf_sz=0; static size_t log_buf_sz=0;
static void syslog_log_function(int priority, const char *line) static void syslog_log_function(int priority, const char *line)
{ {
syslog(priority,"%s",log_buf); syslog(priority,"%s",line);
} }
#ifdef __ANDROID__ #ifdef __ANDROID__
static enum android_LogPriority syslog_priority_to_android(int priority) static enum android_LogPriority syslog_priority_to_android(int priority)
+39 -21
View File
@@ -587,7 +587,7 @@ static uint8_t tvb_get_varint(const uint8_t *tvb, uint64_t *value)
return 8; return 8;
} }
// impossible case // impossible case
if (*value) *value = 0; if (value) *value = 0;
return 0; return 0;
} }
static uint8_t tvb_get_size(uint8_t tvb) static uint8_t tvb_get_size(uint8_t tvb)
@@ -866,7 +866,7 @@ bool QUICDefragCrypto(const uint8_t *clean,size_t clean_len, uint8_t *defrag,siz
uint64_t offset,sz,szmax=0,zeropos=0,pos=0; uint64_t offset,sz,szmax=0,zeropos=0,pos=0;
bool found=false; bool found=false;
struct range64 ranges[MAX_DEFRAG_PIECES]; struct range64 ranges[MAX_DEFRAG_PIECES];
int i,range=0; int i,j,range=0;
while(pos<clean_len) while(pos<clean_len)
{ {
@@ -888,24 +888,54 @@ bool QUICDefragCrypto(const uint8_t *clean,size_t clean_len, uint8_t *defrag,siz
if ((pos+sz)>clean_len) return false; if ((pos+sz)>clean_len) return false;
if ((offset+sz)>defrag_data_len) return false; // defrag buf overflow if ((offset+sz)>defrag_data_len) return false; // defrag buf overflow
// remove exact duplicates early to save cpu
for(i=0;i<range;i++)
if (ranges[i].offset==offset && ranges[i].len==sz)
goto skip_range;
if (zeropos < offset) if (zeropos < offset)
// make sure no uninitialized gaps exist in case of not full fragment coverage // make sure no uninitialized gaps exist in case of not full fragment coverage
memset(defrag_data+zeropos,0,offset-zeropos); memset(defrag_data+zeropos,0,offset-zeropos);
if ((offset+sz) > zeropos) if ((offset+sz) > zeropos)
zeropos=offset+sz; zeropos=offset+sz;
memcpy(defrag_data+offset,clean+pos,sz);
if ((offset+sz) > szmax) szmax = offset+sz;
found=true; found=true;
pos+=sz; if ((offset+sz) > szmax) szmax = offset+sz;
memcpy(defrag_data+offset,clean+pos,sz);
ranges[range].offset = offset; ranges[range].offset = offset;
ranges[range].len = sz; ranges[range].len = sz;
range++; range++;
skip_range:
pos+=sz;
} }
} }
if (found) if (found)
{ {
qsort(ranges, range, sizeof(*ranges), cmp_range64);
// for(i=0 ; i<range ; i++)
// printf("range1 %llu-%llu\n",ranges[i].offset,ranges[i].offset+ranges[i].len);
if (range>0)
{
for (j=0,i=1; i < range; i++)
{
uint64_t current_end = ranges[j].offset + ranges[j].len;
uint64_t next_start = ranges[i].offset;
uint64_t next_end = ranges[i].offset + ranges[i].len;
if (next_start <= current_end)
ranges[j].len = MAX(next_end,current_end) - ranges[j].offset;
else
ranges[++j] = ranges[i];
}
range = j+1;
}
// for(i=0 ; i<range ; i++)
// printf("range2 %llu-%llu\n",ranges[i].offset,ranges[i].offset+ranges[i].len);
defrag[0] = 6; defrag[0] = 6;
defrag[1] = 0; // offset defrag[1] = 0; // offset
// 2..9 - length 64 bit // 2..9 - length 64 bit
@@ -914,21 +944,7 @@ bool QUICDefragCrypto(const uint8_t *clean,size_t clean_len, uint8_t *defrag,siz
defrag[2] |= 0xC0; // 64 bit value defrag[2] |= 0xC0; // 64 bit value
*defrag_len = (size_t)(szmax+10); *defrag_len = (size_t)(szmax+10);
qsort(ranges, range, sizeof(*ranges), cmp_range64); *bFull = range==1 && !ranges[0].offset;
//for(i=0 ; i<range ; i++)
// printf("RANGE %zu len %zu\n",ranges[i].offset,ranges[i].len);
for(i=0,offset=0,*bFull=true ; i<range ; i++)
{
if (ranges[i].offset!=offset)
{
*bFull = false;
break;
}
offset += ranges[i].len;
}
//printf("bFull=%u\n",*bFull); //printf("bFull=%u\n",*bFull);
} }
return found; return found;
@@ -975,6 +991,8 @@ bool IsQUICInitial(const uint8_t *data, size_t len)
if (data[offset] > QUIC_MAX_CID_LENGTH) return false; if (data[offset] > QUIC_MAX_CID_LENGTH) return false;
offset += 1 + data[offset]; offset += 1 + data[offset];
if (offset>=len) return false;
// SCID // SCID
if (data[offset] > QUIC_MAX_CID_LENGTH) return false; if (data[offset] > QUIC_MAX_CID_LENGTH) return false;
offset += 1 + data[offset]; offset += 1 + data[offset];
+4
View File
@@ -95,6 +95,10 @@ bool dropcaps(void);
# define ARCH_NR AUDIT_ARCH_LOONGARCH64 # define ARCH_NR AUDIT_ARCH_LOONGARCH64
#elif defined(__e2k__)
# define ARCH_NR AUDIT_ARCH_E2K
#else #else
# error "Platform does not support seccomp filter yet" # error "Platform does not support seccomp filter yet"
+1 -1
View File
@@ -4,7 +4,7 @@
#include <stdbool.h> #include <stdbool.h>
bool service_run(); bool service_run(int argc, char *argv[]);
#endif #endif
+11 -7
View File
@@ -1,9 +1,13 @@
CC ?= cc CC ?= cc
OPTIMIZE ?= -Os OPTIMIZE ?= -Os
CFLAGS += -std=gnu99 $(OPTIMIZE) -flto=auto CFLAGS += -std=gnu99 $(OPTIMIZE) -flto=auto -ffunction-sections -fdata-sections
CFLAGS_SYSTEMD = -DUSE_SYSTEMD CFLAGS_SYSTEMD = -DUSE_SYSTEMD
CFLAGS_BSD = -Wno-address-of-packed-member CFLAGS_BSD = -Wno-address-of-packed-member
LDFLAGS_ANDROID = -llog LDFLAGS += -flto=auto
LDFLAGS_ANDROID = -Wl,--gc-sections -llog
LDFLAGS_BSD = -Wl,--gc-sections
LDFLAGS_LINUX = -Wl,--gc-sections
LDFLAGS_MAC = -Wl,-dead_strip
LIBS = -lz -lpthread LIBS = -lz -lpthread
LIBS_SYSTEMD = -lsystemd LIBS_SYSTEMD = -lsystemd
LIBS_ANDROID = -lz LIBS_ANDROID = -lz
@@ -13,20 +17,20 @@ SRC_FILES_ANDROID = $(SRC_FILES) andr/*.c
all: tpws all: tpws
tpws: $(SRC_FILES) tpws: $(SRC_FILES)
$(CC) -s $(CFLAGS) -o tpws $(SRC_FILES) $(LIBS) $(LDFLAGS) $(CC) -s $(CFLAGS) -o tpws $(SRC_FILES) $(LIBS) $(LDFLAGS) $(LDFLAGS_LINUX)
systemd: $(SRC_FILES) systemd: $(SRC_FILES)
$(CC) -s $(CFLAGS) $(CFLAGS_SYSTEMD) -o tpws $(SRC_FILES) $(LIBS) $(LIBS_SYSTEMD) $(LDFLAGS) $(CC) -s $(CFLAGS) $(CFLAGS_SYSTEMD) -o tpws $(SRC_FILES) $(LIBS) $(LIBS_SYSTEMD) $(LDFLAGS) $(LDFLAGS_LINUX)
android: $(SRC_FILES) android: $(SRC_FILES)
$(CC) -s $(CFLAGS) -o tpws $(SRC_FILES_ANDROID) $(LIBS_ANDROID) $(LDFLAGS) $(LDFLAGS_ANDROID) $(CC) -s $(CFLAGS) -o tpws $(SRC_FILES_ANDROID) $(LIBS_ANDROID) $(LDFLAGS) $(LDFLAGS_ANDROID)
bsd: $(SRC_FILES) bsd: $(SRC_FILES)
$(CC) -s $(CFLAGS) $(CFLAGS_BSD) -Iepoll-shim/include -o tpws $(SRC_FILES) epoll-shim/src/*.c $(LIBS) $(LDFLAGS) $(CC) -s $(CFLAGS) $(CFLAGS_BSD) -Iepoll-shim/include -o tpws $(SRC_FILES) epoll-shim/src/*.c $(LIBS) $(LDFLAGS) $(LDFLAGS_BSD)
mac: $(SRC_FILES) mac: $(SRC_FILES)
$(CC) $(CFLAGS) $(CFLAGS_BSD) -Iepoll-shim/include -Imacos -o tpwsa -target arm64-apple-macos10.8 $(SRC_FILES) epoll-shim/src/*.c $(LIBS) $(LDFLAGS) $(CC) $(CFLAGS) $(CFLAGS_BSD) -Iepoll-shim/include -Imacos -o tpwsa -target arm64-apple-macos10.8 $(SRC_FILES) epoll-shim/src/*.c $(LIBS) $(LDFLAGS) $(LDFLAGS_MAC)
$(CC) $(CFLAGS) $(CFLAGS_BSD) -Iepoll-shim/include -Imacos -o tpwsx -target x86_64-apple-macos10.8 $(SRC_FILES) epoll-shim/src/*.c $(LIBS) $(LDFLAGS) $(CC) $(CFLAGS) $(CFLAGS_BSD) -Iepoll-shim/include -Imacos -o tpwsx -target x86_64-apple-macos10.8 $(SRC_FILES) epoll-shim/src/*.c $(LIBS) $(LDFLAGS) $(LDFLAGS_MAC)
strip tpwsa tpwsx strip tpwsa tpwsx
lipo -create -output tpws tpwsx tpwsa lipo -create -output tpws tpwsx tpwsa
rm -f tpwsx tpwsa rm -f tpwsx tpwsa
+1 -1
View File
@@ -74,7 +74,7 @@ struct desync_profile
struct hostlist_collection_head hl_collection, hl_collection_exclude; struct hostlist_collection_head hl_collection, hl_collection_exclude;
// pointer to autohostlist. NULL if no autohostlist for the profile. // pointer to autohostlist. NULL if no autohostlist for the profile.
struct hostlist_file *hostlist_auto; struct hostlist_file *hostlist_auto;
int hostlist_auto_fail_threshold, hostlist_auto_fail_time, hostlist_auto_retrans_threshold; int hostlist_auto_fail_threshold, hostlist_auto_fail_time;
hostfail_pool *hostlist_auto_fail_counters; hostfail_pool *hostlist_auto_fail_counters;
}; };
+4
View File
@@ -97,6 +97,10 @@ bool dropcaps(void);
# define ARCH_NR AUDIT_ARCH_LOONGARCH64 # define ARCH_NR AUDIT_ARCH_LOONGARCH64
#elif defined(__e2k__)
# define ARCH_NR AUDIT_ARCH_E2K
#else #else
# error "Platform does not support seccomp filter yet" # error "Platform does not support seccomp filter yet"
+2 -2
View File
@@ -1273,7 +1273,7 @@ void parse_params(int argc, char *argv[])
params.tamper = true; // need to detect blocks and update autohostlist. cannot just slice. params.tamper = true; // need to detect blocks and update autohostlist. cannot just slice.
break; break;
case IDX_HOSTLIST_AUTO_FAIL_THRESHOLD: case IDX_HOSTLIST_AUTO_FAIL_THRESHOLD:
dp->hostlist_auto_fail_threshold = (uint8_t)atoi(optarg); dp->hostlist_auto_fail_threshold = atoi(optarg);
if (dp->hostlist_auto_fail_threshold<1 || dp->hostlist_auto_fail_threshold>20) if (dp->hostlist_auto_fail_threshold<1 || dp->hostlist_auto_fail_threshold>20)
{ {
DLOG_ERR("auto hostlist fail threshold must be within 1..20\n"); DLOG_ERR("auto hostlist fail threshold must be within 1..20\n");
@@ -1281,7 +1281,7 @@ void parse_params(int argc, char *argv[])
} }
break; break;
case IDX_HOSTLIST_AUTO_FAIL_TIME: case IDX_HOSTLIST_AUTO_FAIL_TIME:
dp->hostlist_auto_fail_time = (uint8_t)atoi(optarg); dp->hostlist_auto_fail_time = atoi(optarg);
if (dp->hostlist_auto_fail_time<1) if (dp->hostlist_auto_fail_time<1)
{ {
DLOG_ERR("auto hostlist fail time is not valid\n"); DLOG_ERR("auto hostlist fail time is not valid\n");
+1 -4
View File
@@ -835,8 +835,6 @@ static bool handle_unsent(tproxy_conn_t *conn)
static bool proxy_mode_connect_remote(tproxy_conn_t *conn, struct tailhead *conn_list) static bool proxy_mode_connect_remote(tproxy_conn_t *conn, struct tailhead *conn_list)
{ {
int remote_fd;
if (params.debug>=1) if (params.debug>=1)
{ {
char ip_port[48]; char ip_port[48];
@@ -850,9 +848,8 @@ static bool proxy_mode_connect_remote(tproxy_conn_t *conn, struct tailhead *conn
return false; return false;
} }
if (!(conn->partner = new_conn(remote_fd, true))) if (!(conn->partner = new_conn(0, true)))
{ {
close(remote_fd);
DLOG_ERR("socks out-of-memory (1)\n"); DLOG_ERR("socks out-of-memory (1)\n");
socks_send_rep(conn->socks_ver, conn->fd, S5_REP_GENERAL_FAILURE); socks_send_rep(conn->socks_ver, conn->fd, S5_REP_GENERAL_FAILURE);
return false; return false;