mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-06-13 01:34:45 +02:00
7a0aec7b60
Adds a new read-only endpoint that serves the bundled `repeater/presets/*.yaml`
catalogue so the admin UI can render a network picker without bundling its own
copy of the broker dicts. The UI side of this is paired with
pyMC-dev/pyMC-RepeaterUI#TBD which retires src/assets/broker-templates.json
in favour of authClient.get('/api/broker_presets').
Why
The UI previously shipped a separate JSON snapshot of every supported MC2MQTT
network. The JSON and these YAML files drifted: the Waev entry on the UI side
pointed at mqtt-a.waev.app with audience mqtt.waev.app (single primary, no
failover) while the YAML side here listed two brokers (A + B). The result was
that operators picking 'Waev' from the dropdown silently lost the redundancy
this preset is meant to provide.
What changes
repeater/presets/*.yaml
- Add optional top-level `display_name` and `website` fields. The loader
treats them as advisory metadata for the UI; the runtime connection code
never reads them. `display_name` falls back to the titlecased filename
stem if absent so existing third-party presets keep rendering.
repeater/presets/waev.yaml
- Collapse from two broker entries (waev-a, waev-b) to a single broker on
`mqtt.waev.app`. The Waev edge Worker (see waev/src/router.ts:
MQTT_PRIMARY_FAILOVER_TIMEOUT_MS) already does server-side A/B failover on
the alias host with a 1500 ms timeout. Two independent client connections
would defeat the dedup-on-pubkey-hash contract on the waev ingest side.
Operators who want to pin to a specific container can edit host/audience
after import.
repeater/presets/meshmapper.yaml (new)
- Port of the historical MeshMapper entry from the UI's deprecated JSON.
Single broker on mqtt.meshmapper.cc, format: letsmesh (matches the
published wire contract; bump to a dedicated value if/when wire-level
differentiation lands).
repeater/web/api_endpoints.py
- New `broker_presets` CherryPy handler at `GET /api/broker_presets`.
Unauthenticated to match the existing `mqtt_status` precedent — the
response carries only public hostnames + TLS hints, no PII. Imports the
presets module lazily so a broken YAML never blocks process startup.
Response shape:
{
success: true,
data: [{ id, name, website?, brokers: [ ... raw YAML dicts ... ] }, …]
}
tests/test_presets.py
- Locks the new metadata fields (display_name, website) on all three presets.
- Locks the Waev single-alias-broker design with an explicit comment tying
the test to the waev Worker failover code.
- Adds MeshMapper coverage parallel to the other public-network presets.
- Adds a stub-instance test that drives the new `broker_presets` method on
an APIEndpoints stand-in (bypassing the heavyweight `__init__`) and
asserts the UI-ready response shape.
Verification
- New endpoint serves the expected three presets (letsmesh: 2 brokers,
meshmapper: 1, waev: 1) when exercised end-to-end against a local mock
that imports the real preset loader.
- Existing legacy-config migration tests (broker_index 0/1/-1 → preset +
overrides) still pass — the override pipeline is untouched.
Co-Authored-By: Oz <oz-agent@warp.dev>
45 lines
1.4 KiB
YAML
45 lines
1.4 KiB
YAML
# LetsMesh MC2MQTT broker preset.
|
|
#
|
|
# LetsMesh is the operator of the public MeshCore Packet Analyzer
|
|
# infrastructure. These brokers speak the MeshCoreToMQTT (MC2MQTT)
|
|
# protocol with the "letsmesh" format flavor, which today shares the
|
|
# canonical MC2MQTT topic structure (meshcore/{IATA}/{PUBLIC_KEY}/...).
|
|
#
|
|
# Reference all LetsMesh endpoints with: brokers: [{preset: letsmesh}]
|
|
#
|
|
# Note: order matters for backward compatibility with the legacy
|
|
# letsmesh.broker_index field. Index 0 is Europe, index 1 is US West.
|
|
#
|
|
# Optional UI metadata. Consumed by the GET /api/broker_presets endpoint
|
|
# so the React/Vue admin can render this preset in the "From Template"
|
|
# dropdown. `display_name` and `website` are advisory only — they are
|
|
# never read by the runtime broker connection code.
|
|
display_name: "LetsMesh"
|
|
website: "https://letsmesh.net"
|
|
brokers:
|
|
- name: "Europe (LetsMesh v1)"
|
|
enabled: true
|
|
host: mqtt-eu-v1.letsmesh.net
|
|
port: 443
|
|
transport: "websockets"
|
|
audience: "mqtt-eu-v1.letsmesh.net"
|
|
use_jwt_auth: true
|
|
format: letsmesh
|
|
retain_status: false
|
|
tls:
|
|
enabled: true
|
|
insecure: false
|
|
|
|
- name: "US West (LetsMesh v1)"
|
|
enabled: true
|
|
host: mqtt-us-v1.letsmesh.net
|
|
port: 443
|
|
transport: "websockets"
|
|
audience: "mqtt-us-v1.letsmesh.net"
|
|
use_jwt_auth: true
|
|
format: letsmesh
|
|
retain_status: false
|
|
tls:
|
|
enabled: true
|
|
insecure: false
|