]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Only parse the config listen addr if we have to
authorMatt Joiner <anacrolix@gmail.com>
Tue, 30 Aug 2016 04:19:29 +0000 (14:19 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 30 Aug 2016 04:19:29 +0000 (14:19 +1000)
This fixes a broken benchmark

client.go

index 00a474c584b4c97c4370daee92e3a0c10e86d279..cae1ee7a80209804335cde47c7e608fc25370dd7 100644 (file)
--- 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