]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add the option to disable encryption
authorMatt Joiner <anacrolix@gmail.com>
Mon, 20 Apr 2015 07:30:22 +0000 (17:30 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 20 Apr 2015 07:30:22 +0000 (17:30 +1000)
client.go
config.go

index 46d327919823778976bdca4c9d3aa7e0b069555c..8317ec11a67bee6d714fb803be66be9290357f95 100644 (file)
--- a/client.go
+++ b/client.go
@@ -832,7 +832,7 @@ func (me *Client) establishOutgoingConn(t *torrent, addr string) (c *connection,
        if nc == nil {
                return
        }
-       c, err = handshakesConnection(nc, true, utp)
+       c, err = handshakesConnection(nc, !me.config.DisableEncryption, utp)
        if err != nil {
                nc.Close()
                return
@@ -1084,12 +1084,14 @@ func (cl *Client) receiveHandshakes(c *connection) (t *torrent, err error) {
        cl.mu.Lock()
        skeys := cl.receiveSkeys()
        cl.mu.Unlock()
-       c.rw, c.encrypted, err = maybeReceiveEncryptedHandshake(c.rw, skeys)
-       if err != nil {
-               if err == mse.ErrNoSecretKeyMatch {
-                       err = nil
+       if !cl.config.DisableEncryption {
+               c.rw, c.encrypted, err = maybeReceiveEncryptedHandshake(c.rw, skeys)
+               if err != nil {
+                       if err == mse.ErrNoSecretKeyMatch {
+                               err = nil
+                       }
+                       return
                }
-               return
        }
        ih, ok, err := cl.connBTHandshake(c, nil)
        if err != nil {
@@ -1199,7 +1201,9 @@ func (me *Client) sendInitialMessages(conn *connection, torrent *torrent) {
                                                        return 1
                                                }
                                        }(),
-                                       "e": 1, // Awwww yeah
+                               }
+                               if !me.config.DisableEncryption {
+                                       d["e"] = 1
                                }
                                if torrent.metadataSizeKnown() {
                                        d["metadata_size"] = torrent.metadataSize()
index f052cb56e544f1961ad40e38057b1828688c403f..8a591158993ffc8b2aba9a3f2a9d1e65b557d88d 100644 (file)
--- a/config.go
+++ b/config.go
@@ -39,4 +39,5 @@ type Config struct {
        // Called to instantiate storage for each added torrent. Provided backends
        // are in $REPO/data. If not set, the "file" implementation is used.
        TorrentDataOpener
+       DisableEncryption bool `long:"disable-encryption"`
 }