feat(api, web): implement port ACL and host firewall snapshot features
Build and Push EvoFirewall Docker Image / build-and-push (push) Successful in 1m43s
Build and Push EvoFirewall Docker Image / create-release (push) Skipped

- Added support for managing desired L4 port ACL rules for Linux agents, allowing for open/close actions on specified ports.
- Introduced a new endpoint for CRUD operations on port rules, enhancing the API's capabilities for agent management.
- Implemented functionality to collect and report host firewall snapshots, capturing observed rules and listeners for better monitoring.
- Updated the agent detail view to include tabs for managing port ACLs and viewing host firewall data, improving user experience.
- Enhanced documentation to reflect the new features and API changes, ensuring clarity for users and developers.

These changes significantly improve the management and visibility of firewall rules and port access control for agents.
This commit is contained in:
Denozordec
2026-08-11 15:08:00 +07:00
parent c5069fbdaf
commit 43f5ac2525
22 changed files with 2853 additions and 17 deletions
+25
View File
@@ -81,6 +81,31 @@ IPv6 skipped.
IPv6 skipped.
## Host firewall snapshot + Port ACL (Linux)
### Observed (Host firewall)
Каждый sync агент собирает best-effort снимок и шлёт в `apply-report.host_firewall`:
- `nft list ruleset`, `iptables-save`, optional `ufw` / `firewall-cmd`, `ss -lntu`
- Каждое правило: `ownership: evofw | foreign` (метка по имени table/chain/comment `evofw`)
- CP: `agent_host_firewall_snapshots`; `GET /api/v1/agents/:id/host-firewall`
- UI agent detail → tab **Host firewall** (Rules / Listeners)
Foreign правила **только отображаются** — с CP не редактируются.
### Desired (Port ACL)
Per-agent таблица `agent_port_rules`: `open|close`, `tcp|udp|both`, port range, `src_kind: all|cidr|list`.
- API: CRUD `/api/v1/agents/:id/port-rules`, import `/port-rules/import` (from list или policy set sources)
- Policy `apply_version: 3``port_rules[]` с expanded `src_cidrs`
- nft apply: после L3 allow — close drop, затем open accept (`comment "evofw-port-<id>"`)
- UI: tab **Port ACL** (DataGrid + Sheet create/edit + Import)
- ipset / MikroTik: без L4 apply; секции скрыты для non-linux
Мутация Port ACL бампит `policy_generation` → agent re-apply.
## MikroTik (RouterOS 7.21+)
В UI `/agents`**Добавить агента** → platform **MikroTik**. Скопируйте one-liner: