Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProxyAgent: support socks5 protocol #2224

Open
idranme opened this issue Aug 24, 2023 · 10 comments
Open

ProxyAgent: support socks5 protocol #2224

idranme opened this issue Aug 24, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@idranme
Copy link

idranme commented Aug 24, 2023

This would solve...

Using the socks5 proxy.

The implementation should look like...

import { ProxyAgent } from 'undici'
const client = new ProxyAgent('socks5://127.0.0.1:7890/')

I have also considered...

Additional context

@mcollina
Copy link
Member

This would be amazing, but it'd also be somewhat feasible to create it outside of this module. I recommend that route at this point as we are stretched really thin.

@idranme
Copy link
Author

idranme commented Aug 24, 2023

It would be best if it could be integrated in this module.

@mcollina
Copy link
Member

PRs are welcomed.

@KhafraDev
Copy link
Member

have you tried https://github.com/Kaciras/fetch-socks?

@idranme
Copy link
Author

idranme commented Aug 25, 2023

have you tried https://github.com/Kaciras/fetch-socks?

https://github.com/Kaciras/fetch-socks/blob/master/package.json#L34

This package depends on an undici. So I don't think it's ideal.

@KhafraDev
Copy link
Member

the caret means it supports undici versions of at least 5.22.1

@idranme
Copy link
Author

idranme commented Aug 26, 2023

the caret means it supports undici versions of at least 5.22.1

When I use undici, it installs one more on its side, which will now will exist two undici.

@KhafraDev
Copy link
Member

you can probably use dedupe

@PandaWorker
Copy link

Wouldn't it be simpler to make a buildConnector for each type of proxy and use it as a connector?

const httpProxyBuildConnector = (proxy) => {
 return (opts) => {
    const socket = createConnection(opts);
    return socket;
  }
}

const socksProxyBuildConnector = (proxy) => {
  return (opts) => {
    const socket = createConnection(opts);
    return socket;
  }
}

const proxyConnector = httpProxyBuildConnector(proxy);
const proxyAgent = new Agent({connect: proxyConnector });

const resp = await fetch('localhost:3000/', {
  dispatcher: proxyAgent
});

Or you can do it the same way as done by aiohttp in python (https://github.com/Slzdude/aiohttp-proxy)

@eugenepugach
Copy link

Also after implementation SOCKS5 - we have got CRITICAL Vulnerability ❌ CVE-2023-38545 which affected on the security.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants