client.go | 2 +- client_test.go | 4 ++-- misc.go | 4 ++-- mse/mse.go | 4 ++-- mse/mse_test.go | 2 +- peer_protocol/handshake.go | 2 +- peerconn.go | 2 +- wstracker.go | 5 +++-- diff --git a/client.go b/client.go index a3f55c6f601637d8999b252e036de848e58c3d6f..a6de6c08e2222510d2691ad7f464134538a9c558 100644 --- a/client.go +++ b/client.go @@ -583,7 +583,7 @@ torrent.Add("unsuccessful dials", 1) } } -func reducedDialTimeout(minDialTimeout, max time.Duration, halfOpenLimit int, pendingPeers int) (ret time.Duration) { +func reducedDialTimeout(minDialTimeout, max time.Duration, halfOpenLimit, pendingPeers int) (ret time.Duration) { ret = max / time.Duration((pendingPeers+halfOpenLimit)/halfOpenLimit) if ret < minDialTimeout { ret = minDialTimeout diff --git a/client_test.go b/client_test.go index 86023fb69b0c8aefe33e0536eb097ce824414d2d..cbfe48bbee9323fcc5b54ec8b498e2a9dcb77f94 100644 --- a/client_test.go +++ b/client_test.go @@ -647,7 +647,7 @@ } // 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 { +func makeMagnet(t *testing.T, cl *Client, dir, name string) string { os.MkdirAll(dir, 0o770) file, err := os.Create(filepath.Join(dir, name)) require.NoError(t, err) @@ -684,7 +684,7 @@ } // Test that the leecher can download a torrent in its entirety from the seeder. Note that the // seeder config is done first. -func testSeederLeecherPair(t *testing.T, seeder func(*ClientConfig), leecher func(*ClientConfig)) { +func testSeederLeecherPair(t *testing.T, seeder, leecher func(*ClientConfig)) { cfg := TestingConfig(t) cfg.Seed = true cfg.DataDir = filepath.Join(cfg.DataDir, "server") diff --git a/misc.go b/misc.go index 4a6e1debe3d21634ca2a6f5d40590d8132183a66..139af2d405844534c2e9018dbc68ba9e0eff5f12 100644 --- a/misc.go +++ b/misc.go @@ -43,7 +43,7 @@ } } // The size in bytes of a metadata extension piece. -func metadataPieceSize(totalSize int, piece int) int { +func metadataPieceSize(totalSize, piece int) int { ret := totalSize - piece*(1<<14) if ret > 1<<14 { ret = 1 << 14 @@ -99,7 +99,7 @@ } return nil } -func chunkIndexSpec(index pp.Integer, pieceLength, chunkSize pp.Integer) ChunkSpec { +func chunkIndexSpec(index, pieceLength, chunkSize pp.Integer) ChunkSpec { ret := ChunkSpec{pp.Integer(index) * chunkSize, chunkSize} if ret.Begin+ret.Length > pieceLength { ret.Length = pieceLength - ret.Begin diff --git a/mse/mse.go b/mse/mse.go index 522612c93787077bd8fe96323396d209841259f4..a5477b8f172706af718565cc59a2928651e0b9d5 100644 --- a/mse/mse.go +++ b/mse/mse.go @@ -69,7 +69,7 @@ } return h.Sum(nil) } -func newEncrypt(initer bool, s []byte, skey []byte) (c *rc4.Cipher) { +func newEncrypt(initer bool, s, skey []byte) (c *rc4.Cipher) { c, err := rc4.NewCipher(hash([]byte(func() string { if initer { return "keyA" @@ -542,7 +542,7 @@ return } func InitiateHandshake( - rw io.ReadWriter, skey []byte, initialPayload []byte, cryptoProvides CryptoMethod, + rw io.ReadWriter, skey, initialPayload []byte, cryptoProvides CryptoMethod, ) ( ret io.ReadWriter, method CryptoMethod, err error, ) { diff --git a/mse/mse_test.go b/mse/mse_test.go index c7e3bd573cb2e02d105bdfc8c32ec01d89a23afe..a38e9cc109aec619fb38ce7199312dd5979b5d60 100644 --- a/mse/mse_test.go +++ b/mse/mse_test.go @@ -146,7 +146,7 @@ require.NoError(t, err) } } -func readAndWrite(rw io.ReadWriter, r []byte, w []byte) error { +func readAndWrite(rw io.ReadWriter, r, w []byte) error { var wg sync.WaitGroup wg.Add(1) var wErr error diff --git a/peer_protocol/handshake.go b/peer_protocol/handshake.go index c0b0319d34758f3a00837449ef127bf7936f834a..acdc3da58faa2af1cb3e1bce906488751edaf148 100644 --- a/peer_protocol/handshake.go +++ b/peer_protocol/handshake.go @@ -124,7 +124,7 @@ if string(b[:20]) != Protocol { return res, errors.New("unexpected protocol string") } - copyExact := func(dst []byte, src []byte) { + copyExact := func(dst, src []byte) { if dstLen, srcLen := uint64(len(dst)), uint64(len(src)); dstLen != srcLen { panic("dst len " + strconv.FormatUint(dstLen, 10) + " != src len " + strconv.FormatUint(srcLen, 10)) } diff --git a/peerconn.go b/peerconn.go index 423d4e8b89f122bf82a55f7fc45fd23155f3913a..4a29971418db1cffaae3df83cef6040a2b087181 100644 --- a/peerconn.go +++ b/peerconn.go @@ -235,7 +235,7 @@ } return ret } -func (cn *PeerConn) peerHasAllPieces() (all bool, known bool) { +func (cn *PeerConn) peerHasAllPieces() (all, known bool) { if cn.peerSentHaveAll { return true, true } diff --git a/wstracker.go b/wstracker.go index 396b5aa5f28d0033c5054b2c5b19e2d88da656ad..5338ceb913da7644b2d0db1623b8355799a0d38b 100644 --- a/wstracker.go +++ b/wstracker.go @@ -2,11 +2,12 @@ package torrent import ( "fmt" + "net/url" + "sync" + "github.com/anacrolix/log" "github.com/anacrolix/torrent/tracker/http" "github.com/gorilla/websocket" - "net/url" - "sync" "github.com/anacrolix/torrent/tracker" "github.com/anacrolix/torrent/webtorrent"