Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Module dependencies.
*/
var tls; // lazy-loaded...
var url = require('url');
var dns = require('dns');
var Agent = require('agent-base');
var SocksClient = require('socks').SocksClient;
var inherits = require('util').inherits;
/**
* Module exports.
*/
module.exports = SocksProxyAgent;
/**
* The `SocksProxyAgent`.
*
* @api public
*/
function SocksProxyAgent(opts) {
if (!(this instanceof SocksProxyAgent)) return new SocksProxyAgent(opts);
var socks = require('socks').SocksClient;
var toPull = require('stream-to-pull-stream')
module.exports = function (opts) {
if(!socks) { //we are in browser
console.warn('onion dialing through socks proxy not supported in browser setting')
return {
name: 'onion',
scope: function() { return 'public' },
parse: function (s) { return null }
}
}
opts = opts || {}
var proxyOpts = {
ipaddress: "127.0.0.1",
//TODO: tor port should be configurable.