diff --git a/src/components/general/client-row.tsx b/src/components/general/client-row.tsx
index 2d73867..6ce15ba 100644
--- a/src/components/general/client-row.tsx
+++ b/src/components/general/client-row.tsx
@@ -76,7 +76,9 @@ export default function ClientRow({ client, rules }: Props) {
{client.wg_ip_address || "—"}
- {client.allowed_ips || "—"}
+ {client.allow_all_ips
+ ? "0.0.0.0/0, ::/0"
+ : client.allowed_ips || "—"}
|
(
+ {
+ table: "client_rules",
+ sql_query: {
+ limit: 500,
+ },
+ },
+ );
+
+ const rules_by_client_id = useMemo(() => {
+ const map = new Map();
+
+ for (let i = 0; i < (client_rules || []).length; i++) {
+ const rule = client_rules?.[i];
+ const client_id = Number(rule?.client_id);
+
+ if (!rule || !client_id) {
+ continue;
+ }
+
+ const existing = map.get(client_id) || [];
+ existing.push(rule);
+ map.set(client_id, existing);
+ }
+
+ return map;
+ }, [client_rules]);
+
return (
@@ -40,24 +73,40 @@ export default function PeersTableSection({ clients }: Props) {
{recent.length ? (
-
-
+
+
| Client |
+ Host |
Tunnel IP |
Allowed IPs |
+ Access List |
Public key |
Created |
+ Actions |
{recent.map((client) => (
-
+
))}
) : (
-
+
No clients yet
@@ -68,4 +117,4 @@ export default function PeersTableSection({ clients }: Props) {
)}
);
-}
\ No newline at end of file
+}
diff --git a/src/pages/admin/hosts/[host_id]/edit/index.server.ts b/src/pages/admin/hosts/[host_id]/edit/index.server.ts
index c366ab5..dd25204 100644
--- a/src/pages/admin/hosts/[host_id]/edit/index.server.ts
+++ b/src/pages/admin/hosts/[host_id]/edit/index.server.ts
@@ -1,4 +1,7 @@
import type { BUN_SQLITE_WGUI_HOSTS } from "@/db/types/db";
+import getInterfaceLocalIP from "@/src/functions/backend/setup/get-interface-local-ip";
+import grabHostNetworkInterfaces from "@/src/functions/backend/setup/grab-host-network-interfaces";
+import grabHostPublicIPAddress from "@/src/functions/backend/setup/grab-host-public-ip-address";
import type { PagePropsType, PageQueryObject, TableType } from "@/src/types";
import BunSQLite from "@moduletrace/bun-sqlite";
import type { BunextPageServerFn } from "@moduletrace/bunext/types";
@@ -8,19 +11,23 @@ const server: BunextPageServerFn = async ({ query }) => {
const host_id = Number(page_query.host_id || 0);
- const host_res = await BunSQLite.select<
- BUN_SQLITE_WGUI_HOSTS,
- TableType
- >({
+ const host_res = await BunSQLite.select({
table: "hosts",
targetId: host_id,
});
const host = host_res.singleRes || null;
+ const network_interfaces = await grabHostNetworkInterfaces();
+ const local_ip = host?.interface
+ ? await getInterfaceLocalIP(host?.interface)
+ : null;
+
return {
props: {
host,
+ network_interfaces,
+ is_local_ip: local_ip == host?.public_ip_address,
},
};
};
diff --git a/src/pages/admin/hosts/[host_id]/edit/index.tsx b/src/pages/admin/hosts/[host_id]/edit/index.tsx
index 585f6eb..cb894e5 100644
--- a/src/pages/admin/hosts/[host_id]/edit/index.tsx
+++ b/src/pages/admin/hosts/[host_id]/edit/index.tsx
@@ -9,6 +9,9 @@ import { ArrowLeft } from "lucide-react";
import { useContext } from "react";
import { AppContext } from "@/src/pages/__root";
import EditHostFormSection from "./(sections)/edit-host-form-section";
+import AddHostForm from "../../add/(partials)/add-host-form/add-host-form";
+import _ from "lodash";
+import type { BUN_SQLITE_WGUI_HOSTS_JOIN } from "@/src/types/sql-joins";
export default function AdminEditHostPage() {
const { pageProps, query } = useContext(AppContext);
@@ -40,7 +43,13 @@ export default function AdminEditHostPage() {
{pageProps?.host ? (
-
+ (pageProps.host, ["name", "short_description"])}
+ existing_host_full={pageProps.host}
+ />
) : (
)}
@@ -52,4 +61,4 @@ export default function AdminEditHostPage() {
export const meta: BunextPageModuleMeta = {
title: `Edit Host | ${SiteData["SiteName"]}`,
description: `WireGuard edit host page`,
-};
\ No newline at end of file
+};
diff --git a/src/pages/admin/hosts/[host_id]/index.server.ts b/src/pages/admin/hosts/[host_id]/index.server.ts
index 1d8d9e8..a4269c5 100644
--- a/src/pages/admin/hosts/[host_id]/index.server.ts
+++ b/src/pages/admin/hosts/[host_id]/index.server.ts
@@ -1,14 +1,13 @@
-import type { BUN_SQLITE_WGUI_CLIENTS, BUN_SQLITE_WGUI_HOSTS } from "@/db/types/db";
+import type {
+ BUN_SQLITE_WGUI_CLIENTS,
+ BUN_SQLITE_WGUI_HOSTS,
+} from "@/db/types/db";
import grabHostDirnames from "@/src/functions/backend/setup/grab-host-dir-names";
import type { PagePropsType, PageQueryObject, TableType } from "@/src/types";
import BunSQLite from "@moduletrace/bun-sqlite";
import type { BunextPageServerFn } from "@moduletrace/bunext/types";
-const server: BunextPageServerFn = async ({
- req,
- url,
- query,
-}) => {
+const server: BunextPageServerFn = async ({ query }) => {
const page_query = query as PageQueryObject;
const host_record_res = await BunSQLite.select<
diff --git a/src/pages/admin/hosts/[host_id]/index.tsx b/src/pages/admin/hosts/[host_id]/index.tsx
index 9f31dd0..74f2a76 100644
--- a/src/pages/admin/hosts/[host_id]/index.tsx
+++ b/src/pages/admin/hosts/[host_id]/index.tsx
@@ -59,7 +59,7 @@ export default function AdminSingleHostPage() {
color="primary"
href={`/admin/hosts/${host_id}/clients`}
>
- View Clients
+ Clients
|