Skip to content

Commit

Permalink
fix: use hostname for socks agent (#159)
Browse files Browse the repository at this point in the history
host was deprecated and removed in the next semver major
  • Loading branch information
wraithgar committed Jun 1, 2022
1 parent 99f44e0 commit 331f9cb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/agent.js
Expand Up @@ -198,6 +198,9 @@ function getProxy (proxyUrl, opts, isHttps) {
return new HttpsProxyAgent(popts)
}
} else if (proxyUrl.protocol.startsWith('socks')) {
// socks-proxy-agent uses hostname not host
popts.hostname = popts.host
delete popts.host
return new SocksProxyAgent(popts)
} else {
throw Object.assign(
Expand Down
4 changes: 2 additions & 2 deletions test/agent.js
Expand Up @@ -224,7 +224,7 @@ t.test('get proxy agent', async t => {
}, 'https proxy url, for https request')

t.strictSame(getProxy(new url.URL('socks://proxy.local:443/'), PROXY_OPTS, true), {
host: 'proxy.local',
hostname: 'proxy.local',
port: '443',
protocol: 'socks:',
path: '/',
Expand Down Expand Up @@ -272,7 +272,7 @@ t.test('get proxy agent', async t => {
}, 'https proxy url, for http request')

t.strictSame(getProxy(new url.URL('socks://proxy.local:443/'), PROXY_OPTS, false), {
host: 'proxy.local',
hostname: 'proxy.local',
port: '443',
protocol: 'socks:',
path: '/',
Expand Down

0 comments on commit 331f9cb

Please sign in to comment.