Skip to content

Commit

Permalink
remove port trimming from getLocalAddr
Browse files Browse the repository at this point in the history
  • Loading branch information
equals215 committed Sep 26, 2024
1 parent b09abca commit 7d0e9b1
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions random_local_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 7d0e9b1

Please sign in to comment.