From dce049d6b8cded7d26a7cfb26828e56bd6f04416 Mon Sep 17 00:00:00 2001 From: bol-van Date: Tue, 12 Aug 2025 09:41:55 +0300 Subject: [PATCH] discord custom --- .../custom.d.examples.linux/50-discord-media | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 init.d/custom.d.examples.linux/50-discord-media diff --git a/init.d/custom.d.examples.linux/50-discord-media b/init.d/custom.d.examples.linux/50-discord-media new file mode 100644 index 0000000..d25eb82 --- /dev/null +++ b/init.d/custom.d.examples.linux/50-discord-media @@ -0,0 +1,35 @@ +# this custom script runs desync to all discord media packets + +# can override in config : +NFQWS_OPT_DESYNC_DISCORD_MEDIA="${NFQWS_OPT_DESYNC_DISCORD_MEDIA:---dpi-desync=fake}" +DISCORD_MEDIA_PORT_RANGE="${DISCORD_MEDIA_PORT_RANGE:-50000-50099}" + +alloc_dnum DNUM_DISCORD_MEDIA +alloc_qnum QNUM_DISCORD_MEDIA + +zapret_custom_daemons() +{ + # $1 - 1 - add, 0 - stop + + local opt="--qnum=$QNUM_DISCORD_MEDIA $NFQWS_OPT_DESYNC_DISCORD_MEDIA" + do_nfqws $1 $DNUM_DISCORD_MEDIA "$opt" +} +# size = 156 (8 udp header + 148 payload) && payload starts with 0x01000000 +zapret_custom_firewall() +{ + # $1 - 1 - run, 0 - stop + + local DISABLE_IPV6=1 + local port_range=$(replace_char - : $DISCORD_MEDIA_PORT_RANGE) + local f="-p udp --dport $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 + 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 +} +zapret_custom_firewall_nft() +{ + # stop logic is not required + + 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" + nft_fw_nfqws_post "$f" '' $QNUM_DISCORD_MEDIA +}