core: 修复 windows 下未能记录 32 位 ipv4 掩码和 dhcpv6 ip

This commit is contained in:
bin456789 2023-11-04 12:40:26 +08:00
parent 275a3fc36f
commit 1b9069272d
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -781,7 +781,7 @@ collect_netconf() {
ip=${ips[i]}
subnet=${subnets[i]}
if [[ "$ip" = *.* ]]; then
cidr=$(ipcalc -b "$ip/$subnet" | grep Network: | cut -d/ -f2 | xargs)
cidr=$(ipcalc -b "$ip/$subnet" | grep Netmask: | awk '{print $NF}')
ipv4_addr="$ip/$cidr"
break
fi
@ -794,8 +794,10 @@ collect_netconf() {
cidr=${subnets[i]}
if [[ "$ip" = *:* ]]; then
ipv6_type=$(grep "$ip" <<<"$ipv6_type_list" | awk '{print $1}')
# Public 是 slaac
# 还有类型 Temporary不过有 Temporary 肯定还有 Public因此不用
if [ "$ipv6_type" = Public ] ||
[ "$ipv6_type" = Dhcp ] ||
[ "$ipv6_type" = Manual ]; then
ipv6_addr="$ip/$cidr"
break