Skip to content

Commit

Permalink
Fix addrPortOrZero for unix sockets on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed May 27, 2023
1 parent 8e2139b commit 963c0e0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ipport.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ func addrPortOrZero(addr net.Addr) int {
case *net.TCPAddr:
return raw.Port
default:
// Consider a unix socket on Windows with a name like "C:notanint".
_, port, err := net.SplitHostPort(addr.String())
if err != nil {
return 0
}
i64, err := strconv.ParseUint(port, 0, 16)
if err != nil {
panic(err)
return 0
}
return int(i64)
}
Expand Down

0 comments on commit 963c0e0

Please sign in to comment.