From: Matt Joiner Date: Mon, 20 Apr 2015 07:30:22 +0000 (+1000) Subject: Add the option to disable encryption X-Git-Tag: v1.0.0~1203 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=b37f6d6f962f1965a8f822791029505a1faee426;p=btrtrc.git Add the option to disable encryption --- diff --git a/client.go b/client.go index 46d32791..8317ec11 100644 --- 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() diff --git a/config.go b/config.go index f052cb56..8a591158 100644 --- 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"` }