From 72bd4f362e6f6fdd96121024e82faf6a6d8e47ae Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 2 Jun 2020 16:17:32 +1000 Subject: [PATCH] Add option to disable webseeds --- cmd/torrent/main.go | 8 +++++--- config.go | 1 + torrent.go | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/torrent/main.go b/cmd/torrent/main.go index 3c7414f5..6b14691d 100644 --- a/cmd/torrent/main.go +++ b/cmd/torrent/main.go @@ -145,9 +145,10 @@ var flags = struct { Quiet bool `help:"discard client logging"` Dht bool - TcpPeers bool - UtpPeers bool - Webtorrent bool + TcpPeers bool + UtpPeers bool + Webtorrent bool + DisableWebseeds bool Ipv4 bool Ipv6 bool @@ -221,6 +222,7 @@ func downloadErr(args []string, parent *tagflag.Parser) error { tagflag.ParseArgs(&flags, args, tagflag.Parent(parent)) defer envpprof.Stop() clientConfig := torrent.NewDefaultClientConfig() + clientConfig.DisableWebseeds = flags.DisableWebseeds clientConfig.DisableTCP = !flags.TcpPeers clientConfig.DisableUTP = !flags.UtpPeers clientConfig.DisableIPv4 = !flags.Ipv4 diff --git a/config.go b/config.go index e419b412..ae9b4ea0 100644 --- a/config.go +++ b/config.go @@ -132,6 +132,7 @@ type ClientConfig struct { Extensions PeerExtensionBits DisableWebtorrent bool + DisableWebseeds bool } func (cfg *ClientConfig) SetListenAddr(addr string) *ClientConfig { diff --git a/torrent.go b/torrent.go index c785575c..21859af3 100644 --- a/torrent.go +++ b/torrent.go @@ -2006,6 +2006,9 @@ func (t *Torrent) iterPeers(f func(*peer)) { } func (t *Torrent) addWebSeed(url string) { + if t.cl.config.DisableWebseeds { + return + } if _, ok := t.webSeeds[url]; ok { return } -- 2.48.1