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

+92 -99
View File
@@ -1,165 +1,158 @@
# EasyDNS Web
**Samodzielny panel administracyjny WWW dla EasyDNS**, napisany w Go. Panel jest osobnym projektem i osobną usługą `easydns-ui.service`; **nie zastępuje serwera DNS**, nie jest dodawany do pakietu Rust EasyDNS i nie zmienia jego REST API.
A standalone, self-contained Go administration panel for the EasyDNS Rust DNS server. **This is a separate application and Debian package. It does not install, replace, or modify EasyDNS itself.** The OLED-style UI draws visual inspiration from RustProxy 0.43.1 while keeping its own identity and strict API compatibility.
![EasyDNS OLED operator dashboard — render działającego UI na danych DEMO](design/screenshots/overview-demo.png)
![EasyDNS operator dashboard — demo fixture, not live server data](design/screenshots/overview-demo.png)
## Zakres i wygląd
## Features
Wygląd bazuje na zaakceptowanych makietach RustProxy-inspired / **OLED**: niemal czarne tło, grafitowe panele, niewidoczne gradienty (brak), cienkie obramowania, kompaktowe tabele, płaskie przyciski, linie telemetryczne w cyjanie i bursztynie, oszczędne wskaźniki kolorów. Zamiast generowanego logotypu: **napis EasyDNS**. Bez `API v1` w górnym pasku, fikcyjnych klastrów ani ozdobników.
- Overview, zones, primary-zone creation/import, record CRUD, zone transfers, secondary synchronization, DNS NOTIFY and DNSSEC status.
- DNS lookup, upstreams, policies, read-only views/ACL/rate limits, blocklists, cache, sampled metrics, audit, server status and configuration reload.
- **Optional multi-server management**: one central panel for a local EasyDNS installation plus remote installations (for example one Primary and two Secondary DNS servers).
- Server topology with per-server health, actual DNS role counts, automatic active-server selection and read-only zone serial comparison.
- **Metrics: Aggregate / Split / Single** in multi-server mode. Additive QPS rates and counters can be combined, cache ratios are weighted, and latency percentiles remain per-server. No synthetic history or new EasyDNS API endpoints.
- **Single-server mode by default**. Enable Multi-server using `config.toml` (Debian), `.env` (Compose), or the Configuration toggle only when neither source explicitly sets the mode.
- Secure administrator login, session/CSRF protection, safe confirmations and ETag/If-Match concurrency handling for DNS record changes.
Dostarczone są **oryginalne, zaakceptowane makiety 5 głównych ekranów** w `design/reference/` oraz **28 zrzutów faktycznie wyrenderowanych stron** w `design/screenshots/*-demo.png`. Zrzuty przedstawiają wyłącznie dane testowe; rzeczywisty panel pokazuje to, co zwróci podłączony EasyDNS. Kształt widoków jest zgodny z kierunkiem makiet, ale nie jest odtwarzaniem fikcyjnych przycisków ani danych piksel w piksel.
The panel never invents REST endpoints or server-side capabilities. In particular, the optional “topology” is a **management view**, not a distributed cluster implementation. There is no automatic leader election, quorum, primary/secondary provisioning, DNS replication setup, or secret distribution. EasyDNS itself continues to handle native AXFR/IXFR and NOTIFY, configured on the respective DNS installations.
Panel zawiera: Overview, Zones, Zone Details, Records (create/edit/delete + serial conflict), tworzenie stref z NS lub pełnego zone file, transfers history, secondary synchronization, NOTIFY, DNSSEC inspection, DNS lookup, upstreams, Policies, Views, ACL, Rate Limiting, Blocklists, Cache, Metrics, Audit Log, Server Status, Configuration, confirmations and errors. **Nie ma Query Log**, bo taki endpoint nie istnieje. Ograniczenia szczegółowo w [API-GAPS.md](API-GAPS.md).
## Technology and visual style
## Technologia
Go 1.23+, `net/http`, `html/template`, `go:embed`, embedded Bootstrap 5.3.6 CSS, a small custom OLED stylesheet, vanilla JavaScript/Canvas charts and local SVG icons. No CDN, frontend build step or external Go modules are required. HTMX and Chart.js were optional preferences; this implementation uses native HTML forms and an embedded Canvas renderer instead.
- **Go 1.23+**: serwer HTTP, bezpośredni klient REST i backend sesji.
- **Go `html/template`** oraz **`go:embed`**: wszystkie szablony, CSS/JS i ikony w pojedynczym binarnym pliku.
- **Bootstrap 5.3.6**: dołączony lokalnie, bez zależności od CDN; autorski `app.css` definiuje wzorzec OLED.
- **Vanilla JS**: wykresy natywnym Canvas na prawdziwych próbkach, bez danych syntetycznych; formularze działają bez JavaScript.
- **Ikony SVG** w stylu Lucide, osadzone lokalnie. Nie ma zależności od hostowanego zestawu ikon.
Almost-black backgrounds, fine hairline borders, dense tables, restrained cyan/amber chart lines and flat compact controls. No gradients, oversized decorative cards, invented logo monograms or misleading “API v1” indicators.
HTMX i Chart.js były technologiami preferowanymi, nie obligatoryjnymi. Ten wariant świadomie używa formularzy HTML oraz małego lokalnego renderera Canvas, aby binarka była samowystarczalna. **Nie twierdzi, że wykorzystuje HTMX albo Chart.js.**
Five approved appearance references are in `design/reference/`. The screenshots under `design/screenshots/` are rendered demo fixtures, **not live EasyDNS measurements**. UI elements are constrained by available API data and operations; the style references are not treated as a backend contract.
## Instalacja gotowego `.deb` (Debian / Ubuntu)
## Install with Debian packages
EasyDNS musi być osobno zainstalowany i uruchomiony. Dla Linux `amd64`:
EasyDNS itself must already be installed and running. Install the matching EasyDNS Web package:
```bash
sudo apt install ./easydns-ui_0.1.0_amd64.deb
sudo apt install ./easydns-ui_0.1.1_amd64.deb
# On ARM64, use easydns-ui_0.1.1_arm64.deb instead.
sudo systemctl status easydns-ui
sudo cat /etc/easydns-ui/panel.password
```
Dla ARM64 analogicznie: `easydns-ui_0.1.0_arm64.deb`.
Następnie otwórz na serwerze `http://127.0.0.1:8088` (lub tunel SSH dla pracy z innego komputera):
Open `http://127.0.0.1:8088` on the server. Log in with username **`admin`** and the automatically generated password from the file above. An external workstation can use an SSH tunnel:
```bash
ssh -L 8088:127.0.0.1:8088 user@dns-server
# Then browse to http://127.0.0.1:8088 locally.
```
Zaloguj się użytkownikiem `admin` i hasłem z `/etc/easydns-ui/panel.password`. Hasło **jest automatycznie generowane podczas pierwszej instalacji** i nie jest zapisywane w logach. Po ręcznej zmianie pliku hasła zrestartuj usługę.
The default listener binds to loopback. Do not expose the HTTP panel publicly; use a TLS reverse proxy or an SSH/VPN tunnel. For browser access via HTTPS, set `cookie_secure = true` under `[panel]` in `/etc/easydns-ui/config.toml` and restart the service.
**Token EasyDNS jest inny niż hasło panelu.** EasyDNS tworzy token sam w `/etc/easydns/data/control.token`, kiedy jego TCP REST API jest włączone. Backend Go odczytuje ten plik na każde chronione żądanie, wysyłając `Authorization: Bearer ...` **wyłącznie do EasyDNS**. Nie tworzy, nie zastępuje ani nie wyświetla tokenu. Instalator `.deb` dodaje użytkownika serwisu `easydns-ui` do grupy `easydns` (jeżeli istnieje). Jeżeli uprawnienia katalogów nadal blokują odczyt, ustaw właściwe prawa zgodnie z instalacją EasyDNS, nie kopiuj tokenu do kodu lub HTML.
The panel's login password is **not** the EasyDNS API token. On the local machine, EasyDNS automatically generates `/etc/easydns/data/control.token` when its TCP REST interface is enabled. The Go backend reads that file directly and sends `Authorization: Bearer` only when talking to the EasyDNS API. No API token appears in HTML/JavaScript. Alternatively, the Go panel can communicate through the local Unix control socket (file permissions still apply).
Konfiguracja panelu: `/etc/default/easydns-ui`.
## Configure one Primary and two Secondary servers (optional)
```ini
EASYDNS_UI_LISTEN=127.0.0.1:8088
EASYDNS_API_URL=http://127.0.0.1:9953
EASYDNS_API_TOKEN_FILE=/etc/easydns/data/control.token
```
1. Install EasyDNS on all three machines and configure their real DNS zones, transfers/ACLs and NOTIFY **using EasyDNS's native configuration**, not the panel.
2. Install EasyDNS Web on **one** machine. Its local EasyDNS instance is the default managed server.
3. Enable the feature. **Debian:** set `[multiserver] enabled = true` in `/etc/easydns-ui/config.toml` and restart the panel. **Docker Compose:** set `EASYDNS_UI_MULTISERVER=true` in `.env` and recreate the container. When neither source explicitly defines the enabled flag, Configuration offers an optional in-panel toggle.
The new **Servers** navigation item and server selector appear. Selecting a server in the toolbar changes context automatically without a separate Switch button. The **ACTIVE SERVER** bar identifies the API target for normal DNS pages and **Single** Metrics. In **Metrics → Aggregate / Split**, the scope changes to all registered servers and is labeled **FLEET METRICS**. Each server's zone list is separate; use **Servers → Zone comparison** for a multi-server zone view. See [MULTI-SERVER.md](MULTI-SERVER.md) for troubleshooting.
4. Go to **Servers → Add server**. Add `dns-secondary-01` with **Secondary** as the *panel display label*, its HTTPS EasyDNS API URL, and the **generated control token belonging to that remote installation**. Repeat for `dns-secondary-02`.
5. Open **Servers** to see availability and actual DNS role counts. Select a server to operate its normal EasyDNS UI, or choose **Compare zone serials** to check whether the same zone is present and what SOA serial each server reports.
6. Open **Metrics** and choose **Aggregate** (default), **Split**, or **Single**. Aggregate adds rates only while every server has recent readings; incomplete data is marked rather than silently treated as zero. See [MULTI-SERVER.md](MULTI-SERVER.md) for the exact mathematics and limitations.
Alternatywa bez tokenu dla API działającego tylko przez Unix socket:
For a remote token, read the token on its own machine securely (for example through SSH). It is **not** the local token and cannot be retrieved through the existing REST API. Remote API connections must use HTTPS with a trusted certificate. Plain HTTP is accepted only for `localhost`, `127.0.0.1` or `::1` on the panel machine, e.g. via a loopback SSH tunnel. Tokens entered in the UI are stored only in private files under `/var/lib/easydns-ui/tokens/` (0600). Tokens preconfigured in TOML or Compose `.env` are held in process memory. None are returned to the browser.
```ini
EASYDNS_API_SOCKET=/etc/easydns/data/control.sock
```
The panel's **Primary/Secondary labels do not modify the actual server role**. The individual EasyDNS `GET /api/v1/status` response reports the real primary and secondary zone counts. A different SOA serial is a diagnostic observation, not proof that synchronization failed. **No automatic synchronization is performed across servers**: open an existing secondary zone on the selected server to use EasyDNS's supported manual `POST /api/v1/zones/{zone}/sync` operation.
Restart panelu po zmianie konfiguracji:
**Disable Multi-server** by setting `[multiserver] enabled = false` in TOML, or `EASYDNS_UI_MULTISERVER=false` in `.env`, then restarting the panel. If neither source explicitly sets this option, disable it using the Configuration toggle. Previously registered UI-managed connections remain saved for later re-enabling, but remote polling stops.
Explicit TOML and environment values are authoritative: the Multi-server toggle is hidden in Configuration and a previous `settings.json` preference cannot override them. Server names and role labels supplied in TOML or `.env` are read-only in the Servers inventory; labels for panel-added servers remain editable. An explicitly configured local role is read-only as well. The inventory uses only LOCAL/REMOTE badges, not configuration-source badges. The `nodes.json` file holds UI-managed metadata, and `settings.json` stores the optional UI toggle only when configuration does not set it.
See [MULTI-SERVER.md](MULTI-SERVER.md) for an illustrated topology guide, setup, security and limitations.
## Configuration and service
**Debian:** configure the panel using `/etc/easydns-ui/config.toml` (protected, `root:easydns-ui`, mode `0640`). The package creates this file as a Debian conffile; it survives upgrades. The installer separately generates `/etc/easydns-ui/panel.password` and `/etc/easydns-ui/session.key` if they do not exist.
```bash
sudoedit /etc/easydns-ui/config.toml
sudo systemctl restart easydns-ui
sudo journalctl -u easydns-ui -f
```
### HTTPS i dostęp z sieci
**Upgrade note for Multi-server users:** 0.1.1 treats `[multiserver] enabled` in TOML as authoritative. If an older 0.1.0 installation had Multi-server enabled only via the web toggle while `config.toml` still says `enabled = false`, change the TOML value to `true` and restart after upgrading. Existing remote connections and tokens remain saved; they are not deleted.
Domyślnie panel nasłuchuje **tylko na 127.0.0.1**. Nie publikuj portu HTTP bez TLS. Użyj tunelu SSH lub reverse proxy z HTTPS i wtedy w `/etc/default/easydns-ui` ustaw `EASYDNS_UI_COOKIE_SECURE=true`. Autoryzacja administratora w panelu: sesja podpisana HMAC, ciasteczko `HttpOnly` i `SameSite=Strict`, token CSRF dla wszystkich operacji POST, ograniczenie prób logowania, CSP i `no-store` dla stron z danymi. API EasyDNS nie jest udostępnione przeglądarce.
The TOML file can configure username, password, API URL, API token (or the generated token file), bind address, session settings and up to 15 additional server connections. For an existing installation upgraded from the old `/etc/default/easydns-ui`, copy any custom values to the TOML file; the old shell environment file is no longer sourced by the systemd unit.
## Budowanie z repozytorium
**Docker Compose:** copy `.env.example` to `.env`, set `EASYDNS_UI_PASSWORD`, `EASYDNS_API_URL`, and `EASYDNS_API_TOKEN`, and run:
```bash
cp .env.example .env
chmod 600 .env
docker compose up -d --build
```
Each remote server can also be configured with a separate `EASYDNS_UI_SERVER_N_TOKEN`. The container uses a persistent volume for session signing and the server registry. Docker doesn't need a TOML file. The exposed port binds to `127.0.0.1:8088` by default.
See **[CONFIGURATION.md](CONFIGURATION.md)** for complete Debian TOML examples, Docker Compose `.env` variables, security, configuration precedence and fingerprinted static files. A Debian package never installs or alters the Rust DNS server itself. Purging the package removes the panel-owned configuration and credentials; a normal update preserves them.
## Build from source
```bash
# Go 1.23+ i dpkg-deb na maszynie budującej
make test
make vet
make build
./bin/easydns-ui -version
make deb GOARCH=amd64
make deb GOARCH=arm64
make deb GOARCH=amd64 VERSION=0.1.1
make deb GOARCH=arm64 VERSION=0.1.1
```
Wyniki `.deb` w `dist/`. Wszystkie zasoby panelu są embedowane.
### Reproducible Docker-based Debian packaging
### Budowanie pakietów `.deb` przez Docker (zalecane)
Na komputerze budującym wystarczy **Docker Engine / Docker Desktop**. Nie musisz instalować Go, kompilatora ARM, QEMU ani `dpkg-deb` na hoście. Skrypt uruchamia obraz `golang:1.23-bookworm`, wykorzystuje istniejące `scripts/build-deb.sh` do pakowania i zapisuje pliki na hoście w `dist/`. Nie uruchamia ani nie pakuje serwera Rust EasyDNS.
Only Docker is required on the build host (no local Go or `dpkg-deb`):
```bash
# Z katalogu głównego repozytorium — domyślnie dwie architektury
./scripts/build_deb.sh
# Tylko AMD64 lub ARM64
./scripts/build_deb.sh # amd64 + arm64
./scripts/build_deb.sh --arch amd64
./scripts/build_deb.sh --arch arm64
# Wersja pakietu i opcjonalnie inny obraz Go (musi zawierać dpkg-deb)
./scripts/build_deb.sh --version 0.2.0
IMAGE=golang:1.23-bookworm ./scripts/build_deb.sh --arch all
# Równoważne wywołanie przez Makefile
make docker-deb ARCH=all VERSION=0.1.0
./scripts/build_deb.sh --arch arm64 --version 0.1.1
make docker-deb ARCH=all VERSION=0.1.1
```
Pliki wynikowe: `dist/easydns-ui_0.1.0_amd64.deb` i `dist/easydns-ui_0.1.0_arm64.deb`. Docker pobiera obraz przy pierwszym wywołaniu, więc wtedy potrzebny jest dostęp do rejestru obrazów. **Sam kontener budujący nie ma dostępu do sieci** (`--network none`) i kompiluje z `GOPROXY=off`. Architektury są kompilowane krzyżowo (`CGO_ENABLED=0`) z jednego obrazu; nie potrzeba `buildx`. Pliki w `dist/` należą do użytkownika uruchamiającego skrypt.
The default build image is `golang:1.23-bookworm`, including Debian tools. The Docker build container runs with networking disabled (`--network none`), uses the existing `scripts/build-deb.sh` package definition, and compiles both Linux architectures with `CGO_ENABLED=0`. Packages are placed in `dist/`.
Bez Dockera nadal działa `make deb GOARCH=amd64` / `GOARCH=arm64`, ale wymaga Go i `dpkg-deb` na hoście.
Lokalne uruchomienie z już istniejącymi plikami logowania i tokenem:
```bash
EASYDNS_UI_PASSWORD_FILE=/bezpieczna/sciezka/panel.password \
EASYDNS_UI_SESSION_KEY_FILE=/bezpieczna/sciezka/session.key \
EASYDNS_API_TOKEN_FILE=/etc/easydns/data/control.token \
EASYDNS_API_URL=http://127.0.0.1:9953 \
EASYDNS_UI_LISTEN=127.0.0.1:8088 \
./bin/easydns-ui
```
Plik `panel.password` powinien zawierać tajne hasło długości co najmniej 16 znaków, a `session.key` co najmniej 32 losowe bajty lub 64 znaki hex. Gotowy pakiet tworzy oba automatycznie. W kodzie **nie ma** żadnego API tokenu ani domyślnego hasła.
## Struktura repo
## Project structure
```text
EasyDNS-Web/
├── cmd/easydns-ui/main.go # Punkt wejścia Go
├── internal/config/ # Zmienne środowiskowe
├── internal/easydns/ # Typowany REST API client; token tylko backend
├── internal/server/ # Routing, HTML templates, sesje, walidacja
│ └── web/
│ ├── templates/ # Go HTML Templates
│ └── static/ # OLED CSS, JS, SVG, Bootstrap 5, go:embed
├── internal/telemetry/ # Polling rzeczywistych liczników /stats
├── packaging/ # systemd, Debian maintainer scripts, env
├── scripts/build_deb.sh # Docker: obie architektury (bez Go/dpkg na hoście)
├── scripts/build-deb.sh # Natomiast pakowanie .deb (Go + dpkg-deb)
├── design/
│ ├── reference/ # 5 zaakceptowanych obrazów referencyjnych
│ └── screenshots/ # 28 zrzutów UI z danych DEMO
├── cmd/easydns-ui/main.go # service entry point
├── internal/config/ # TOML, environment overrides + validation
├── internal/easydns/ # native EasyDNS REST client/models
├── internal/multiserver/ # optional node registry + sampling
├── internal/server/ # HTTP handlers, auth, HTML templates
│ └── web/ # embedded OLED CSS/JS/icons/templates
├── internal/telemetry/ # genuine stats samples (RAM)
├── packaging/ # systemd and Debian maintainer scripts
├── scripts/build_deb.sh # Docker package builder
├── scripts/build-deb.sh # native Debian package builder
├── design/reference/ # approved visual references
├── design/screenshots/ # demo fixture screenshots
├── MULTI-SERVER.md
├── API-MAPPING.md
├── API-GAPS.md
├── UI-STRUCTURE.md
├── DESIGN-SYSTEM.md
├── SECURITY.md
└── Makefile
└── SECURITY.md
```
## API i zgodność z backendem
## API and operational limits
Bazą do mapowania był dostarczony **EasyDNS v0.1.4** (załączony kod Rust `crates/dns-api/src/handlers.rs`, trasy w `lib.rs`, `docs/api.md`). Aktualnego zdalnego `master` nie potwierdzono na potrzeby tego wydania. Wdrożenie w nowszej wersji wymaga uruchomienia testów zgodności. Panel **nie definiuje nowych endpointów EasyDNS**. HTTP `/ui/telemetry` to **wewnętrzny endpoint Go**, udostępniający przeglądarce wyłącznie próbki statystyk panelu — nie jest endpointem serwera DNS.
The API contract is based on the supplied **EasyDNS Rust 0.1.4** source (`docs/api.md`, `crates/dns-api/src/{handlers,lib}.rs`). The remote public `master` revision was not revalidated for this package; check compatibility when upgrading the Rust server. All native operations go through the real `/api/v1/...` endpoints. URLs such as `/servers`, `/configuration/multi-server`, and `/ui/telemetry` are **Go panel routes, not EasyDNS API endpoints**.
- [API-MAPPING.md](API-MAPPING.md): szczegółowe mapowanie ekranów do oryginalnych endpointów i pól JSON.
- [UI-STRUCTURE.md](UI-STRUCTURE.md): menu, przepływy i zachowania formularzy.
- [API-GAPS.md](API-GAPS.md): nieobsługiwane funkcje i różnice wobec koncepcyjnych grafik.
- [DESIGN-SYSTEM.md](DESIGN-SYSTEM.md): paleta OLED, komponenty, typografia, wykresy.
- [SECURITY.md](SECURITY.md): model uwierzytelniania, token, TLS, uprawnienia.
`GET /api/v1/stats` supplies counters and latency snapshots, not a 24-hour server history. The panel polls every 15 seconds and stores up to 1,440 genuine samples per selected server (up to six hours), in memory. History disappears after restarting the panel. There is no query-log API, transfer queue progress, native cluster membership, or CRUD for Views/ACL/rate-limiting. See [API-GAPS.md](API-GAPS.md).
### Ograniczenia danych telemetrycznych
## Documentation
`GET /api/v1/stats` zwraca liczniki bieżące i kwantyle opóźnień, **nie** pełną historię 24h. Go zbiera pomiary co 15 sekund i utrzymuje ostatnie 1440 próbek (**do 6 godzin**, w RAM). Na wykresach **nie pojawiają się sztuczne wartości**, a historia znika po restarcie panelu. Polityki / Views / ACL / Rate Limiting i DNSSEC mają ograniczoną możliwość edycji, zgodnie z `API-GAPS.md`.
- [MULTI-SERVER.md](MULTI-SERVER.md) — optional server management, topology and setup.
- [API-MAPPING.md](API-MAPPING.md) — REST routes, JSON fields and UI actions.
- [UI-STRUCTURE.md](UI-STRUCTURE.md) — navigation and form interactions.
- [API-GAPS.md](API-GAPS.md) — unsupported or read-only operations.
- [DESIGN-SYSTEM.md](DESIGN-SYSTEM.md) — OLED tokens, density and controls.
- [SECURITY.md](SECURITY.md) — login, secrets, HTTPS and trust boundaries.
## Licencje
Kod panelu: MIT (patrz `LICENSE`). Bootstrap CSS: MIT, informacje w `THIRD-PARTY-NOTICES.md`. RustProxy był **inspiracją stylistyczną**, nie jest komponentem tego projektu i nie jest dołączony do repozytorium.
Panel source: MIT. Embedded Bootstrap CSS: MIT, see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md). RustProxy is a visual reference only and is not included as a dependency.