Remove interface names from IPv6
This commit is contained in:
parent
12fae2ebb8
commit
8946dd1898
2 changed files with 7 additions and 3 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -91,10 +92,11 @@ func (ip *Checker) ContainsIP(addr net.IP) bool {
|
|||
}
|
||||
|
||||
func parseIP(addr string) (net.IP, error) {
|
||||
userIP := net.ParseIP(addr)
|
||||
if userIP == nil {
|
||||
parsedAddr, err := netip.ParseAddr(addr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't parse IP from address %s", addr)
|
||||
}
|
||||
|
||||
return userIP, nil
|
||||
ip := parsedAddr.As16()
|
||||
return ip[:], nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue