From 93685a55fed7ea4f1529c2483d7d31a691ba99d2 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 1 Oct 2020 10:46:27 +1000 Subject: [PATCH] Include ip param in http announces --- tracker/http.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tracker/http.go b/tracker/http.go index caf0cff6..443bd58e 100644 --- a/tracker/http.go +++ b/tracker/http.go @@ -5,12 +5,12 @@ import ( "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 @@ func setAnnounceParams(_url *url.URL, ar *AnnounceRequest, opts Announce) { // 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() } -- 2.44.0