diff --git a/README.md b/README.md index 59841c0..8aa4fc9 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,12 @@ interzone servers over IPFS.

Managing the server's users

Users: totals, a card per person, search, filter and sort. + +

The server's dashboard

+Dashboard: CPU, memory, disk, containers and certificates, live. +

The IPFS swarm's map of Iran

+IPFS swarm: every node sharing the mirror, placed on a map of Iran, with what each sends and receives. + ## Community diff --git a/docs/screenshots/dashboard.png b/docs/screenshots/dashboard.png new file mode 100644 index 0000000..8208193 Binary files /dev/null and b/docs/screenshots/dashboard.png differ diff --git a/docs/screenshots/host-map.png b/docs/screenshots/host-map.png new file mode 100644 index 0000000..c39b7ee Binary files /dev/null and b/docs/screenshots/host-map.png differ diff --git a/internal/ui/layout_test.go b/internal/ui/layout_test.go index 822434d..11e304a 100644 --- a/internal/ui/layout_test.go +++ b/internal/ui/layout_test.go @@ -114,28 +114,7 @@ func TestLayout(t *testing.T) { PublishedParts: []deploy.HostPart{{Name: "packages", Size: 3 << 30, Pinned: false}, {Name: "oci", Size: 15 << 30, Pinned: false}, {Name: "git", Size: 200 << 20, Pinned: true}, {Name: "bin", Size: 300 << 20, Pinned: true}}, Last: "fetching bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi"} }}, - {"host-map", func(a *App) { - localMirror.Store(true) // shootAll clears it - a.jump(a.index("Host")) - hs := a.cur().(*hostScreen) - hs.statsFor, hs.phase = targetKey(hs.target()), 1.3 - ip := netip.MustParseAddr - hs.stats = &deploy.HostStats{Installed: true, Active: true, Mirror: "ipfs", Parts: []string{"oci", "packages", "git", "bin"}, Peers: 4, - RepoSize: 19 << 30, DiskFree: 80 << 30, RateIn: 2e5, RateOut: 3e6, TotalIn: 6 << 30, TotalOut: 40 << 30, - DataSent: 38 << 30, DataReceived: 1 << 30, Published: "2026-10-29T03:00:00Z", - PublishedParts: []deploy.HostPart{{Name: "oci", Pinned: true}, {Name: "packages", Pinned: true}, {Name: "git", Pinned: true}, {Name: "bin", Pinned: true}}, - Self: []netip.Addr{ip("2.176.0.1")}, PeerList: []deploy.Peer{ - {ID: "a", Addr: ip("5.160.0.1"), Sent: 9 << 30, Latency: 41 * time.Millisecond, Inbound: true}, - {ID: "b", Addr: ip("81.169.145.1"), Sent: 2 << 30, Latency: 120 * time.Millisecond}, - {ID: "c", Addr: ip("10.0.0.1"), Recv: 1 << 20}, - {ID: "d", Addr: ip("2.176.200.1"), Latency: 18 * time.Millisecond}}} - hs.in, hs.out = []float64{0, 1e5, 2e5}, []float64{1e6, 4e6, 3e6} - hs.rates = map[string]peerRate{"a": {out: 2e6}, "b": {out: 1e6}} - hs.peerHist = map[string][]float64{"a": {1e6, 3e6, 2e6}, "b": {0, 1e6, 1e6}} - at := time.Date(2026, 10, 29, 14, 5, 0, 0, time.UTC) - hs.comings = []hostComing{{at, hs.stats.PeerList[3], true}, {at.Add(time.Minute), deploy.Peer{Addr: ip("8.8.8.8")}, false}} - hs.ripples = []ripple{{addr: ip("2.176.200.1"), start: 0.5, join: true}} - }}, + {"host-map", openHostMap}, {"maintenance", func(a *App) { deliver(a, maintainMsg("vacuum")) }}, {"users-bridge", func(a *App) { openUsers(a) @@ -157,6 +136,29 @@ func TestLayoutWide(t *testing.T) { }{{"dashboard", openDashboard}, {"mirrors", openMirrors}, {"users", openUsers}}) } +func openHostMap(a *App) { + localMirror.Store(true) // shootAll clears it + a.jump(a.index("Host")) + hs := a.cur().(*hostScreen) + hs.statsFor, hs.phase = targetKey(hs.target()), 1.3 + ip := netip.MustParseAddr + hs.stats = &deploy.HostStats{Installed: true, Active: true, Mirror: "ipfs", Parts: []string{"oci", "packages", "git", "bin"}, Peers: 4, + RepoSize: 19 << 30, DiskFree: 80 << 30, RateIn: 2e5, RateOut: 3e6, TotalIn: 6 << 30, TotalOut: 40 << 30, + DataSent: 38 << 30, DataReceived: 1 << 30, Published: "2026-10-29T03:00:00Z", + PublishedParts: []deploy.HostPart{{Name: "oci", Pinned: true}, {Name: "packages", Pinned: true}, {Name: "git", Pinned: true}, {Name: "bin", Pinned: true}}, + Self: []netip.Addr{ip("2.176.0.1")}, PeerList: []deploy.Peer{ + {ID: "a", Addr: ip("5.160.0.1"), Sent: 9 << 30, Latency: 41 * time.Millisecond, Inbound: true}, + {ID: "b", Addr: ip("81.169.145.1"), Sent: 2 << 30, Latency: 120 * time.Millisecond}, + {ID: "c", Addr: ip("10.0.0.1"), Recv: 1 << 20}, + {ID: "d", Addr: ip("2.176.200.1"), Latency: 18 * time.Millisecond}}} + hs.in, hs.out = []float64{0, 1e5, 2e5}, []float64{1e6, 4e6, 3e6} + hs.rates = map[string]peerRate{"a": {out: 2e6}, "b": {out: 1e6}} + hs.peerHist = map[string][]float64{"a": {1e6, 3e6, 2e6}, "b": {0, 1e6, 1e6}} + at := time.Date(2026, 10, 29, 14, 5, 0, 0, time.UTC) + hs.comings = []hostComing{{at, hs.stats.PeerList[3], true}, {at.Add(time.Minute), deploy.Peer{Addr: ip("8.8.8.8")}, false}} + hs.ripples = []ripple{{addr: ip("2.176.200.1"), start: 0.5, join: true}} +} + func openDashboard(a *App) { a.jump(a.index("Dashboard")) ds := a.cur().(*dashboardScreen) diff --git a/internal/ui/shot_test.go b/internal/ui/shot_test.go index 9b4d2cb..df8f695 100644 --- a/internal/ui/shot_test.go +++ b/internal/ui/shot_test.go @@ -1,6 +1,7 @@ package ui import ( + "net/netip" "os" "path/filepath" "strings" @@ -28,6 +29,32 @@ func TestShot(t *testing.T) { open func(*App) }{ {"users", openUsers}, + {"dashboard", openDashboard}, + // The README's map: the sample swarm with more nodes across Iran. + {"host-map", func(a *App) { + openHostMap(a) + hs := a.cur().(*hostScreen) + ip := netip.MustParseAddr + for i, p := range []struct { + addr string + ms time.Duration + sent, in, out float64 + }{ + {"2.180.0.1", 62, 7e9, 0, 4e6}, {"2.182.32.1", 55, 5e9, 0, 2e6}, {"2.182.214.1", 48, 4e9, 3e5, 1e6}, + {"2.182.169.1", 30, 3e9, 0, 0}, {"2.183.156.1", 70, 2e9, 2e6, 0}, {"2.183.80.1", 38, 2e9, 0, 5e5}, + {"2.184.160.1", 90, 1e9, 0, 0}, {"2.181.112.1", 110, 8e8, 1e6, 0}, {"2.183.131.1", 75, 6e8, 0, 0}, + {"2.187.32.1", 66, 4e8, 0, 3e5}, {"2.183.0.1", 58, 3e8, 0, 0}, + } { + id := string(rune('e' + i)) + hs.stats.PeerList = append(hs.stats.PeerList, deploy.Peer{ID: id, Addr: ip(p.addr), Sent: int64(p.sent), Latency: p.ms * time.Millisecond, Inbound: i%3 == 0}) + if p.in+p.out > 0 { + hs.rates[id] = peerRate{in: p.in, out: p.out} + hs.peerHist[id] = []float64{p.out / 2, p.in + p.out, (p.in + p.out) * 0.8} + } + } + hs.stats.Peers = len(hs.stats.PeerList) + hs.ripples = append(hs.ripples, ripple{addr: ip("2.183.80.1"), start: 0.2, join: true}) + }}, // The wiki's guide, on the Friends & family preset. {"wiki-confirm", func(a *App) { a.cfg.Target = config.Target{Mode: "ssh", Host: "192.0.2.1", User: "root"} @@ -124,6 +151,7 @@ func TestShot(t *testing.T) { } } lipgloss.SetColorProfile(termenv.Ascii) + localMirror.Store(false) } // fakeDeploy shows a first install part way through, or finished, without diff --git a/scripts/screenshots/shots.sh b/scripts/screenshots/shots.sh index 7da7dbd..be4e065 100755 --- a/scripts/screenshots/shots.sh +++ b/scripts/screenshots/shots.sh @@ -10,8 +10,8 @@ # scripts/screenshots/shots.sh grab NAME [WIDTH] save the session's screen as NAME.png # (1400 px wide; phone shots: WIDTH 0) # scripts/screenshots/shots.sh phone A B C join three phone shots into phone.png -# scripts/screenshots/shots.sh users draw users.png from the layout tests' -# sample people (no server needed) +# scripts/screenshots/shots.sh users draw users.png, dashboard.png and host-map.png +# from the layout tests' sample data (no server needed) # scripts/screenshots/shots.sh stop # # Drive the session between grabs with tmux send-keys or tmux attach -t shot. @@ -77,7 +77,9 @@ phone() { users() { mkdir -p "$work/raw" (cd "$repo" && INTERZONE_SHOT="$work/raw" go test ./internal/ui -run '^TestShot$' -count=1 >/dev/null) - python3 "$repo/scripts/screenshots/render.py" "$work/raw/users.ans" "$out/users.png" 1400 + for n in users dashboard host-map; do + python3 "$repo/scripts/screenshots/render.py" "$work/raw/$n.ans" "$out/$n.png" 1400 + done } stop() {