From eb87f6c27b06a85825df9a8ac8ef133d66566058 Mon Sep 17 00:00:00 2001 From: Ricky Miller Date: Tue, 31 May 2022 20:14:24 +0900 Subject: [PATCH] fix: make opts.host work again (#96) * fix: make opts.host work again * Update package.json * Update package.json Co-authored-by: Kiko Beats --- package.json | 4 ++-- src/index.ts | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 6239752..afb2c14 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.ts b/src/index.ts index d979d03..4250893 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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; @@ -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') { @@ -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