From 05d299e13d23555d0d3d9bf2ddab15bcc9193063 Mon Sep 17 00:00:00 2001 From: bol-van Date: Thu, 9 Dec 2021 20:22:28 +0300 Subject: [PATCH] blockcheck: improve graceful termination --- blockcheck.sh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/blockcheck.sh b/blockcheck.sh index eec7479..c06003e 100755 --- a/blockcheck.sh +++ b/blockcheck.sh @@ -394,6 +394,7 @@ check_domain() # in case was interrupted before nfqws_ipt_unprepare $2 + tpws_ipt_unprepare $2 killall nfqws tpws 2>/dev/null echo "- checking without DPI bypass" @@ -432,6 +433,19 @@ check_domain_https() check_domain curl_test_https 443 1 $1 } +configure_ip_version() +{ + if [ "$IPV" = 6 ]; then + IPTABLES=ip6tables; + LOCALHOST=::1; + LOCALHOST_IPT=[::1]; + else + IPTABLES=iptables + LOCALHOST=127.0.0.1 + LOCALHOST_IPT=127.0.0.1 + fi +} + ask_params() { echo @@ -450,10 +464,7 @@ ask_params() echo invalid ip version. should be 4 or 6. exitp 1 } - IPTABLES=iptables - LOCALHOST=127.0.0.1 - LOCALHOST_IPT=127.0.0.1 - [ "$IPV" = 6 ] && { IPTABLES=ip6tables; LOCALHOST=::1; LOCALHOST_IPT=[::1]; } + configure_ip_version ENABLE_HTTP=1 ask_yes_no_var ENABLE_HTTP "check http" @@ -576,10 +587,12 @@ sigint() # make sure we are not in a middle state that impacts connectivity echo echo terminating... - tpws_ipt_unprepare 80 - tpws_ipt_unprepare 443 - nfqws_ipt_unprepare 80 - nfqws_ipt_unprepare 443 + [ -n "$IPV" ] && { + tpws_ipt_unprepare 80 + tpws_ipt_unprepare 443 + nfqws_ipt_unprepare 80 + nfqws_ipt_unprepare 443 + } killall nfqws tpws 2>/dev/null exitp 1 }