Allow DHT server config to be passed through when creating a new client
This commit is contained in:
parent
1c78c81075
commit
50e3db173f
14
client.go
14
client.go
|
@ -333,13 +333,17 @@ func NewClient(cfg *Config) (cl *Client, err error) {
|
|||
go cl.acceptConnections(utpL, true)
|
||||
}
|
||||
if !cfg.NoDHT {
|
||||
cfg := dht.ServerConfig{
|
||||
Addr: listenAddr(),
|
||||
dhtCfg := cfg.DHTConfig
|
||||
if dhtCfg == nil {
|
||||
dhtCfg = &dht.ServerConfig{}
|
||||
}
|
||||
if utpL != nil {
|
||||
cfg.Conn = utpL.RawConn
|
||||
if dhtCfg.Addr == "" {
|
||||
dhtCfg.Addr = listenAddr()
|
||||
}
|
||||
cl.dHT, err = dht.NewServer(&cfg)
|
||||
if dhtCfg.Conn == nil && utpL != nil {
|
||||
dhtCfg.Conn = utpL.RawConn
|
||||
}
|
||||
cl.dHT, err = dht.NewServer(dhtCfg)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue