Skip to content

Instantly share code, notes, and snippets.

@qix
Created November 22, 2016 22:24
Show Gist options
  • Save qix/95b9a850420a3874826bad5da5b1ff00 to your computer and use it in GitHub Desktop.
Save qix/95b9a850420a3874826bad5da5b1ff00 to your computer and use it in GitHub Desktop.
'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