rc.services: exclude wireguard tunnels for ntp (code optimization)

This commit is contained in:
bergware
2023-07-18 13:12:11 +02:00
parent a5b16f05bb
commit 5adeed0515

View File

@@ -190,15 +190,14 @@ check() {
nets=()
while IFS='\n' read -r net; do
net=($net)
# exclude wireguard VPN docker tunnels
[[ ${net:0:2} == wg && $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8 ]] && continue
# exclude wireguard VPN docker tunnels and ntp
[[ ${net:0:2} == wg && ($CALLER == ntp || $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8) ]] && continue
net1=$(sub ${net[1]})
if [[ "avahi show" =~ $CALLER ]]; then
[[ -n $net && -n $net1 && -z $(good $net $net1) ]] && bind+=($net)
[[ -n $net1 ]] && ipv4=yes nets+=($net1)
else
# exclude wireguard tunnels for ntp
[[ $CALLER == ntp && ${net:0:2} == wg ]] && continue
[[ -n $net1 && -z $(good $net1) ]] && ipv4=yes bind+=($net1)
fi
done <<< $(ip -br -4 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ {print $1,$3}'|sort)
@@ -206,15 +205,14 @@ check() {
nets=()
while IFS='\n' read -r net; do
net=($net)
# exclude wireguard VPN docker tunnels
[[ ${net:0:2} == wg && $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8 ]] && continue
# exclude wireguard VPN docker tunnels and ntp
[[ ${net:0:2} == wg && ($CALLER == ntp || $(grep -Pom1 '^TYPE:1="\K[^"]+' $WIREGUARD/$net.cfg) == 8) ]] && continue
net1=$(sub $(main ${net[@]}))
if [[ "avahi show" =~ $CALLER ]]; then
[[ -n $net && -n $net1 && -z $(good $net $net1) ]] && bind+=($net)
[[ -n $net1 ]] && ipv6=yes nets+=($net1)
else
# exclude wireguard tunnels for ntp
[[ $CALLER == ntp && ${net:0:2} == wg ]] && continue
[[ -z $deny6 && -n $net1 && -z $(good $net1) ]] && ipv6=yes bind+=($net1)
fi
done <<< $(ip -br -6 addr show scope global|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/{$2="";print}'|sort)