From 135b152497da4a3c0799786f65b74eace661ff38 Mon Sep 17 00:00:00 2001 From: bol-van Date: Mon, 11 Aug 2025 20:23:38 +0300 Subject: [PATCH] stun4all, wg4all improve --- init.d/custom.d.examples.linux/50-stun4all | 30 ++++++++++++++++++++++ init.d/custom.d.examples.linux/50-wg4all | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 init.d/custom.d.examples.linux/50-stun4all diff --git a/init.d/custom.d.examples.linux/50-stun4all b/init.d/custom.d.examples.linux/50-stun4all new file mode 100644 index 0000000..72f33bc --- /dev/null +++ b/init.d/custom.d.examples.linux/50-stun4all @@ -0,0 +1,30 @@ +# this custom script runs desync to all stun packets + +# can override in config : +NFQWS_OPT_DESYNC_STUN="${NFQWS_OPT_DESYNC_STUN:---dpi-desync=fake}" + +alloc_dnum DNUM_STUN4ALL +alloc_qnum QNUM_STUN4ALL + +zapret_custom_daemons() +{ + # $1 - 1 - add, 0 - stop + + local opt="--qnum=$QNUM_STUN4ALL $NFQWS_OPT_DESYNC_STUN" + do_nfqws $1 $DNUM_STUN4ALL "$opt" +} +# size = 156 (8 udp header + 148 payload) && payload starts with 0x01000000 +zapret_custom_firewall() +{ + # $1 - 1 - run, 0 - stop + + local f='-p udp -p udp -m length --length 28: -m u32 --u32' + fw_nfqws_post $1 "$f 0>>22&0x3C@8&0xC0000003=0 && 0>>22&0x3C@12=0x2112A442" "$f 48&0xC0000003=0 && 52=0x2112A442" $QNUM_STUN4ALL +} +zapret_custom_firewall_nft() +{ + # stop logic is not required + + local f="udp length >= 28 @ih,0,2 0 @ih,30,2 0 @ih,32,32 0x2112A442" + nft_fw_nfqws_post "$f" "$f" $QNUM_STUN4ALL +} diff --git a/init.d/custom.d.examples.linux/50-wg4all b/init.d/custom.d.examples.linux/50-wg4all index 0bf096a..825a21a 100644 --- a/init.d/custom.d.examples.linux/50-wg4all +++ b/init.d/custom.d.examples.linux/50-wg4all @@ -25,6 +25,6 @@ zapret_custom_firewall_nft() { # stop logic is not required - local f="udp length 156 @th,64,32 0x01000000" + local f="udp length 156 @ih,0,32 0x01000000" nft_fw_nfqws_post "$f" "$f" $QNUM_WG4ALL }