From af47b859e41be51732768cf7f1334b10a277b357 Mon Sep 17 00:00:00 2001 From: Jeferson Ramos Date: Mon, 24 Nov 2025 13:59:50 -0300 Subject: [PATCH] socks5 update --- src/utils/makeProxyAgent.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/utils/makeProxyAgent.ts b/src/utils/makeProxyAgent.ts index c2f5affa..5be908f0 100644 --- a/src/utils/makeProxyAgent.ts +++ b/src/utils/makeProxyAgent.ts @@ -1,7 +1,7 @@ import { socksDispatcher } from 'fetch-socks'; import { HttpsProxyAgent } from 'https-proxy-agent'; import { SocksProxyAgent } from 'socks-proxy-agent'; -import { ProxyAgent } from 'undici'; +import { Agent, ProxyAgent } from 'undici'; type Proxy = { host: string; @@ -26,7 +26,16 @@ function selectProxyAgent(proxyUrl: string): HttpsProxyAgent | SocksProx return new HttpsProxyAgent(url); case PROXY_SOCKS_PROTOCOL: case PROXY_SOCKS5_PROTOCOL: - return new SocksProxyAgent(url); + + let urlSocks = ''; + + if(url.username && url.password) { + urlSocks = `socks://${url.username}:${url.password}@${url.hostname}:${url.port}`; + } else { + urlSocks = `socks://${url.hostname}:${url.port}`; + } + + return new SocksProxyAgent(urlSocks); default: throw new Error(`Unsupported proxy protocol: ${url.protocol}`); }