From: Matt Joiner <anacrolix@gmail.com>
Date: Mon, 8 Jun 2015 08:16:01 +0000 (+1000)
Subject: Don't try to connect again without encryption, if encryption is disabled
X-Git-Tag: v1.0.0~1155
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=d63c5e5b981ecb6e3c14966b9288bbd3a34774b0;p=btrtrc.git

Don't try to connect again without encryption, if encryption is disabled
---

diff --git a/client.go b/client.go
index b9b9e70e..2d6bbab5 100644
--- a/client.go
+++ b/client.go
@@ -819,6 +819,12 @@ func (me *Client) establishOutgoingConn(t *torrent, addr string) (c *connection,
 		return
 	}
 	nc.Close()
+	// Try again without encryption, using whichever protocol type worked last
+	// time.
+	if me.config.DisableEncryption {
+		// We already tried without encryption.
+		return
+	}
 	if utp {
 		nc, err = me.dialUTP(addr, t)
 	} else {