Created
November 22, 2016 22:24
-
-
Save qix/95b9a850420a3874826bad5da5b1ff00 to your computer and use it in GitHub Desktop.
This file contains 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
'use strict'; | |
const Promise = require('bluebird'); | |
const SocksAgent = require('socks5-http-client/lib/Agent'); | |
const fetchHttp = require('../../lib/utils/fetchHttp'); | |
defineTest('socks proxy works', { | |
tags: ['socks', 'httpEndpoint'], | |
}, Promise.coroutine(function*(test) { | |
const {url, queue} = test.tagData.httpEndpoint; | |
let remoteAddress; | |
yield fetchHttp(_no_trc, { | |
method: 'GET', | |
url, | |
agentClass: SocksAgent, | |
agentOptions: { | |
socksHost: test.tagData.socks.host, | |
socksPort: test.tagData.socks.port, | |
}, | |
}); | |
({remoteAddress} = yield queue.pop()); | |
// Make sure that the remoteAddress was the socks host. We use `endsWith` | |
// because the ip address comes through as IPv6 | |
// e.g. "::ffff:172.17.0.15" | |
// @NOTE: This might be flakey and need to be updated later. | |
test.assert.equal(remoteAddress, `::ffff:${test.tagData.socks.host}`); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment