Add OnQuery Hook
This commit is contained in:
parent
25d76e0449
commit
60e215aa81
@ -313,6 +313,7 @@ func (cl *Client) newDhtServer(conn net.PacketConn) (s *dht.Server, err error) {
|
||||
}(),
|
||||
StartingNodes: cl.config.DhtStartingNodes,
|
||||
ConnectionTracking: cl.config.ConnTracker,
|
||||
OnQuery: cl.config.DHTOnQuery,
|
||||
}
|
||||
s, err = dht.NewServer(&cfg)
|
||||
if err == nil {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/anacrolix/dht"
|
||||
"github.com/anacrolix/dht/krpc"
|
||||
"github.com/anacrolix/missinggo"
|
||||
"github.com/anacrolix/missinggo/conntrack"
|
||||
"github.com/anacrolix/missinggo/expect"
|
||||
@ -124,6 +125,9 @@ type ClientConfig struct {
|
||||
dropDuplicatePeerIds bool
|
||||
|
||||
ConnTracker *conntrack.Instance
|
||||
|
||||
// OnQuery hook func
|
||||
DHTOnQuery func(query *krpc.Msg, source net.Addr) (propagate bool)
|
||||
}
|
||||
|
||||
func (cfg *ClientConfig) SetListenAddr(addr string) *ClientConfig {
|
||||
|
Loading…
x
Reference in New Issue
Block a user