-
-
Notifications
You must be signed in to change notification settings - Fork 335
Allow proxy usage on tracker clients #157
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
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ee7783b
Add a httpAgent options to http and websocket client trackers.
yciabaud 98a50c1
Add a socks proxy to udp client trackers.
yciabaud f358ed8
Update http agent mock to node 5+
yciabaud d62682e
Bugfix in socks configuration
yciabaud c3b0f80
Use new socket to connect to the proxy relay and slice the proxy head…
yciabaud c7880bf
Add documentation for proxy
yciabaud ab26542
Provide http and https agents for proxy.
yciabaud 9eb71e3
Update documentation
yciabaud 55fa45a
Check socks version for UDP proxy
yciabaud c1e9640
Clone proxy settings to prevent Socks instances concurrency
yciabaud 8747f7e
Generate socks http agents on the fly (reuse is not working)
yciabaud 8ea50ea
Use clone to deepcopy socks opts
yciabaud 04383f3
Dont create agent for now since we cannot reuse it between requests.
yciabaud 31a35d5
Removed unused require
yciabaud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,8 @@ var Buffer = require('safe-buffer').Buffer | |
| var Client = require('../') | ||
| var common = require('./common') | ||
| var fixtures = require('webtorrent-fixtures') | ||
| var http = require('http') | ||
| var net = require('net') | ||
| var test = require('tape') | ||
|
|
||
| var peerId1 = Buffer.from('01234567890123456789') | ||
|
|
@@ -380,3 +382,56 @@ test('http: client announce with numwant', function (t) { | |
| test('udp: client announce with numwant', function (t) { | ||
| testClientAnnounceWithNumWant(t, 'udp') | ||
| }) | ||
|
|
||
| function testClientStartHttpAgent (t, serverType) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, socks proxy is hard to test... |
||
| t.plan(5) | ||
|
|
||
| common.createServer(t, serverType, function (server, announceUrl) { | ||
| var agent = new http.Agent() | ||
| var agentUsed = false | ||
| agent.createConnection = function (opts, fn) { | ||
| agentUsed = true | ||
| return net.createConnection(opts, fn) | ||
| } | ||
| var client = new Client({ | ||
| infoHash: fixtures.leaves.parsedTorrent.infoHash, | ||
| announce: announceUrl, | ||
| peerId: peerId1, | ||
| port: port, | ||
| wrtc: {}, | ||
| proxyOpts: { | ||
| httpAgent: agent | ||
| } | ||
| }) | ||
|
|
||
| if (serverType === 'ws') common.mockWebsocketTracker(client) | ||
| client.on('error', function (err) { t.error(err) }) | ||
| client.on('warning', function (err) { t.error(err) }) | ||
|
|
||
| client.once('update', function (data) { | ||
| t.equal(data.announce, announceUrl) | ||
| t.equal(typeof data.complete, 'number') | ||
| t.equal(typeof data.incomplete, 'number') | ||
|
|
||
| t.ok(agentUsed) | ||
|
|
||
| client.stop() | ||
|
|
||
| client.once('update', function () { | ||
| t.pass('got response to stop') | ||
| server.close() | ||
| client.destroy() | ||
| }) | ||
| }) | ||
|
|
||
| client.start() | ||
| }) | ||
| } | ||
|
|
||
| test('http: client.start(httpAgent)', function (t) { | ||
| testClientStartHttpAgent(t, 'http') | ||
| }) | ||
|
|
||
| test('ws: client.start(httpAgent)', function (t) { | ||
| testClientStartHttpAgent(t, 'ws') | ||
| }) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add a comment here that explains the difference between socket and proxySocket