From 44a17602edfc471ee04807e31d3c753423a001df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=B8=EF=B8=8F?= <29265684+buffermet@users.noreply.github.com> Date: Mon, 20 Sep 2021 15:42:07 +1000 Subject: [PATCH] fix: adopt new IPv4 parsing logic --- network/net.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/network/net.go b/network/net.go index a1497d9a..5996f85c 100644 --- a/network/net.go +++ b/network/net.go @@ -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 } }