From c83738f3f4bd4aa830d7c6fc87ae5cb73c0d3c81 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 17 Mar 2020 13:47:53 +1100 Subject: [PATCH] Update to latest anacrolix/dht --- client.go | 2 +- client_test.go | 7 +++---- config.go | 16 +++++++++------- go.mod | 2 +- go.sum | 2 ++ 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/client.go b/client.go index 42a280d5..9095609b 100644 --- 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()), diff --git a/client_test.go b/client_test.go index 0ca330a9..7c440a95 100644 --- a/client_test.go +++ b/client_test.go @@ -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) diff --git a/config.go b/config.go index c0ea9ed3..d3a3c066 100644 --- 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 00578c10..2ea93d74 100644 --- 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 8e3c25d5..2cb9cad2 100644 --- 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= -- 2.44.0