mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-11-22 19:17:58 +00:00
Both features are OPT-IN ("los" and "planner" config blocks, default
off); with them off nothing is fetched and payloads are unchanged.
Route view
- Multi-path picker discoverability: on-map "N hops shown · tap to see
all" badge, picker pulse (reduced-motion safe), one-time tip, row hover
arrow; "no GPS" hops counted apart from "unresolved".
- Line of sight for every leg of a packet route: clear / marginal /
blocked chips (first-Fresnel clearance, k=4/3), obstruction markers on
the map, docked terrain-profile panel with antenna/frequency inputs and
a &los= deep link. Backed by GET /api/elevation/profile, an Open-Meteo
proxy that only accepts known node positions, with weighted budgets,
back-off and a per-IP limit.
Repeater planner (#/tools/planner)
- Chain: LOS on every leg between any number of points or nodes.
- Relay: best single relay for A→B among known repeaters and open
terrain.
- Area: suggested new repeater sites that best join the existing
repeater backbone in a box up to 100×100 km, picked greedily to merge
clusters, then remove single points of failure, then reach unlinked
repeaters.
- Terrain: SRTM 1° tiles from AWS Open Data, in memory only (~90 m,
bounded LRU); the server stays read-only. Exact-length gunzip, fetch
budget with back-off, missing terrain reported rather than read as sea
level, fuzzed pixel maths.
- GET /api/planner/{profile,relay,coverage}: quantised cache keys, 202 +
progress then cached 200, separate compute slots, per-IP and global
limits, failed jobs remembered, unpolled jobs cancelled. Nodes pass the
same blacklist / hidden-name / geo_filter rules as /api/nodes. The Go
LOS maths matches public/los.js on shared test vectors.
Also: the per-IP client limiter is extracted from elevation.go into
client_limit.go (behaviour-preserving) so both features share it.
Perf (real SRTM): coverage cold 1.5-5.6 s (tile download), warm 10 ms;
worst real compute 545 ms; peak RSS 91 MiB; live /api/nodes and
/api/packets p95 at most 1.6x while a job computes (GOMAXPROCS=2).
Tests: Go suites for elevation, terrain (fuzz), LOS vectors, graph
(brute-force property test), search and planner API; frontend unit
suites in test-all.sh; Playwright e2e for route LOS and the planner.
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: efiten <erwin.fiten@gmail.com>
85 lines
2.1 KiB
Go
85 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"log"
|
|
"net/http"
|
|
"strings"
|
|
"sync"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestClientLogID(t *testing.T) {
|
|
a, b := "198.51.100.20", "198.51.100.21"
|
|
ida, idb := clientLogID(a), clientLogID(b)
|
|
if ida != clientLogID(a) {
|
|
t.Error("ID must be stable within a process")
|
|
}
|
|
if ida == idb {
|
|
t.Error("different IPs must get different IDs")
|
|
}
|
|
if len(ida) != 12 {
|
|
t.Errorf("len = %d, want 12 hex chars", len(ida))
|
|
}
|
|
for ip, id := range map[string]string{a: ida, b: idb, "2001:db8::7": clientLogID("2001:db8::7")} {
|
|
if strings.Contains(id, ip) || strings.Trim(id, "0123456789abcdef") != "" {
|
|
t.Errorf("ID %q for %s must be bare hex with no IP in it", id, ip)
|
|
}
|
|
}
|
|
if clientLogID(clientSharedKey) != "shared" {
|
|
t.Error("clients that cannot be told apart must log as shared")
|
|
}
|
|
}
|
|
|
|
type lockedBuf struct {
|
|
mu sync.Mutex
|
|
b bytes.Buffer
|
|
}
|
|
|
|
func (l *lockedBuf) Write(p []byte) (int, error) {
|
|
l.mu.Lock()
|
|
defer l.mu.Unlock()
|
|
return l.b.Write(p)
|
|
}
|
|
|
|
func (l *lockedBuf) String() string {
|
|
l.mu.Lock()
|
|
defer l.mu.Unlock()
|
|
return l.b.String()
|
|
}
|
|
|
|
func TestPlannerJobLogHasNoClientIP(t *testing.T) {
|
|
h := newPlannerHarness(t)
|
|
h.p.fastWait = plannerFastWait
|
|
var buf lockedBuf
|
|
prev := log.Writer()
|
|
log.SetOutput(&buf)
|
|
defer log.SetOutput(prev)
|
|
|
|
ip := "198.51.100.77"
|
|
if w := h.get("/api/planner/profile?pts=30.1,-97.1,30.2,-97.0", ip); w.Code != http.StatusOK {
|
|
t.Fatalf("job: %d %s", w.Code, w.Body.String())
|
|
}
|
|
var line string
|
|
for deadline := time.Now().Add(5 * time.Second); time.Now().Before(deadline); time.Sleep(10 * time.Millisecond) {
|
|
for _, l := range strings.Split(buf.String(), "\n") {
|
|
if strings.Contains(l, "[planner]") && strings.Contains(l, "client=") && strings.Contains(l, "outcome=") {
|
|
line = l
|
|
}
|
|
}
|
|
if line != "" {
|
|
break
|
|
}
|
|
}
|
|
if line == "" {
|
|
t.Fatalf("no planner job log line; log: %q", buf.String())
|
|
}
|
|
if strings.Contains(buf.String(), ip) {
|
|
t.Errorf("log contains the client IP: %q", buf.String())
|
|
}
|
|
if !strings.Contains(line, "client="+clientLogID(ip)) {
|
|
t.Errorf("line %q lacks client=%s", line, clientLogID(ip))
|
|
}
|
|
}
|