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

fix: make opts.host work again #96

Merged
merged 3 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@
"@types/node": "latest",
"cacheable-lookup": "^6.0.4",
"conventional-github-releaser": "latest",
"dns2": "^2.0.1",
"dns2": "latest",
"finepack": "latest",
"git-authors-cli": "latest",
"mocha": "latest",
"mocha": "9",
"nano-staged": "latest",
"npm-check-updates": "latest",
"prettier-standard": "latest",
Expand Down
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import net from 'net'
import tls from 'tls'

interface BaseSocksProxyAgentOptions {
/**
* hostname is preferred over host
*
* @deprecated
*/
host?: string | null;
port?: string | number | null;
username?: string | null;
Expand All @@ -25,10 +30,10 @@ function parseSocksProxy (opts: SocksProxyAgentOptions): { lookup: boolean, prox
let lookup = false
let type: SocksProxy['type'] = 5

const host = opts.hostname
const host = opts.hostname || opts.host

if (host == null) {
throw new TypeError('No "host"')
throw new TypeError('No "hostname"')
}

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

return proxyOptions
Expand Down