v0.1.1
Go quality gates / test (push) Waiting to run

This commit is contained in:
Mateusz Gruszczyński committed 2026-11-30 14:44:28 +01:00
1 parent 8c4d463f1e
commit de13d851a8
75 files changed
+4656 -442

No files matched your search

+65 -43
View File
@@ -1,48 +1,70 @@
# API-MAPPING — ekran → EasyDNS REST
# EasyDNS REST API mapping
Źródło prawdy: dostarczone EasyDNS **v0.1.4**: `docs/api.md`, `crates/dns-api/src/handlers.rs`, `crates/dns-api/src/lib.rs`. Poniższe ścieżki **po prawej stronie** należą wyłącznie do EasyDNS, prefiks REST `/api/v1` (z wyjątkiem `/readyz`). Panel pod spodem ma własne strony `/zones`, `/metrics` itd., które nie są nowymi endpointami backendu DNS.
The native API contract was reviewed against the supplied **EasyDNS Rust 0.1.4** source (`docs/api.md`, `crates/dns-api/src/handlers.rs`, `crates/dns-api/src/lib.rs`). All endpoints in the main table below have the EasyDNS prefix `/api/v1`, except `/readyz`. Panel routes such as `/zones`, `/servers`, `/metrics` and `/configuration` belong to the standalone **Go web UI**, not to the Rust server.
| Widok panelu | EasyDNS REST endpoint | Metoda | Odczytywane/wysyłane pola JSON | Działania i ograniczenia |
## Single-server pages (also available for the selected server in multi-server mode)
| Panel screen | Native EasyDNS endpoint | HTTP | JSON fields / request | Supported UI operations and limits |
|---|---|---|---|---|
| Overview | `/status`, `/stats`, `/health`, `/audit?n=6` | GET | `version,mode,uptime_seconds,roles.{primary,secondary,recursive,forwarder},queries_total,responses,cache_hit_rate,blocked,rate_limited,latency_p95_s,status,expired_zones,items` | Odczyt, bez fikcyjnego stanu klastra / 24h serwera |
| Zones | `/zones?page=&per_page=&name=&kind=` | GET | `items[]:{name,kind,serial,loaded,expired,records,status},pagination:{page,per_page,total}` | Filtracja i stronicowanie, bez fikcyjnego sortowania po stronie serwera |
| Create Zone | `/zones` | POST | `{name,ns[],hostmaster?,transfer_acl[],notify[]}` | Tworzenie tylko stref primary; HTTP 400/409/422 |
| Import Zone File | `/zones` | POST | `{name,zone_file,transfer_acl[],notify[]}` | Wysyłka treści całego pliku strefy (jako JSON); brak odczytu istniejących zone files |
| Zone Details | `/zones/{zone}` | GET | `name,kind,serial,loaded,expired,records,status,config,journal_entries,dnssec`, `ETag` | Szczegóły strefy, konfiguracja i stan; `config` tylko odczyt |
| Records | `/zones/{zone}/records?name=&type=&page=&per_page=` | GET | `items[]:{id,name,type,ttl,data},pagination,serial`, `ETag` | Tabela, filtry, odczyt tylko primary/secondary; brak endpointu `GET /records/{id}` |
| Add Record | `/zones/{zone}/records` | POST | `{name,type,ttl,data}`, nagłówek `If-Match: "serial"` | Tylko primary, SOA wykluczone; 412 przy konflikcie seriala |
| Edit Record | `/zones/{zone}/records/{id}` | PUT | `{name,type,ttl,data}`, `If-Match` | Aktualizacja całego rekordu; ID wcześniej z listy; 400/404/409/412/422 |
| Delete Record | `/zones/{zone}/records/{id}` | DELETE | `If-Match`; identyfikator rekordu w URL | Potwierdzenie DELETE, bez usuwania SOA |
| Replace Zone | `/zones/{zone}` | PUT | `{zone_file}`, `If-Match` | Pełna podmiana, ETag 412, 422 dla błędu treści, brak GET tekstu pliku |
| Delete Zone | `/zones/{zone}` | DELETE | identyfikator strefy z URL | Tylko strefy API-overlay; 409 dla plikowych; potwierdzenie nazwy |
| Transfer History | `/zones/{zone}/transfers` | GET | `items[]:{time_unix,direction,kind,peer,serial,records,ok,error,duration_ms}` | Historia, **nie** żywa kolejka lub procentowy progres |
| Secondary Sync | `/zones/{zone}/sync` | POST | zwrot `result,serial` | Wyłącznie secondary; 409 jeśli inny typ; 502 przy błędzie transferu |
| DNS Notify | `/zones/{zone}/notify` | POST | zwrot `targets` | Tylko gdy skonfigurowano cele; HTTP 202 oznacza akceptację wysyłki |
| DNSSEC Status | `/zones/{zone}` | GET | `dnssec` / `config.dnssec` | Stan i parametry tylko do odczytu; brak REST API do generowania/rotacji kluczy |
| DNS Lookup | `/query?name=&type=` | GET | `rcode,aa,answers[],authority[],elapsed_ms` | Jedno bieżące zapytanie; API nie daje historii zapytań klientów |
| Upstreams | `/upstreams` | GET | `items[]:{group,strategy,servers[]:{address,stats:{queries,failures,healthy,ewma_rtt_ms,...}}}` | Bieżące grupy i zdrowie serwerów, bez edit/delete upstream |
| Add Upstream | `/upstreams` | POST | `{address}` | Dodaje do overlay i przeładowuje konfigurację |
| Policies | `/policies` | GET | `policy,rate_limit,views,acls,api_allowed_clients,recursion_allowed_clients` | Odczyt aktywnych ustawień |
| Policies Settings | `/policies` | PUT | `{allowlist:[],block_action}` | Tylko te dwa pola zapisywalne; pozostałe nie mają REST CRUD |
| Views | `/policies` | GET | `views[]` | **Read-only**; brak create/edit/delete views |
| ACL | `/policies` | GET | `acls,recursion_allowed_clients,api_allowed_clients` | **Read-only**; brak edycji nazwanych ACL i client ACL |
| Rate Limiting | `/policies`, `/stats` | GET | `rate_limit,rate_limited` | **Read-only**; licznik zbiorczy, brak zmian limitera |
| Blocklists | `/blocklists` | GET | `lists[],loaded[],rules,update_interval,state` | Odczyt list, stan i liczba reguł; brak listy pojedynczych reguł z GET |
| Add Block Rule | `/blocklists` | POST | `{rule}` | Dodaje pojedynczą regułę; brak edit/delete per-rule |
| Cache | `/cache` | GET | `entries,capacity,hits,misses,inserts,evictions,expired,stale_served,prefetches` | Liczniki, bez listowania kluczy cache |
| Flush Cache | `/cache` / `/cache?domain=...` | DELETE | zwrot `removed` | Usuwa całość (potwierdzenie) albo wskazaną domenę |
| Metrics | `/stats` | GET | `queries_total,responses,sources,latency_p50_s,latency_p95_s,latency_p99_s,cache,blocked,rate_limited,uptime_seconds` | Statystyki bieżące; szereg czasowy wyliczany z odczytów w pamięci Go |
| Audit Log | `/audit?n=` | GET | `items[]:{time_unix,actor,action,target,result,detail}` | Ostatnie zdarzenia administracyjne; brak filtrowania czasu / Query Log |
| Server Status | `/status`, `/health`, `/readyz` | GET | `listeners,roles,zones,version,mode,uptime_seconds,expired_zones`, plaintext `/readyz` | Odczyt, brak akcji start/stop usługi |
| Configuration | `/status`, `/policies` | GET | `mode,version,roles.default_resolution,dnssec_validation,policy.block_action,...` | Odczyt wybranych parametrów, brak ogólnego edytora konfiguracji |
| Hot Reload | `/config/reload` | POST | raport / stan reload (serwerowy response) | Odświeża konfigurację z dysku, poprzednia pozostaje aktywna gdy błąd |
| Overview | `/status`, `/stats`, `/health`, `/audit?n=6` | GET | `version,mode,uptime_seconds,roles,queries_total,responses,cache_hit_rate,blocked,rate_limited,latency_p95_s,status,expired_zones,items` | Read status and true counters; no claimed 24-hour native history or native cluster status |
| Zones | `/zones?page=&per_page=&name=&kind=` | GET | `items[]:{name,kind,serial,loaded,expired,records,status}`, `pagination:{page,per_page,total}` | Search by supported filters and paginate; no fictional server-side sorting |
| Create primary zone | `/zones` | POST | `{name,ns[],hostmaster?,transfer_acl[],notify[]}` | Only creates Primary zones; native validation/status errors apply |
| Create from zone file | `/zones` | POST | `{name,zone_file,transfer_acl[],notify[]}` | Upload the entire zone text as JSON; cannot fetch the existing source file |
| Zone details | `/zones/{zone}` | GET | `name,kind,serial,loaded,expired,records,status,config,journal_entries,dnssec`, `ETag` | Inspect current zone and configuration; most `config` values are read-only |
| DNS records | `/zones/{zone}/records?name=&type=&page=&per_page=` | GET | `items[]:{id,name,type,ttl,data}`, `pagination`, `serial`, `ETag` | List and filter; there is no native GET by record ID |
| Add record | `/zones/{zone}/records` | POST | `{name,type,ttl,data}`, `If-Match` | Primary zones only; SOA is excluded; 412 conflict on stale serial |
| Edit record | `/zones/{zone}/records/{id}` | PUT | `{name,type,ttl,data}`, `If-Match` | Replace record; ID is found from paginated list; 400/404/409/412/422 possible |
| Delete record | `/zones/{zone}/records/{id}` | DELETE | ID in path, `If-Match` | Explicit confirmation; cannot delete SOA through record CRUD |
| Replace zone contents | `/zones/{zone}` | PUT | `{zone_file}`, `If-Match` | Full replacement only, with confirmation; 412 serial conflict, 422 invalid zone text |
| Delete zone | `/zones/{zone}` | DELETE | Zone identifier in path | Deletes API-created overlay zones; 409 for config-file zones; exact-name confirmation |
| Transfer history | `/zones/{zone}/transfers` | GET | `items[]:{time_unix,direction,kind,peer,serial,records,ok,error,duration_ms}` | Completed transfer history; **not** a live queue or progress percentage |
| Secondary synchronization | `/zones/{zone}/sync` | POST | `result,serial` | Refresh an existing Secondary; 409 for the wrong zone type; 502 on transfer errors |
| DNS NOTIFY | `/zones/{zone}/notify` | POST | `targets` | Request NOTIFY for configured targets; 202 means accepted, not guaranteed delivered |
| DNSSEC status | `/zones/{zone}` | GET | `dnssec`, `config.dnssec` | Inspect existing status; no key/signing CRUD |
| DNS lookup | `/query?name=&type=` | GET | `rcode,aa,answers[],authority[],elapsed_ms` | Run a query now; the API has no query log |
| Upstreams | `/upstreams` | GET | `items[]:{group,strategy,servers[]:{address,stats:{queries,failures,healthy,ewma_rtt_ms,...}}}` | Read resolver groups/health |
| Add upstream | `/upstreams` | POST | `{address}` | Add to overlay; no update/delete upstream endpoints |
| Policies | `/policies` | GET | `policy,rate_limit,views,acls,api_allowed_clients,recursion_allowed_clients` | Read effective policy |
| Writable policy fields | `/policies` | PUT | `{allowlist:[],block_action}` | Only these two fields are writable |
| Views | `/policies` | GET | `views[]` | Read-only; no Views CRUD |
| ACL | `/policies` | GET | `acls,recursion_allowed_clients,api_allowed_clients` | Read-only; no ACL CRUD |
| Rate limiting | `/policies`, `/stats` | GET | `rate_limit,rate_limited` | Read-only configuration and aggregate counter |
| Blocklists | `/blocklists` | GET | `lists[],loaded[],rules,update_interval,state` | Read feed state/aggregate counts; no per-rule listing |
| Add block rule | `/blocklists` | POST | `{rule}` | Add a single rule; no edit/delete per-rule |
| Cache | `/cache` | GET | `entries,capacity,hits,misses,inserts,evictions,expired,stale_served,prefetches` | Counters only; no key browser |
| Flush cache | `/cache`, `/cache?domain=...` | DELETE | Response `removed` | Full invalidation with confirmation, or targeted invalidation |
| Metrics | `/stats` | GET | `queries_total,responses,sources,latency_p50_s,latency_p95_s,latency_p99_s,cache,blocked,rate_limited,uptime_seconds` | Real snapshots; Go samples every 15 seconds in RAM |
| Audit log | `/audit?n=` | GET | `items[]:{time_unix,actor,action,target,result,detail}` | Recent administrative operations; not client DNS query history |
| Server status | `/status`, `/health`, `/readyz` | GET | `listeners,roles,zones,version,mode,uptime_seconds,expired_zones`; `/readyz` plain response | Five-item status strip, listeners and zone states; no restart/stop |
| Configuration | `/status`, `/policies` | GET | `mode,version,roles.default_resolution,dnssec_validation,policy.block_action,...` | Selected runtime settings, mostly read-only |
| Hot reload | `/config/reload` | POST | Native reload result | Reload config from disk, preserving the prior active state if validation fails |
## Autoryzacja i odpowiedzi
## Optional multi-server screens: no new EasyDNS endpoints
- TCP: EasyDNS generuje sam `control.token` w `<data_dir>/control.token` przy włączonym API TCP. Go odczytuje token z pliku w backendzie i używa `Authorization: Bearer TOKEN` do EasyDNS. Token nie jest udostępniany w HTML ani JavaScript.
- Unix: `control.sock`, prawo dostępu wg właściciela/grupy, bez bearer tokenu; serwer audytuje UID/PID.
- Typowy błąd: `{"error":{"status":412,"message":"..."}}`; panel wyświetla serwerowy `message` i odpowiednie ostrzeżenie.
- Obsługiwane statusy: m.in. 400 nieprawidłowe parametry, 401/403 brak uprawnień, 404 brak zasobu, 409 konflikt, **412** niezgodność `If-Match`, **422** odrzucony zone file/RDATA, 502 problem secondary, 503 niedostępny stan, 500 błąd wewnętrzny.
- `ETag` (nazwa serial) pobierany z listy rekordów / szczegółów strefy i zachowywany przez Go w formularzu; przy zapisie wysyłany `If-Match`.
- Endpoint `GET /api/v1/openapi.json` istnieje, ale panel go nie wywołuje do generowania fikcyjnych formularzy.
- Lokalna trasa Go `GET /ui/telemetry` **nie jest endpointem EasyDNS**: zwraca tylko zmierzone sample JSON i wymaga zalogowania do panelu.
| Go panel screen/action | Go panel HTTP route | Native REST performed | Operation and boundary |
|---|---|---|---|
| Enable/disable multi-server | `POST /configuration/multi-server` | **None** | Save panel-only preference to a private local file; retain remote definitions on disable |
| Server inventory and topology | `GET /servers` | `GET /api/v1/health` and `GET /api/v1/status` **per managed instance** | Live connectivity, reported mode/version/role counts; panel-supplied labels only |
| Add managed server | `GET /servers/new`, `POST /servers` | None during registration | Save its URL, panel label and its existing remote generated token in private panel files; API is probed on the inventory screen |
| Change display role | `POST /servers/{id}/role` | **None** | Update Primary/Secondary/Unassigned label in panel metadata; no DNS server mutation |
| Remove remote connection | `GET/POST /servers/{id}/remove` | **None** | Remove panel metadata and panel-stored remote token; does not remove DNS server |
| Select active server | `POST /servers/select` | **None** | Set browser's HttpOnly server-context cookie; subsequent standard pages use that server's native API |
| Compare zone SOA serials | `GET /servers/compare?zone=...` | `GET /api/v1/zones/{zone}` **per managed instance** | Read-only comparison against panel-labeled Primary; no automatic transfer or failure inference |
| Selected server's normal pages | All existing Go panel pages | Unchanged native methods from the table above | One server API client per request, never a new or generic API proxy |
| Sampled charts — Single | `GET /ui/telemetry` | `GET /api/v1/stats` for selected server (Go polling) | Authenticated Go-local JSON for measured per-node history; no new EasyDNS endpoint |
| Sampled charts — Split | `GET /ui/telemetry?mode=split` | `GET /api/v1/stats` per enabled node (Go polling) | JSON `mode,nodes[]:{id,name,role,samples[],error,lastPoll}`; measured per-node series, no invented data |
| Sampled charts — Aggregate | `GET /ui/telemetry?mode=aggregate` | Same native `/stats` per node (Go polling) | JSON `nodes[],samples[]:{time,queryRate,noerror,nxdomain,servfail,refused,blocked,cacheHitRate,contributors}`; strict complete rates, weighted cache, no percentile aggregation |
| Fleet Metrics snapshot | `GET /metrics?mode=…` (aggregate / split / single) | `GET /api/v1/stats` per registered server (concurrent reads) | Aggregate cumulative counters from responding servers only; Split individual stats; Single selected node |
The maximum is 15 remote servers plus the local instance. HTTP API transport is restricted to loopback; remote addresses must use verified HTTPS.
## Authentication and error handling
- **Local TCP EasyDNS:** Rust generates `control.token` automatically under its configured data directory. The Go backend reads that file and sends `Authorization: Bearer <token>`; the token is never exposed in HTML or logs.
- **Local Unix socket:** Requires OS filesystem access; native EasyDNS may audit the peer's UID/PID; no bearer header is used.
- **Remote TCP:** Each remote installation has its *own* generated token. An administrator supplies it once when adding the connection; Go stores it with mode `0600`. There is no REST endpoint to fetch or rotate a remote token.
- **Error responses:** Native envelope `{"error":{"status":412,"message":"..."}}`. Typical statuses include 400 invalid parameters, 401/403 access denied, 404 missing resource, 409 conflict, **412 stale ETag**, **422 invalid zone/RDATA**, 502 secondary transfer failure, and 503 unavailable. UI shows a safe message and preserves form state where possible.
- **Concurrency:** Current zone serial/ETag is sent using `If-Match` for record editing and full zone replacement.
- **Native OpenAPI:** `GET /api/v1/openapi.json` exists but is not used to invent UI operations.
See [MULTI-SERVER.md](MULTI-SERVER.md) and [API-GAPS.md](API-GAPS.md) for role semantics and unsupported operations.