From 3b139078c3ed8ce9b1e708ce9805dc4a31e3628c Mon Sep 17 00:00:00 2001 From: Jeferson Ramos Date: Wed, 19 Nov 2025 13:34:33 -0300 Subject: [PATCH] Removendo uso do undici com proxy socks --- src/utils/makeProxyAgent.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/makeProxyAgent.ts b/src/utils/makeProxyAgent.ts index e882876e..3de058cd 100644 --- a/src/utils/makeProxyAgent.ts +++ b/src/utils/makeProxyAgent.ts @@ -19,11 +19,13 @@ function selectProxyAgent(proxyUrl: string): HttpsProxyAgent | SocksProx // the end so, we add the protocol constants without the `:` to avoid confusion. const PROXY_HTTP_PROTOCOL = 'http:'; const PROXY_SOCKS_PROTOCOL = 'socks:'; + const PROXY_SOCKS5_PROTOCOL = 'socks5:'; switch (url.protocol) { case PROXY_HTTP_PROTOCOL: return new HttpsProxyAgent(url); case PROXY_SOCKS_PROTOCOL: + case PROXY_SOCKS5_PROTOCOL: return new SocksProxyAgent(url); default: throw new Error(`Unsupported proxy protocol: ${url.protocol}`); @@ -45,7 +47,7 @@ export function makeProxyAgent(proxy: Proxy | string): HttpsProxyAgent | return selectProxyAgent(proxyUrl); } -export function makeProxyAgentUndici(proxy: Proxy | string): ProxyAgent { +export function makeProxyAgentUndici(proxy: Proxy | string): ProxyAgent|SocksProxyAgent { let proxyUrl: string let protocol: string @@ -73,10 +75,10 @@ export function makeProxyAgentUndici(proxy: Proxy | string): ProxyAgent { switch (protocol) { case PROXY_HTTP_PROTOCOL: case PROXY_HTTPS_PROTOCOL: + return new ProxyAgent(proxyUrl) case PROXY_SOCKS4_PROTOCOL: case PROXY_SOCKS5_PROTOCOL: - return new ProxyAgent(proxyUrl) - + return new SocksProxyAgent(proxyUrl) default: throw new Error(`Unsupported proxy protocol: ${protocol}`) }