]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add option to disable webseeds
authorMatt Joiner <anacrolix@gmail.com>
Tue, 2 Jun 2020 06:17:32 +0000 (16:17 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 2 Jun 2020 06:17:32 +0000 (16:17 +1000)
cmd/torrent/main.go
config.go
torrent.go

index 3c7414f5ccc4cdff7df656c80b5a16ebfa565f08..6b14691d55a79f0d10840741161c66cd0b26a871 100644 (file)
@@ -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
index e419b412242b13b2266df848a4d40ccdc1a16e0c..ae9b4ea09b1ef6a62f558b88a824244f143f7229 100644 (file)
--- 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 {
index c785575c47181b7e240b1b3b4a0ef23499353d27..21859af37905a1619647afab2102396c6bc0f99e 100644 (file)
@@ -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
        }