client.go | 14 +++++++++----- config.go | 5 +++++ diff --git a/client.go b/client.go index 7230118bb060203c3918ec63e8c5ce0825b6ee33..d00c2c43dca2a722352f7a665e88a921897f71df 100644 --- a/client.go +++ b/client.go @@ -333,13 +333,17 @@ cl.listeners = append(cl.listeners, utpL) 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 } diff --git a/config.go b/config.go index 06c35761ca455ba8ce1195110f1c3b46dfffe922..9b1cae618f069d8c0615e44d625d8416020d27c2 100644 --- a/config.go +++ b/config.go @@ -1,11 +1,16 @@ package torrent +import ( + "bitbucket.org/anacrolix/go.torrent/dht" +) + type Config struct { DataDir string ListenAddr string DisableTrackers bool DownloadStrategy DownloadStrategy NoDHT bool + DHTConfig *dht.ServerConfig NoUpload bool PeerID string DisableUTP bool