proxy-chain icon indicating copy to clipboard operation
proxy-chain copied to clipboard

Providing custom http agent for using socks 4/5

Open vladgovor77771 opened this issue 5 years ago • 5 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 :)

vladgovor77771 avatar May 21 '20 18:05 vladgovor77771

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

jancurn avatar May 22 '20 08:05 jancurn

@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?

avently avatar Sep 22 '21 05:09 avently

https://github.com/apify/proxy-chain/pull/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

franz101 avatar Oct 22 '21 23:10 franz101

Another solution here: https://github.com/orlv/tiny-proxy-chain/blob/94fb49c7b9b930817d0308c116d9de6d8b90db8a/index.js#L265

franz101 avatar Oct 22 '21 23:10 franz101

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.

mydesk00001 avatar Jul 24 '23 19:07 mydesk00001