Add option to disable webseeds

This commit is contained in:
Matt Joiner 2020-06-02 16:17:32 +10:00
parent 997384a394
commit 72bd4f362e
3 changed files with 9 additions and 3 deletions

View 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

View File

@ -132,6 +132,7 @@ type ClientConfig struct {
Extensions PeerExtensionBits
DisableWebtorrent bool
DisableWebseeds bool
}
func (cfg *ClientConfig) SetListenAddr(addr string) *ClientConfig {

View 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
}