fix: IPv6 supports prefixlen 128 (#301)

fix: #300
This commit is contained in:
jeessy2
2022-06-14 18:10:16 +08:00
committed by GitHub
parent 29ef7ee973
commit c7d63c22e3

View File

@ -31,9 +31,9 @@ func GetNetInterface() (ipv4NetInterfaces []NetInterface, ipv6NetInterfaces []Ne
for _, address := range addrs {
if ipnet, ok := address.(*net.IPNet); ok && ipnet.IP.IsGlobalUnicast() {
ones, bits := ipnet.Mask.Size()
_, bits := ipnet.Mask.Size()
// 需匹配全局单播地址
if bits == 128 && ones < bits && ipv6Unicast.Contains(ipnet.IP) {
if bits == 128 && ipv6Unicast.Contains(ipnet.IP) {
ipv6 = append(ipv6, ipnet.IP.String())
}
if bits == 32 {