init,install_easy: socks mode

This commit is contained in:
bol-van
2021-03-04 21:03:26 +03:00
parent 5228b91ea5
commit ae9a72f5b0
6 changed files with 98 additions and 17 deletions

View File

@@ -9,6 +9,7 @@ HOSTLIST="$ZHOSTLIST.gz"
PIDDIR=/var/run
TPPORT=988
TPWS_USER=daemon
TPWS_WAIT="--bind-wait-ip=60"
TPWS="$ZAPRET_BASE/tpws/tpws"
@@ -85,6 +86,7 @@ filter_apply_hostlist_target()
# $1 - var name of tpws or nfqws params
[ "$MODE_FILTER" = "hostlist" ] && eval $1="\"\$$1 --hostlist=$HOSTLIST\""
}
tpws_apply_binds()
{
local o
@@ -96,6 +98,20 @@ tpws_apply_binds()
}
eval $1="\"\$$1 $o\""
}
tpws_apply_socks_binds()
{
local o
[ "$DISABLE_IPV4" = "1" ] || {
o="--bind-addr=127.0.0.1"
[ -n "$IFACE_LAN" ] && o="$o --bind-iface4=$IFACE_LAN $TPWS_WAIT"
}
[ "$DISABLE_IPV6" = "1" ] || {
o="$o --bind-addr=::1"
[ -n "$IFACE_LAN" ] && o="$o --bind-iface6=$IFACE_LAN $TPWS_WAIT"
}
eval $1="\"\$$1 $o\""
}
wait_interface_ll()
{
@@ -374,6 +390,8 @@ zapret_do_firewall()
pf_anchors_clear
fi
;;
tpws-socks)
;;
*)
echo "unsupported MODE=$MODE"
return 1
@@ -416,6 +434,16 @@ zapret_do_daemons()
opt="$opt $TPWS_OPT"
do_daemon $1 1 "$TPWS" "$opt"
;;
tpws-socks)
[ "$1" = "1" ] && [ "$DISABLE_IPV4" = "1" ] && [ "$DISABLE_IPV6" = "1" ] && {
echo "both ipv4 and ipv6 are disabled. nothing to do"
return 0
}
opt="--socks --user=$TPWS_USER --port=$TPPORT"
tpws_apply_socks_binds opt
filter_apply_hostlist_target opt
do_daemon $1 1 "$TPWS" "$opt"
;;
filter)
;;
custom)