core: Change net.IP to netip.Addr; use netip.Prefix (#4966)

Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
This commit is contained in:
WilczyńskiT
2022-08-18 00:10:57 +02:00
committed by GitHub
parent a944de4ab7
commit c7772588bd
5 changed files with 50 additions and 57 deletions

View File

@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"net"
"net/netip"
"os"
"strconv"
"strings"
@ -400,7 +401,7 @@ func (na NetworkAddress) isLoopback() bool {
if na.Host == "localhost" {
return true
}
if ip := net.ParseIP(na.Host); ip != nil {
if ip, err := netip.ParseAddr(na.Host); err == nil {
return ip.IsLoopback()
}
return false
@ -410,7 +411,7 @@ func (na NetworkAddress) isWildcardInterface() bool {
if na.Host == "" {
return true
}
if ip := net.ParseIP(na.Host); ip != nil {
if ip, err := netip.ParseAddr(na.Host); err == nil {
return ip.IsUnspecified()
}
return false