Migration 0019: static_routes (id, destination, gateway, dev, metric,
table_name, active, comment).
internal/services/staticroutes/:
- CRUD-Repo
- Generator schreibt /etc/edgeguard/routes.conf (pipe-format) und
triggert `sudo systemctl restart edgeguard-routes.service`
- LiveAll() ruft `ip -j route show table all` und parsed JSON
internal/handlers/routes.go:
GET /api/v1/routes — managed (DB)
POST/PUT/DELETE — CRUD (re-render + apply on mutate)
GET /api/v1/routes/live — kernel-state via ip(8)
postinst:
- /usr/sbin/edgeguard-apply-routes (root-owned shell-script). Liest
routes.conf, flusht `proto 250` (= edgeguard), setzt neue Routen
mit proto 250. Andere Quellen (kernel/dhcp/manuell) bleiben
unangetastet.
- /etc/systemd/system/edgeguard-routes.service (Type=oneshot,
After=network-online.target). Beim Boot automatisch via
multi-user.target.
- /etc/iproute2/rt_protos.d/edgeguard.conf — Symbol "edgeguard" =
250 damit `ip route show proto edgeguard` funktioniert.
(Debian 13 hat kein /etc/iproute2 default → .d-Pattern statt
rt_protos-Anhängen.)
- sudoers: edgeguard ALL=(root) NOPASSWD: /usr/bin/systemctl
restart edgeguard-routes.service
UI: Networks-Page jetzt mit Tabs (Interfaces + Routen). Routes-Tab
hat zwei Cards:
- Live-Routen (read-only, 30s refresh, `proto edgeguard` farblich
hervorgehoben)
- Verwaltete Routen (CRUD-Tabelle, Add/Edit-Modal mit destination/
gateway/dev/metric/table/active/comment)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
40 lines
1.5 KiB
SQL
40 lines
1.5 KiB
SQL
-- +goose Up
|
|
-- +goose StatementBegin
|
|
|
|
-- Static routes — managed durch EdgeGuard, geschrieben in
|
|
-- /etc/edgeguard/routes.conf und appliziert via `ip route … proto
|
|
-- edgeguard`. Markierung mit Protocol-ID 250 (in der apply-script
|
|
-- gemappt) damit der Operator manuell-gesetzte Routen im Kernel
|
|
-- erkennt und nicht beim flush wegradiert.
|
|
--
|
|
-- destination: CIDR ("10.0.5.0/24" oder "0.0.0.0/0").
|
|
-- gateway: IPv4/v6 oder NULL (für on-link via dev).
|
|
-- dev: interface name (optional; bei Gateway-only kann ip das
|
|
-- selbst auflösen, aber explizit ist besser).
|
|
-- metric: Priorität — niedriger gewinnt (default 100).
|
|
-- table: routing table name oder "main" (default).
|
|
|
|
CREATE TABLE IF NOT EXISTS static_routes (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
destination TEXT NOT NULL,
|
|
gateway TEXT,
|
|
dev TEXT,
|
|
metric INTEGER NOT NULL DEFAULT 100,
|
|
table_name TEXT NOT NULL DEFAULT 'main',
|
|
active BOOLEAN NOT NULL DEFAULT TRUE,
|
|
comment TEXT,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
CONSTRAINT static_routes_metric_check CHECK (metric >= 0 AND metric <= 65535)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_static_routes_active ON static_routes (active) WHERE active;
|
|
CREATE INDEX IF NOT EXISTS idx_static_routes_dest ON static_routes (destination);
|
|
|
|
-- +goose StatementEnd
|
|
|
|
-- +goose Down
|
|
-- +goose StatementBegin
|
|
DROP TABLE IF EXISTS static_routes;
|
|
-- +goose StatementEnd
|