apify / proxy-chain

Node.js implementation of a proxy server (think Squid) with support for SSL, authentication and upstream proxy chaining.

Home Page:https://www.npmjs.com/package/proxy-chain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Providing custom http agent for using socks 4/5

vladgovor77771 opened this issue · comments

Simply modified your code on handler_forward.js

// custom `http.Agent` support, set `server.httpAgent`
if (!!this.server.httpAgent) reqOpts.agent = this.server.httpAgent;

And in server.js in constructor add
this.httpAgent = options.httpAgent;

Then, if we want to create server with socks proxy for example, do this:

const { SocksProxyAgent } = require('socks-proxy-agent');
const ProxyChain = require('../proxy-chain');
const info = {
  host: ip,
  port: 8080,
}

const agent = new SocksProxyAgent(info);

const options = {
  port: 8086,
  verbose: true,
  httpAgent: agent
}

const server = new ProxyChain.Server(options);

server.listen();

But I don't undestand why is it under comment, so we can't use it without code customisation.
@jancurn , Can you please add 2 strings to next update please :)

Thanks for the hint @vladgovor77771, we'll look into it when we have time.

@vladgovor77771 what workaround can be used now? Because your code is not working as far as i can see. The agent is not used.
Maybe alternative library?

#171

I have made a workaround but currently not working for https...
The implementation from @temp3l can maybe help:
https://github.com/temp3l/proxy-chain/tree/socksProxy

Thanks for the hint @vladgovor77771, we'll look into it when we have time.

Please update these for getting Socks5 support. Waiting for your response.

Closing as support for SOCKS has been added in 2.5.0, which is now released.