Skip to content

Commit 2d5df04

Browse files
committed
修复 codex review 警告
从 IPv4 已过滤的 scope link 路由提取 LAN 接口名,再用这些接口名去查 IPv6 全局前缀
1 parent b4a9702 commit 2d5df04

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scripts/starts/fw_getlanip.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@ getlanip() { #获取局域网host地址
33
while [ "$i" -le "20" ]; do
44
#ipv4局域网网段
55
host_ipv4=$(ip route show scope link | grep -Ev 'wan|utun|iot|peer|docker|podman|virbr|vnet|ovs|vmbr|veth|vmnic|vboxnet|lxcbr|xenbr|vEthernet' | awk '{print $1}')
6-
#ipv6局域网网段
7-
[ "$ipv6_redir" = "ON" ] && host_ipv6=$(ip -6 route show | grep -Ev 'default|unreachable|fe80::/|wan|ppp|utun|iot|peer|docker|podman|virbr|vnet|ovs|vmbr|veth|vmnic|vboxnet|lxcbr|xenbr|vEthernet' | awk '{print $1}' | tr '\n' ' ' | sed 's/ $//')
6+
#ipv6局域网网段 - 从IPv4已识别的LAN接口获取全局IPv6前缀
7+
[ "$ipv6_redir" = "ON" ] && {
8+
lan_ifaces=$(ip route show scope link | grep -Ev 'ppp|wan|utun|iot|peer|docker|podman|virbr|vnet|ovs|vmbr|veth|vmnic|vboxnet|lxcbr|xenbr|vEthernet' | awk '{for(i=1;i<=NF;i++) if($i=="dev") {print $(i+1); break}}' | grep -v '^lo$' | sort -u)
9+
host_ipv6=$(
10+
for iface in $lan_ifaces; do
11+
ip -6 addr show dev $iface 2>/dev/null
12+
done | grep 'scope global' | awk '{print $2}' | tr '\n' ' ' | sed 's/ $//'
13+
)
14+
}
815
[ -f "$TMPDIR"/ShellCrash.log ] && break
916
[ -n "$host_ipv4" -a "$ipv6_redir" != "ON" ] && break
1017
[ -n "$host_ipv4" -a -n "$host_ipv6" ] && break

0 commit comments

Comments
 (0)