Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit eb87f6c

Browse files
fix: make opts.host work again (#96)
* fix: make opts.host work again * Update package.json * Update package.json Co-authored-by: Kiko Beats <[email protected]>
1 parent 4a2036c commit eb87f6c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@
113113
"@types/node": "latest",
114114
"cacheable-lookup": "^6.0.4",
115115
"conventional-github-releaser": "latest",
116-
"dns2": "^2.0.1",
116+
"dns2": "latest",
117117
"finepack": "latest",
118118
"git-authors-cli": "latest",
119-
"mocha": "latest",
119+
"mocha": "9",
120120
"nano-staged": "latest",
121121
"npm-check-updates": "latest",
122122
"prettier-standard": "latest",

src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import net from 'net'
88
import tls from 'tls'
99

1010
interface BaseSocksProxyAgentOptions {
11+
/**
12+
* hostname is preferred over host
13+
*
14+
* @deprecated
15+
*/
1116
host?: string | null;
1217
port?: string | number | null;
1318
username?: string | null;
@@ -25,10 +30,10 @@ function parseSocksProxy (opts: SocksProxyAgentOptions): { lookup: boolean, prox
2530
let lookup = false
2631
let type: SocksProxy['type'] = 5
2732

28-
const host = opts.hostname
33+
const host = opts.hostname || opts.host
2934

3035
if (host == null) {
31-
throw new TypeError('No "host"')
36+
throw new TypeError('No "hostname"')
3237
}
3338

3439
if (typeof opts.port === 'number') {
@@ -110,7 +115,7 @@ const normalizeProxyOptions = (input: string | SocksProxyAgentOptions): SocksPro
110115
proxyOptions = input
111116
}
112117
if (proxyOptions == null) {
113-
throw new TypeError('a SOCKS proxy server `host` and `port` must be specified!')
118+
throw new TypeError('a SOCKS proxy server `hostname` and `port` must be specified!')
114119
}
115120

116121
return proxyOptions

0 commit comments

Comments
 (0)