]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Support disabling webtorrent
authorMatt Joiner <anacrolix@gmail.com>
Mon, 1 Jun 2020 08:24:46 +0000 (18:24 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 1 Jun 2020 08:24:46 +0000 (18:24 +1000)
cmd/torrent/main.go
config.go
file.go
torrent.go

index 4ccbf3ea90728f0195d77ad0ae400e218e994e79..3c7414f5ccc4cdff7df656c80b5a16ebfa565f08 100644 (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 {
index 105e8674bfca7775a3e039ddf0165f81e0d45e20..e419b412242b13b2266df848a4d40ccdc1a16e0c 100644 (file)
--- 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 f02424000971f46f65583864c7fd1809aac8b841..e2ebcf4d5c6cf5a2a8c90b1e8a109f8caa4f3282 100644 (file)
--- 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.
index a2152638daa717ce59d935acc51c291ec3654664..c87ddc4dc2b21c93ef5932bfc83c11e6d723bdd1 100644 (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) {