update dependencies and fix lint warnings

This commit is contained in:
Lawrence, Rendall
2026-02-18 18:12:58 +03:00
parent 36a9022ef4
commit 08686d74b7
18 changed files with 205 additions and 139 deletions
+2
View File
@@ -1,5 +1,7 @@
// Package http implements a BitTorrent frontend via the HTTP protocol as
// described in BEP 3 and BEP 23.
//
//nolint:revive
package http
import (
+1
View File
@@ -1,3 +1,4 @@
//nolint:revive
package http
import (
+1
View File
@@ -1,3 +1,4 @@
//nolint:revive
package http
import (
+30 -9
View File
@@ -15,14 +15,35 @@ var (
{},
{"peer_id": {testPeerID}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}},
{"peer_id": {testPeerID}, "ip": {"192.168.0.1"}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}},
{"peer_id": {testPeerID}, "ip": {"192.168.0.1"}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}, "numwant": {"28"}},
{"peer_id": {testPeerID}, "ip": {"192.168.0.1"}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}, "event": {"stopped"}},
{"peer_id": {testPeerID}, "ip": {"192.168.0.1"}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}, "event": {"started"}, "numwant": {"13"}},
{
"peer_id": {testPeerID}, "ip": {"192.168.0.1"}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"},
"numwant": {"28"},
},
{
"peer_id": {testPeerID}, "ip": {"192.168.0.1"}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"},
"event": {"stopped"},
},
{
"peer_id": {testPeerID}, "ip": {"192.168.0.1"}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"},
"event": {"started"}, "numwant": {"13"},
},
{"peer_id": {testPeerID}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}, "no_peer_id": {"1"}},
{"peer_id": {testPeerID}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}, "compact": {"0"}, "no_peer_id": {"1"}},
{"peer_id": {testPeerID}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}, "compact": {"0"}, "no_peer_id": {"1"}, "key": {"peerKey"}},
{"peer_id": {testPeerID}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}, "compact": {"0"}, "no_peer_id": {"1"}, "key": {"peerKey"}, "trackerid": {"trackerId"}},
{"peer_id": {"%3Ckey%3A+0x90%3E"}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}, "compact": {"0"}, "no_peer_id": {"1"}, "key": {"peerKey"}, "trackerid": {"trackerId"}},
{
"peer_id": {testPeerID}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}, "compact": {"0"},
"no_peer_id": {"1"},
},
{
"peer_id": {testPeerID}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}, "compact": {"0"},
"no_peer_id": {"1"}, "key": {"peerKey"},
},
{
"peer_id": {testPeerID}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"}, "compact": {"0"},
"no_peer_id": {"1"}, "key": {"peerKey"}, "trackerid": {"trackerId"},
},
{
"peer_id": {"%3Ckey%3A+0x90%3E"}, "port": {"6881"}, "downloaded": {"1234"}, "left": {"4321"},
"compact": {"0"}, "no_peer_id": {"1"}, "key": {"peerKey"}, "trackerid": {"trackerId"},
},
{"peer_id": {"%3Ckey%3A+0x90%3E"}, "compact": {"1"}},
{"peer_id": {""}, "compact": {""}},
}
@@ -102,7 +123,7 @@ func TestParseShouldNotPanicURLData(_ *testing.T) {
}
func BenchmarkParseQuery(b *testing.B) {
announceStrings := make([][]byte, 0)
announceStrings := make([][]byte, 0, len(ValidAnnounceArguments))
for i := range ValidAnnounceArguments {
announceStrings = append(announceStrings, []byte(ValidAnnounceArguments[i].Encode()))
}
@@ -114,7 +135,7 @@ func BenchmarkParseQuery(b *testing.B) {
}
func BenchmarkURLParseQuery(b *testing.B) {
announceStrings := make([]string, 0)
announceStrings := make([]string, 0, len(ValidAnnounceArguments))
for i := range ValidAnnounceArguments {
announceStrings = append(announceStrings, ValidAnnounceArguments[i].Encode())
}
+3 -1
View File
@@ -1,3 +1,4 @@
//nolint:revive
package http
import (
@@ -105,7 +106,8 @@ func parseAnnounce(r *fasthttp.RequestCtx, opts ParseOptions) (*bittorrent.Annou
// Parse the IP address where the client is listening.
request.RequestAddresses = requestedIPs(r, qp, opts)
if err = bittorrent.SanitizeAnnounce(request, opts.MaxNumWant, opts.DefaultNumWant, opts.FilterPrivateIPs); err != nil {
if err = bittorrent.SanitizeAnnounce(request, opts.MaxNumWant, opts.DefaultNumWant,
opts.FilterPrivateIPs); err != nil {
request = nil
}
+1
View File
@@ -1,3 +1,4 @@
//nolint:revive
package http
import (
+1
View File
@@ -1,3 +1,4 @@
//nolint:revive
package http
import (
+1
View File
@@ -1,3 +1,4 @@
//nolint:revive
package http
import (