tracker/http.go | 18 ++++++++++++------ diff --git a/tracker/http.go b/tracker/http.go index caf0cff64d9fee2dffa446de5c9818fc730fd87e..443bd58e8de623a1ad9b3dfd5ee3ebdab0d72e7d 100644 --- a/tracker/http.go +++ b/tracker/http.go @@ -5,12 +5,12 @@ "bytes" "crypto/tls" "fmt" "io" + "log" "math" "net" "net/http" "net/url" "strconv" - "time" "github.com/anacrolix/dht/v2/krpc" "github.com/anacrolix/missinggo/httptoo" @@ -95,12 +95,18 @@ q.Set("compact", "1") // According to https://wiki.vuze.com/w/Message_Stream_Encryption. TODO: // Take EncryptionPolicy or something like it as a parameter. q.Set("supportcrypto", "1") - if opts.ClientIp4.IP != nil { - q.Set("ipv4", opts.ClientIp4.String()) - } - if opts.ClientIp6.IP != nil { - q.Set("ipv6", opts.ClientIp6.String()) + doIp := func(versionKey string, ip net.IP) { + if ip == nil { + return + } + ipString := ip.String() + q.Set(versionKey, ipString) + // Let's try listing them. BEP 3 mentions having an "ip" param, and BEP 7 says we can list + // addresses for other address-families, although it's not encouraged. + q.Add("ip", ipString) } + doIp("ipv4", opts.ClientIp4.IP) + doIp("ipv6", opts.ClientIp6.IP) _url.RawQuery = q.Encode() }