From 378b7ebf262957fe426ce3840cce35271fa10641 Mon Sep 17 00:00:00 2001 From: bol-van Date: Fri, 4 Mar 2022 19:41:34 +0300 Subject: [PATCH] init.d: QUIC customs --- init.d/openwrt/custom-nfqws-quic4all | 47 ++++++++++++++++++++++++++++ init.d/sysv/custom-nfqws-quic4all | 47 ++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 init.d/openwrt/custom-nfqws-quic4all create mode 100644 init.d/sysv/custom-nfqws-quic4all diff --git a/init.d/openwrt/custom-nfqws-quic4all b/init.d/openwrt/custom-nfqws-quic4all new file mode 100644 index 0000000..e6d6ae7 --- /dev/null +++ b/init.d/openwrt/custom-nfqws-quic4all @@ -0,0 +1,47 @@ +# this custom script in addition to MODE=nfqws runs desync to all QUIC initial packets, without ipset/hostlist filtering +# need to add to config : NFQWS_OPT_DESYNC_QUIC="--dpi-desync=fake --dpi-desync-fooling=badsum --dpi-desync-cutoff=d4" +# NOTE : do not use TTL fooling. chromium QUIC engine breaks sessions if TTL expired in transit received + +QNUM2=$(($QNUM+10)) + +zapret_custom_daemons() +{ + # stop logic is managed by procd + + local MODE_OVERRIDE=nfqws + local opt + + start_daemons_procd + + opt="--qnum=$QNUM2 $NFQWS_OPT_BASE $NFQWS_OPT_DESYNC_QUIC" + run_daemon 100 $NFQWS "$opt" +} +zapret_custom_firewall() +{ + # $1 - 1 - run, 0 - stop + + local MODE_OVERRIDE=nfqws + local f + local first_packets_only="-m connbytes --connbytes-dir=original --connbytes-mode=packets --connbytes 1:3" + local desync="-m mark ! --mark $DESYNC_MARK/$DESYNC_MARK" + + zapret_do_firewall_rules_ipt $1 + + f="-p udp --dport 443" + fw_nfqws_post $1 "$f $desync $first_packets_only" "$f $desync $first_packets_only" $QNUM2 + +} +zapret_custom_firewall_nft() +{ + # stop logic is not required + + local MODE_OVERRIDE=nfqws + local f + local first_packets_only="ct original packets 1-3" + local desync="mark and $DESYNC_MARK == 0" + + zapret_apply_firewall_rules_nft + + f="udp dport 443" + nft_fw_nfqws_post $1 "$f $desync $first_packets_only" "$f $desync $first_packets_only" $QNUM2 +} diff --git a/init.d/sysv/custom-nfqws-quic4all b/init.d/sysv/custom-nfqws-quic4all new file mode 100644 index 0000000..3542c39 --- /dev/null +++ b/init.d/sysv/custom-nfqws-quic4all @@ -0,0 +1,47 @@ +# this custom script in addition to MODE=nfqws runs desync to all QUIC initial packets, without ipset/hostlist filtering +# need to add to config : NFQWS_OPT_DESYNC_QUIC="--dpi-desync=fake --dpi-desync-fooling=badsum --dpi-desync-cutoff=d4" +# NOTE : do not use TTL fooling. chromium QUIC engine breaks sessions if TTL expired in transit received + +QNUM2=$(($QNUM+10)) + +zapret_custom_daemons() +{ + # $1 - 1 - run, 0 - stop + + local MODE_OVERRIDE=nfqws + local opt + + zapret_do_daemons $1 + + opt="--qnum=$QNUM2 $NFQWS_OPT_BASE $NFQWS_OPT_DESYNC_QUIC" + do_nfqws $1 100 "$opt" +} +zapret_custom_firewall() +{ + # $1 - 1 - run, 0 - stop + + local MODE_OVERRIDE=nfqws + local f + local first_packets_only="-m connbytes --connbytes-dir=original --connbytes-mode=packets --connbytes 1:3" + local desync="-m mark ! --mark $DESYNC_MARK/$DESYNC_MARK" + + zapret_do_firewall_rules_ipt $1 + + f="-p udp --dport 443" + fw_nfqws_post $1 "$f $desync $first_packets_only" "$f $desync $first_packets_only" $QNUM2 + +} +zapret_custom_firewall_nft() +{ + # stop logic is not required + + local MODE_OVERRIDE=nfqws + local f + local first_packets_only="ct original packets 1-3" + local desync="mark and $DESYNC_MARK == 0" + + zapret_apply_firewall_rules_nft + + f="udp dport 443" + nft_fw_nfqws_post $1 "$f $desync $first_packets_only" "$f $desync $first_packets_only" $QNUM2 +}