client.go | 7 +++---- dht/dht.go | 6 +++++- diff --git a/client.go b/client.go index 29e0f1ef2c7001d5673a8e23cf65ad3f8db0c2ab..7e743b8f711519e723e45377642977395a3e5412 100644 --- a/client.go +++ b/client.go @@ -514,7 +514,9 @@ } if !cfg.NoDHT { dhtCfg := cfg.DHTConfig if dhtCfg == nil { - dhtCfg = &dht.ServerConfig{} + dhtCfg = &dht.ServerConfig{ + IPBlocklist: cl.ipBlockList, + } } if dhtCfg.Addr == "" { dhtCfg.Addr = listenAddr() @@ -525,9 +527,6 @@ } cl.dHT, err = dht.NewServer(dhtCfg) if err != nil { return - } - if cl.ipBlockList != nil { - cl.dHT.SetIPBlockList(cl.ipBlockList) } } diff --git a/dht/dht.go b/dht/dht.go index de96fe9ecb4e1e7e3c218752511e608b9e42423a..01d2835209a7c0221bbe421087042be1acce1c72 100644 --- a/dht/dht.go +++ b/dht/dht.go @@ -65,6 +65,9 @@ BootstrapNodes []string // 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 @@ if c == nil { c = &ServerConfig{} } s = &Server{ - config: *c, + config: *c, + ipBlockList: c.IPBlocklist, } if c.Conn != nil { s.socket = c.Conn