feat(ipsec): enhance IPsec management with peer and certificate handling
Docker images / prepare-release (push) Successful in 8s
Docker images / backend-test (push) Successful in 2m39s
Docker images / frontend-image (push) Successful in 2m56s
Docker images / updater-image (push) Successful in 44s
Docker images / backend-image (push) Successful in 2m35s
Docker images / notify-webhook (push) Skipped
Docker images / publish-release (push) Successful in 15s

- Added support for managing IPsec peers, including editing and deleting functionality.
- Introduced a new UI component for displaying peers and their details within the IPsec server grid.
- Updated the IPsec user creation form to allow binding identities to specific peers.
- Enhanced backend routes and services to handle peer patching and deletion requests.
- Improved data structures to accommodate multiple peers and certificates for each server.
- Added tests to ensure proper functionality of new peer management features.
This commit is contained in:
Denozordec
2026-09-12 21:04:49 +07:00
parent 7755d77340
commit 7365d8d8fb
14 changed files with 953 additions and 106 deletions
+25
View File
@@ -15,6 +15,7 @@ export type IpsecAuthKind = "certificate" | "pre-shared-key"
export type IpsecUserFormState = {
serverId: string
name: string
peerName: string
authMethod: IpsecAuthKind
psk: string
remoteId: string
@@ -26,6 +27,7 @@ export type IpsecUserFormState = {
export const defaultIpsecUserForm = (): IpsecUserFormState => ({
serverId: "",
name: "",
peerName: "",
authMethod: "certificate",
psk: "",
remoteId: "",
@@ -35,11 +37,13 @@ export const defaultIpsecUserForm = (): IpsecUserFormState => ({
})
type ServerOption = { id: string; name: string; host: string }
export type PeerOption = { serverId: string; name: string; managed: boolean }
function IpsecUserSheet({
open,
onOpenChange,
servers,
peers,
busy,
defaultServerId,
editing,
@@ -49,6 +53,8 @@ function IpsecUserSheet({
open: boolean
onOpenChange: (v: boolean) => void
servers: ServerOption[]
/** Доступные peers (серверы) для привязки identity при создании. */
peers?: PeerOption[]
busy?: boolean
defaultServerId?: string
/** Режим редактирования: сервер и метод аутентификации не меняются. */
@@ -67,6 +73,7 @@ function IpsecUserSheet({
queueMicrotask(() => setForm({
serverId: edit.serverId,
name: edit.name,
peerName: edit.peerName ?? "",
authMethod: edit.authMethod,
psk: "",
remoteId: edit.remoteId ?? "",
@@ -118,6 +125,24 @@ function IpsecUserSheet({
</select>
</FormField>
) : null}
{!editing && (peers ?? []).some((p) => p.serverId === form.serverId) ? (
<FormField label="Peer (сервер)" hint="К какому peer привязать identity">
<select
className="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]"
value={form.peerName}
onChange={(e) => set("peerName", e.target.value)}
>
<option value="">Автоматически (managed/первый)</option>
{(peers ?? [])
.filter((p) => p.serverId === form.serverId)
.map((p) => (
<option key={`${p.serverId}:${p.name}`} value={p.name}>
{p.name}{p.managed ? "" : " (RouterOS)"}
</option>
))}
</select>
</FormField>
) : null}
<FormField label="Имя клиента" required hint={editing ? undefined : "CN сертификата и отображаемое имя"}>
<Input
placeholder="alice"