Major updates
This commit is contained in:
@@ -16,11 +16,7 @@ type Params = {
|
||||
clients?: BUN_SQLITE_WGUI_CLIENTS[];
|
||||
};
|
||||
|
||||
export default function deriveHostConfig({
|
||||
host,
|
||||
variables,
|
||||
clients,
|
||||
}: Params) {
|
||||
export default function deriveHostConfig({ host, variables, clients }: Params) {
|
||||
const host_id = host?.id || AppData["WireguardHostID"];
|
||||
|
||||
const wg_ip_address =
|
||||
@@ -33,16 +29,14 @@ export default function deriveHostConfig({
|
||||
host_id,
|
||||
interface_name,
|
||||
config_path: `${HOSTS_CONFIG_DIR}/${interface_name}.conf`,
|
||||
systemd_unit_name: `wg-quick@${interface_name}.service`,
|
||||
|
||||
address: wg_ip_address ? `${wg_ip_address}/24` : undefined,
|
||||
listen_port: LISTEN_PORT,
|
||||
post_up: `${IP_TABLES_DIR}/${host_id}-up.sh`,
|
||||
post_down: `${IP_TABLES_DIR}/${host_id}-down.sh`,
|
||||
private_key: host?.private_key,
|
||||
public_key: host?.public_key,
|
||||
client_count: clients?.filter(
|
||||
(client) => (client.host_id || 0) == host_id,
|
||||
).length || 0,
|
||||
client_count:
|
||||
clients?.filter((client) => (client.host_id || 0) == host_id)
|
||||
.length || 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,7 @@ export default function InterfaceConfigSection({
|
||||
const rows = [
|
||||
{ keyName: "Address", value: config.address || "—" },
|
||||
{ keyName: "ListenPort", value: String(config.listen_port) },
|
||||
{
|
||||
keyName: "PrivateKey",
|
||||
value: config.private_key
|
||||
? "•••••••••••• (redacted)"
|
||||
: "Not set",
|
||||
},
|
||||
,
|
||||
{ keyName: "PostUp", value: config.post_up },
|
||||
{ keyName: "PostDown", value: config.post_down },
|
||||
];
|
||||
@@ -43,7 +38,9 @@ export default function InterfaceConfigSection({
|
||||
function buildConfigText() {
|
||||
const lines = ["[Interface]"];
|
||||
for (const row of rows) {
|
||||
lines.push(`${row.keyName} = ${row.value}`);
|
||||
if (row) {
|
||||
lines.push(`${row.keyName} = ${row.value}`);
|
||||
}
|
||||
}
|
||||
lines.push("");
|
||||
lines.push(
|
||||
@@ -59,12 +56,12 @@ export default function InterfaceConfigSection({
|
||||
<H2 className="text-[13.5px] font-medium text-foreground-light/60 dark:text-foreground-dark/60 mb-0!">
|
||||
Interface configuration
|
||||
</H2>
|
||||
<P noMargin className="font-mono text-[11.5px] text-foreground-light/40 dark:text-foreground-dark/40">
|
||||
<P
|
||||
noMargin
|
||||
className="font-mono text-[11.5px] text-foreground-light/40 dark:text-foreground-dark/40"
|
||||
>
|
||||
{config.config_path}
|
||||
</P>
|
||||
<P noMargin className="font-mono text-[11.5px] text-foreground-light/40 dark:text-foreground-dark/40">
|
||||
{config.systemd_unit_name}
|
||||
</P>
|
||||
</Stack>
|
||||
<AdminButton
|
||||
Icon={Copy}
|
||||
@@ -79,13 +76,17 @@ export default function InterfaceConfigSection({
|
||||
<Span className="px-5 py-3 font-mono text-[12.5px] font-semibold text-secondary dark:text-secondary block">
|
||||
[Interface]
|
||||
</Span>
|
||||
{rows.map((row) => (
|
||||
<InterfaceConfigRow
|
||||
key={row.keyName}
|
||||
keyName={row.keyName}
|
||||
value={row.value}
|
||||
/>
|
||||
))}
|
||||
{rows.map((row) => {
|
||||
if (!row) return;
|
||||
|
||||
return (
|
||||
<InterfaceConfigRow
|
||||
key={row.keyName}
|
||||
keyName={row.keyName}
|
||||
value={row.value}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
<Row className="justify-between gap-4 px-5 py-2.5 border-t border-slate-200/60 dark:border-white/5">
|
||||
<Span className="font-mono text-[12px] text-foreground-light/35 dark:text-foreground-dark/35">
|
||||
# Public key ·{" "}
|
||||
@@ -97,4 +98,4 @@ export default function InterfaceConfigSection({
|
||||
</div>
|
||||
</AdminCard>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user