2021-03-04 11:30:38 +00:00
|
|
|
# this custom script demonstrates how to apply tpws to http and nfqws to https
|
2021-03-20 15:54:16 +00:00
|
|
|
# it preserves config settings : MODE_HTTP, MODE_HTTPS, MODE_FILTER, TPWS_OPT, NFQWS_OPT_DESYNC, NFQWS_OPT_DESYNC_HTTPS
|
2021-03-04 11:30:38 +00:00
|
|
|
|
|
|
|
zapret_custom_daemons()
|
|
|
|
{
|
2022-02-15 14:15:36 +00:00
|
|
|
# $1 - 1 - run, 0 - stop
|
|
|
|
|
2021-03-04 11:30:38 +00:00
|
|
|
local opt
|
|
|
|
|
|
|
|
[ "$MODE_HTTP" = "1" ] && {
|
2021-03-20 10:03:47 +00:00
|
|
|
opt="--port=$TPPORT $TPWS_OPT"
|
2021-03-04 11:30:38 +00:00
|
|
|
filter_apply_hostlist_target opt
|
|
|
|
do_tpws $1 1 "$opt"
|
|
|
|
}
|
|
|
|
|
|
|
|
[ "$MODE_HTTPS" = "1" ] && {
|
2021-03-20 15:54:16 +00:00
|
|
|
opt="--qnum=$QNUM $NFQWS_OPT_DESYNC_HTTPS"
|
2021-03-04 11:30:38 +00:00
|
|
|
filter_apply_hostlist_target opt
|
2024-09-18 16:27:50 +00:00
|
|
|
filter_apply_suffix opt "$NFQWS_OPT_DESYNC_HTTPS_SUFFIX"
|
2021-03-04 11:30:38 +00:00
|
|
|
do_nfqws $1 2 "$opt"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
zapret_custom_firewall()
|
|
|
|
{
|
2022-02-15 14:15:36 +00:00
|
|
|
# $1 - 1 - run, 0 - stop
|
|
|
|
|
2021-03-04 11:30:38 +00:00
|
|
|
local f4 f6
|
2024-03-02 14:53:37 +00:00
|
|
|
local first_packet_only="$ipt_connbytes 1:$(first_packets_for_mode)"
|
2021-03-04 11:30:38 +00:00
|
|
|
local desync="-m mark ! --mark $DESYNC_MARK/$DESYNC_MARK"
|
|
|
|
|
|
|
|
[ "$MODE_HTTP" = "1" ] && {
|
2023-12-13 14:10:56 +00:00
|
|
|
f4="-p tcp -m multiport --dports $HTTP_PORTS_IPT"
|
2021-03-04 11:30:38 +00:00
|
|
|
f6=$f4
|
|
|
|
filter_apply_ipset_target f4 f6
|
|
|
|
fw_tpws $1 "$f4" "$f6" $TPPORT
|
|
|
|
}
|
|
|
|
|
|
|
|
[ "$MODE_HTTPS" = "1" ] && {
|
2023-12-13 14:10:56 +00:00
|
|
|
f4="-p tcp -m multiport --dports $HTTPS_PORTS_IPT $first_packet_only"
|
2021-03-04 11:30:38 +00:00
|
|
|
f6=$f4
|
|
|
|
filter_apply_ipset_target f4 f6
|
|
|
|
fw_nfqws_post $1 "$f4 $desync" "$f6 $desync" $QNUM
|
2024-03-02 14:53:37 +00:00
|
|
|
# for modes that require incoming traffic
|
|
|
|
fw_reverse_nfqws_rule $1 "$f4" "$f6" $QNUM
|
2021-03-04 11:30:38 +00:00
|
|
|
}
|
|
|
|
}
|
2022-02-15 14:15:36 +00:00
|
|
|
zapret_custom_firewall_nft()
|
|
|
|
{
|
|
|
|
# stop logic is not required
|
|
|
|
|
|
|
|
local f4 f6
|
2024-03-02 14:53:37 +00:00
|
|
|
local first_packet_only="$nft_connbytes 1-$(first_packets_for_mode)"
|
2022-02-15 14:15:36 +00:00
|
|
|
local desync="mark and $DESYNC_MARK == 0"
|
|
|
|
|
|
|
|
[ "$MODE_HTTP" = "1" ] && {
|
2023-12-13 14:10:56 +00:00
|
|
|
f4="tcp dport {$HTTP_PORTS}"
|
2022-02-15 14:15:36 +00:00
|
|
|
f6=$f4
|
|
|
|
nft_filter_apply_ipset_target f4 f6
|
|
|
|
nft_fw_tpws "$f4" "$f6" $TPPORT
|
|
|
|
}
|
|
|
|
|
|
|
|
[ "$MODE_HTTPS" = "1" ] && {
|
2023-12-13 14:10:56 +00:00
|
|
|
f4="tcp dport {$HTTPS_PORTS} $first_packet_only"
|
2022-02-15 14:15:36 +00:00
|
|
|
f6=$f4
|
|
|
|
nft_filter_apply_ipset_target f4 f6
|
|
|
|
nft_fw_nfqws_post "$f4 $desync" "$f6 $desync" $QNUM
|
2024-03-02 14:53:37 +00:00
|
|
|
# for modes that require incoming traffic
|
|
|
|
nft_fw_reverse_nfqws_rule "$f4" "$f6" $QNUM
|
2022-02-15 14:15:36 +00:00
|
|
|
}
|
|
|
|
}
|