]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Provide default starting nodes to DHT if default torrent client config is used
authorMatt Joiner <anacrolix@gmail.com>
Fri, 18 Aug 2017 01:14:28 +0000 (11:14 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 18 Aug 2017 01:14:28 +0000 (11:14 +1000)
https://github.com/anacrolix/torrent/issues/178

client.go

index e66e519c9d29c215ae81baf2bb5aaab34081abbf..44a43619024b98c32c7571cff2537ff29d093fa5 100644 (file)
--- a/client.go
+++ b/client.go
@@ -225,7 +225,17 @@ func listen(tcp, utp bool, networkSuffix, addr string) (tcpL net.Listener, utpSo
 // Creates a new client.
 func NewClient(cfg *Config) (cl *Client, err error) {
        if cfg == nil {
-               cfg = &Config{}
+               cfg = &Config{
+                       DHTConfig: dht.ServerConfig{
+                               StartingNodes: func() []dht.Addr {
+                                       addrs, err := dht.GlobalBootstrapAddrs()
+                                       if err != nil {
+                                               log.Printf("error getting dht bootstrap addrs for default torrent client config: %s", err)
+                                       }
+                                       return addrs
+                               }(),
+                       },
+               }
        }
 
        defer func() {