sysv init calls : start-fw,stop-fw

This commit is contained in:
bolvan
2019-05-14 23:14:14 +03:00
parent 3b61dbc20f
commit 087c374959
5 changed files with 66 additions and 42 deletions

View File

@@ -78,7 +78,9 @@ dnat6_target()
# get target ip address for DNAT. prefer link locals
# tpws should be as inaccessible from outside as possible
# link local address can appear not immediately after ifup
[ -n "$DNAT6_TARGET" ] || {
# DNAT6_TARGET=- means attempt was made but address was not found (to avoid multiple re-attempts)
[ "$DNAT6_TARGET" = '-' ] || {
# no reason to query if its down
network_is_up lan || return
@@ -95,9 +97,13 @@ dnat6_target()
sleep 1
do :; done
[ -z "$DNAT6_TARGET" ] && {
echo no link local. getting global
DNAT6_TARGET=$(get_ipv6_global $DEVICE)
[ -n "$DNAT6_TARGET" ] || {
echo no link local. getting global
DNAT6_TARGET=$(get_ipv6_global $DEVICE)
[ -n "$DNAT6_TARGET" ] || {
echo could not get any address
DNAT6_TARGET=-
}
}
}
}
@@ -161,8 +167,10 @@ __fw_tpws6()
done
network_get_device DEVICE lan
dnat6_target
ipt6 PREROUTING -t nat -i $DEVICE $IPT_FILTER_HTTP -j DNAT --to [$DNAT6_TARGET]:$TPPORT_HTTP
[ "$1" != "1" ] || ipt6 PREROUTING -t nat -i $DEVICE $IPT_FILTER_HTTPS -j DNAT --to [$DNAT6_TARGET]:$TPPORT_HTTPS
[ "$DNAT6_TARGET" != '-' ] && {
ipt6 PREROUTING -t nat -i $DEVICE $IPT_FILTER_HTTP -j DNAT --to [$DNAT6_TARGET]:$TPPORT_HTTP
[ "$1" != "1" ] || ipt6 PREROUTING -t nat -i $DEVICE $IPT_FILTER_HTTPS -j DNAT --to [$DNAT6_TARGET]:$TPPORT_HTTPS
}
}
fw_tpws6()
{
@@ -177,6 +185,6 @@ fw_tpws_https6()
create_ipset()
{
echo "Creating ipset"
"$IPSET_CR" $1
echo "Creating ipset"
"$IPSET_CR" $1
}

View File

@@ -48,8 +48,8 @@ run_daemon()
run_tpws()
{
[ "$DISABLE_IPV4" != "1" ] && run_daemon $1 $TPWS "$TPWS_OPT_BASE $2"
[ "$DISABLE_IPV6" != "1" ] && {
[ "$DISABLE_IPV4" = "1" ] || run_daemon $1 $TPWS "$TPWS_OPT_BASE $2"
[ "$DISABLE_IPV6" = "1" ] || {
run_daemon $((60+$1)) $TPWS "$TPWS_OPT_BASE6 $2"
network_get_device DEVICE lan
[ -n "$DEVICE" ] && run_daemon $((660+$1)) $TPWS "$TPWS_OPT_BASE6_PRE --bind-iface6=$DEVICE $2"
@@ -57,8 +57,8 @@ run_tpws()
}
stop_tpws()
{
[ "$DISABLE_IPV4" != "1" ] && stop_daemon $1 $TPWS
[ "$DISABLE_IPV6" != "1" ] && {
[ "$DISABLE_IPV4" = "1" ] || stop_daemon $1 $TPWS
[ "$DISABLE_IPV6" = "1" ] || {
stop_daemon $((60+$1)) $TPWS
stop_daemon $((660+$1)) $TPWS
}