Skip to content

Commit 3b13907

Browse files
committed
Removendo uso do undici com proxy socks
1 parent 3818313 commit 3b13907

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/utils/makeProxyAgent.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ function selectProxyAgent(proxyUrl: string): HttpsProxyAgent<string> | SocksProx
1919
// the end so, we add the protocol constants without the `:` to avoid confusion.
2020
const PROXY_HTTP_PROTOCOL = 'http:';
2121
const PROXY_SOCKS_PROTOCOL = 'socks:';
22+
const PROXY_SOCKS5_PROTOCOL = 'socks5:';
2223

2324
switch (url.protocol) {
2425
case PROXY_HTTP_PROTOCOL:
2526
return new HttpsProxyAgent(url);
2627
case PROXY_SOCKS_PROTOCOL:
28+
case PROXY_SOCKS5_PROTOCOL:
2729
return new SocksProxyAgent(url);
2830
default:
2931
throw new Error(`Unsupported proxy protocol: ${url.protocol}`);
@@ -45,7 +47,7 @@ export function makeProxyAgent(proxy: Proxy | string): HttpsProxyAgent<string> |
4547
return selectProxyAgent(proxyUrl);
4648
}
4749

48-
export function makeProxyAgentUndici(proxy: Proxy | string): ProxyAgent {
50+
export function makeProxyAgentUndici(proxy: Proxy | string): ProxyAgent|SocksProxyAgent {
4951
let proxyUrl: string
5052
let protocol: string
5153

@@ -73,10 +75,10 @@ export function makeProxyAgentUndici(proxy: Proxy | string): ProxyAgent {
7375
switch (protocol) {
7476
case PROXY_HTTP_PROTOCOL:
7577
case PROXY_HTTPS_PROTOCOL:
78+
return new ProxyAgent(proxyUrl)
7679
case PROXY_SOCKS4_PROTOCOL:
7780
case PROXY_SOCKS5_PROTOCOL:
78-
return new ProxyAgent(proxyUrl)
79-
81+
return new SocksProxyAgent(proxyUrl)
8082
default:
8183
throw new Error(`Unsupported proxy protocol: ${protocol}`)
8284
}

0 commit comments

Comments
 (0)