Skip to content

Commit 331f9cb

Browse files
authored
fix: use hostname for socks agent (#159)
host was deprecated and removed in the next semver major
1 parent 99f44e0 commit 331f9cb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/agent.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ function getProxy (proxyUrl, opts, isHttps) {
198198
return new HttpsProxyAgent(popts)
199199
}
200200
} else if (proxyUrl.protocol.startsWith('socks')) {
201+
// socks-proxy-agent uses hostname not host
202+
popts.hostname = popts.host
203+
delete popts.host
201204
return new SocksProxyAgent(popts)
202205
} else {
203206
throw Object.assign(

test/agent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ t.test('get proxy agent', async t => {
224224
}, 'https proxy url, for https request')
225225

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

274274
t.strictSame(getProxy(new url.URL('socks://proxy.local:443/'), PROXY_OPTS, false), {
275-
host: 'proxy.local',
275+
hostname: 'proxy.local',
276276
port: '443',
277277
protocol: 'socks:',
278278
path: '/',

0 commit comments

Comments
 (0)