From: Matt Joiner Date: Sun, 16 Nov 2014 19:18:08 +0000 (-0600) Subject: Actually announce to DHT, don't just get peers X-Git-Tag: v1.0.0~1544 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=eeae2d3285f3fd86be61f1fe7a97e87a2d3f23e8;p=btrtrc.git Actually announce to DHT, don't just get peers --- diff --git a/client.go b/client.go index 6a768606..017ebe77 100644 --- a/client.go +++ b/client.go @@ -1268,6 +1268,18 @@ func (cl *Client) announceTorrentDHT(t *torrent) { } } ps.Close() + + // After a GetPeers, we can announce on the best nodes that gave us an + // announce token. + + port := cl.incomingPeerPort() + // If port is zero, then we're not listening, and there's nothing to + // announce. + if port != 0 { + // We can't allow the port to be implied as long as the UTP and + // DHT ports are different. + cl.dHT.AnnouncePeer(port, false, t.InfoHash.AsString()) + } } } diff --git a/misc.go b/misc.go index 4a903a35..29541515 100644 --- a/misc.go +++ b/misc.go @@ -27,6 +27,10 @@ type ( pieceSum [20]byte ) +func (ih *InfoHash) AsString() string { + return string(ih[:]) +} + type piece struct { Hash pieceSum PendingChunkSpecs map[chunkSpec]struct{}