Fix race to set IPBlocklist on DHT before it bootstraps and serves
This commit is contained in:
parent
665e3c72fc
commit
5de6abd6a7
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user