Sending negative ports and lefts through to HTTP trackers was making them mad.
req := tracker.AnnounceRequest{
Event: tracker.Started,
NumWant: -1,
- Port: int16(cl.incomingPeerPort()),
+ Port: uint16(cl.incomingPeerPort()),
PeerId: cl.peerID,
InfoHash: t.InfoHash,
}
return
}
cl.mu.RLock()
- req.Left = t.bytesLeft()
+ req.Left = uint64(t.bytesLeft())
trackers := t.Trackers
cl.mu.RUnlock()
if cl.announceTorrentTrackersFastStart(&req, trackers, t) {
newAnnounce:
for cl.waitWantPeers(t) {
cl.mu.RLock()
- req.Left = t.bytesLeft()
+ req.Left = uint64(t.bytesLeft())
trackers = t.Trackers
cl.mu.RUnlock()
numTrackersTried := 0
q.Set("port", fmt.Sprintf("%d", ar.Port))
q.Set("uploaded", strconv.FormatInt(ar.Uploaded, 10))
q.Set("downloaded", strconv.FormatInt(ar.Downloaded, 10))
- q.Set("left", strconv.FormatInt(ar.Left, 10))
+ q.Set("left", strconv.FormatUint(ar.Left, 10))
if ar.Event != None {
q.Set("event", ar.Event.String())
}
"net/url"
)
+// Marshalled as binary by the UDP client, so be careful making changes.
type AnnounceRequest struct {
InfoHash [20]byte
PeerId [20]byte
Downloaded int64
- Left int64
+ Left uint64
Uploaded int64
Event AnnounceEvent
IPAddress int32
Key int32
NumWant int32 // How many peer addresses are desired. -1 for default.
- Port int16
+ Port uint16
} // 82 bytes
type AnnounceResponse struct {