undici
undici copied to clipboard
ProxyAgent: support socks5 protocol
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
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.
It would be best if it could be integrated in this module.
PRs are welcomed.
have you tried https://github.com/Kaciras/fetch-socks?
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.
the caret means it supports undici versions of at least 5.22.1
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.
you can probably use dedupe
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)
Also after implementation SOCKS5 - we have got CRITICAL Vulnerability ❌ CVE-2023-38545 which affected on the security.