From 7557c9bd4e65b34d9f1f7307f7841f27ec8d2a78 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 30 Aug 2016 14:19:29 +1000 Subject: [PATCH] Only parse the config listen addr if we have to This fixes a broken benchmark --- client.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) 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 -- 2.48.1