cmd/torrent/main.go | 29 +++++++++++++++++++---------- config.go | 2 ++ file.go | 1 - torrent.go | 3 +++ diff --git a/cmd/torrent/main.go b/cmd/torrent/main.go index 4ccbf3ea90728f0195d77ad0ae400e218e994e79..3c7414f5ccc4cdff7df656c80b5a16ebfa565f08 100644 --- a/cmd/torrent/main.go +++ b/cmd/torrent/main.go @@ -144,23 +144,31 @@ Progress bool 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 @@ clientConfig.Seed = flags.Seed 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 105e8674bfca7775a3e039ddf0165f81e0d45e20..e419b412242b13b2266df848a4d40ccdc1a16e0c 100644 --- a/config.go +++ b/config.go @@ -130,6 +130,8 @@ DefaultRequestStrategy RequestStrategyMaker Extensions PeerExtensionBits + + DisableWebtorrent bool } func (cfg *ClientConfig) SetListenAddr(addr string) *ClientConfig { diff --git a/file.go b/file.go index f02424000971f46f65583864c7fd1809aac8b841..e2ebcf4d5c6cf5a2a8c90b1e8a109f8caa4f3282 100644 --- a/file.go +++ b/file.go @@ -96,7 +96,6 @@ if len(fip) == 0 { 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 a2152638daa717ce59d935acc51c291ec3654664..c87ddc4dc2b21c93ef5932bfc83c11e6d723bdd1 100644 --- a/torrent.go +++ b/torrent.go @@ -1383,6 +1383,9 @@ } 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) {