mirror of
https://github.com/unraid/webgui.git
synced 2026-01-05 00:59:48 -06:00
rc.library: do not allow duplicates in bind list
This commit is contained in:
@@ -48,9 +48,14 @@ scan() {
|
||||
|
||||
good() {
|
||||
data=;
|
||||
for i in ${!bind[@]}; do
|
||||
[[ ${bind[$i]} == $1 || ${1:0:4} == fe80 ]] && data=$1
|
||||
for i in ${bind[@]}; do
|
||||
[[ $i == $1 || ${1:0:4} == fe80 ]] && data=$1
|
||||
done
|
||||
if [[ -n $2 ]]; then
|
||||
for i in ${nets[@]}; do
|
||||
[[ $i == $2 || ${2:0:4} == fe80 ]] && data=$2
|
||||
done
|
||||
fi
|
||||
echo $data
|
||||
}
|
||||
|
||||
@@ -137,27 +142,31 @@ check() {
|
||||
# preset return values
|
||||
bind=(); ipv4=no; ipv6=no; family=any;
|
||||
# active ipv4 interfaces (including wireguard)
|
||||
nets=()
|
||||
while IFS='\n' read -r net; do
|
||||
net=($net)
|
||||
net1=$(sub ${net[1]})
|
||||
if [[ "avahi show" =~ $CALLER ]]; then
|
||||
[[ -n $net && -z $(good $net) ]] && bind+=($net)
|
||||
[[ -n ${net[1]} ]] && ipv4=yes
|
||||
[[ -n $net && -z $(good $net $net1) ]] && bind+=($net)
|
||||
[[ -n $net1 ]] && ipv4=yes nets+=($net1)
|
||||
else
|
||||
# exclude wireguard tunnels for ntp
|
||||
[[ $CALLER == ntp ]] && name=$(show ${net[1]}) || name=
|
||||
[[ ${name:0:2} != wg && -n ${net[1]} && -z $(good ${net[1]}) ]] && ipv4=yes bind+=($(sub ${net[1]}))
|
||||
[[ $CALLER == ntp ]] && name=$(show $net1) || name=
|
||||
[[ ${name:0:2} != wg && -n $net1 && -z $(good $net1) ]] && ipv4=yes bind+=($net1)
|
||||
fi
|
||||
done <<< $(ip -br -4 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ {print $1,$3}')
|
||||
# active ipv6 interfaces (including wireguard)
|
||||
nets=()
|
||||
while IFS='\n' read -r net; do
|
||||
net=($net)
|
||||
net1=$(sub ${net[1]})
|
||||
if [[ "avahi show" =~ $CALLER ]]; then
|
||||
[[ -n $net && -z $(good $net) ]] && bind+=($net)
|
||||
[[ -n ${net[1]} ]] && ipv6=yes
|
||||
[[ -n $net && -z $(good $net $net1) ]] && bind+=($net)
|
||||
[[ -n $net1 ]] && ipv6=yes nets+=($net1)
|
||||
else
|
||||
# exclude wireguard tunnels for ntp
|
||||
[[ $CALLER == ntp ]] && name=$(show ${net[1]}) || name=
|
||||
[[ ${name:0:2} != wg && -n ${net[1]} && -z $(good ${net[1]}) ]] && ipv6=yes bind+=($(sub ${net[1]}))
|
||||
[[ $CALLER == ntp ]] && name=$(show $net1) || name=
|
||||
[[ ${name:0:2} != wg && -n $net1 && -z $(good $net1) ]] && ipv6=yes bind+=($net1)
|
||||
fi
|
||||
done <<< $(ip -br -6 addr|awk '/^(br|bond|eth|wg)[0-9]+(\.[0-9]+)?/ && $3 !~ "^fe80" {print $1,$3}')
|
||||
# add loopback interface
|
||||
|
||||
Reference in New Issue
Block a user