feat(api, web): enhance agent installation process with invited status and policy support
- Updated the agent enrollment process to include an 'invited' status, allowing for better tracking of agent states. - Implemented support for install links that can now include an `install_link_id`, facilitating the transition from invited to pending status upon enrollment. - Enhanced the MikroTik installation script to include the `EvofwInstallLinkId` for better tracking and management. - Added new API endpoints for fetching agent policies and serving MikroTik-specific installation scripts. - Improved the web UI to reflect the new agent statuses and provide copyable installation commands for agents. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
+36
-7
@@ -2,17 +2,25 @@
|
||||
|
||||
## Short install (рекомендуется)
|
||||
|
||||
В UI `/agents` → **Добавить агента** создаёт install-ссылку. На хосте:
|
||||
В UI `/agents` → **Добавить агента**:
|
||||
|
||||
1. Создаётся агент со статусом **Invited** (сразу виден в таблице) + install-ссылка.
|
||||
2. Скопируйте one-liner (колонка Install или Sheet):
|
||||
|
||||
**Linux:**
|
||||
```bash
|
||||
curl -fsSL https://<cp>/agent-install/<id> | bash
|
||||
# или короткий slug:
|
||||
curl -fsSL https://<cp>/<slug> | bash
|
||||
```
|
||||
|
||||
Скрипт уже содержит `EVOFW_CP_URL`, `EVOFW_SEED`, `EVOFW_CLIENT_NAME`. После enroll одобрите агента во вкладке Pending.
|
||||
**MikroTik:**
|
||||
```
|
||||
/tool fetch url="https://<cp>/agent-install/<id>" dst-path=evofw-install.rsc; /import file-name=evofw-install.rsc
|
||||
```
|
||||
|
||||
API (auth): `POST /api/v1/install-links` `{ "name": "web-01", "platform": "linux" }`.
|
||||
3. После enroll статус станет **Pending** — одобрите агента (Approve).
|
||||
4. **Approved** — агент синхронизирует политику.
|
||||
|
||||
API (auth): `POST /api/v1/install-links` `{ "name": "web-01", "platform": "linux" | "mikrotik" }`.
|
||||
|
||||
## Linux (legacy one-liner)
|
||||
|
||||
@@ -24,15 +32,36 @@ curl -fsSL https://<cp>/v1/agent/install.sh | \
|
||||
bash
|
||||
```
|
||||
|
||||
Создаёт нового агента со статусом Pending (без Invited).
|
||||
|
||||
Файлы: `/etc/evofw/agent.conf`, `/usr/local/sbin/evofw-firewall.sh`, timer `evofw-firewall.timer` (default 1min).
|
||||
|
||||
Backend auto-detect: nft → ipset → iptables.
|
||||
|
||||
Whitelist: nft chain policy drop + allow set. Blacklist: policy accept + deny set.
|
||||
|
||||
## MikroTik
|
||||
## MikroTik (RouterOS 7.21+)
|
||||
|
||||
Скачайте `/v1/agent/mikrotik-install.rsc`, задайте globals `EvofwCpUrl`, `EvofwSeed`, `EvofwName`, import. Scheduler каждую минуту тянет policy. Настройте filter на address-list `EVOFW_DENY` / `EVOFW_ALLOW`.
|
||||
В UI `/agents` → **Добавить агента** → platform **MikroTik**. Скопируйте one-liner:
|
||||
|
||||
```
|
||||
/tool fetch url="https://<cp>/agent-install/<id>" dst-path=evofw-install.rsc; /import file-name=evofw-install.rsc
|
||||
```
|
||||
|
||||
Или короткий slug: `https://<cp>/<slug>`.
|
||||
|
||||
Install RSC:
|
||||
|
||||
1. Enroll (с `install_link_id` → агент Invited → Pending).
|
||||
2. Создаёт filter-правила `evofw-*` и address-list `EVOFW_DENY` / `EVOFW_ALLOW`.
|
||||
3. Scheduler `evofw-sync` каждую минуту: `GET /v1/agent/policy.rsc` → `/import` (списки + режим).
|
||||
|
||||
**Blacklist:** `drop` по `EVOFW_DENY` в `input` и `forward`.
|
||||
**Whitelist:** `accept` по `EVOFW_ALLOW` + catch-all `drop` только в `forward` (input не закрывается — Winbox/SSH).
|
||||
|
||||
Legacy: скачайте `/v1/agent/mikrotik-install.rsc`, задайте globals `EvofwCpUrl`, `EvofwSeed`, `EvofwName`, опционально `EvofwInstallLinkId`, затем `/import`.
|
||||
|
||||
Одобрите агента в UI — после Approve sync начнёт применять политику.
|
||||
|
||||
## Force sync
|
||||
|
||||
|
||||
Reference in New Issue
Block a user