From: Matt Joiner Date: Tue, 30 Aug 2016 04:19:29 +0000 (+1000) Subject: Only parse the config listen addr if we have to X-Git-Tag: v1.0.0~608 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=7557c9bd4e65b34d9f1f7307f7841f27ec8d2a78;p=btrtrc.git Only parse the config listen addr if we have to This fixes a broken benchmark --- diff --git a/client.go b/client.go index 00a474c5..cae1ee7a 100644 --- a/client.go +++ b/client.go @@ -200,13 +200,17 @@ func listen(tcp, utp bool, networkSuffix, addr string) (tcpL net.Listener, utpSo if addr == "" { addr = ":50007" } - host, port, err := missinggo.ParseHostPort(addr) - if err != nil { - return - } - if tcp && utp && port == 0 { - // If both protocols are active, they need to have the same port. - return listenBothSameDynamicPort(networkSuffix, host) + if tcp && utp { + var host string + var port int + host, port, err = missinggo.ParseHostPort(addr) + if err != nil { + return + } + if port == 0 { + // If both protocols are active, they need to have the same port. + return listenBothSameDynamicPort(networkSuffix, host) + } } defer func() { if err != nil { @@ -1405,8 +1409,8 @@ type Handle interface { // magnet URIs and torrent metainfo files. type TorrentSpec struct { // The tiered tracker URIs. - Trackers [][]string - InfoHash metainfo.Hash + Trackers [][]string + InfoHash metainfo.Hash InfoBytes []byte // The name to use if the Name field from the Info isn't available. DisplayName string