mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2026-01-28 10:34:26 +01:00
Add error message for tor urls
This commit is contained in:
committed by
Tony Giorgio
parent
e1843e6493
commit
ee32e59eb7
@@ -1,4 +1,4 @@
|
||||
import { createForm, url } from "@modular-forms/solid";
|
||||
import { createForm, custom, url } from "@modular-forms/solid";
|
||||
import { createResource, Match, Suspense, Switch } from "solid-js";
|
||||
|
||||
import {
|
||||
@@ -24,6 +24,26 @@ import {
|
||||
} from "~/logic/mutinyWalletSetup";
|
||||
import { eify } from "~/utils";
|
||||
|
||||
const validateNotTorUrl = async (value?: string) => {
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if it is one of the default URLs, it's safe
|
||||
// need this handling for self-hosting deployments
|
||||
if (
|
||||
value === import.meta.env.VITE_PROXY ||
|
||||
value === import.meta.env.VITE_ESPLORA ||
|
||||
value === import.meta.env.VITE_RGS ||
|
||||
value === import.meta.env.VITE_LSP ||
|
||||
value === import.meta.env.VITE_STORAGE
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !value.includes(".onion");
|
||||
};
|
||||
|
||||
function SettingsStringsEditor(props: {
|
||||
initialSettings: MutinyWalletSettingStrings;
|
||||
}) {
|
||||
@@ -54,7 +74,13 @@ function SettingsStringsEditor(props: {
|
||||
<div />
|
||||
<Field
|
||||
name="proxy"
|
||||
validate={[url(i18n.t("settings.servers.error_proxy"))]}
|
||||
validate={[
|
||||
url(i18n.t("settings.servers.error_proxy")),
|
||||
custom(
|
||||
validateNotTorUrl,
|
||||
i18n.t("settings.servers.error_tor")
|
||||
)
|
||||
]}
|
||||
>
|
||||
{(field, props) => (
|
||||
<TextField
|
||||
@@ -68,7 +94,13 @@ function SettingsStringsEditor(props: {
|
||||
</Field>
|
||||
<Field
|
||||
name="esplora"
|
||||
validate={[url(i18n.t("settings.servers.error_esplora"))]}
|
||||
validate={[
|
||||
url(i18n.t("settings.servers.error_esplora")),
|
||||
custom(
|
||||
validateNotTorUrl,
|
||||
i18n.t("settings.servers.error_tor")
|
||||
)
|
||||
]}
|
||||
>
|
||||
{(field, props) => (
|
||||
<TextField
|
||||
@@ -82,7 +114,13 @@ function SettingsStringsEditor(props: {
|
||||
</Field>
|
||||
<Field
|
||||
name="rgs"
|
||||
validate={[url(i18n.t("settings.servers.error_rgs"))]}
|
||||
validate={[
|
||||
url(i18n.t("settings.servers.error_rgs")),
|
||||
custom(
|
||||
validateNotTorUrl,
|
||||
i18n.t("settings.servers.error_tor")
|
||||
)
|
||||
]}
|
||||
>
|
||||
{(field, props) => (
|
||||
<TextField
|
||||
@@ -96,7 +134,13 @@ function SettingsStringsEditor(props: {
|
||||
</Field>
|
||||
<Field
|
||||
name="lsp"
|
||||
validate={[url(i18n.t("settings.servers.error_lsp"))]}
|
||||
validate={[
|
||||
url(i18n.t("settings.servers.error_lsp")),
|
||||
custom(
|
||||
validateNotTorUrl,
|
||||
i18n.t("settings.servers.error_tor")
|
||||
)
|
||||
]}
|
||||
>
|
||||
{(field, props) => (
|
||||
<TextField
|
||||
@@ -110,7 +154,13 @@ function SettingsStringsEditor(props: {
|
||||
</Field>
|
||||
<Field
|
||||
name="storage"
|
||||
validate={[url(i18n.t("settings.servers.error_lsp"))]}
|
||||
validate={[
|
||||
url(i18n.t("settings.servers.error_lsp")),
|
||||
custom(
|
||||
validateNotTorUrl,
|
||||
i18n.t("settings.servers.error_tor")
|
||||
)
|
||||
]}
|
||||
>
|
||||
{(field, props) => (
|
||||
<TextField
|
||||
|
||||
Reference in New Issue
Block a user