1
0
Fork 0

Remove interface names from IPv6

This commit is contained in:
Jeroen De Meerleer 2024-07-01 16:26:04 +02:00 committed by GitHub
parent 12fae2ebb8
commit 8946dd1898
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -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
}