From 09b587f17b1b44555ca841f4d93874e71613b7bb Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Fri, 19 Jul 2019 13:04:10 +1000 Subject: [PATCH] Comments --- client_test.go | 2 ++ cmd/torrent/main.go | 5 ++--- mse/mse.go | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/client_test.go b/client_test.go index 7f292d9a..682b33f5 100644 --- a/client_test.go +++ b/client_test.go @@ -943,6 +943,8 @@ func TestSetMaxEstablishedConn(t *testing.T) { waitTotalConns(6) } +// Creates a file containing its own name as data. Make a metainfo from that, adds it to the given +// client, and returns a magnet link. func makeMagnet(t *testing.T, cl *Client, dir string, name string) string { os.MkdirAll(dir, 0770) file, err := os.Create(filepath.Join(dir, name)) diff --git a/cmd/torrent/main.go b/cmd/torrent/main.go index 67b5122b..caac4855 100644 --- a/cmd/torrent/main.go +++ b/cmd/torrent/main.go @@ -200,9 +200,8 @@ func main() { defer client.Close() go exitSignalHandlers(client) - // Write status on the root path on the default HTTP muxer. This will be - // bound to localhost somewhere if GOPPROF is set, thanks to the envpprof - // import. + // Write status on the root path on the default HTTP muxer. This will be bound to localhost + // somewhere if GOPPROF is set, thanks to the envpprof import. http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { client.WriteStatus(w) }) diff --git a/mse/mse.go b/mse/mse.go index d9b87803..b51a5aaf 100644 --- a/mse/mse.go +++ b/mse/mse.go @@ -25,8 +25,8 @@ import ( const ( maxPadLen = 512 - CryptoMethodPlaintext CryptoMethod = 1 - CryptoMethodRC4 CryptoMethod = 2 + CryptoMethodPlaintext CryptoMethod = 1 // After header obfuscation, drop into plaintext + CryptoMethodRC4 CryptoMethod = 2 // After header obfuscation, use RC4 for the rest of the stream AllSupportedCrypto = CryptoMethodPlaintext | CryptoMethodRC4 ) @@ -557,6 +557,7 @@ func ReceiveHandshake(rw io.ReadWriter, skeys SecretKeyIter, selectCrypto Crypto type SecretKeyIter func(callback func(skey []byte) (more bool)) func DefaultCryptoSelector(provided CryptoMethod) CryptoMethod { + // We prefer plaintext for performance reasons. if provided&CryptoMethodPlaintext != 0 { return CryptoMethodPlaintext } -- 2.48.1