]> Sergey Matveev's repositories - btrtrc.git/blobdiff - ipport.go
Drop support for go 1.20
[btrtrc.git] / ipport.go
index f710354a938362c2ce30c4c6dca465abb8763399..a85a97fc10422229ba7cdaececd7fbe5d4b5abbc 100644 (file)
--- a/ipport.go
+++ b/ipport.go
@@ -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.ParseInt(port, 0, 0)
+               i64, err := strconv.ParseUint(port, 0, 16)
                if err != nil {
-                       panic(err)
+                       return 0
                }
                return int(i64)
        }