feat(wireguard): implement WireGuard interface management and permissions
Docker images / prepare-release (push) Successful in 8s
Docker images / backend-image (push) Successful in 1m39s
Docker images / frontend-image (push) Successful in 2m56s
Docker images / notify-webhook (push) Skipped
Docker images / updater-image (push) Successful in 53s
Docker images / publish-release (push) Successful in 10s

Added comprehensive support for managing WireGuard interfaces, including CRUD operations and peer management. Updated permissions to include access control for WireGuard routes. Enhanced the UI components to display and interact with WireGuard configurations, improving user experience and functionality. Introduced new tests for WireGuard-related functionalities to ensure reliability.
This commit is contained in:
Denozordec
2026-09-05 02:10:55 +07:00
parent 883842636b
commit 15ad53af1f
25 changed files with 3122 additions and 231 deletions
+107
View File
@@ -0,0 +1,107 @@
import type {
WgCreateInterface,
WgCreatePeerRequest,
WgExportRequest,
WgExportResponse,
WgImportRequest,
WgImportResponse,
WgListResponse,
WgPatchInterface,
WgPatchPeer,
} from "@mmapp/contracts/wireguard"
import { requestJson } from "@/shared/api/http-client"
export async function listWireGuard(
baseUrl: string,
opts?: { serverId?: string; includePrivateKey?: boolean },
): Promise<WgListResponse> {
const q = new URLSearchParams()
if (opts?.serverId) q.set("serverId", opts.serverId)
if (opts?.includePrivateKey) q.set("includePrivateKey", "1")
const qs = q.toString()
return requestJson<WgListResponse>(baseUrl, `/api/wireguard${qs ? `?${qs}` : ""}`)
}
export async function createWireGuardInterface(
baseUrl: string,
payload: WgCreateInterface,
): Promise<unknown> {
return requestJson(baseUrl, "/api/wireguard/interfaces", {
method: "POST",
body: JSON.stringify(payload),
})
}
export async function patchWireGuardInterface(
baseUrl: string,
serverId: string,
rosId: string,
payload: WgPatchInterface,
): Promise<{ ok: boolean }> {
return requestJson(baseUrl, `/api/wireguard/interfaces/${encodeURIComponent(serverId)}/${encodeURIComponent(rosId)}`, {
method: "PATCH",
body: JSON.stringify(payload),
})
}
export async function deleteWireGuardInterface(
baseUrl: string,
serverId: string,
rosId: string,
): Promise<{ ok: boolean }> {
return requestJson(baseUrl, `/api/wireguard/interfaces/${encodeURIComponent(serverId)}/${encodeURIComponent(rosId)}`, {
method: "DELETE",
})
}
export async function createWireGuardPeer(
baseUrl: string,
payload: WgCreatePeerRequest,
): Promise<{ ok: boolean }> {
return requestJson(baseUrl, "/api/wireguard/peers", {
method: "POST",
body: JSON.stringify(payload),
})
}
export async function patchWireGuardPeer(
baseUrl: string,
serverId: string,
rosId: string,
payload: WgPatchPeer,
): Promise<{ ok: boolean }> {
return requestJson(baseUrl, `/api/wireguard/peers/${encodeURIComponent(serverId)}/${encodeURIComponent(rosId)}`, {
method: "PATCH",
body: JSON.stringify(payload),
})
}
export async function deleteWireGuardPeer(
baseUrl: string,
serverId: string,
rosId: string,
): Promise<{ ok: boolean }> {
return requestJson(baseUrl, `/api/wireguard/peers/${encodeURIComponent(serverId)}/${encodeURIComponent(rosId)}`, {
method: "DELETE",
})
}
export async function importWireGuard(
baseUrl: string,
payload: WgImportRequest,
): Promise<WgImportResponse> {
return requestJson(baseUrl, "/api/wireguard/import", {
method: "POST",
body: JSON.stringify(payload),
})
}
export async function exportWireGuard(
baseUrl: string,
payload: WgExportRequest,
): Promise<WgExportResponse> {
return requestJson(baseUrl, "/api/wireguard/export", {
method: "POST",
body: JSON.stringify(payload),
})
}