aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxim Karasev <begs@disroot.org>2021-10-29 01:32:50 +0300
committerAndy Postnikov <apostnikov@gmail.com>2021-10-29 06:30:36 +0000
commit1825e786d33a67875f1785ce25d3c164052e85e1 (patch)
treee3562dd61bee3e05e393eccba0e1f0a45a384f45
parent55f68fa2a77dce529f6431602f692243da0644e8 (diff)
testing/zapret: fix and improve init script
-rw-r--r--testing/zapret/APKBUILD8
-rw-r--r--testing/zapret/zapret.initd26
2 files changed, 15 insertions, 19 deletions
diff --git a/testing/zapret/APKBUILD b/testing/zapret/APKBUILD
index e4c9c9e522f..8a2e8aa9399 100644
--- a/testing/zapret/APKBUILD
+++ b/testing/zapret/APKBUILD
@@ -3,13 +3,13 @@
pkgname=zapret
pkgver=0.0.0_git20211019
_commit=6a821ab49ac11819fcba014149ac25e0f89a2e30
-pkgrel=0
+pkgrel=1
pkgdesc="DPI (deep package inspection) bypass toolkit"
url="https://github.com/bol-van/zapret"
arch="all"
license="MIT"
makedepends="zlib-dev libcap-dev libnetfilter_queue-dev bsd-compat-headers"
-depends_openrc="iptables ip6tables"
+depends_openrc="iptables ip6tables ipset"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://github.com/bol-van/zapret/archive/$_commit/zapret-$pkgver.tar.gz
@@ -31,7 +31,7 @@ package() {
mkdir -p "$pkgdir"/usr/share/"$pkgname"/ipset
cp ipset/* "$pkgdir"/usr/share/"$pkgname"/ipset
- ln -s /etc/conf.d/zapret "$pkgdir"/usr/share/"$pkgname"/ipset/config
+ ln -s /etc/conf.d/zapret "$pkgdir"/usr/share/"$pkgname"/config
mkdir -p "$pkgdir"/usr/share/doc/"$pkgname"
cp -r docs/* "$pkgdir"/usr/share/doc/"$pkgname"
@@ -41,6 +41,6 @@ package() {
sha512sums="
58e872de2f519a41cc2072704bf23e6792b2f9a50b227fbafe5dae3c83346f41acbcbf774da928e7f5e3d9642a313514b2e86360b7ea49068af608188dc05c3d zapret-0.0.0_git20211019.tar.gz
-65a6ffdc2c4149978a39350163e4da96cce61d931cbbbc1c79ee672fa3b318fccea40c1aeb752b27e16fe0698bf14dadd72907ce9113bb4cc983c994b35a2b5d zapret.initd
+24d829cbe4dd74591ee31519d69e5722eda06edcbed2314b69a0da7be25053a85a1399bd9a5af84e8880a711a4434dcd9601886bc87836d80bb5e83476f33539 zapret.initd
d5836351a52ed93ef83c16a03d811c25fd0a258a3f770753045bbf9b690bf3baa2c48374632e52b6213bac158245040266210920a4e4c70064a65e8f77d46e26 zapret.confd
"
diff --git a/testing/zapret/zapret.initd b/testing/zapret/zapret.initd
index 505f464cad0..81ef0af8616 100644
--- a/testing/zapret/zapret.initd
+++ b/testing/zapret/zapret.initd
@@ -143,14 +143,14 @@ prepare_tpws_fw4() {
}
unprepare_tpws_fw4() {
- [ -n "$IFACE_LAN" ] && {
+ if [ -n "$IFACE_LAN" ]; then
for lan in $IFACE_LAN ; do
ipt_del INPUT -i $lan -j input_rule_zapret
sysctl -qw net.ipv4.conf.$lan.route_localnet=0
done
iptables -F input_rule_zapret 2>/dev/null
iptables -X input_rule_zapret 2>/dev/null
- }
+ fi
}
unprepare_tpws_fw() {
@@ -448,8 +448,9 @@ tpws_apply_socks_binds() {
}
create_ipset() {
- echo "Creating ipset"
+ ebegin "Creating ipset"
"$IPSET_CR" "$@"
+ eend $?
}
zapret_do_firewall() {
@@ -474,7 +475,6 @@ zapret_do_firewall() {
fw_tpws $1 "$f4" "$f6" $TPPORT
fi
;;
-
nfqws)
if [ ! "$MODE_HTTP" = "1" ] && [ ! "$MODE_HTTPS" = "1" ]; then
echo both http and https are disabled. not applying redirection.
@@ -508,15 +508,9 @@ zapret_do_firewall() {
existf zapret_custom_firewall && zapret_custom_firewall $1
;;
esac
- [ "$1" = 0 ] && unprepare_tpws_fw
-}
-
-zapret_apply_firewall() {
- zapret_do_firewall 1 "$@"
-}
-
-zapret_unapply_firewall() {
- zapret_do_firewall 0 "$@"
+ if [ "$1" = 0 ]; then
+ unprepare_tpws_fw
+ fi
}
zapret_do_daemons() {
@@ -552,9 +546,11 @@ zapret_do_daemons() {
}
start() {
- zapret_do_daemons 1 "$@"
+ zapret_do_daemons 1
+ [ "$INIT_APPLY_FW" != "1" ] || zapret_do_firewall 1
}
stop() {
- zapret_do_daemons 0 "$@"
+ zapret_do_daemons 0
+ [ "$INIT_APPLY_FW" != "1" ] || zapret_do_firewall 0
}