Skip to content

ProxyAgent: support socks5 protocol #2224

Closed

Description

@idranme

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

Activity

  1. mcollina commented on Aug 24, 2023

    @mcollina
    SponsorMember

    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.

  2. idranme commented on Aug 24, 2023

    @idranme
    Author

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

  3. mcollina commented on Aug 24, 2023

    @mcollina
    SponsorMember

    PRs are welcomed.

  4. KhafraDev commented on Aug 25, 2023

    @KhafraDev
    Member
  5. idranme commented on Aug 25, 2023

    @idranme
    Author

    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.

  6. KhafraDev commented on Aug 25, 2023

    @KhafraDev
    Member

    the caret means it supports undici versions of at least 5.22.1

  7. idranme commented on Aug 26, 2023

    @idranme
    Author

    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.

  8. KhafraDev commented on Sep 5, 2023

    @KhafraDev
    Member

    you can probably use dedupe

  9. PandaWorker commented on Sep 9, 2023

    @PandaWorker
    Contributor

    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)

  10. eugenepugach commented on Nov 9, 2023

    @eugenepugach

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

  11. joyeecheung commented on Mar 5, 2025

    @joyeecheung
    Member

    If no one is working on it I am interested in picking it up, as I am working on nodejs/node#57165 I think it would be a great addition for Node.js built fetch to work more seamlessly with socks 5 proxies. The lack of support of it was one of the reasons I added the local README config in node-core-utils as a workaround (because if you try to fetch github raw content within Chinese GFW you get connection issues). It would also help closing nodejs/node-core-utils#653 and overall making Node.js easier to use for developers in China (socks5 is very popular in China).

  12. metcoder95 commented on Mar 7, 2025

    @metcoder95
    Member

    Go for it, I believe hasn't been progress since then

  13. grepsuzette commented on Sep 8, 2025

    @grepsuzette

    Not just socks5:// but also socks5h, for dns resolution through the proxy, which is often critical.

  14. AffiTheCreator commented on Dec 22, 2025

    @AffiTheCreator

    Hi Team,

    Thanks for all your hard work!

    Just a friendly reminder from a happy user: would it be possible to share an update on when PR #4385 will be merged?

    Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions