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 {
address := a.String()
if IPv4Validator.MatchString(address) {
if !strings.ContainsRune(address, '/') {
// plain ip
e.SetIP(address)
} else {
// ip/bits
e.SetNetwork(address)
}
} else {
// ipv6/xxx
switch true {
case IPv4Validator.MatchString(address):
e.SetIP(address)
break
case IPv4BlockValidator.MatchString(address):
e.SetNetwork(address)
break
default:
e.SetIPv6(address)
break
}
}