Support disabling webtorrent

This commit is contained in:
Matt Joiner 2020-06-01 18:24:46 +10:00
parent cf6d161256
commit 67c9021e97
4 changed files with 24 additions and 11 deletions

View File

@ -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 {

View File

@ -130,6 +130,8 @@ type ClientConfig struct {
DefaultRequestStrategy RequestStrategyMaker
Extensions PeerExtensionBits
DisableWebtorrent bool
}
func (cfg *ClientConfig) SetListenAddr(addr string) *ClientConfig {

View File

@ -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.

View File

@ -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) {