7 "github.com/anacrolix/dht/v2"
8 "github.com/anacrolix/dht/v2/krpc"
9 peer_store "github.com/anacrolix/dht/v2/peer-store"
12 type DhtServer interface {
16 AddNode(ni krpc.NodeInfo) error
17 Ping(addr *net.UDPAddr)
18 Announce(hash [20]byte, port int, impliedPort bool) (DhtAnnounce, error)
19 WriteStatus(io.Writer)
22 // Optional interface for DhtServer's that can expose their peer store (if any).
23 type PeerStorer interface {
24 PeerStore() peer_store.Interface
27 type DhtAnnounce interface {
29 Peers() <-chan dht.PeersValues
32 type anacrolixDhtServerWrapper struct {
36 func (me anacrolixDhtServerWrapper) Stats() interface{} {
37 return me.Server.Stats()
40 type anacrolixDhtAnnounceWrapper struct {
44 func (me anacrolixDhtAnnounceWrapper) Peers() <-chan dht.PeersValues {
45 return me.Announce.Peers
48 func (me anacrolixDhtServerWrapper) Announce(hash [20]byte, port int, impliedPort bool) (DhtAnnounce, error) {
49 ann, err := me.Server.Announce(hash, port, impliedPort)
50 return anacrolixDhtAnnounceWrapper{ann}, err
53 func (me anacrolixDhtServerWrapper) Ping(addr *net.UDPAddr) {
54 me.Server.Ping(addr, nil)
57 var _ DhtServer = anacrolixDhtServerWrapper{}