diff --git a/client.go b/client.go index 29e0f1ef..7e743b8f 100644 --- a/client.go +++ b/client.go @@ -514,7 +514,9 @@ func NewClient(cfg *Config) (cl *Client, err error) { if !cfg.NoDHT { dhtCfg := cfg.DHTConfig if dhtCfg == nil { - dhtCfg = &dht.ServerConfig{} + dhtCfg = &dht.ServerConfig{ + IPBlocklist: cl.ipBlockList, + } } if dhtCfg.Addr == "" { dhtCfg.Addr = listenAddr() @@ -526,9 +528,6 @@ func NewClient(cfg *Config) (cl *Client, err error) { if err != nil { return } - if cl.ipBlockList != nil { - cl.dHT.SetIPBlockList(cl.ipBlockList) - } } return diff --git a/dht/dht.go b/dht/dht.go index de96fe9e..01d28352 100644 --- a/dht/dht.go +++ b/dht/dht.go @@ -65,6 +65,9 @@ type ServerConfig struct { // Disable the DHT security extension: // http://www.libtorrent.org/dht_sec.html. NoSecurity bool + // Initial IP blocklist to use. Applied before serving and bootstrapping + // begins. + IPBlocklist *iplist.IPList } type ServerStats struct { @@ -115,7 +118,8 @@ func NewServer(c *ServerConfig) (s *Server, err error) { c = &ServerConfig{} } s = &Server{ - config: *c, + config: *c, + ipBlockList: c.IPBlocklist, } if c.Conn != nil { s.socket = c.Conn