mirror of
https://github.com/bol-van/zapret.git
synced 2025-05-24 22:32:58 +03:00
fixing lots of problems with getting link local address after reboot
This commit is contained in:
@@ -5,6 +5,12 @@ TPPORT_HTTP=1188
|
||||
TPPORT_HTTPS=1189
|
||||
TPWS_USER=daemon
|
||||
|
||||
# max wait time for the link local ipv6 on the LAN interface
|
||||
LINKLOCAL_WAIT_SEC=5
|
||||
|
||||
[ -n "$ZAPRET_BASE" ] || ZAPRET_BASE=/opt/zapret
|
||||
IPSET_CR=$ZAPRET_BASE/ipset/create_ipset.sh
|
||||
|
||||
exists()
|
||||
{
|
||||
which $1 >/dev/null 2>/dev/null
|
||||
@@ -71,16 +77,32 @@ 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" ] || {
|
||||
# no reason to query if its down
|
||||
network_is_up lan || return
|
||||
|
||||
local DEVICE
|
||||
network_get_device DEVICE lan
|
||||
DNAT6_TARGET=$(get_ipv6_linklocal $DEVICE)
|
||||
[ -z "$DNAT6_TARGET" ] && DNAT6_TARGET=$(get_ipv6_global $DEVICE)
|
||||
|
||||
local ct=0
|
||||
while
|
||||
DNAT6_TARGET=$(get_ipv6_linklocal $DEVICE)
|
||||
[ -n "$DNAT6_TARGET" ] && break
|
||||
[ "$ct" -ge "$LINKLOCAL_WAIT_SEC" ] && break
|
||||
echo waiting for the link local for another $(($LINKLOCAL_WAIT_SEC - $ct)) seconds ...
|
||||
ct=$(($ct+1))
|
||||
sleep 1
|
||||
do :; done
|
||||
|
||||
[ -z "$DNAT6_TARGET" ] && {
|
||||
echo no link local. getting global
|
||||
DNAT6_TARGET=$(get_ipv6_global $DEVICE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fw_nfqws()
|
||||
{
|
||||
local DEVICE wan_iface
|
||||
@@ -150,3 +172,11 @@ fw_tpws_https6()
|
||||
{
|
||||
__fw_tpws6 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
create_ipset()
|
||||
{
|
||||
echo "Creating ipset"
|
||||
"$IPSET_CR" $1
|
||||
}
|
||||
|
Reference in New Issue
Block a user