X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=dht.go;h=77975a2f5d19337db3fd18e32d106a4b5fc39542;hb=HEAD;hp=464090f992eb9a8e230dbe3facee8a51246fad3c;hpb=bc186ac2114b21b2115ae5737fc4a081fbe247da;p=btrtrc.git diff --git a/dht.go b/dht.go index 464090f9..77975a2f 100644 --- a/dht.go +++ b/dht.go @@ -9,11 +9,14 @@ import ( peer_store "github.com/anacrolix/dht/v2/peer-store" ) +// DHT server interface for use by a Torrent or Client. It's reasonable for this to make assumptions +// for torrent-use that might not be the default behaviour for the DHT server. type DhtServer interface { Stats() interface{} ID() [20]byte Addr() net.Addr AddNode(ni krpc.NodeInfo) error + // This is called asynchronously when receiving PORT messages. Ping(addr *net.UDPAddr) Announce(hash [20]byte, port int, impliedPort bool) (DhtAnnounce, error) WriteStatus(io.Writer) @@ -51,7 +54,9 @@ func (me AnacrolixDhtServerWrapper) Announce(hash [20]byte, port int, impliedPor } func (me AnacrolixDhtServerWrapper) Ping(addr *net.UDPAddr) { - me.Server.Ping(addr) + me.Server.PingQueryInput(addr, dht.QueryInput{ + RateLimiting: dht.QueryRateLimiting{NoWaitFirst: true}, + }) } var _ DhtServer = AnacrolixDhtServerWrapper{}