socks-proxy-agent
Advanced tools
Comparing version 6.2.0-beta.0 to 6.2.0-beta.1
/// <reference types="node" /> | ||
import { SocksProxy } from 'socks'; | ||
import { Agent, ClientRequest, RequestOptions } from 'agent-base'; | ||
import CacheableLookup from 'cacheable-lookup'; | ||
import { AgentOptions } from 'agent-base'; | ||
@@ -16,3 +15,2 @@ import { Url } from 'url'; | ||
interface SocksProxyAgentOptionsExtra { | ||
dnsCache?: CacheableLookup; | ||
timeout?: number; | ||
@@ -23,6 +21,5 @@ } | ||
export declare class SocksProxyAgent extends Agent { | ||
private readonly lookup; | ||
private readonly shouldLookup; | ||
private readonly proxy; | ||
private readonly tlsConnectionOptions; | ||
private readonly dnsCache; | ||
timeout: number | null; | ||
@@ -29,0 +26,0 @@ constructor(input: string | SocksProxyAgentOptions, options?: SocksProxyAgentOptionsExtra); |
@@ -18,4 +18,4 @@ "use strict"; | ||
const agent_base_1 = require("agent-base"); | ||
const cacheable_lookup_1 = __importDefault(require("cacheable-lookup")); | ||
const debug_1 = __importDefault(require("debug")); | ||
const dns_1 = __importDefault(require("dns")); | ||
const tls_1 = __importDefault(require("tls")); | ||
@@ -113,11 +113,10 @@ const debug = (0, debug_1.default)('socks-proxy-agent'); | ||
constructor(input, options) { | ||
var _a, _b; | ||
var _a; | ||
const proxyOptions = normalizeProxyOptions(input); | ||
super(proxyOptions); | ||
const parsedProxy = parseSocksProxy(proxyOptions); | ||
this.lookup = parsedProxy.lookup; | ||
this.shouldLookup = parsedProxy.lookup; | ||
this.proxy = parsedProxy.proxy; | ||
this.tlsConnectionOptions = proxyOptions.tls != null ? proxyOptions.tls : {}; | ||
this.dnsCache = (_a = options === null || options === void 0 ? void 0 : options.dnsCache) !== null && _a !== void 0 ? _a : new cacheable_lookup_1.default(); | ||
this.timeout = (_b = options === null || options === void 0 ? void 0 : options.timeout) !== null && _b !== void 0 ? _b : null; | ||
this.timeout = (_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : null; | ||
} | ||
@@ -133,11 +132,21 @@ /** | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { lookup, proxy, timeout } = this; | ||
let { host, port } = opts; | ||
const { shouldLookup, proxy, timeout } = this; | ||
let { host, port, lookup: lookupCallback } = opts; | ||
if (host == null) { | ||
throw new Error('No `host` defined!'); | ||
} | ||
if (lookup) { | ||
if (shouldLookup) { | ||
// Client-side DNS resolution for "4" and "5" socks proxy versions. | ||
const res = yield this.dnsCache.lookupAsync(host); | ||
host = res.address; | ||
host = yield new Promise((resolve, reject) => { | ||
// Use the request's custom lookup, if one was configured: | ||
const lookupFn = lookupCallback !== null && lookupCallback !== void 0 ? lookupCallback : dns_1.default.lookup; | ||
lookupFn(host, {}, (err, res) => { | ||
if (err) { | ||
reject(err); | ||
} | ||
else { | ||
resolve(res); | ||
} | ||
}); | ||
}); | ||
} | ||
@@ -144,0 +153,0 @@ const socksOpts = { |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/TooTallNate/node-socks-proxy-agent#readme", | ||
"version": "6.2.0-beta.0", | ||
"version": "6.2.0-beta.1", | ||
"main": "dist/index.js", | ||
@@ -87,3 +87,2 @@ "author": { | ||
"agent-base": "^6.0.2", | ||
"cacheable-lookup": "~6.0.4", | ||
"debug": "^4.3.3", | ||
@@ -97,3 +96,5 @@ "socks": "^2.6.2" | ||
"@types/node": "latest", | ||
"cacheable-lookup": "^6.0.4", | ||
"conventional-github-releaser": "latest", | ||
"dns2": "^2.0.1", | ||
"finepack": "latest", | ||
@@ -100,0 +101,0 @@ "git-authors-cli": "latest", |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
26791
3
229
22
- Removedcacheable-lookup@~6.0.4
- Removedcacheable-lookup@6.0.4(transitive)