feat: Urutau 1.0.0, lightweight threat intelligence and web analytics
Release / Plan (reuse the published image?) (push) Successful in 4s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 1m29s
CI / Tests (Linux, race detector) (push) Failing after 1m48s
CI / Dependency audit (push) Successful in 21s
Release / ci (push) Failing after 1m50s
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Skipped
Release / Gitea release (push) Skipped

Always-on Go service (stdlib only) that follows the Traefik JSON access
log, the sshd log and the fail2ban log of a host, classifies attacks,
scores sources, keeps bounded aggregates with snapshots, and serves an
embedded dashboard with live updates, offline geolocation (DB-IP Lite),
privacy-friendly traffic analytics, an exportable blocklist and
token-authenticated federation between instances.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-14 16:13:34 -03:00
commit b4a2c2c9ec
99 files changed
+15403

No files matched your search

+84
View File
@@ -0,0 +1,84 @@
<p align="center"><a href="../README.md">◂ Back to README</a></p>
# Terminal
```
urutau serve [flags] run the daemon and the dashboard
urutau doctor [--json] [flags] check the sources and the data directory
urutau healthcheck [flags] exit 0 when the local daemon answers /api/health
urutau version print the version
urutau help print the usage
```
The access token is never a flag: `urutau serve` reads it from the `URUTAU_TOKEN` environment variable, or from the file named by `URUTAU_TOKEN_FILE`, so it does not show up in the process list. Tokens need at least 32 characters and about 128 bits of estimated entropy (length times Shannon entropy; periodic or sequential tokens are refused) (`openssl rand -base64 48` is recommended (`-hex 32` also works)). Every flag below has a `URUTAU_*` environment default; a flag wins over the variable. See [configuration.md](configuration.md).
## `urutau serve`
| Flag | Variable | Default | Meaning |
|---|---|---|---|
| `--bind` | `URUTAU_BIND` | `0.0.0.0:8790` | listen address |
| `--name` | `URUTAU_NAME` | hostname | name of this instance |
| `--data-dir` | `URUTAU_DATA_DIR` | `/data` | directory of the snapshot (`urutau-state.gob`) |
| `--traefik-log` | `URUTAU_TRAEFIK_LOG` | `/data/coolify/proxy/access.log` | Traefik JSON access log; empty disables |
| `--auth-log` | `URUTAU_AUTH_LOG` | `/var/log/auth.log` | sshd log; empty disables |
| `--fail2ban-log` | `URUTAU_FAIL2BAN_LOG` | `/var/log/fail2ban.log` | fail2ban log; empty disables |
| `--trusted` | `URUTAU_TRUSTED` | empty | CIDRs of trusted origins; their events are dropped entirely. `--ignore` / `URUTAU_IGNORE` is an alias |
| `--ignore` | `URUTAU_IGNORE` | `127.0.0.0/8,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7,fe80::/10,100.64.0.0/10,169.254.0.0/16` | same effect as `--trusted`, with the private ranges as default |
| `--monitor-ua` | `URUTAU_MONITOR_UA` | `(?i)^(Uptime-Kuma/\|Beszel\|Coolify\|kube-probe/\|Go-http-client/.*healthcheck)` | regular expression of monitoring User-Agents |
| `--monitor-from` | `URUTAU_MONITOR_FROM` | empty | CIDRs the monitors come from; when set, the monitoring User-Agent only counts from them. Empty: only `ok` answers are filtered |
| `--domains` | `URUTAU_DOMAINS` | empty | allowlist of analytics domains (exact or `*.example.com`); empty tracks every domain that answers 2xx; recommended when a backend answers 2xx for any Host |
| `--geo-dir` | `URUTAU_GEO_DIR` | `<data-dir>/geo` | directory of the DB-IP Lite databases (city and ASN) |
| `--geo-update` | `URUTAU_GEO_UPDATE` | `24h` | how often to check for a newer database; `0` turns the download off |
| `--peer` | `URUTAU_PEERS` | none | peer `name=https://url`; repeat the flag, or comma separate the variable |
| `--peer-token` | `URUTAU_PEER_TOKEN` | empty | token shared with the peers; prefer the variable or `URUTAU_PEER_TOKEN_FILE` (a flag shows up in the process list). Per-peer: `URUTAU_PEER_TOKEN_<NAME>` |
| `--admin-users` | `URUTAU_ADMIN_USERS` | empty | SSH users whose successful login keeps their IP out of the blocklist for 24 h; the immunity is off unless set |
| `--peer-allow` | `URUTAU_PEER_ALLOW` | empty | source CIDRs allowed to call the export; empty accepts any source with the token |
| `--trusted-proxy` | `URUTAU_TRUSTED_PROXY` | `127.0.0.0/8,::1` (the compose file sets `10.250.0.0/24`) | proxies whose `X-Forwarded-For` is trusted, read right to left (login rate limit, `--peer-allow`) |
| `--retention` | `URUTAU_RETENTION` | `168h` | how long data is kept (1h to 168h) |
| `--insecure-no-auth` | none | off | disable authentication; only on a loopback bind |
Validation at start: peers must be `name=https://host` (plain `http` only on loopback), `URUTAU_PEER_TOKEN` must be set and different from `URUTAU_TOKEN`, names must be unique and cannot be `all` or the instance's own name, `--retention` must be at least 1h, and `URUTAU_TOKEN` and every peer token must have at least 32 characters and about 128 bits of estimated entropy; each peer needs a client token (`URUTAU_PEER_TOKEN_<NAME>` or the general `URUTAU_PEER_TOKEN` as fallback), and peer names must not collide in that variable name (unless `--insecure-no-auth` on a loopback address).
```bash
export URUTAU_TOKEN=$(openssl rand -base64 48)
urutau serve --bind 127.0.0.1:8790 --data-dir ./data \
--traefik-log "" --auth-log /var/log/auth.log
```
The daemon logs to stderr, saves a snapshot on `SIGTERM` or `SIGINT` and exits 0 on a clean stop.
## Noise and monitoring
```bash
urutau serve --trusted "10.0.0.0/8,203.0.113.7" \
--monitor-ua '(?i)uptime-kuma|statuscake'
```
`--trusted` drops every event from those origins. `--monitor-ua` matches the User-Agent of benign requests (`ok` or `notfound`) and counts them apart as "monitoring"; a request that is a `scanner`, `exploit` or `bruteforce` still counts as an attack.
## Geolocation
```bash
urutau serve --geo-dir /data/geo --geo-update 24h
```
Urutau downloads the DB-IP Lite city and ASN databases into `--geo-dir` when they are missing or older than 35 days, then checks every `--geo-update` for the current month's file. The file is verified before it replaces the old one, and a failed download never stops the service. Data by [DB-IP](https://db-ip.com), CC BY 4.0.
## `urutau doctor`
Checks the configuration (token, peers, bind), each log source (readable, size), that the data directory is writable, the geolocation databases and the snapshot. Statuses are `ok`, `warn` (a source that cannot be opened yet), `fail` and `off` (disabled). The exit code is 1 when any check is `fail`, which makes it usable in a healthcheck or a deploy script.
```bash
urutau doctor
docker exec urutau urutau doctor --json
```
`--json` prints `{"version", "name", "ok", "checks": [{"name", "status", "detail"}], "geo", "state"}`. `geo` reports the directory, update interval, attribution and the build dates of the loaded databases; `state` reports the snapshot (path, size, IPs, domains and requests in 7 days) or that none exists yet. A snapshot that cannot be read shows up as `warn`.
## `urutau healthcheck`
Calls `/api/health` on the local bind address and exits 0 when it answers `{"status":"ok"}`, 1 otherwise. It is the container `HEALTHCHECK`, which is why the image has no `curl`. It accepts the same flags as `serve` (for a non-default `--bind`).
## `urutau version`
Prints `urutau <version>`. `--version` and `-v` work too.