mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-30 00:09:07 +01:00
treat old wiretrustee domain as cloud
This commit is contained in:
@@ -79,7 +79,7 @@ Page-specific chrome and providers live in the page, not the layout:
|
|||||||
- `typography/` — `Label`, `HelpText`.
|
- `typography/` — `Label`, `HelpText`.
|
||||||
- `empty-state/` — `EmptyState`, `NoResults`, `NotConnectedState`, `DaemonUnavailableOverlay`.
|
- `empty-state/` — `EmptyState`, `NoResults`, `NotConnectedState`, `DaemonUnavailableOverlay`.
|
||||||
- Flat at root: `Badge`, `CopyToClipboard`, `DropdownMenu`, `SquareIcon`, `Tooltip`, `TruncatedText`, `VerticalTabs`, `LanguagePicker`, `ManagementServerSwitch`.
|
- Flat at root: `Badge`, `CopyToClipboard`, `DropdownMenu`, `SquareIcon`, `Tooltip`, `TruncatedText`, `VerticalTabs`, `LanguagePicker`, `ManagementServerSwitch`.
|
||||||
- `hooks/` — `useAutoSizeWindow.ts` (auto-size + `Window.Show` for auxiliary dialogs), `useKeyboardShortcut.ts`, `useManagementUrl.ts` (management-URL helpers: `CLOUD_MANAGEMENT_URL`, `isValidManagementUrl`, `normalizeManagementUrl`, `isCloudManagementUrl`, `checkManagementUrlReachable`).
|
- `hooks/` — `useAutoSizeWindow.ts` (auto-size + `Window.Show` for auxiliary dialogs), `useKeyboardShortcut.ts`, `useManagementUrl.ts` (management-URL helpers: `CLOUD_MANAGEMENT_URL`, `isValidManagementUrl`, `normalizeManagementUrl`, `isNetbirdCloud`, `checkManagementUrlReachable`).
|
||||||
- `lib/` — pure utilities (no JSX, no React state): `cn.ts`, `errors.ts` (`formatErrorMessage` + the `errorDialog({Title, Message})` window wrapper), `formatters.ts` (byte/latency/relative-time + `shortenDns`), `sorting.ts` (`reconcileOrder` — order-preserving list reconciliation shared by the peers/networks/profiles lists), `i18n.ts`, `logs.ts` (forwards console + uncaught errors to the Go log pipeline), `platform.ts` (`isMacOS`/`isWindows`), `welcome.ts`.
|
- `lib/` — pure utilities (no JSX, no React state): `cn.ts`, `errors.ts` (`formatErrorMessage` + the `errorDialog({Title, Message})` window wrapper), `formatters.ts` (byte/latency/relative-time + `shortenDns`), `sorting.ts` (`reconcileOrder` — order-preserving list reconciliation shared by the peers/networks/profiles lists), `i18n.ts`, `logs.ts` (forwards console + uncaught errors to the Go log pipeline), `platform.ts` (`isMacOS`/`isWindows`), `welcome.ts`.
|
||||||
- `assets/` — fonts, logos, flags.
|
- `assets/` — fonts, logos, flags.
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,15 @@ import { useSettings } from "@/contexts/SettingsContext.tsx";
|
|||||||
import { useConfirm } from "@/contexts/DialogContext.tsx";
|
import { useConfirm } from "@/contexts/DialogContext.tsx";
|
||||||
|
|
||||||
export const CLOUD_MANAGEMENT_URL = "https://api.netbird.io:443";
|
export const CLOUD_MANAGEMENT_URL = "https://api.netbird.io:443";
|
||||||
|
const CLOUD_MANAGEMENT_URLS = new Set([
|
||||||
|
CLOUD_MANAGEMENT_URL,
|
||||||
|
"https://api.wiretrustee.com:443", // legacy cloud endpoint
|
||||||
|
]);
|
||||||
|
|
||||||
|
export function isNetbirdCloud(url: string): boolean {
|
||||||
|
if (!url || url.trim() === "") return true;
|
||||||
|
return CLOUD_MANAGEMENT_URLS.has(url);
|
||||||
|
}
|
||||||
|
|
||||||
// Matches http(s)://host[:port][/path][?query][#fragment]; host = domain, localhost, or IPv4.
|
// Matches http(s)://host[:port][/path][?query][#fragment]; host = domain, localhost, or IPv4.
|
||||||
// Syntactic validation only — reachability is checked via checkManagementUrlReachable.
|
// Syntactic validation only — reachability is checked via checkManagementUrlReachable.
|
||||||
@@ -30,11 +39,6 @@ export function isValidManagementUrl(input: string): boolean {
|
|||||||
return URL_PATTERN.test(trimmed);
|
return URL_PATTERN.test(trimmed);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCloudManagementUrl(url: string): boolean {
|
|
||||||
if (!url || url.trim() === "") return true;
|
|
||||||
return url === CLOUD_MANAGEMENT_URL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can false-negative for self-hosted behind internal DNS / self-signed certs — treat as a soft warning, not a hard block.
|
// Can false-negative for self-hosted behind internal DNS / self-signed certs — treat as a soft warning, not a hard block.
|
||||||
export async function checkManagementUrlReachable(
|
export async function checkManagementUrlReachable(
|
||||||
url: string,
|
url: string,
|
||||||
@@ -60,7 +64,7 @@ export enum ManagementMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function modeFromUrl(url: string): ManagementMode {
|
function modeFromUrl(url: string): ManagementMode {
|
||||||
return url === CLOUD_MANAGEMENT_URL ? ManagementMode.Cloud : ManagementMode.SelfHosted;
|
return isNetbirdCloud(url) ? ManagementMode.Cloud : ManagementMode.SelfHosted;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useManagementUrl() {
|
export function useManagementUrl() {
|
||||||
@@ -69,14 +73,14 @@ export function useManagementUrl() {
|
|||||||
const { config, saveField } = useSettings();
|
const { config, saveField } = useSettings();
|
||||||
const [modeState, setModeState] = useState<ManagementMode>(modeFromUrl(config.managementUrl));
|
const [modeState, setModeState] = useState<ManagementMode>(modeFromUrl(config.managementUrl));
|
||||||
const [url, setUrl] = useState(
|
const [url, setUrl] = useState(
|
||||||
config.managementUrl === CLOUD_MANAGEMENT_URL ? "" : config.managementUrl,
|
isNetbirdCloud(config.managementUrl) ? "" : config.managementUrl,
|
||||||
);
|
);
|
||||||
const [checking, setChecking] = useState(false);
|
const [checking, setChecking] = useState(false);
|
||||||
const [unreachable, setUnreachable] = useState(false);
|
const [unreachable, setUnreachable] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setModeState(modeFromUrl(config.managementUrl));
|
setModeState(modeFromUrl(config.managementUrl));
|
||||||
if (config.managementUrl !== CLOUD_MANAGEMENT_URL) {
|
if (!isNetbirdCloud(config.managementUrl)) {
|
||||||
setUrl(config.managementUrl);
|
setUrl(config.managementUrl);
|
||||||
}
|
}
|
||||||
}, [config.managementUrl]);
|
}, [config.managementUrl]);
|
||||||
@@ -86,7 +90,7 @@ export function useManagementUrl() {
|
|||||||
}, [url, modeState]);
|
}, [url, modeState]);
|
||||||
|
|
||||||
const setMode = async (next: ManagementMode) => {
|
const setMode = async (next: ManagementMode) => {
|
||||||
if (next === ManagementMode.Cloud && config.managementUrl !== CLOUD_MANAGEMENT_URL) {
|
if (next === ManagementMode.Cloud && !isNetbirdCloud(config.managementUrl)) {
|
||||||
const ok = await confirm({
|
const ok = await confirm({
|
||||||
title: t("settings.general.management.switchCloudTitle"),
|
title: t("settings.general.management.switchCloudTitle"),
|
||||||
description: t("settings.general.management.switchCloudMessage"),
|
description: t("settings.general.management.switchCloudMessage"),
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { useProfile } from "@/contexts/ProfileContext";
|
|||||||
import { useConfirm } from "@/contexts/DialogContext";
|
import { useConfirm } from "@/contexts/DialogContext";
|
||||||
import { Settings as SettingsSvc } from "@bindings/services";
|
import { Settings as SettingsSvc } from "@bindings/services";
|
||||||
import { SetConfigParams } from "@bindings/services/models.js";
|
import { SetConfigParams } from "@bindings/services/models.js";
|
||||||
import { CLOUD_MANAGEMENT_URL } from "@/hooks/useManagementUrl.ts";
|
import { isNetbirdCloud } from "@/hooks/useManagementUrl.ts";
|
||||||
import { SectionGroup, SettingsBottomBar } from "@/modules/settings/SettingsSection.tsx";
|
import { SectionGroup, SettingsBottomBar } from "@/modules/settings/SettingsSection.tsx";
|
||||||
import { cn } from "@/lib/cn";
|
import { cn } from "@/lib/cn";
|
||||||
import { reconcileOrder } from "@/lib/sorting";
|
import { reconcileOrder } from "@/lib/sorting";
|
||||||
@@ -108,7 +108,7 @@ export function ProfilesTab() {
|
|||||||
await addProfile(name);
|
await addProfile(name);
|
||||||
// SetConfig is keyed by profile name, so it writes the not-yet-active
|
// SetConfig is keyed by profile name, so it writes the not-yet-active
|
||||||
// profile. Write before switching so any reconnect targets the right deployment.
|
// profile. Write before switching so any reconnect targets the right deployment.
|
||||||
if (managementUrl !== CLOUD_MANAGEMENT_URL) {
|
if (!isNetbirdCloud(managementUrl)) {
|
||||||
await SettingsSvc.SetConfig(
|
await SettingsSvc.SetConfig(
|
||||||
new SetConfigParams({ profileName: name, username, managementUrl }),
|
new SetConfigParams({ profileName: name, username, managementUrl }),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { ConfirmDialog } from "@/components/dialog/ConfirmDialog";
|
|||||||
import { useAutoSizeWindow } from "@/hooks/useAutoSizeWindow";
|
import { useAutoSizeWindow } from "@/hooks/useAutoSizeWindow";
|
||||||
import { errorDialog, formatErrorMessage } from "@/lib/errors";
|
import { errorDialog, formatErrorMessage } from "@/lib/errors";
|
||||||
import i18next from "@/lib/i18n";
|
import i18next from "@/lib/i18n";
|
||||||
import { isCloudManagementUrl } from "@/hooks/useManagementUrl";
|
import { isNetbirdCloud } from "@/hooks/useManagementUrl";
|
||||||
import { WelcomeStepTray } from "./WelcomeStepTray";
|
import { WelcomeStepTray } from "./WelcomeStepTray";
|
||||||
import { WelcomeStepManagement } from "./WelcomeStepManagement";
|
import { WelcomeStepManagement } from "./WelcomeStepManagement";
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ function shouldShowManagementStep(
|
|||||||
): boolean {
|
): boolean {
|
||||||
if (activeProfile !== "default") return false;
|
if (activeProfile !== "default") return false;
|
||||||
if (email.trim() !== "") return false;
|
if (email.trim() !== "") return false;
|
||||||
return isCloudManagementUrl(managementUrl);
|
return isNetbirdCloud(managementUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
type InitialState = {
|
type InitialState = {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
CLOUD_MANAGEMENT_URL,
|
CLOUD_MANAGEMENT_URL,
|
||||||
ManagementMode,
|
ManagementMode,
|
||||||
checkManagementUrlReachable,
|
checkManagementUrlReachable,
|
||||||
isCloudManagementUrl,
|
isNetbirdCloud,
|
||||||
isValidManagementUrl,
|
isValidManagementUrl,
|
||||||
normalizeManagementUrl,
|
normalizeManagementUrl,
|
||||||
} from "@/hooks/useManagementUrl";
|
} from "@/hooks/useManagementUrl";
|
||||||
@@ -27,7 +27,7 @@ export function WelcomeStepManagement({
|
|||||||
onContinue,
|
onContinue,
|
||||||
}: Readonly<WelcomeStepManagementProps>) {
|
}: Readonly<WelcomeStepManagementProps>) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const startsCloud = isCloudManagementUrl(initialUrl);
|
const startsCloud = isNetbirdCloud(initialUrl);
|
||||||
const [mode, setMode] = useState<ManagementMode>(
|
const [mode, setMode] = useState<ManagementMode>(
|
||||||
startsCloud ? ManagementMode.Cloud : ManagementMode.SelfHosted,
|
startsCloud ? ManagementMode.Cloud : ManagementMode.SelfHosted,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user