]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Update to latest anacrolix/dht
authorMatt Joiner <anacrolix@gmail.com>
Tue, 17 Mar 2020 02:47:53 +0000 (13:47 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 17 Mar 2020 02:47:53 +0000 (13:47 +1100)
client.go
client_test.go
config.go
go.mod
go.sum

index 42a280d58f321eb4f7eecc07787568d334c37a8f..9095609b847443e21e19e7fa9e0a7dbd8ad3fd64 100644 (file)
--- a/client.go
+++ b/client.go
@@ -315,7 +315,7 @@ func (cl *Client) newAnacrolixDhtServer(conn net.PacketConn) (s *dht.Server, err
                        }
                        return cl.config.PublicIp4
                }(),
-               StartingNodes:      cl.config.DhtStartingNodes,
+               StartingNodes:      cl.config.DhtStartingNodes(conn.LocalAddr().Network()),
                ConnectionTracking: cl.config.ConnTracker,
                OnQuery:            cl.config.DHTOnQuery,
                Logger:             cl.logger.WithValues("dht", conn.LocalAddr().String()),
index 0ca330a93f924bee300c7ee3d7a312f1cac664e2..7c440a952912130be47069682bafd1f4c371b8b9 100644 (file)
@@ -424,10 +424,9 @@ func TestAddMetainfoWithNodes(t *testing.T) {
        cfg := TestingConfig()
        cfg.ListenHost = func(string) string { return "" }
        cfg.NoDHT = false
-       cfg.DhtStartingNodes = func() ([]dht.Addr, error) { return nil, nil }
-       // For now, we want to just jam the nodes into the table, without
-       // verifying them first. Also the DHT code doesn't support mixing secure
-       // and insecure nodes if security is enabled (yet).
+       cfg.DhtStartingNodes = func(string) dht.StartingNodesGetter { return func() ([]dht.Addr, error) { return nil, nil } }
+       // For now, we want to just jam the nodes into the table, without verifying them first. Also the
+       // DHT code doesn't support mixing secure and insecure nodes if security is enabled (yet).
        // cfg.DHTConfig.NoSecurity = true
        cl, err := NewClient(cfg)
        require.NoError(t, err)
index c0ea9ed373116688acac581a09ee6b30824ba822..d3a3c06656e0f80e3b4407a3e9191ea1b8b32bfa 100644 (file)
--- a/config.go
+++ b/config.go
@@ -36,7 +36,7 @@ type ClientConfig struct {
 
        // Don't create a DHT.
        NoDHT            bool `long:"disable-dht"`
-       DhtStartingNodes dht.StartingNodesGetter
+       DhtStartingNodes func(network string) dht.StartingNodesGetter
        // Never send chunks to peers.
        NoUpload bool `long:"no-upload"`
        // Disable uploading even when it isn't fair.
@@ -151,12 +151,14 @@ func NewDefaultClientConfig() *ClientConfig {
                TorrentPeersHighWater:          500,
                TorrentPeersLowWater:           50,
                HandshakesTimeout:              4 * time.Second,
-               DhtStartingNodes:               dht.GlobalBootstrapAddrs,
-               ListenHost:                     func(string) string { return "" },
-               UploadRateLimiter:              unlimited,
-               DownloadRateLimiter:            unlimited,
-               ConnTracker:                    conntrack.NewInstance(),
-               DisableAcceptRateLimiting:      true,
+               DhtStartingNodes: func(network string) dht.StartingNodesGetter {
+                       return func() ([]dht.Addr, error) { return dht.GlobalBootstrapAddrs(network) }
+               },
+               ListenHost:                func(string) string { return "" },
+               UploadRateLimiter:         unlimited,
+               DownloadRateLimiter:       unlimited,
+               ConnTracker:               conntrack.NewInstance(),
+               DisableAcceptRateLimiting: true,
                HeaderObfuscationPolicy: HeaderObfuscationPolicy{
                        Preferred:        true,
                        RequirePreferred: false,
diff --git a/go.mod b/go.mod
index 00578c102fca19a4ce9829b9d1166e73ec838b1c..2ea93d740693e673ed8efa41f630c947ac7a33b0 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/anacrolix/torrent
 require (
        bazil.org/fuse v0.0.0-20180421153158-65cc252bf669
        github.com/alexflint/go-arg v1.2.0
-       github.com/anacrolix/dht/v2 v2.5.0
+       github.com/anacrolix/dht/v2 v2.5.1-0.20200317023935-129f05e9b752
        github.com/anacrolix/envpprof v1.1.0
        github.com/anacrolix/go-libutp v1.0.2
        github.com/anacrolix/log v0.6.0
diff --git a/go.sum b/go.sum
index 8e3c25d55112bffa75c0b968506dea07ee6c2ac7..2cb9cad21d69ced101eb38b413e0731fdd01c032 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -29,6 +29,8 @@ github.com/anacrolix/dht/v2 v2.2.1-0.20191103020011-1dba080fb358/go.mod h1:d7ARx
 github.com/anacrolix/dht/v2 v2.3.2-0.20200103043204-8dce00767ebd/go.mod h1:cgjKyErDnKS6Mej5D1fEqBKg3KwFF2kpFZJp3L6/fGI=
 github.com/anacrolix/dht/v2 v2.5.0 h1:AYoGu41z2fellHU9zdFZOQFr8E3epyAGWk6RfOz5UVE=
 github.com/anacrolix/dht/v2 v2.5.0/go.mod h1:7RLvyOjm+ZPA7vgFRP+1eRjFzrh27p/nF0VCk5LcjoU=
+github.com/anacrolix/dht/v2 v2.5.1-0.20200317023935-129f05e9b752 h1:Cg9KyjeymlTOYY+SQ2FeIij9eaZI/eUFprAXYWL0AA8=
+github.com/anacrolix/dht/v2 v2.5.1-0.20200317023935-129f05e9b752/go.mod h1:7RLvyOjm+ZPA7vgFRP+1eRjFzrh27p/nF0VCk5LcjoU=
 github.com/anacrolix/envpprof v0.0.0-20180404065416-323002cec2fa h1:xCaATLKmn39QqLs3tUZYr6eKvezJV+FYvVOLTklxK6U=
 github.com/anacrolix/envpprof v0.0.0-20180404065416-323002cec2fa/go.mod h1:KgHhUaQMc8cC0+cEflSgCFNFbKwi5h54gqtVn8yhP7c=
 github.com/anacrolix/envpprof v1.0.0 h1:AwZ+mBP4rQ5f7JSsrsN3h7M2xDW/xSE66IPVOqlnuUc=