fix: better ipv6 detection logic

This commit is contained in:
Simone Margaritelli 2024-09-22 15:03:06 +02:00
parent 8446d66d12
commit a234c20650
5 changed files with 30 additions and 12 deletions

View file

@ -196,16 +196,12 @@ func buildEndpointFromInterface(iface net.Interface) (*Endpoint, error) {
for _, a := range addrs {
address := a.String()
switch true {
case IPv4Validator.MatchString(address):
if IPv4Validator.MatchString(address) {
e.SetIP(address)
break
case IPv4BlockValidator.MatchString(address):
} else if IPv4BlockValidator.MatchString(address) {
e.SetNetwork(address)
break
default:
} else {
e.SetIPv6(address)
break
}
}