From a99482b5a81c07c32654c0f856c7cf74796441b2 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sun, 26 Apr 2020 14:38:37 +0200 Subject: [PATCH] feat(wallet): support connecting to .onion domains --- utils/validateHost.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/utils/validateHost.js b/utils/validateHost.js index 1a3c6e099a1..46e11dd38af 100644 --- a/utils/validateHost.js +++ b/utils/validateHost.js @@ -23,16 +23,20 @@ const validateHost = async host => { try { const { host: lndHost, port: lndPort } = splitHostname(host) - // If the hostname starts with a number, ensure that it is a valid IP address. - if (!isFQDN(lndHost, { require_tld: false }) && !isIP(lndHost)) { - return createError(`${lndHost} is not a valid IP address or hostname`, 'LND_GRPC_HOST_ERROR') - } - // If the host includes a port, ensure that it is a valid. if (lndPort && !isPort(lndPort)) { return createError(`${lndPort} is not a valid port`, 'LND_GRPC_HOST_ERROR') } + if (lndHost.endsWith('.onion')) { + return true + } + + // If the hostname starts with a number, ensure that it is a valid IP address. + if (!isFQDN(lndHost, { require_tld: false }) && !isIP(lndHost)) { + return createError(`${lndHost} is not a valid IP address or hostname`, 'LND_GRPC_HOST_ERROR') + } + try { // Do a DNS lookup to ensure that the host is reachable. await dnsLookup(lndHost)