feat!: Urutau 2.0.0, ultralight probes and a single analysis hub
CI / Format and vet (pull_request) Failing after 53s
CI / Dependency audit (pull_request) Successful in 33s
CI / Tests (Linux, race detector) (pull_request) Successful in 2m1s
CI / Docker images (build and smoke test) (pull_request) Failing after 47s

Each server runs an ultralight probe (scratch image, ~7 MiB RSS) that
tails the logs, ships raw lines to the hub over HTTPS with an on-disk
spool, and applies enforce decisions locally. The hub keeps one node per
probe (primary node = the 1.x data dir, unchanged), does all analysis and
serves the UI. Peer federation is removed. 'urutau import' brings 1.x
data dirs in with hash and count verification. UI: probes page, host
qualified incidents, IPs never wrap, egress heatmap labels, live and
replay globes no longer auto-rotate, replay repeat, live traffic metrics.

BREAKING CHANGE: URUTAU_PEERS, URUTAU_PEER_* and /api/v1/peer/* are gone;
log path variables move from the hub to the probe. See docs/migration-2.0.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-15 22:14:50 -03:00
1 parent 23a7a5963a
commit 8546d14cef
130 files changed
+9396 -3311

No files matched your search

+3 -3
View File
@@ -90,7 +90,7 @@ func TestParse(t *testing.T) {
func TestWorkloadsAndContainers(t *testing.T) {
e := newEng(t, Config{Workloads: "ciberlab=name:jhxint9g9uz91:scanner;mail=10.0.7.0/24,10.0.8.4/32:mail;lab=10.0.5.0/24"})
e.SetContainers(map[netip.Addr]string{ip("172.18.0.4"): "jhxint9g9uz91-20260101123456", ip("172.18.0.9"): "runner-q620o15zg7-1700000000000"})
e.SetContainerMap(map[netip.Addr]string{ip("172.18.0.4"): "jhxint9g9uz91-20260101123456", ip("172.18.0.9"): "runner-q620o15zg7-1700000000000"})
cases := []struct {
ev Event
name, role string
@@ -108,7 +108,7 @@ func TestWorkloadsAndContainers(t *testing.T) {
}
}
// IP changes: the map in force at Ingest wins
e.SetContainers(map[netip.Addr]string{ip("172.18.0.5"): "jhxint9g9uz91-20260102000000"})
e.SetContainerMap(map[netip.Addr]string{ip("172.18.0.5"): "jhxint9g9uz91-20260102000000"})
if n, _ := e.resolve(mk(t0, "172.18.0.5", "1.1.1.1", "tcp", 1)); n != "ciberlab" {
t.Errorf("remap: %s", n)
}
@@ -460,7 +460,7 @@ func TestReportByCountry(t *testing.T) {
func TestNameMatchExactAndPrefix(t *testing.T) {
e := newEng(t, Config{Workloads: "a=name:web:default;b=name:api*:default;c=name:pay:default"})
e.SetContainers(map[netip.Addr]string{ip("172.18.0.1"): "web-1700000000000", ip("172.18.0.2"): "webshell-1700000000000",
e.SetContainerMap(map[netip.Addr]string{ip("172.18.0.1"): "web-1700000000000", ip("172.18.0.2"): "webshell-1700000000000",
ip("172.18.0.3"): "apigw-17", ip("172.18.0.4"): "pay", ip("172.18.0.5"): "payroll"})
for src, want := range map[string]string{"172.18.0.1": "a", "172.18.0.2": "webshell", "172.18.0.3": "b", "172.18.0.4": "c", "172.18.0.5": "payroll"} {
if n, _ := e.resolve(mk(t0, src, "1.1.1.1", "tcp", 1)); n != want {
+26 -3
View File
@@ -1,6 +1,7 @@
package egress
import (
"bytes"
"container/list"
"errors"
"fmt"
@@ -276,8 +277,12 @@ func readNameservers(path string) []netip.Addr {
if err != nil {
return nil
}
return parseNameservers(string(b))
}
func parseNameservers(text string) []netip.Addr {
var out []netip.Addr
for _, ln := range strings.Split(string(b), "\n") {
for _, ln := range strings.Split(text, "\n") {
f := strings.Fields(ln)
if len(f) >= 2 && f[0] == "nameserver" {
if a, err := netip.ParseAddr(f[1]); err == nil {
@@ -328,13 +333,31 @@ func (e *Engine) fanPromote(pk pairKey, t int64) *pairState {
return p
}
// SetContainers replaces the address to container-name map (tests, wiring).
func (e *Engine) SetContainers(m map[netip.Addr]string) {
// SetContainerMap replaces the address to container-name map (tests, wiring).
func (e *Engine) SetContainerMap(m map[netip.Addr]string) {
e.mu.Lock()
e.containers = m
e.mu.Unlock()
}
// SetContainers replaces the container map with the content of a
// containers.map file sent by a probe ("<ip> <name>" per line).
func (e *Engine) SetContainers(data []byte) {
m, _ := parseContainers(bytes.NewReader(data))
e.SetContainerMap(m)
}
// SetResolv adds the nameservers of a resolv.conf sent by a probe to the
// allowed resolvers (those of the configuration stay).
func (e *Engine) SetResolv(data []byte) {
ns := parseNameservers(string(data))
e.mu.Lock()
for _, a := range ns {
e.resolvers[a] = true
}
e.mu.Unlock()
}
func (e *Engine) reloadMap() {
if e.cfg.Containers == "" {
return
+22
View File
@@ -23,8 +23,24 @@ type Source struct {
Log *slog.Logger
backfilling atomic.Bool
fol atomic.Pointer[tail.Follower]
remote bool
rstate atomic.Pointer[string]
}
// NewRemoteSource creates a source fed by a probe through Feed: there is no
// file and nothing to start.
func NewRemoteSource(e *Engine, log *slog.Logger) *Source {
s := NewSource("", e, log)
s.remote = true
return s
}
// Feed analyses one line received from a probe.
func (s *Source) Feed(line []byte) { s.E.Ingest(line) }
// SetState sets the state shown for a remote source (following, waiting, error).
func (s *Source) SetState(st string) { s.rstate.Store(&st) }
// NewSource creates the source of e reading path.
func NewSource(path string, e *Engine, log *slog.Logger) *Source {
if log == nil {
@@ -37,6 +53,12 @@ func NewSource(path string, e *Engine, log *slog.Logger) *Source {
}
func (s *Source) state() string {
if s.remote {
if p := s.rstate.Load(); p != nil {
return *p
}
return "waiting"
}
switch f := s.fol.Load(); {
case s.backfilling.Load():
return "backfill"
+7 -1
View File
@@ -3,6 +3,7 @@ package egress
import (
"bufio"
"fmt"
"io"
"net/netip"
"os"
"regexp"
@@ -106,8 +107,13 @@ func LoadContainers(path string) (map[netip.Addr]string, error) {
return nil, err
}
defer fh.Close()
return parseContainers(fh)
}
// parseContainers reads the containers.map format from r.
func parseContainers(r io.Reader) (map[netip.Addr]string, error) {
m := map[netip.Addr]string{}
sc := bufio.NewScanner(fh)
sc := bufio.NewScanner(r)
sc.Buffer(make([]byte, 0, 4096), 4096)
for n := 0; sc.Scan() && n < maxMapLines; n++ {
f := strings.Fields(sc.Text())