From eeae2d3285f3fd86be61f1fe7a97e87a2d3f23e8 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sun, 16 Nov 2014 13:18:08 -0600 Subject: [PATCH] Actually announce to DHT, don't just get peers --- client.go | 12 ++++++++++++ misc.go | 4 ++++ 2 files changed, 16 insertions(+) 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{} -- 2.48.1