From 4937028e04c39c1bb51e22300459d5862272cf80 Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Mon, 15 Apr 2019 18:32:26 +0200 Subject: [PATCH] Switch from dns.resolve to dns.lookup (issue #124) --- src/proxy.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/proxy.ts b/src/proxy.ts index 8a9a20b..814a061 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -6,9 +6,11 @@ import { FileSystemConfig } from './fileSystemConfig'; import * as Logging from './logging'; import { toPromise } from './toPromise'; -async function resolveHostname(hostname: string): Promise { - if (hostname === 'localhost') return ['127.0.0.1']; - return toPromise(cb => dns.resolve(hostname, cb)); +async function resolveHostname(hostname: string): Promise { + return toPromise(cb => dns.lookup(hostname, cb)).then((ip) => { + Logging.debug(`Resolved hostname "${hostname}" to: ${ip}`); + return ip; + }); } function validateConfig(config: FileSystemConfig) { @@ -25,7 +27,7 @@ export async function socks(config: FileSystemConfig): Promise