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

Commit

Permalink
feat(wallet): support connecting to .onion domains
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed May 3, 2020
1 parent ad6e5f5 commit a99482b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions utils/validateHost.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a99482b

Please sign in to comment.