TooTallNate / proxy-agents

Node.js HTTP Proxy Agents Monorepo
https://proxy-agents.n8.io
871 stars 229 forks source link

[socks-proxy-agent] pass socket_options to SocksClient #302

Closed lukekarrys closed 2 months ago

lukekarrys commented 2 months ago

This PR adds the option socketOptions which will get passed along to SocksClient.createConnection as socket_options.

Another solution would be to spread all the unused constructor options to the SocksClient.createConnection options since there are a few more that are allowed. I didn't go this route since I only have a use case for socket_options and I didn't want to couple the two APIs too closely. But I'd be happy to rework this PR if desired.

For reference the SocksClientOptions interface is:

interface SocksClientOptions {
    command: SocksCommandOption;
    destination: SocksRemoteHost;
    proxy: SocksProxy;
    timeout?: number;
    existing_socket?: Duplex;
    set_tcp_nodelay?: boolean;
    socket_options?: SocketConnectOpts;
}
changeset-bot[bot] commented 2 months ago

🦋 Changeset detected

Latest commit: 35869195216e9d8c90dc5f08f098d18d903a0df3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------------- | ----- | | socks-proxy-agent | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
proxy-agents ✅ Ready (Inspect) Visit Preview Mar 30, 2024 1:08am
melroy89 commented 2 months ago

CI/CD fails, due to too many socket connections or.. ? 😆


  FAIL test/e2e.test.ts (32.526 s)
    HttpsProxyAgent
      ✕ should work over NordVPN proxy (30002 ms)

    ● HttpsProxyAgent › should work over NordVPN proxy

      thrown: "Exceeded timeout of 30000 ms for a test.
      Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

        49 |
        50 | describe('HttpsProxyAgent', () => {
      > 51 |    it('should work over NordVPN proxy', async () => {
           |    ^
        52 |        const { NORDVPN_USERNAME, NORDVPN_PASSWORD } = process.env;
        53 |        if (!NORDVPN_USERNAME) {
        54 |            throw new Error('`NORDVPN_USERNAME` env var is not defined');

        at test/e2e.test.ts:51:2
        at Object.<anonymous> (test/e2e.test.ts:50:1)