client.go | 12 ++++++++++++ misc.go | 4 ++++ diff --git a/client.go b/client.go index 6a768606cfca89d9178f4dabfcf5147464bca403..017ebe7782f29a2c4ce4828acfbc587c69dbb58b 100644 --- a/client.go +++ b/client.go @@ -1268,6 +1268,18 @@ return } } 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 4a903a359ee34f3860aa3a881aafb460178ff599..295415151fd8bd63517ef58dd76342de6cc634ca 100644 --- a/misc.go +++ b/misc.go @@ -27,6 +27,10 @@ InfoHash [20]byte pieceSum [20]byte ) +func (ih *InfoHash) AsString() string { + return string(ih[:]) +} + type piece struct { Hash pieceSum PendingChunkSpecs map[chunkSpec]struct{}