From fb32e01a2fa84d104c114becf1a6a65636240305 Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Thu, 23 May 2024 17:09:06 +0200 Subject: [PATCH] Connect to .onion via HTTP instead of HTTPS --- src/lib/router.ts | 7 ++++--- src/lib/utils.ts | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/router.ts b/src/lib/router.ts index 888c8eb24..655cfdd61 100644 --- a/src/lib/router.ts +++ b/src/lib/router.ts @@ -169,9 +169,10 @@ function extractBaseUrl(hostAndPort: string): BaseUrl { return { hostname, port: Number(port), - scheme: utils.isLocal(hostname) - ? "http" - : config.nodes.defaultHttpdScheme, + scheme: + utils.isLocal(hostname) || utils.isOnion(hostname) + ? "http" + : config.nodes.defaultHttpdScheme, }; } else { return { diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 8ed5d8bd1..017728969 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -264,6 +264,11 @@ export function isLocal(addr: string): boolean { ); } +// Check whether the given domain name is an onion domain name. +export function isOnion(addr: string): boolean { + return addr.endsWith(".onion"); +} + // Get the gravatar URL of an email. export function gravatarURL(email: string): string { const address = email.trim().toLowerCase();