mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-05 10:35:18 +02:00
Fix some clients address showing issues
This commit is contained in:
parent
f1291d4d7d
commit
78bfcf5b1c
5 changed files with 61 additions and 510 deletions
|
@ -205,7 +205,7 @@ export async function createSite(
|
||||||
exitNodeId,
|
exitNodeId,
|
||||||
name,
|
name,
|
||||||
niceId,
|
niceId,
|
||||||
// address: updatedAddress || null,
|
address: updatedAddress || null,
|
||||||
subnet,
|
subnet,
|
||||||
type,
|
type,
|
||||||
dockerSocketEnabled: type == "newt",
|
dockerSocketEnabled: type == "newt",
|
||||||
|
@ -221,7 +221,7 @@ export async function createSite(
|
||||||
orgId,
|
orgId,
|
||||||
name,
|
name,
|
||||||
niceId,
|
niceId,
|
||||||
// address: updatedAddress || null,
|
address: updatedAddress || null,
|
||||||
type,
|
type,
|
||||||
dockerSocketEnabled: type == "newt",
|
dockerSocketEnabled: type == "newt",
|
||||||
subnet: "0.0.0.0/0"
|
subnet: "0.0.0.0/0"
|
||||||
|
|
|
@ -1,462 +0,0 @@
|
||||||
"use client";
|
|
||||||
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormDescription,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage
|
|
||||||
} from "@app/components/ui/form";
|
|
||||||
import { Input } from "@app/components/ui/input";
|
|
||||||
import { toast } from "@app/hooks/useToast";
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import { z } from "zod";
|
|
||||||
import { useParams, useRouter } from "next/navigation";
|
|
||||||
import {
|
|
||||||
CreateSiteBody,
|
|
||||||
CreateSiteResponse,
|
|
||||||
PickSiteDefaultsResponse
|
|
||||||
} from "@server/routers/site";
|
|
||||||
import { generateKeypair } from "./[niceId]/wireguardConfig";
|
|
||||||
import CopyTextBox from "@app/components/CopyTextBox";
|
|
||||||
import { Checkbox } from "@app/components/ui/checkbox";
|
|
||||||
import {
|
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectItem,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue
|
|
||||||
} from "@app/components/ui/select";
|
|
||||||
import { formatAxiosError } from "@app/lib/api";
|
|
||||||
import { createApiClient } from "@app/lib/api";
|
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
|
||||||
import { SiteRow } from "./SitesTable";
|
|
||||||
import { AxiosResponse } from "axios";
|
|
||||||
import { Button } from "@app/components/ui/button";
|
|
||||||
import Link from "next/link";
|
|
||||||
import {
|
|
||||||
ArrowUpRight,
|
|
||||||
ChevronsUpDown,
|
|
||||||
Loader2,
|
|
||||||
SquareArrowOutUpRight
|
|
||||||
} from "lucide-react";
|
|
||||||
import {
|
|
||||||
Collapsible,
|
|
||||||
CollapsibleContent,
|
|
||||||
CollapsibleTrigger
|
|
||||||
} from "@app/components/ui/collapsible";
|
|
||||||
import LoaderPlaceholder from "@app/components/PlaceHolderLoader";
|
|
||||||
import { useTranslations } from "next-intl";
|
|
||||||
|
|
||||||
type CreateSiteFormProps = {
|
|
||||||
onCreate?: (site: SiteRow) => void;
|
|
||||||
setLoading?: (loading: boolean) => void;
|
|
||||||
setChecked?: (checked: boolean) => void;
|
|
||||||
orgId: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function CreateSiteForm({
|
|
||||||
onCreate,
|
|
||||||
setLoading,
|
|
||||||
setChecked,
|
|
||||||
orgId
|
|
||||||
}: CreateSiteFormProps) {
|
|
||||||
const api = createApiClient(useEnvContext());
|
|
||||||
const { env } = useEnvContext();
|
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
|
||||||
const [isChecked, setIsChecked] = useState(false);
|
|
||||||
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
|
||||||
|
|
||||||
const [keypair, setKeypair] = useState<{
|
|
||||||
publicKey: string;
|
|
||||||
privateKey: string;
|
|
||||||
} | null>(null);
|
|
||||||
|
|
||||||
const t = useTranslations();
|
|
||||||
|
|
||||||
const createSiteFormSchema = z.object({
|
|
||||||
name: z
|
|
||||||
.string()
|
|
||||||
.min(2, {
|
|
||||||
message: t('nameMin', {len: 2})
|
|
||||||
})
|
|
||||||
.max(30, {
|
|
||||||
message: t('nameMax', {len: 30})
|
|
||||||
}),
|
|
||||||
method: z.enum(["wireguard", "newt", "local"])
|
|
||||||
});
|
|
||||||
|
|
||||||
type CreateSiteFormValues = z.infer<typeof createSiteFormSchema>;
|
|
||||||
|
|
||||||
const defaultValues: Partial<CreateSiteFormValues> = {
|
|
||||||
name: "",
|
|
||||||
method: "newt"
|
|
||||||
};
|
|
||||||
|
|
||||||
const [siteDefaults, setSiteDefaults] =
|
|
||||||
useState<PickSiteDefaultsResponse | null>(null);
|
|
||||||
|
|
||||||
const [loadingPage, setLoadingPage] = useState(true);
|
|
||||||
|
|
||||||
const handleCheckboxChange = (checked: boolean) => {
|
|
||||||
// setChecked?.(checked);
|
|
||||||
setIsChecked(checked);
|
|
||||||
};
|
|
||||||
|
|
||||||
const form = useForm<CreateSiteFormValues>({
|
|
||||||
resolver: zodResolver(createSiteFormSchema),
|
|
||||||
defaultValues
|
|
||||||
});
|
|
||||||
|
|
||||||
const nameField = form.watch("name");
|
|
||||||
const methodField = form.watch("method");
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const nameIsValid = nameField?.length >= 2 && nameField?.length <= 30;
|
|
||||||
const isFormValid = methodField === "local" || isChecked;
|
|
||||||
|
|
||||||
// Only set checked to true if name is valid AND (method is local OR checkbox is checked)
|
|
||||||
setChecked?.(nameIsValid && isFormValid);
|
|
||||||
}, [nameField, methodField, isChecked, setChecked]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!open) return;
|
|
||||||
|
|
||||||
const load = async () => {
|
|
||||||
setLoadingPage(true);
|
|
||||||
// reset all values
|
|
||||||
setLoading?.(false);
|
|
||||||
setIsLoading(false);
|
|
||||||
form.reset();
|
|
||||||
setChecked?.(false);
|
|
||||||
setKeypair(null);
|
|
||||||
setSiteDefaults(null);
|
|
||||||
|
|
||||||
const generatedKeypair = generateKeypair();
|
|
||||||
setKeypair(generatedKeypair);
|
|
||||||
|
|
||||||
await api
|
|
||||||
.get(`/org/${orgId}/pick-site-defaults`)
|
|
||||||
.catch((e) => {
|
|
||||||
// update the default value of the form to be local method
|
|
||||||
form.setValue("method", "local");
|
|
||||||
})
|
|
||||||
.then((res) => {
|
|
||||||
if (res && res.status === 200) {
|
|
||||||
setSiteDefaults(res.data.data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
||||||
|
|
||||||
setLoadingPage(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
load();
|
|
||||||
}, [open]);
|
|
||||||
|
|
||||||
async function onSubmit(data: CreateSiteFormValues) {
|
|
||||||
setLoading?.(true);
|
|
||||||
setIsLoading(true);
|
|
||||||
let payload: CreateSiteBody = {
|
|
||||||
name: data.name,
|
|
||||||
type: data.method
|
|
||||||
};
|
|
||||||
|
|
||||||
if (data.method == "wireguard") {
|
|
||||||
if (!keypair || !siteDefaults) {
|
|
||||||
toast({
|
|
||||||
variant: "destructive",
|
|
||||||
title: t('siteErrorCreate'),
|
|
||||||
description: t('siteErrorCreateKeyPair')
|
|
||||||
});
|
|
||||||
setLoading?.(false);
|
|
||||||
setIsLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
payload = {
|
|
||||||
...payload,
|
|
||||||
subnet: siteDefaults.subnet,
|
|
||||||
exitNodeId: siteDefaults.exitNodeId,
|
|
||||||
pubKey: keypair.publicKey
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (data.method === "newt") {
|
|
||||||
if (!siteDefaults) {
|
|
||||||
toast({
|
|
||||||
variant: "destructive",
|
|
||||||
title: t('siteErrorCreate'),
|
|
||||||
description: t('siteErrorCreateDefaults')
|
|
||||||
});
|
|
||||||
setLoading?.(false);
|
|
||||||
setIsLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
payload = {
|
|
||||||
...payload,
|
|
||||||
subnet: siteDefaults.subnet,
|
|
||||||
exitNodeId: siteDefaults.exitNodeId,
|
|
||||||
secret: siteDefaults.newtSecret,
|
|
||||||
newtId: siteDefaults.newtId
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await api
|
|
||||||
.put<
|
|
||||||
AxiosResponse<CreateSiteResponse>
|
|
||||||
>(`/org/${orgId}/site/`, payload)
|
|
||||||
.catch((e) => {
|
|
||||||
toast({
|
|
||||||
variant: "destructive",
|
|
||||||
title: t('siteErrorCreate'),
|
|
||||||
description: formatAxiosError(e)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (res && res.status === 201) {
|
|
||||||
const data = res.data.data;
|
|
||||||
|
|
||||||
onCreate?.({
|
|
||||||
name: data.name,
|
|
||||||
id: data.siteId,
|
|
||||||
nice: data.niceId.toString(),
|
|
||||||
address: data.address?.split("/")[0],
|
|
||||||
mbIn:
|
|
||||||
data.type == "wireguard" || data.type == "newt"
|
|
||||||
? t('megabytes', {count: 0})
|
|
||||||
: "-",
|
|
||||||
mbOut:
|
|
||||||
data.type == "wireguard" || data.type == "newt"
|
|
||||||
? t('megabytes', {count: 0})
|
|
||||||
: "-",
|
|
||||||
orgId: orgId as string,
|
|
||||||
type: data.type as any,
|
|
||||||
online: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setLoading?.(false);
|
|
||||||
setIsLoading(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
const wgConfig =
|
|
||||||
keypair && siteDefaults
|
|
||||||
? `[Interface]
|
|
||||||
Address = ${siteDefaults.subnet}
|
|
||||||
ListenPort = 51820
|
|
||||||
PrivateKey = ${keypair.privateKey}
|
|
||||||
|
|
||||||
[Peer]
|
|
||||||
PublicKey = ${siteDefaults.publicKey}
|
|
||||||
AllowedIPs = ${siteDefaults.address.split("/")[0]}/32
|
|
||||||
Endpoint = ${siteDefaults.endpoint}:${siteDefaults.listenPort}
|
|
||||||
PersistentKeepalive = 5`
|
|
||||||
: "";
|
|
||||||
|
|
||||||
const newtConfig = `newt --id ${siteDefaults?.newtId} --secret ${siteDefaults?.newtSecret} --endpoint ${env.app.dashboardUrl}`;
|
|
||||||
|
|
||||||
const newtConfigDockerCompose = `services:
|
|
||||||
newt:
|
|
||||||
image: fosrl/newt
|
|
||||||
container_name: newt
|
|
||||||
restart: unless-stopped
|
|
||||||
environment:
|
|
||||||
- PANGOLIN_ENDPOINT=${env.app.dashboardUrl}
|
|
||||||
- NEWT_ID=${siteDefaults?.newtId}
|
|
||||||
- NEWT_SECRET=${siteDefaults?.newtSecret}`;
|
|
||||||
|
|
||||||
const newtConfigDockerRun = `docker run -dit fosrl/newt --id ${siteDefaults?.newtId} --secret ${siteDefaults?.newtSecret} --endpoint ${env.app.dashboardUrl}`;
|
|
||||||
|
|
||||||
return loadingPage ? (
|
|
||||||
<LoaderPlaceholder height="300px" />
|
|
||||||
) : (
|
|
||||||
<div className="space-y-4">
|
|
||||||
<Form {...form}>
|
|
||||||
<form
|
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
|
||||||
className="space-y-4"
|
|
||||||
id="create-site-form"
|
|
||||||
>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="name"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>{t('name')}</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input autoComplete="off" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
<FormDescription>
|
|
||||||
{t('siteNameDescription')}
|
|
||||||
</FormDescription>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="method"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>{t('method')}</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Select
|
|
||||||
value={field.value}
|
|
||||||
onValueChange={field.onChange}
|
|
||||||
>
|
|
||||||
<SelectTrigger>
|
|
||||||
<SelectValue placeholder={t('methodSelect')} />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value="local">
|
|
||||||
{t('local')}
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem
|
|
||||||
value="newt"
|
|
||||||
disabled={!siteDefaults}
|
|
||||||
>
|
|
||||||
Newt
|
|
||||||
</SelectItem>
|
|
||||||
<SelectItem
|
|
||||||
value="wireguard"
|
|
||||||
disabled={!siteDefaults}
|
|
||||||
>
|
|
||||||
WireGuard
|
|
||||||
</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
<FormDescription>
|
|
||||||
{t('siteMethodDescription')}
|
|
||||||
</FormDescription>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{form.watch("method") === "newt" && (
|
|
||||||
<Link
|
|
||||||
className="text-sm text-primary flex items-center gap-1"
|
|
||||||
href="https://docs.fossorial.io/Newt/install"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
<span>
|
|
||||||
{t('siteLearnNewt')}
|
|
||||||
</span>
|
|
||||||
<SquareArrowOutUpRight size={14} />
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="w-full">
|
|
||||||
{form.watch("method") === "wireguard" && !isLoading ? (
|
|
||||||
<>
|
|
||||||
<CopyTextBox text={wgConfig} />
|
|
||||||
<span className="text-sm text-muted-foreground mt-2">
|
|
||||||
{t('siteSeeConfigOnce')}
|
|
||||||
</span>
|
|
||||||
</>
|
|
||||||
) : form.watch("method") === "wireguard" &&
|
|
||||||
isLoading ? (
|
|
||||||
<p>{t('siteLoadWGConfig')}</p>
|
|
||||||
) : form.watch("method") === "newt" && siteDefaults ? (
|
|
||||||
<>
|
|
||||||
<div className="mb-2">
|
|
||||||
<Collapsible
|
|
||||||
open={isOpen}
|
|
||||||
onOpenChange={setIsOpen}
|
|
||||||
className="space-y-2"
|
|
||||||
>
|
|
||||||
<div className="mx-auto mb-2">
|
|
||||||
<CopyTextBox
|
|
||||||
text={newtConfig}
|
|
||||||
wrapText={false}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<span className="text-sm text-muted-foreground">
|
|
||||||
{t('siteSeeConfigOnce')}
|
|
||||||
</span>
|
|
||||||
<div className="flex items-center justify-between space-x-4">
|
|
||||||
<CollapsibleTrigger asChild>
|
|
||||||
<Button
|
|
||||||
variant="text"
|
|
||||||
size="sm"
|
|
||||||
className="p-0 flex items-center justify-between w-full"
|
|
||||||
>
|
|
||||||
<h4 className="text-sm font-semibold">
|
|
||||||
{t('siteDocker')}
|
|
||||||
</h4>
|
|
||||||
<div>
|
|
||||||
<ChevronsUpDown className="h-4 w-4" />
|
|
||||||
<span className="sr-only">
|
|
||||||
{t('toggle')}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</Button>
|
|
||||||
</CollapsibleTrigger>
|
|
||||||
</div>
|
|
||||||
<CollapsibleContent className="space-y-4">
|
|
||||||
<div className="space-y-2">
|
|
||||||
<b>{t('dockerCompose')}</b>
|
|
||||||
<CopyTextBox
|
|
||||||
text={
|
|
||||||
newtConfigDockerCompose
|
|
||||||
}
|
|
||||||
wrapText={false}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="space-y-2">
|
|
||||||
<b>{t('dockerRun')}</b>
|
|
||||||
|
|
||||||
<CopyTextBox
|
|
||||||
text={newtConfigDockerRun}
|
|
||||||
wrapText={false}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</CollapsibleContent>
|
|
||||||
</Collapsible>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{form.watch("method") === "local" && (
|
|
||||||
<Link
|
|
||||||
className="text-sm text-primary flex items-center gap-1"
|
|
||||||
href="https://docs.fossorial.io/Pangolin/without-tunneling"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
<span>{t('siteLearnLocal')}</span>
|
|
||||||
<SquareArrowOutUpRight size={14} />
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{(form.watch("method") === "newt" ||
|
|
||||||
form.watch("method") === "wireguard") && (
|
|
||||||
<div className="flex items-center space-x-2">
|
|
||||||
<Checkbox
|
|
||||||
id="terms"
|
|
||||||
checked={isChecked}
|
|
||||||
onCheckedChange={handleCheckboxChange}
|
|
||||||
/>
|
|
||||||
<label
|
|
||||||
htmlFor="terms"
|
|
||||||
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
||||||
>
|
|
||||||
{t('siteConfirmCopy')}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ColumnDef } from "@tanstack/react-table";
|
import { Column, ColumnDef } from "@tanstack/react-table";
|
||||||
import { SitesDataTable } from "./SitesDataTable";
|
import { SitesDataTable } from "./SitesDataTable";
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
|
@ -20,7 +20,6 @@ import Link from "next/link";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import CreateSiteForm from "./CreateSiteForm";
|
|
||||||
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
|
import ConfirmDeleteDialog from "@app/components/ConfirmDeleteDialog";
|
||||||
import { toast } from "@app/hooks/useToast";
|
import { toast } from "@app/hooks/useToast";
|
||||||
import { formatAxiosError } from "@app/lib/api";
|
import { formatAxiosError } from "@app/lib/api";
|
||||||
|
@ -60,6 +59,7 @@ export default function SitesTable({ sites, orgId }: SitesTableProps) {
|
||||||
|
|
||||||
const api = createApiClient(useEnvContext());
|
const api = createApiClient(useEnvContext());
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
const { env } = useEnvContext();
|
||||||
|
|
||||||
// Update local state when props change (e.g., after refresh)
|
// Update local state when props change (e.g., after refresh)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -280,9 +280,9 @@ export default function SitesTable({ sites, orgId }: SitesTableProps) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
...(env.flags.enableClients ? [{
|
||||||
accessorKey: "address",
|
accessorKey: "address",
|
||||||
header: ({ column }) => {
|
header: ({ column }: { column: Column<SiteRow, unknown> }) => {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
|
@ -295,7 +295,7 @@ export default function SitesTable({ sites, orgId }: SitesTableProps) {
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
}] : []),
|
||||||
{
|
{
|
||||||
id: "actions",
|
id: "actions",
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
|
|
|
@ -10,12 +10,14 @@ import {
|
||||||
InfoSectionTitle
|
InfoSectionTitle
|
||||||
} from "@app/components/InfoSection";
|
} from "@app/components/InfoSection";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
|
|
||||||
type SiteInfoCardProps = {};
|
type SiteInfoCardProps = {};
|
||||||
|
|
||||||
export default function SiteInfoCard({}: SiteInfoCardProps) {
|
export default function SiteInfoCard({}: SiteInfoCardProps) {
|
||||||
const { site, updateSite } = useSiteContext();
|
const { site, updateSite } = useSiteContext();
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
const { env } = useEnvContext();
|
||||||
|
|
||||||
const getConnectionTypeString = (type: string) => {
|
const getConnectionTypeString = (type: string) => {
|
||||||
if (type === "newt") {
|
if (type === "newt") {
|
||||||
|
@ -34,7 +36,7 @@ export default function SiteInfoCard({}: SiteInfoCardProps) {
|
||||||
<InfoIcon className="h-4 w-4" />
|
<InfoIcon className="h-4 w-4" />
|
||||||
<AlertTitle className="font-semibold">{t('siteInfo')}</AlertTitle>
|
<AlertTitle className="font-semibold">{t('siteInfo')}</AlertTitle>
|
||||||
<AlertDescription className="mt-4">
|
<AlertDescription className="mt-4">
|
||||||
<InfoSections cols={2}>
|
<InfoSections cols={env.flags.enableClients ? 3 : 2}>
|
||||||
{(site.type == "newt" || site.type == "wireguard") && (
|
{(site.type == "newt" || site.type == "wireguard") && (
|
||||||
<>
|
<>
|
||||||
<InfoSection>
|
<InfoSection>
|
||||||
|
@ -61,6 +63,12 @@ export default function SiteInfoCard({}: SiteInfoCardProps) {
|
||||||
{getConnectionTypeString(site.type)}
|
{getConnectionTypeString(site.type)}
|
||||||
</InfoSectionContent>
|
</InfoSectionContent>
|
||||||
</InfoSection>
|
</InfoSection>
|
||||||
|
<InfoSection>
|
||||||
|
<InfoSectionTitle>Address</InfoSectionTitle>
|
||||||
|
<InfoSectionContent>
|
||||||
|
{site.address?.split("/")[0]}
|
||||||
|
</InfoSectionContent>
|
||||||
|
</InfoSection>
|
||||||
</InfoSections>
|
</InfoSections>
|
||||||
</AlertDescription>
|
</AlertDescription>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
|
|
@ -595,7 +595,9 @@ WantedBy=default.target`
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{env.flags.enableClients && (
|
{env.flags.enableClients &&
|
||||||
|
form.watch("method") ===
|
||||||
|
"newt" && (
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="clientAddress"
|
name="clientAddress"
|
||||||
|
@ -628,9 +630,12 @@ WantedBy=default.target`
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
<FormDescription>
|
<FormDescription>
|
||||||
Specify the IP
|
Specify the
|
||||||
address of the
|
IP address
|
||||||
host.
|
of the host
|
||||||
|
for clients
|
||||||
|
to connect
|
||||||
|
to.
|
||||||
</FormDescription>
|
</FormDescription>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue