File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 11import { socksDispatcher } from 'fetch-socks' ;
22import { HttpsProxyAgent } from 'https-proxy-agent' ;
33import { SocksProxyAgent } from 'socks-proxy-agent' ;
4- import { ProxyAgent } from 'undici' ;
4+ import { Agent , ProxyAgent } from 'undici' ;
55
66type Proxy = {
77 host : string ;
@@ -26,7 +26,16 @@ function selectProxyAgent(proxyUrl: string): HttpsProxyAgent<string> | SocksProx
2626 return new HttpsProxyAgent ( url ) ;
2727 case PROXY_SOCKS_PROTOCOL :
2828 case PROXY_SOCKS5_PROTOCOL :
29- return new SocksProxyAgent ( url ) ;
29+
30+ let urlSocks = '' ;
31+
32+ if ( url . username && url . password ) {
33+ urlSocks = `socks://${ url . username } :${ url . password } @${ url . hostname } :${ url . port } ` ;
34+ } else {
35+ urlSocks = `socks://${ url . hostname } :${ url . port } ` ;
36+ }
37+
38+ return new SocksProxyAgent ( urlSocks ) ;
3039 default :
3140 throw new Error ( `Unsupported proxy protocol: ${ url . protocol } ` ) ;
3241 }
You can’t perform that action at this time.
0 commit comments