Commit Graph
20 Commits
Author SHA1 Message Date
Audric 3d281e16d7 sat: full partner-node parity across reflector + satellites
Extends MsgTrunkNodeList (type 121) with a 7th vector `sat_ids` so a
parent reflector can advertise both its own clients (sat_id="") and
clients learned from each connected satellite (sat_id=<satellite_id>)
in a single message. The sat_id is recipient-relative — empty means
"on whoever sent this list" — so the same field is reused on the
trunk, twin and satellite paths without a global namespace.

Reflector::sendNodeListToAllPeers now builds a combined view (parent-
local + every connected satellite's stamped roster) and fans it out:
  - to trunks and twin: full combined list
  - to each satellite: combined minus that sat's own contribution,
    additionally filtered by SATELLITE_FILTER (self-echo guard +
    audio-path scoping)
  - up to the parent (when running as a satellite): local clients only

SatelliteLink (parent side) and SatelliteClient (sat side) gain
sendNodeList / handleMsgTrunkNodeList wired into the type-121 dispatch.
Parent stamps each ingested entry with the SatelliteLink's id, then
schedules a debounced re-broadcast so trunk peers and sibling sats see
the new contribution. /status now exposes:
  - parent: /status.satellites[<id>].nodes (per-sat partner roster)
  - parent: /status.trunks[*].nodes[*].sat_id (attribution)
  - satellite: /status.satellite.parent_nodes (parent's combined view)

Result: refA, S1, S2 all render the same set of callsigns, with each
entry tagged so consumers can tell where it physically lives.

Wire-format note: this is the second lockstep bump on type 121 within
~24h of a3757ca. Peers running an older fork build will fail to unpack
and silently empty their partner roster until upgraded; pre-jay peers
keep ignoring it.

Tests: 35 → 39. Three /status-level checks (sat-attached client visible
on parent, on far-trunk peer with sat_id, parent-local visible on
satellite) plus a multi-sat wire-level cross-visibility test that
verifies sat_id stamping and the self-echo guard.
2026-04-28 15:11:40 +02:00
Audric a3757ca634 trunk: ship rich per-client status blob in MsgTrunkNodeList (fixes #3)
Extends type 121 with a parallel string vector carrying each local
client's m_status["nodes"][callsign] verbatim. Receivers parse,
recursively sanitize (depth/length bounded), and surface the rich
blob under /status.trunks[*].nodes (and /status.twin.nodes), MQTT
nodes/<peer> and Redis live:peer_node:<peer>:<callsign>.status —
bringing partner nodes to parity with local-client status entries
(monitoredTGs, restrictedTG, qth, rx/tx config, protoVer, ...).

isTalker is derived on the receive side from the live trunk-talker
map (MsgTrunkTalkerStart/Stop) rather than carried in the blob,
since blob cadence is event-debounced login/logout/TG-change.

Lockstep wire bump: peers running an older fork build that knows
type 121 with the original 5-vector shape will fail to unpack and
silently empty their partner roster until upgraded. Pre-jayReflector
peers (no type 121 at all) keep ignoring it as before.
2026-04-28 11:24:40 +02:00
Audric 7241239c92 test: 3-way mesh conversation (test_32) + N0THRD third test client
test_32_three_way_conversation drives one distinct V2 client on each of
the three mesh reflectors. All three select a TG owned by reflector 'b'
(121001), then each talks in round-robin while the other two listen.
Pass 1 primes m_peer_interested_tgs on every reflector pair; pass 2
measures and fails if any of the six sender→listener pairs delivers no
UDP audio/flush.

Exercises the owner-relay path (refA→refB→refC and refC→refB→refA) that
test_11 and test_17 miss because they only use two reflectors.

TEST_CLIENTS gains N0THRD — distinct callsigns are mandatory: when two
non-owners forward TrunkTalkerStart to the owner with the same
callsign, the owner's per-TG trunk-talker slot cannot disambiguate.

A small MsgHeartbeat (type 1) keepalive is sent between turns so idle
listener sockets do not hit HEARTBEAT_RX_CNT_RESET (15s).
2026-04-20 18:35:58 +02:00
Audric f24098cd05 test: satellite filter visible in /status (test_16c)
Verifies three behaviors in one test against the HTTP /status endpoint:
  1. The "filter" key is ABSENT when no filter has been sent.
  2. After sat.send_filter("222"), /status.satellites[SAT_ID].filter
     converges to "222" within the wait_until timeout.
  3. After sat.send_filter(""), the key is dropped again.

Covers the passive observability path added in the prior commit. Since
all three observer surfaces (HTTP, MQTT, Redis) serialize the same
statusJson(), the HTTP check is representative.
2026-04-20 14:55:09 +02:00
Audric ba5d03e491 test: satellite TG filter (RED — reproduces bug)
Add test_16b_satellite_tg_filter exercising MsgTrunkFilter (type 122):
satellite sends a filter matching only CLUSTER_TGS[0], then a trunk peer
originates talker+audio on both CLUSTER_TGs. The satellite must receive
the matching TG and NOT receive the non-matching one.

Fails on current master: the parent has no handler for MsgTrunkFilter,
so the filter is silently ignored and every cluster TG is forwarded to
the satellite. This commit documents the bug; the next commit applies
the sysop patch that makes the assertion pass.

Adds MSG_TRUNK_FILTER = 122 wire constant, a build_trunk_filter()
packer, and SatellitePeer.send_filter() helper.
2026-04-20 12:52:41 +02:00
Audric bf5af3eca0 trunk: expose peer roster in /status.trunks[SECTION].nodes
Cache the most recent sanitized MsgTrunkNodeList per TrunkLink in
m_partner_nodes and surface it from statusJson() as trunks[X].nodes.
/status now matches the roster that was already flowing to MQTT
(nodes/<peer_id>) and Redis (pushPeerNode).

Cleared when the link goes fully inactive — single, paired inbound,
and paired outbound disconnect paths all check isActive() before
clearing so a single surviving inbound/outbound in a paired group
keeps the cache live. Redis tombstones are already handled by
Reflector::onTrunkStateChanged() and unchanged here.

Caveat (pre-existing): in PAIRED mode the two sources share one
peerId(), so the latest arrival overwrites the prior one — same
behaviour MQTT and Redis already have. Fixing that requires
per-connection peer_id attribution, out of scope for this patch.
2026-04-19 00:02:58 +02:00
Audric 688a62ec5b publishing: MQTT works in satellite mode + Redis publishes per-client status blob
- Move MQTT init above the satellite early-return in Reflector::initialize so
  satellite-mode reflectors publish to MQTT (client connect/disconnect, talker
  events, full status, etc.) just like full reflectors.
- Add reflector-sat (SATELLITE_OF=reflector-a) to the default test compose so
  satellite mode is exercised end-to-end. New test_31 verifies MQTT
  client-connect/disconnect events under the satellite's own topic prefix.
- Add RedisStore::pushClientStatus and Reflector::publishClientStatus to write
  the per-client status JSON (qth, rx siglev/sql_open/enabled/active,
  monitoredTGs, selected TG, ...) to live:client:<callsign>.status. Hooked
  from publishRxUpdate, handleNodeInfo, setMonitoredTGs, and setTg.
- New Redis test_live_client_status_blob sends a synthetic MsgNodeInfoV2 with
  qth+rx and asserts the parsed blob contains the expected fields.

31/31 trunk + 10/10 twin + 14/14 redis pass.
2026-04-17 01:05:37 +02:00
Audric 7b95d0d2ce redis: mirror peer node lists + sanitize trunk-received strings
Peer node lists (MsgTrunkNodeList, type 121) now propagate into Redis
alongside the existing MQTT publish, so dashboards reading Redis see a
complete view of local + peer rosters. Each remote entry is stored as
live:peer_node:<peer_id>:<callsign> with 60s TTL; a per-peer cache
diffs incoming snapshots so dropped callsigns are DEL'd, and a full
trunk-down deletes all of that peer's entries.

All untrusted strings arriving via the trunk (peer_id from the hello,
plus callsign/qth/lat/lon in node lists) are now sanitized at receive:
control chars + ':' stripped, length bounded (32 callsign, 64 peer_id
and qth), non-finite and out-of-range coordinates cleared. Entries
whose callsign becomes empty after sanitization are dropped.

Also reorders TrunkLink in/outbound onDisconnected so the state-change
notification fires after the per-direction state is cleared, letting
consumers that inspect isActive() (like the Redis peer-node cleanup)
see the correct post-disconnect state.

Adds RedisPeerNodeTest (3 cases: populate+diff, sanitization, trunk-
down cleanup) and a build_node_list wire helper in test_trunk.py.
Exposes the trunk port in docker-compose.redis.yml so the host can
inject trunk frames against the r1 test reflector.
2026-04-16 21:25:37 +02:00
Audric 0700e01453 test(mqtt): add tests for client connect/disconnect, full status, and local nodes
Tests 28-30 cover MQTT publish paths that were untested:
- client connected/disconnected events with tg and ip fields
- periodic retained status message (mirrors /status endpoint)
- retained nodes/local list on client connect
2026-04-16 18:48:03 +02:00
Audric 337cfa7208 TWIN: forward mirrored audio/flush to satellites + integration tests
TwinLink::handleMsgTrunkAudio and handleMsgTrunkFlush now call
forwardAudioToSatellitesExcept / forwardFlushToSatellitesExcept,
mirroring TrunkLink. Without this, satellites attached to a twin
member only saw talker-state updates for traffic originated on the
partner — the audio frames themselves were dropped.

Adds test_09 (satellite handshakes with the twin parent) and test_10
(client on ref2 transmits; satellite on ref1 receives TalkerStart +
audio frames via the TWIN-mirror path). Wires a [SATELLITE] section
and host port mapping into the twin topology generator and lets
SatellitePeer.connect_satellite take an explicit port override.
2026-04-16 00:18:27 +02:00
Audric ba3b100361 Fix 4 pre-existing legacy-test failures
Three distinct root causes, all pre-existing on master and confirmed
there with the same symptoms:

1. tests/generate_configs.py was missing COMMAND_PTY=, so the reflector
   never opened its admin PTY. Every PTY-driven test (MUTE, UNMUTE, CFG,
   TRUNK RELOAD) wrote to a regular file that nobody read. Adding the
   config entry makes those commands actually reach the reflector, fixing
   test_24_pty_trunk_mute and test_25_pty_trunk_reload.

2. TrunkLink::statusJson built active_talkers by iterating the global
   trunk-talker map and filtering by isSharedTG(tg), which checks the
   peer's remote_prefix. When TG_MAP remaps a peer-owned wire TG to a
   local-owned TG, the local TG no longer matches the peer's prefix, so
   the view silently dropped it. Iterate m_peer_active_tgs directly
   instead — that set already contains post-remap local TGs for this
   specific peer. Fixes test_22_tg_map_remap_in.

3. Python test harness parsed MsgTrunkNodeList vector-length prefixes as
   u32 ('!I'), but AsyncMsg.h MsgPacker<std::vector> emits u16 lengths.
   The parser mis-read into garbage at huge offsets and crashed with a
   struct.error. Switch read_vec_str/u32/f32 to u16 ('!H') to match the
   wire format. Fixes test_27_node_list_emitted.

Legacy suite: 27/27 passing (was 23/27).
Redis suite: 10/10 still passing.
2026-04-15 15:59:36 +02:00
Audric 5708e2d0e8 Merge jayReflector additions: per-trunk filters, node-list, PTY mute
Ports DJ1JAY / FM-Funknetz' jayReflector features (https://github.com/dj1jay/jayReflector)
into GeuReflector while keeping the in-process MqttPublisher.

Per-trunk config (TrunkLink): BLACKLIST_TGS, ALLOW_TGS, TG_MAP (with
explicit-route bypass of the prefix routing check), PEER_ID. New helpers
TgFilter.h provide exact / "24*" / "10-20" syntax shared across keys.

Wire protocol (additive, backward compatible — older peers ignore unknown
types): MsgTrunkNodeList (type 121) carries callsign + current_tg + optional
lat/lon/QTH; MsgTrunkFilter (type 122) reserved for satellite TG filters.

Reflector emits debounced (500 ms) MsgTrunkNodeList to all trunk peers on
local client login/logout/TG change. Inbound lists are republished via MQTT
under nodes/<peer_id>; the local list under nodes/local. New MQTT_NAME global
key inserts a path component so several reflectors can share a TOPIC_PREFIX.

PTY commands (Reflector): TRUNK MUTE|UNMUTE <section> <callsign>,
TRUNK RELOAD [<section>] re-reads BLACKLIST_TGS/ALLOW_TGS/TG_MAP without
restart, TRUNK STATUS [<section>] dumps a one-line summary per link.
Mute is applied on the inbound audio path.

Tests: 8 new integration tests (19-27) plus a TEST_PEER_FILTER fixture in
topology.py. Tests cover PEER_ID hello, BLACKLIST/ALLOW/TG_MAP semantics,
PTY MUTE/RELOAD/STATUS via docker exec, MQTT_NAME topic namespacing, and
node-list emission. Total now 27 tests.

Docs: docs/JAY-additions.md credits DJ1JAY / FM-Funknetz and lists every
merged feature with file pointers and the filter-evaluation order.
README.md links it. svxreflector.conf.in documents every new key.

Bumps SVXREFLECTOR to 1.3.99.13+trunk.
2026-04-14 23:48:03 +02:00
Audric 8b6148a678 Fix satellite disconnect loop: parent now sends hello reply
The parent SatelliteLink never sent a hello reply after authenticating
the satellite client. This caused two problems:

1. The satellite client's m_hello_received stayed false, preventing it
   from forwarding any local events to the parent.
2. No parent→satellite traffic until the first heartbeat at ~10s,
   allowing intermediate firewalls/NAT to kill the idle connection
   (observed as ~7s disconnect-after-auth loops).

Send a MsgTrunkHello reply from the parent, matching what TrunkLink
already does for trunk peers. Update tests for two-way handshake.
2026-04-10 10:59:39 +02:00
Audric bca223afbe Add MQTT integration test for talker events
Add mosquitto broker to test Docker Compose, configure [MQTT] sections
in all generated reflector configs, and add test_18_mqtt_talker_event
that verifies talker start/stop events are published to MQTT topics.
2026-04-08 20:36:23 +02:00
Audric 05c4c88ff3 Require matching trunk section names and cap audio debug at 500 frames
Trunk link matching now requires the peer's hello ID (section name) to
match the local [TRUNK_x] section name. Both sides of a trunk link must
use the same section name, agreed upon by both sysops. This replaces
the previous matching by secret+prefix only.

BREAKING CHANGE: existing deployments must rename their [TRUNK_x]
sections so both sides use the same name for each link.

Also cap TRUNK_DEBUG audio frame logging at 500 frames per trunk link
to prevent excessive log output during sustained transmissions.
2026-04-05 18:22:04 +02:00
Audric 4e6bff7962 Merge /config into /status and remove /config endpoint
All static configuration fields (version, local_prefix, listen_port,
http_port, mode, satellite/satellite_server) are now included directly
in the /status JSON response. The /config endpoint is removed.
2026-03-29 15:29:45 +02:00
Audric accb4b3686 Fix bidirectional trunk routing and monitoring client notifications
Two bugs prevented real-world trunk conversations from working:

1. onTrunkTalkerUpdated only notified clients selected on a TG, not
   clients monitoring it. SvxLink repeaters monitoring a foreign TG
   never received MsgTalkerStart and could not auto-switch. Fixed by
   adding TgMonitorFilter to trunk talker broadcasts, matching the
   existing behavior of onTalkerUpdated for local talkers.

2. Trunk TG routing was one-way: when a client visited a foreign TG,
   isSharedTG forwarded to the owner, but the owner had no return
   path. Added per-link peer interest tracking — when a peer sends
   MsgTrunkTalkerStart for a TG, the receiving side records interest
   and forwards local activity on that TG back. Interest refreshes
   on audio, expires after 10 minutes idle, clears on disconnect.

New integration test verifies the full round-trip: client-A talks on
a foreign TG, monitoring client-B receives the notification, client-B
replies, and client-A receives audio back through the trunk.
2026-03-28 19:09:38 +01:00
Audric eca3c71122 Fix TG number substring match in log grep and remove debug logging
The interactive tester's log parser matched "TG #1" as a substring of
"TG #12001", "TG #10", etc., causing false positives for short TG numbers.
Use a regex negative lookahead (?!\d) so "TG #1" only matches when not
followed by another digit. Same fix applied to test_15 satellite routing.

Also remove debug logging accidentally left in TrunkLink::onLocalTalkerStart.
2026-03-27 15:19:13 +01:00
Audric d2f4acffcd Add satellite integration tests
5 new tests covering satellite protocol: handshake and /status visibility,
audio delivery from satellite to parent's local clients, trunk-to-satellite
audio forwarding, satellite audio routed to trunk peers via parent, and
disconnect cleanup. Reflector-a acts as the satellite parent with a
[SATELLITE] section; a SatellitePeer class connects as a fake satellite
using MsgTrunkHello with ROLE_SATELLITE.
2026-03-27 14:58:51 +01:00
Audric 685d7253ff Fix trunk receive-side TG filtering and add integration test suite
The receive-side handlers (handleMsgTrunkTalkerStart, handleMsgTrunkAudio,
etc.) used isSharedTG() which only checks the remote peer's prefix. This
caused non-cluster TGs to be silently dropped on the receiving reflector —
e.g. a client on reflector-a talking on TG 40001 (owned by reflector-b)
would never reach reflector-b because reflector-b checked the TG against
reflector-a's prefix instead of its own.

Add isOwnedTG() that accepts TGs matching either the local or remote
prefix, and use it in all four receive handlers. The send-side still uses
isSharedTG() (remote prefix only) which is correct.

Also add a Docker-based integration test suite (tests/) with 11 automated
tests covering handshake, routing, cross-reflector audio delivery, cluster
TGs, heartbeat, disconnect cleanup, and trunk-to-trunk isolation. An
interactive mode lets users test arbitrary TG numbers with routing verified
via reflector logs. Topology is defined once in tests/topology.py.

Fix Dockerfile to copy built shared libraries to the runtime image.
2026-03-27 14:43:57 +01:00