diff --git a/cmd/torrent/main.go b/cmd/torrent/main.go index 4ccbf3ea..3c7414f5 100644 --- a/cmd/torrent/main.go +++ b/cmd/torrent/main.go @@ -144,23 +144,31 @@ var flags = struct { PieceStates bool Quiet bool `help:"discard client logging"` Dht bool - TcpPeers bool - UtpPeers bool - Ipv4 bool - Ipv6 bool - Pex bool + + TcpPeers bool + UtpPeers bool + Webtorrent bool + + Ipv4 bool + Ipv6 bool + Pex bool + tagflag.StartPos + Torrent []string `arity:"+" help:"torrent file path or magnet uri"` }{ UploadRate: -1, DownloadRate: -1, Progress: true, Dht: true, - TcpPeers: true, - UtpPeers: true, - Ipv4: true, - Ipv6: true, - Pex: true, + + TcpPeers: true, + UtpPeers: true, + Webtorrent: true, + + Ipv4: true, + Ipv6: true, + Pex: true, } func stdoutAndStderrAreSameFile() bool { @@ -224,6 +232,7 @@ func downloadErr(args []string, parent *tagflag.Parser) error { clientConfig.PublicIp4 = flags.PublicIP clientConfig.PublicIp6 = flags.PublicIP clientConfig.DisablePEX = !flags.Pex + clientConfig.DisableWebtorrent = !flags.Webtorrent if flags.PackedBlocklist != "" { blocklist, err := iplist.MMapPackedFile(flags.PackedBlocklist) if err != nil { diff --git a/config.go b/config.go index 105e8674..e419b412 100644 --- a/config.go +++ b/config.go @@ -130,6 +130,8 @@ type ClientConfig struct { DefaultRequestStrategy RequestStrategyMaker Extensions PeerExtensionBits + + DisableWebtorrent bool } func (cfg *ClientConfig) SetListenAddr(addr string) *ClientConfig { diff --git a/file.go b/file.go index f0242400..e2ebcf4d 100644 --- a/file.go +++ b/file.go @@ -96,7 +96,6 @@ func (f *File) DisplayPath() string { return f.t.info.Name } return strings.Join(fip, "/") - } // The download status of a piece that comprises part of a File. diff --git a/torrent.go b/torrent.go index a2152638..c87ddc4d 100644 --- a/torrent.go +++ b/torrent.go @@ -1383,6 +1383,9 @@ func (t *Torrent) startScrapingTracker(_url string) { sl := func() torrentTrackerAnnouncer { switch u.Scheme { case "ws", "wss": + if t.cl.config.DisableWebtorrent { + return nil + } return t.startWebsocketAnnouncer(*u) } if u.Scheme == "udp4" && (t.cl.config.DisableIPv4Peers || t.cl.config.DisableIPv4) {