diff --git a/random_local_ip.go b/random_local_ip.go index d89285a..e5106c2 100644 --- a/random_local_ip.go +++ b/random_local_ip.go @@ -125,16 +125,9 @@ func getNextIP(availableIPs *availableIPs) net.IP { } func getLocalAddr(network, IP string) any { - lastColon := strings.LastIndex(IP, ":") - if lastColon == -1 { - return nil - } - - ip := IP[:lastColon] - ip = strings.TrimPrefix(ip, "[") - ip = strings.TrimSuffix(ip, "]") + IP = strings.Trim(IP, "[]") - destIP := net.ParseIP(ip) + destIP := net.ParseIP(IP) if destIP == nil { return nil }