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 19s
CI / Tests (Linux, race detector) (push) Successful in 35s
CI / Dependency audit (push) Successful in 16s
Release / ci (push) Successful in 35s
Release / Build image (arm64) (push) Successful in 51s
Release / Build image (amd64) (push) Successful in 1m11s
Release / Publish tags (push) Successful in 13s
Release / Gitea release (push) Skipped
A new console interface (side rail, seven pages, opening sentence and active slice on every page, IP drawer, light and dark design tokens); a Geography page that drills from the world to a country's regions and cities; a Live page drawing attacks as arcs on a flat map or a globe. Backend: GET /api/v1/geo, GET /api/v1/live/recent, host/src/dst on live events, --location, a strict static file pattern, and live federation through GET /api/v1/peer/stream (peer token only, bounded and sanitized relay on the hub). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
package store
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestParseLocation(t *testing.T) {
|
|
l, err := ParseLocation("-8.05, -34.9, Recife, PE")
|
|
if err != nil || l.Lat != -8.05 || l.Lon != -34.9 || l.Label != "Recife, PE" {
|
|
t.Fatal(l, err)
|
|
}
|
|
if l, err := ParseLocation(""); l != nil || err != nil {
|
|
t.Fatal("empty is unset")
|
|
}
|
|
for _, bad := range []string{"1", "a,b", "91,0", "0,181", "NaN,0", "0,0,x\x01y", "0,0," + strings.Repeat("a", 65)} {
|
|
if _, err := ParseLocation(bad); err == nil {
|
|
t.Errorf("%q must be refused", bad)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestPeerLocationAndLiveSanitize(t *testing.T) {
|
|
e := PeerExport{V: ExportVersion, Summary: Summary{Hosts: []HostInfo{{Name: "x", Location: &Location{Lat: 95, Lon: 0}}}}}
|
|
if e.Sanitize("24h"); e.Summary.Hosts[0].Location != nil {
|
|
t.Fatal("invalid location must be dropped")
|
|
}
|
|
e = PeerExport{V: ExportVersion, Summary: Summary{Hosts: []HostInfo{{Name: "x", Location: &Location{Lat: 1, Lon: 2, Label: "a\x00" + strings.Repeat("b", 100)}}}}}
|
|
e.Sanitize("24h")
|
|
if l := e.Summary.Hosts[0].Location; l == nil || len(l.Label) != 64 || strings.ContainsRune(l.Label, 0) {
|
|
t.Fatalf("%+v", l)
|
|
}
|
|
le := LiveEvent{FeedEvent: FeedEvent{IP: "::ffff:1.2.3.4", Cat: "scanner", T: 1}}
|
|
if !le.Sanitize(1_800_000_000) || le.IP != "1.2.3.4" || le.T != 1_800_000_000 {
|
|
t.Fatalf("%+v", le)
|
|
}
|
|
}
|