Viewer: listen-only APRS region and project links

- APRS-IS station positions for one bounded region, receive-only;
  beacon text and raw packets are never published
- Top-right links to GitHub, Discussions and the token page
- Launcher tests

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
BigBodyCobainandClaude Fable 5.2 committed 2026-11-23 07:40:35 -07:00
1 parent 89f4bb14d4
commit ea27721840
6 files changed
+188 -18

No files matched your search

+28 -1
View File
@@ -32,7 +32,7 @@ def test_real_policy_file_loads_and_withholds_private_layers():
for key in ("stocks", "telegram_osint", "liveuamap", "trending_markets", "crowdthreat"):
assert not policy.is_public(key, "fast") and not policy.is_public(key, "slow"), key
# Every engine switch that feeds a withheld or private surface stays off.
for gate in ("ai_intel", "sar", "sigint_aprs", "telegram_osint", "road_corridor_trends"):
for gate in ("ai_intel", "sar", "telegram_osint", "road_corridor_trends", "gt_risk"):
assert policy.engine_layers[gate] is False, gate
@@ -205,3 +205,30 @@ def test_real_policy_publishes_cameras_direct_only():
rule = policy.rule("cctv")
assert policy.is_public("cctv", "fast") and rule["direct_media"]["drop_types"] == ["hls"]
assert policy.engine_layers["cctv"] is True
def test_real_policy_publishes_radio_positions_without_any_text(tmp_path):
policy = br.Policy.load(br.DEFAULT_POLICY)
bridge = br.Bridge(policy, br.DirPublisher(tmp_path), set())
payload = {
"sigint": [
{
"source": "aprs",
"callsign": "N0CALL-9",
"lat": 40.7,
"lng": -74.0,
"symbol": "/>",
"comment": "on my way home",
"status": "QRV",
"raw_message": "N0CALL-9>APRS:!4042.00N/07400.00W>on my way home",
"emergency_keyword": "help",
},
{"source": "meshtastic", "callsign": "!abc", "lat": 1.0, "lng": 2.0, "text": "private chat"},
{"source": "js8call", "callsign": "K1ABC", "lat": 3.0, "lng": 4.0},
]
}
bridge.publish_tier("fast", payload)
assert _read(tmp_path, "fast.json")["sigint"] == [
{"source": "aprs", "callsign": "N0CALL-9", "lat": 40.7, "lng": -74.0, "symbol": "/>"},
{"source": "meshtastic", "callsign": "!abc", "lat": 1.0, "lng": 2.0},
]
+48 -1
View File
@@ -37,7 +37,6 @@ PUBLIC_ENGINE_ENV = {
"MESH_INFONET_RELAY_AUTO_WORMHOLE": "false",
"MESH_INFONET_ALLOW_CLEARNET_SYNC": "false",
"MESH_MQTT_ENABLED": "false",
"APRS_IS_ENABLED": "false",
"OPENCLAW_ACCESS_TIER": "restricted",
# No background transport warm-up.
"MESH_PRIVACY_PREWARM_ENABLE": "false",
@@ -107,6 +106,7 @@ def main() -> int:
for key, value in PUBLIC_ENGINE_ENV.items():
os.environ[key] = value
print(f"[public-engine] APRS listen: {apply_aprs_listen(policy_path)}")
# The dev "bind all interfaces" switch must never apply here.
os.environ.pop("SHADOWBROKER_DEV_BIND_ALL", None)
os.environ["BACKEND_PORT"] = str(args.port)
@@ -157,6 +157,53 @@ def borrow_feed_keys(env_file: Path, policy_path: Path) -> list[str]:
return loaded
APRS_MAX_RADIUS_KM = 500.0
_APRS_ENV_NAMES = (
"APRS_IS_HOST",
"APRS_IS_PORT",
"APRS_IS_FILTER",
"APRS_IS_PRIVATE_SERVER",
"APRS_IS_CALLSIGN",
"APRS_IS_LAT",
"APRS_IS_LON",
"APRS_IS_RADIUS_KM",
)
def apply_aprs_listen(policy_path: Path, environ: dict | None = None) -> str:
"""Configure listen-only APRS-IS from public-layers.json. Returns a summary.
Receive only: the login uses the no-transmit passcode, a generic callsign
and the public server, for one bounded region. Anything else in the
environment that could widen or redirect it is cleared.
"""
import json
env = os.environ if environ is None else environ
for name in _APRS_ENV_NAMES:
env.pop(name, None)
env["APRS_IS_ENABLED"] = "false"
cfg = json.loads(policy_path.read_text(encoding="utf-8")).get("aprs_listen") or {}
if not cfg.get("enabled"):
return "off"
try:
lat = float(cfg["lat"])
lon = float(cfg["lon"])
radius = float(cfg.get("radius_km", 100))
except (KeyError, TypeError, ValueError):
return "off (aprs_listen needs numeric lat, lon and radius_km)"
if not (-90.0 <= lat <= 90.0 and -180.0 <= lon <= 180.0):
return "off (aprs_listen lat/lon out of range)"
radius = max(1.0, min(radius, APRS_MAX_RADIUS_KM))
env["APRS_IS_ENABLED"] = "true"
env["APRS_IS_LAT"] = f"{lat:.5f}"
env["APRS_IS_LON"] = f"{lon:.5f}"
env["APRS_IS_RADIUS_KM"] = f"{radius:g}"
env["APRS_IS_CALLSIGN"] = "N0CALL"
return f"on, {radius:g} km around {lat:.2f}, {lon:.2f}"
def apply_public_layers(policy_path: Path) -> None:
"""Set the backend's fetcher switches from viewer/public-layers.json.
+66
View File
@@ -0,0 +1,66 @@
"""Tests for the public engine launcher. Run: python -m pytest viewer/engine -q"""
from __future__ import annotations
import json
import os
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
import run_public_engine as launcher # noqa: E402
def _policy(tmp_path, **aprs):
path = tmp_path / "public-layers.json"
path.write_text(json.dumps({"aprs_listen": aprs, "engine_keys": ["AIS_API_KEY"]}), encoding="utf-8")
return path
def test_aprs_listen_is_receive_only_and_bounded(tmp_path):
env = {
"APRS_IS_PRIVATE_SERVER": "true",
"APRS_IS_FILTER": "t/poimqstunw",
"APRS_IS_HOST": "example.invalid",
"APRS_IS_CALLSIGN": "W1AW",
}
summary = launcher.apply_aprs_listen(_policy(tmp_path, enabled=True, lat=40.7, lon=-74.0, radius_km=9000), env)
assert summary.startswith("on, 500 km")
assert env["APRS_IS_ENABLED"] == "true"
assert env["APRS_IS_RADIUS_KM"] == "500"
assert env["APRS_IS_CALLSIGN"] == "N0CALL"
# Nothing inherited that could widen the feed or point it elsewhere.
for name in ("APRS_IS_PRIVATE_SERVER", "APRS_IS_FILTER", "APRS_IS_HOST"):
assert name not in env
def test_aprs_listen_off_by_default_and_on_bad_input(tmp_path):
env = {"APRS_IS_ENABLED": "true", "APRS_IS_LAT": "1", "APRS_IS_LON": "2"}
assert launcher.apply_aprs_listen(_policy(tmp_path), env) == "off"
assert env == {"APRS_IS_ENABLED": "false"}
for bad in ({"enabled": True}, {"enabled": True, "lat": "x", "lon": 1}, {"enabled": True, "lat": 95, "lon": 0}):
env = {}
assert launcher.apply_aprs_listen(_policy(tmp_path, **bad), env).startswith("off")
assert env == {"APRS_IS_ENABLED": "false"}
def test_borrow_feed_keys_reads_only_listed_names(tmp_path, monkeypatch):
env_file = tmp_path / "other-install.env"
env_file.write_text("AIS_API_KEY=ais-value-123\nADMIN_KEY=admin-value-456\nexport OTHER=x\n", encoding="utf-8")
monkeypatch.delenv("AIS_API_KEY", raising=False)
monkeypatch.delenv("ADMIN_KEY", raising=False)
try:
loaded = launcher.borrow_feed_keys(env_file, _policy(tmp_path))
assert loaded == ["AIS_API_KEY"]
assert os.environ["AIS_API_KEY"] == "ais-value-123"
assert "ADMIN_KEY" not in os.environ
finally:
os.environ.pop("AIS_API_KEY", None)
def test_real_policy_aprs_region_is_valid():
cfg = json.loads((Path(__file__).resolve().parents[1] / "public-layers.json").read_text(encoding="utf-8"))
aprs = cfg["aprs_listen"]
assert 1 <= aprs["radius_km"] <= launcher.APRS_MAX_RADIUS_KM
assert -90 <= aprs["lat"] <= 90 and -180 <= aprs["lon"] <= 180
+17 -4
View File
@@ -2,6 +2,7 @@
"_comment": [
"The single list of what the public viewer may show.",
"engine_keys: the only key names the engine may borrow from another install's .env (--keys-from).",
"aprs_listen: one listen-only APRS-IS region (max 500 km). Nothing is ever sent.",
"engine_layers: fetcher switches forced on the public engine at start.",
"keys: top-level data keys the bridge may publish. Anything not listed, or",
"listed with public=false, never leaves the engine machine.",
@@ -15,6 +16,13 @@
"FIRMS_MAP_KEY",
"GFW_API_TOKEN"
],
"aprs_listen": {
"_comment": "Listen-only APRS-IS station positions for ONE region. The app caps public APRS-IS at a 500 km radius. Use a neutral city, never the owner's own location: this file is public.",
"enabled": true,
"lat": 40.7128,
"lon": -74.006,
"radius_km": 500
},
"engine_layers": {
"flights": true,
"private": true,
@@ -39,7 +47,7 @@
"datacenters": true,
"military_bases": true,
"sigint_meshtastic": true,
"sigint_aprs": false,
"sigint_aprs": true,
"weather_alerts": true,
"air_quality": true,
"volcanoes": true,
@@ -117,9 +125,10 @@
"sigint": {
"tier": "fast",
"public": true,
"why": "Node positions only. Message text never leaves the engine.",
"why": "Station and node positions only. Message text, beacon comments and raw packets never leave the engine.",
"only_sources": [
"meshtastic"
"meshtastic",
"aprs"
],
"drop_fields": [
"text",
@@ -127,7 +136,11 @@
"msg",
"payload",
"raw",
"channel"
"raw_message",
"channel",
"comment",
"status",
"emergency_keyword"
]
},
"sigint_totals": {
+18 -11
View File
@@ -2,7 +2,7 @@
import React, { useEffect, useState } from 'react';
import { Eye, Info, X, Target, AlertTriangle, Minus, Wrench, ExternalLink } from 'lucide-react';
import { VIEWER_REPO_URL } from './config';
import { VIEWER_LINKS } from './config';
import { feedAgeMs, feedIsStale, useFeedStatus } from './feedStatus';
function useNow(intervalMs: number): number {
@@ -53,7 +53,7 @@ export function ViewerHeaderCard({ onAbout }: { onAbout: () => void }) {
: `Live · updated ${ageLabel(age ?? 0)}`}
</span>
</div>
<div className="mt-2.5 flex items-center gap-2">
<div className="mt-2.5 flex flex-wrap items-center gap-2">
<button
type="button"
onClick={onAbout}
@@ -62,15 +62,19 @@ export function ViewerHeaderCard({ onAbout }: { onAbout: () => void }) {
<Info size={12} aria-hidden="true" />
About &amp; sources
</button>
<a
href={VIEWER_REPO_URL}
target="_blank"
rel="noopener noreferrer"
className="sb-chip flex items-center gap-1.5 px-3 py-1.5 text-[10.5px] font-mono tracking-[0.14em] uppercase text-cyan-300 hover:text-cyan-100"
>
<ExternalLink size={12} aria-hidden="true" />
Run the full app
</a>
{VIEWER_LINKS.map((link) => (
<a
key={link.href}
href={link.href}
title={link.title}
target="_blank"
rel="noopener noreferrer"
className="sb-chip flex items-center gap-1.5 px-3 py-1.5 text-[10.5px] font-mono tracking-[0.14em] uppercase text-cyan-300 hover:text-cyan-100"
>
<ExternalLink size={12} aria-hidden="true" />
{link.label}
</a>
))}
</div>
</div>
);
@@ -181,6 +185,9 @@ const SOURCES: { name: string; what: string; href: string }[] = [
{ name: 'NASA FIRMS / GIBS', what: 'Fires and satellite imagery', href: 'https://earthdata.nasa.gov' },
{ name: 'GDELT Project', what: 'Global incidents', href: 'https://www.gdeltproject.org' },
{ name: 'Meshtastic map (Liam Cottle)', what: 'Public mesh node positions', href: 'https://meshtastic.liamcottle.net' },
{ name: 'APRS-IS', what: 'Amateur radio station positions (one region, listen-only)', href: 'https://www.aprs-is.net' },
{ name: 'KiwiSDR / OpenMHZ', what: 'Receiver and scanner locations; you listen on their sites', href: 'http://kiwisdr.com' },
{ name: 'Public traffic agencies', what: 'Road cameras, loaded from each agency directly', href: 'https://github.com/BigBodyCobain/Shadowbroker' },
{ name: 'OpenFreeMap / OpenMapTiles / OpenStreetMap', what: 'Basemap', href: 'https://openfreemap.org' },
{ name: 'Esri World Imagery', what: 'Satellite basemap', href: 'https://www.esri.com' },
{ name: 'Wikipedia', what: 'Summaries (CC BY-SA)', href: 'https://www.wikipedia.org' },
+11 -1
View File
@@ -26,7 +26,6 @@ export const VIEWER_HIDDEN_LAYERS: ReadonlySet<string> = new Set([
'ai_intel', // the owner's private pins
'sar', // the owner's watch areas
'road_corridor_trends', // starts jobs on the owner's server
'sigint_aprs', // not published
'telegram_osint', // media is relayed through the owner's server
'crowdthreat', // not published
'gt_risk', // not published
@@ -36,3 +35,14 @@ export const VIEWER_HIDDEN_LAYERS: ReadonlySet<string> = new Set([
export const VIEWER_STALE_AFTER_MS = 4 * 60 * 1000;
export const VIEWER_REPO_URL = 'https://github.com/BigBodyCobain/Shadowbroker';
/** Top-right links. Each opens the project's own page on that site in a new tab. */
export const VIEWER_LINKS: readonly { label: string; title: string; href: string }[] = [
{ label: 'GitHub', title: 'Source code, and the full app to run yourself', href: VIEWER_REPO_URL },
{ label: 'Discussions', title: 'Project discussion board', href: `${VIEWER_REPO_URL}/discussions` },
{
label: 'pump.fun',
title: 'The project token page on pump.fun',
href: 'https://pump.fun/coin/8Uk9f5WfJndkC9VkFRLDwEpHgD2KD8BcFbqh5zuBpump',
},
];