webtorrent / bittorrent-tracker

🌊 Simple, robust, BitTorrent tracker (client & server) implementation
https://webtorrent.io
MIT License
1.72k stars 314 forks source link

socksProxy Socks.Agent is not a constructor #495

Closed bl00m closed 8 months ago

bl00m commented 10 months ago

What version of this package are you using? Version 10.0.12

What operating system, Node.js, and npm version? OS: NixOS Node: v18.17.1 npm: 9.6.7

What happened? I try to use a socks proxy with this configuration:

  const opts = {
    infoHash,
    peerId,
    announce,
    port: 6881,
    proxyOpts: {
      socksProxy: {
        proxy: {
          ipaddress: "127.0.0.1",
          port: 8080,
          type: 5
        }
      }
    }
  }

  const client = new Client(opts)

When i run this I get:

./node_modules/bittorrent-tracker/lib/client/http-tracker.js:122
        agent = new Socks.Agent(clone(this.client._proxyOpts.socksProxy), (parsedUrl.protocol === 'https:'))
                ^

TypeError: Socks.Agent is not a constructor

What did you expect to happen? I expect this proxy configuration to work.

Are you willing to submit a pull request to fix this bug? I looked at the documentation for socks and it seems that this way of instantiating an agent does not work in this version. There is a link to the v1 documentation when this was the case. I didn't look much at how the library is used in bittorrent-tracker yet but I may be able to fix the calls to the socks api if there is not to much of them.

ThaUnknown commented 8 months ago

this was fixed in v11, now the user needs to provide the socks proxy implementation