fix: adopt new IPv4 parsing logic

This commit is contained in:
☸️ 2021-09-20 15:42:07 +10:00 committed by GitHub
commit 44a17602ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -196,17 +196,16 @@ func buildEndpointFromInterface(iface net.Interface) (*Endpoint, error) {
for _, a := range addrs { for _, a := range addrs {
address := a.String() address := a.String()
if IPv4Validator.MatchString(address) { switch true {
if !strings.ContainsRune(address, '/') { case IPv4Validator.MatchString(address):
// plain ip
e.SetIP(address) e.SetIP(address)
} else { break
// ip/bits case IPv4BlockValidator.MatchString(address):
e.SetNetwork(address) e.SetNetwork(address)
} break
} else { default:
// ipv6/xxx
e.SetIPv6(address) e.SetIPv6(address)
break
} }
} }