Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxy options to allow proxying tracker and peer connections #874

Open
wants to merge 16 commits into
base: master
from
Open
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Use clone to deepcopy socks opts and add socks agent generation to we…

…bconns
  • Loading branch information
yciabaud committed Aug 26, 2016
commit 124bfc930944ff827cbc370f3a386f5f5fd7bb74
@@ -5,6 +5,7 @@ module.exports = Torrent
var addrToIPPort = require('addr-to-ip-port')
var BitField = require('bitfield')
var ChunkStoreWriteStream = require('chunk-store-stream/write')
var clone = require('clone')
var debug = require('debug')('webtorrent:torrent')
var Discovery = require('torrent-discovery')
var EventEmitter = require('events').EventEmitter
@@ -1660,7 +1661,7 @@ Torrent.prototype._drain = function () {
}

if (self.client.proxyOpts && self.client.proxyOpts.socksProxy && self.client.proxyOpts.proxyPeerConnections) {
var proxyOpts = extend(self.client.proxyOpts.socksProxy, {
var proxyOpts = clone(self.client.proxyOpts.socksProxy, {
command: 'connect',
target: opts
})
@@ -2,11 +2,13 @@ module.exports = WebConn

var BitField = require('bitfield')
var Buffer = require('safe-buffer').Buffer
var clone = require('clone')
var debug = require('debug')('webtorrent:webconn')
var get = require('simple-get')
var inherits = require('inherits')
var sha1 = require('simple-sha1')
var url = require('url')
var Socks = require('socks')
var Wire = require('bittorrent-protocol')

var VERSION = require('../package.json').version
@@ -119,9 +121,13 @@ WebConn.prototype.httpRequest = function (pieceIndex, offset, length, cb) {
)

var agent
if (self._torrent.client.proxyOpts && self._torrent.client.proxyOpts.proxyPeerConnections) {
var proxyOpts = self._torrent.client.proxyOpts
if (proxyOpts && proxyOpts.proxyPeerConnections) {
agent = parsedUrl.protocol === 'https:'
? self._torrent.client.proxyOpts.httpsAgent : self._torrent.client.proxyOpts.httpAgent
? proxyOpts.httpsAgent : proxyOpts.httpAgent
if (!agent && proxyOpts.socksProxy) {
agent = new Socks.Agent(clone(proxyOpts.socksProxy), (parsedUrl.protocol === 'https:'))
}
}
var opts = {
url: parsedUrl,
@@ -32,6 +32,7 @@
"bittorrent-dht": "^7.2.2",
"bittorrent-protocol": "^2.1.5",
"chunk-store-stream": "^2.0.2",
"clone": "^1.0.2",
"create-torrent": "^3.24.5",
"debug": "^2.2.0",
"end-of-stream": "^1.1.0",
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.