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

Commit

Permalink
fix: make opts.host work again (#96)
Browse files Browse the repository at this point in the history
* fix: make opts.host work again

* Update package.json

* Update package.json

Co-authored-by: Kiko Beats <josefrancisco.verdu@gmail.com>
  • Loading branch information
richardkazuomiller and Kikobeats authored May 31, 2022
1 parent 4a2036c commit eb87f6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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

0 comments on commit eb87f6c

Please sign in to comment.