Commit Graph
100 Commits
Author SHA1 Message Date
Audric bc9b6e7b30 feat(proto): add MsgPeerClient{Connected,Disconnected,Rx,Status} (125-128)
Wire types for per-client liveness deltas. No call sites yet — emit
and dispatch added in subsequent commits.
2026-04-28 18:05:01 +02:00
Audric 18d92a2b11 refactor: rename MsgTrunk* -> MsgPeer*
The eight MsgTrunk* types flow over trunk, satellite, and twin links —
"Trunk" was a misleading prefix for what is actually a shared peer
protocol. Wire IDs (115-122) and field layouts are unchanged, so this
is wire-equivalent: a renamed reflector and an old reflector
interoperate identically.

Also renames docs/TRUNK_PROTOCOL.md -> docs/PEER_PROTOCOL.md.

Twin-only types MsgTwinExt* (123/124) stay as-is.
2026-04-28 18:00:24 +02:00
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 d9ec356f10 mqtt: raise default STATUS_INTERVAL from 1000 ms to 30000 ms
The full-status snapshot is a bootstrap / drift-correction mechanism;
per-event topics (talker, client, trunk, nodes) already deliver every
change live. The retained payload scales with mesh size — at a few
hundred nodes with the rich per-client status blob it is hundreds of
KB, which makes a 1 s republish expensive on broker bandwidth and
reflector CPU. Lower it explicitly via [MQTT] STATUS_INTERVAL only
when a small mesh has a consumer that depends on near-real-time full
snapshots.

Test configs keep STATUS_INTERVAL=1000 to verify retained-status
behaviour in seconds.
2026-04-28 11:30:50 +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 69c3c2eea3 docs: document owner-relay fanout + peer-interest TTL
README.md: "Full-mesh topology" bullet now spells out single-hop
owner-relay: a non-owner sends to the TG's owner, owner fans out to
every other trunk peer with interest, no daisy-chain relay.

docs/TRUNK_PROTOCOL.md: new "Owner-Relay Fanout" subsection under "TG
Ownership and Routing" with the fanout model, a refA/refB/refC
worked example matching test_32, scaling argument (O(N) TCP sends on
the owner for N reflectors), and the peer-interest caveat. The caveat
paragraph now also states the 10-minute inactivity TTL
(PEER_INTEREST_TIMEOUT_S = 600), refresh-on-each-packet behavior,
and immediate clear on trunk disconnect — so sysops don't have to
hunt for the timeout in the code.
2026-04-20 18:55:44 +02:00
Audric 60c69b05ff docs: TESTS.md for test_32 + owner-relay semantics, bump to 35 tests 2026-04-20 18:36:03 +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 9f4011d3e2 trunk: owner-relay received audio/flush/talker to other trunk peers
Trunks are meant to form a full audio mesh, but the previous code
broadcast trunk-received audio only to local clients and satellites —
never to other trunk peers. That made three-way conversations impossible
whenever the speaker and the intended listener were both non-owners of
the TG (e.g. refA and refC on a TG owned by refB).

Now, when a TrunkLink receives MsgTrunkTalkerStart/Stop/Audio/Flush for
a TG this reflector locally owns, Reflector re-forwards the event to
every other trunk peer via the existing onLocal* filters (shared /
cluster / peer-interest). Loop prevention: only the owner relays and
the source link is excluded from the fanout, so it stays single-hop.

isLocalTG(tg) performs longest-prefix-match across m_local_prefixes
vs. m_all_prefixes — owner if our prefix wins globally.
2026-04-20 18:35:45 +02:00
Audric 962e1ffc10 docs: surface SATELLITE_FILTER in /status + bump test count to 34
README: add an "Observability" paragraph noting that the active filter
appears under /status.satellites[<id>].filter — and by extension in the
MQTT retained status topic and Redis live📡<id> snapshot,
since those surfaces reserialize the same JSON. Omitted when no filter
is set.

DESIGN_SATELLITE_AND_CLUSTER: add an "Observable state" row to the
TrunkLink vs SatelliteLink comparison table listing the fields in
SatelliteLink::statusJson() including the new filter field.

tests/TESTS.md: bump trunk test count 33 -> 34 and add a row for
test_16c (satellite filter visible in /status).
2026-04-20 15:16:27 +02:00
Audric a4f0e9522d Merge branch 'feature/satellite-status-filter'
Exposes the active SATELLITE_FILTER in SatelliteLink::statusJson() as
satellites[<id>].filter. One edit feeds all three observer surfaces
(HTTP /status, MQTT retained status, Redis live snapshot) since they
all serialize the same JSON.

Contains:
  - satellite: emit filter in statusJson when non-empty
  - test: test_16c verifies filter appears and clears in /status
2026-04-20 15:09:18 +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 bf74bbdc78 satellite: expose active TG filter in statusJson
When a satellite advertises a SATELLITE_FILTER via MsgTrunkFilter, the
parent-side SatelliteLink now emits it as satellites[<id>].filter in
its JSON status. Key is omitted when no filter is set (empty => all TGs
pass), so existing consumers that check for its absence keep working.

This single field propagates to three observer surfaces for free:
  - HTTP /status — Reflector::refreshStatus() copies statusJson() into
    m_status["satellites"].
  - Redis live snapshot — statusChanged -> publishSatelliteStatusToRedis
    reserializes statusJson() to live📡<id> on every filter
    change (handleMsgTrunkFilter already emits statusChanged).
  - MQTT retained "status" topic — the periodic publishFullStatus(m_status)
    timer includes the same JSON.

Passive propagation only — no dedicated MQTT filter-change event.
Follow-up work if active notifications are needed: emit a
satellite/<id>/filter topic from handleMsgTrunkFilter.
2026-04-20 14:54:19 +02:00
Audric de47c62dfa docs: document SATELLITE_FILTER and bump test count to 33
README: drop "satellite forwards all TGs unconditionally" claim. Add a
SATELLITE_FILTER line to the satellite-side config example and a section
explaining the bidirectional, opt-in scope (advertised via
MsgTrunkFilter type 122).

DESIGN_SATELLITE_AND_CLUSTER: update the routing comparison row —
satellite is still unfiltered by default but now has SATELLITE_FILTER.

TRUNK_PROTOCOL: promote MsgTrunkFilter from "intended for" to
"used by" satellite links, describe when it is sent.

tests/TESTS.md: bump trunk test count 32 -> 33 and add a row for
test_16b (satellite TG filter honored by parent).
2026-04-20 14:42:26 +02:00
Audric 2d3f2c97af Merge branch 'feature/satellite-filter'
Adds SATELLITE_FILTER support (bidirectional TG filter between a
satellite and its parent) via MsgTrunkFilter (type 122).

Contains:
  - test: satellite TG filter (RED commit reproducing the bug)
  - satellite: sysop patch (Jens DJ1JAY / FM-Funknetz) making it pass
  - docs: clarify that SATELLITE_FILTER is bidirectional in scope
2026-04-20 14:31:16 +02:00
Audric b94a447bf1 docs: clarify SATELLITE_FILTER is bidirectional
The filter is applied on both legs of the satellite: outbound to the
parent (local events for non-matching TGs are suppressed) and inbound
from the parent (advertised via MsgTrunkFilter so the parent skips
forwarding non-matching TGs). The previous comments only mentioned
the inbound direction, which was misleading.
2026-04-20 14:05:32 +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 bd31369e5e docs: sync README / MQTT / TWIN / TESTS with v1.3.3
- README /status example adds twin{...}, trunks[X].nodes and muted;
  node-list bullet now mentions twin partner as well as trunk peers.
- docs/MQTT.md documents the nodes/local + nodes/<peer_id> topics
  (retained) that were already being published but absent from the
  docs; the QoS/retain table is extended accordingly.
- docs/TWIN_PROTOCOL.md status line bumped to v1.3.x+twin2 and test
  count updated (8 -> 11) to include the partner-roster test.
- tests/TESTS.md bumps the trunk suite (31 -> 32) and twin suite
  (10 -> 11) counts and adds entries for the two new roster tests.
2026-04-19 00:45:44 +02:00
Audric 69c993ad77 version: SVXREFLECTOR 1.3.99.13+trunk.twin2
Bump the twin suffix to reflect roster exchange over the [TWIN]
link and /status / MQTT / Redis attribution work merged for
issue #3.
2026-04-19 00:15:53 +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 cadc5c5aa2 twin: fan twin partner roster into MQTT and Redis
Route the twin-received MsgTrunkNodeList through
Reflector::onPeerNodeList() — the same fan-out TrunkLink uses —
so MQTT publishes nodes/<peer_id> and Redis pushPeerNode entries
also cover the twin partner, not just trunk peers.

Before this, /status exposed twin.nodes but MQTT/Redis did not;
consumers reading only from Redis or MQTT missed the roster of
the twin partner entirely.

On twin link-down, clearPartnerRosterIfInactive() pushes an
empty list so onPeerNodeList's tombstone path clears Redis /
empties the MQTT topic — matching the cleanup we do for a
trunk peer that goes down.
2026-04-18 23:49:34 +02:00
Audric fa6f137e1c twin: expose partner roster in /status (fixes #3)
Reflector::refreshStatus() now emits a m_status["twin"] object
(host, port, connection/hello state, prefix, peer_id, priorities)
mirroring the existing trunks[] pattern.

To populate the partner's connected-stations list, TwinLink now
carries MsgTrunkNodeList (type 121) over the [TWIN] socket —
reusing the trunk wire message, no new protocol type. Local
roster changes flow via Reflector::sendNodeListToAllPeers() ->
TwinLink::onLocalNodeListUpdated(); incoming lists are sanitized
and cached in m_partner_nodes, surfaced as twin.nodes.

Without this, [TWIN]-paired reflectors could not observe each
other's rosters from /status — the data was not on the wire at
all (TwinLink only carried talker state).
2026-04-18 23:33:57 +02:00
Audric 4bbd53172a docs: link docs/LOGGING.md from README index 2026-04-18 21:30:33 +02:00
Audric efa02459e9 logging: address code-review feedback
- Fix a critical regression where startup errors emitted before
  geulog::configure() (bad --config path, unknown CLI flag, --version
  banner) were queued into the async deque with no running worker
  and silently dropped on exit(). detail::enqueue() now falls back to
  synchronous ::write() to stdout/stderr when the worker is inactive.
- Remove the dead TRUNK_DEBUG parse block in Reflector.cpp and the
  m_trunk_debug member in Reflector.h — all gates were already
  removed in Phase 1; only the (unread) parse remained.
- Replace the #TRUNK_DEBUG=0 comment in svxreflector.conf.in with a
  documented LOG= reference block.
- Restore the [host:port] peer identity on the ReflectorClient
  ENOTCONN debug line so sysops can still correlate failures.
- Revert sighup_handler and sigterm_handler to async-signal-safe
  ::write(STDERR_FILENO, ...) instead of calling the (mutex-taking,
  allocating) facade from signal context.
- Retag two MsgTrunk* diagnostic sites in ReflectorMsg.h from core
  to trunk to match the enclosing-class rule.
- Doc: note that argument expressions are evaluated at the call site
  before the shouldLog() gate runs, and reword the "never drops"
  claim to acknowledge rare short-write truncation.
2026-04-18 21:02:42 +02:00
Audric 9761c6147f docs: add LOGGING.md — sysop reference for the logging facade
Covers the LOG= config tag, the PTY commands (LOG SHOW / LOG sub=lvl /
LOG RESET), the seven subsystem tags, Docker vs. --logfile deployment
paths, performance guarantees (async, gate-before-format), and the
TRUNK_DEBUG migration story.

Follows the style of docs/MQTT.md / docs/REDIS.md.
2026-04-18 19:29:43 +02:00
Audric 14878d285c logging: migrate remaining cold paths to facade
Sweeps startup banners, config validation, HTTP /status lifecycle, TLS
and certificate diagnostics, MQTT and Redis publisher lifecycle, and
ReflectorMsg serialisation errors through geulog::{info,warn,error}.
No behaviour change — every line retains its message content and level.

After this commit, grep for cout/cerr << in src/svxlink/reflector/
returns no real call sites (only #if 0 blocks and string literals).
2026-04-18 19:28:16 +02:00
Audric ccec8f1e95 logging: facade (hand-rolled async worker) + hot-path migration; drop TRUNK_DEBUG
Adds src/misc/Log.h / Log.cpp exposing geulog::{trace,debug,info,warn,error}
(subsystem, args...) with gate-before-format. Seven named loggers
(trunk, satellite, twin, client, mqtt, redis, core) share a mutex-guarded
deque drained by a single background worker thread writing to fd=1.
Levels come from [GLOBAL] LOG=*=warn,trunk=debug,... and are runtime-
settable via /dev/shm/reflector_ctrl (LOG SHOW / LOG sub=lvl / LOG RESET).
Writes continue to fd=1 so LogWriter file/syslog paths are unchanged.

Migrated hot paths only: audio relay, talker start/stop, handshake,
heartbeat, per-client RX, per-frame trunk/satellite/twin relay, plus the
ENOTCONN sendMsg race at ReflectorClient:302 (demoted to debug since it
is per-disconnect noise, not a fault).

Cold paths (startup banners, config validation, TLS/CA diagnostics,
MQTT/Redis publisher lifecycle) remain on raw cout/cerr and move in the
next commit.

TRUNK_DEBUG is removed; a startup warning points at LOG=trunk=debug.
2026-04-18 18:35:51 +02:00
Audric 59ae728713 reflector: fix clientStatus() isMember check to target nodes subtree
The existence guard in clientStatus() checked m_status.isMember(callsign)
against the root object, which never matched a real callsign, so every
call wiped m_status["nodes"][callsign] back to an empty object. Check
m_status["nodes"].isMember(callsign) instead so the init only fires for
genuinely new callsigns and existing per-node state survives refreshes.
2026-04-17 17:02:08 +02:00
Audric bc02c8c6d8 mqtt: log mosquitto_publish() failures with rate-limited cerr
Publish failures (invalid topic, offline broker, queue full) were silent
because the rc was discarded. At production volume a naive log floods on
any flap, so emit on first failure + error-code change, then suppress for
60s and include the suppressed count on the next line.
2026-04-17 15:36:49 +02:00
Audric bd196d6365 build: opt-out WITH_MQTT/WITH_REDIS flags + extend Redis to /status parity
- Add CMake options WITH_MQTT (default ON) and WITH_REDIS (default ON).
  When OFF, the matching .cpp is dropped from the target, the pkg_check
  is skipped, and MqttPublisher.h / RedisStore.h expose no-op stub
  classes so every call site in Reflector.cpp / ReflectorClient.cpp /
  TrunkLink.cpp keeps compiling. svxreflector.cpp's --import-conf-to-redis
  is gated on WITH_REDIS. Lets sysops who don't run MQTT or Redis drop
  libmosquitto-dev / libhiredis-dev from their build environment.
  README.md and docs/INSTALL.md document the flags.

- Fill the gap between /status and Redis with three new event-driven
  keys (all small, all using the existing 60s TTL refresh):
    * live:meta  — mode, version, local_prefix, listen_port, http_port,
      cluster_tgs, satellite-server stats. Written at startup, on
      reloadClusterTgs(), and on satellite connect/disconnect.
    * live📡<sat_id> — per-satellite status blob. Written via
      a new SatelliteLink::statusChanged signal on hello + on every
      talker start/stop. Cleared on disconnect / cleanup.
    * live:trunk:<section>.status — extended trunk hash with the full
      TrunkLink::statusJson() snapshot. Written at startup, on trunk
      state changes, and on config.changed-all reloads.

  A dashboard can now reconstruct the equivalent of GET /status from a
  handful of small Redis keys instead of one ~500 KB blob — idiomatic
  Redis usage, no per-second hot-write churn.

- New Redis tests: live_meta_populated_at_startup,
  live_trunk_carries_status_blob.

All four flag combinations build cleanly. 31 trunk + 10 twin + 16 redis
pass.
2026-04-17 02:52:36 +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 6b7a1f0306 docs(tests): sync counts + document Redis peer-node tests
Trunk count 27→30 (MQTT tests 28-30 from 0700e01) and Redis count
10→13 with three new rows for RedisPeerNodeTest (populate+diff,
hostile-string sanitization, trunk-down cleanup) from 7b95d0d.
2026-04-16 21:36:52 +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 5777bbb56e docs(tests): document twin satellite tests and Redis harness
Reflect tests added since the last doc sync: twin tests 9-10
(satellite + twin audio mirror), the satellite-on-ref1 in the twin
topology, and the separate Redis integration harness and its 10
test_redis.py cases.
2026-04-16 01:03:28 +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 7507c116e6 docs: polish TWIN_PROTOCOL and TESTS for shipped-feature framing
TWIN_PROTOCOL.md:
- Drop "DESIGN DRAFT" from the title.
- Rename "Implementation Sketch (non-binding)" to "Implementation" and
  rewrite as descriptive prose naming the actual files that shipped.
- Rename "Resolved Decisions" to "Design Rationale"; drop "from the
  original draft" framing.
- Correct the split-brain reconnect note: state heals via normal event
  flow; there is no bulk state-dump on reconnect.

TESTS.md:
- Document the two-phase run (default 3-reflector mesh + twin 4-reflector
  topology) and the --topology twin flag.
- Add a "Twin Test Topology" section with diagram and port-mapping table.
- Add a new test-case table for the 8 twin-protocol tests.
- List test_twin.py and the twin-related topology fields in File Structure.
2026-04-15 23:07:55 +02:00
Audric b25cbff36a docs(TWIN): reflect that audio-mirror path is now integration-tested 2026-04-15 23:03:20 +02:00
Audric 600542c8a8 Merge feature/twin-protocol: TWIN (HA-pair) protocol
Adds a dedicated [TWIN] link between two reflectors that share a
LOCAL_PREFIX, with active/active external-trunk ownership via a new
PAIRED=1 flag on existing [TRUNK_x] sections. External peers see the
twin pair as one logical trunk with sticky per-transmission socket
selection and instant failover.

Highlights:
- New TwinLink class, twin TCP server on port 5304, 2s/5s heartbeat.
- New messages: MsgTwinExtTalkerStart/Stop (types 123/124), ROLE_TWIN (=2).
- TGHandler gains per-peer attribution (setTrunkTalkerForTGViaPeer,
  clearTrunkTalkersForPeer, peerIdForTG) so external trunk-talker state
  mirrored across the twin link can be cleaned up per-peer on disconnect.
- TrunkLink extended for PAIRED=1: multi-host HOST list, one TcpPrioClient
  per host, relaxed one-inbound-per-section rule, sticky per-transmission
  send with instant failover.
- 8 integration tests covering handshake, mirror, failover, audio path.

Spec: docs/TWIN_PROTOCOL.md
2026-04-15 23:01:17 +02:00
Audric 81bd3eabf3 TWIN audio-mirror: stale-inbound cleanup + end-to-end integration test
Two changes:

1. TwinLink::acceptInboundConnection now treats an existing but-disconnected
   m_inbound_con as stale and replaces it with the new arriving connection,
   and wires a disconnected signal on the inbound so m_inbound_con is
   cleared when the remote end goes away. Without these, a partner container
   restart left the surviving twin holding a dead inbound reference that
   kept rejecting the partner's reconnection attempts until the heartbeat
   RX timeout cleared it (5s window, mid-test).

2. New test_08_audio_mirror_between_twins integration test. Reuses ClientPeer
   from test_trunk.py to connect a V2 sender to ref1 and a V2 receiver to
   ref2, both on TG 26201 (prefix 262). Sends audio from ref1's client,
   asserts the receiver on ref2 gets UDP audio + flush datagrams. Proves
   the Phase C1 path end-to-end:
     ref1 client UDP audio
       -> TGHandler.talkerUpdated -> TwinLink.onLocalAudio
       -> MsgTrunkAudio over [TWIN]
       -> ref2.handleMsgTrunkAudio -> broadcastUdpMsg
       -> ref2 client UDP socket.

All 8 tests now pass (36s wall clock).
2026-04-15 22:59:21 +02:00
Audric 06a2275ee6 Fix: guard send paths against writing to closed sockets; lower test port bases
Three fixes surfaced while running the E3 integration suite end-to-end:

1. sendMsgOnPairedInbound / sendMsgOnPairedOutbound / TwinLink sendMsgOn*
   now check isConnected() before calling write(). Without the guard, a
   heartbeat TX firing between the remote peer dying and our RX-timeout
   cleanup tripped an "assert sock >= 0" inside Async::TcpConnection::write
   and crashed the reflector (seen in test_07 as ref2 exiting with SIGSEGV
   after ref1 was killed).

2. Twin topology trunk_port_base values reduced (45000-48000) so the
   http-port offset (+3080) stays <= 65535. The earlier 60000-63000 bases
   produced 66080, which docker compose rejected as an invalid hostPort.

3. Twin reflector names lowercased (refa, refc) to satisfy Docker's image
   tag constraint (lowercase-only).

All 7 integration tests now pass end-to-end:
  - twin handshake (mutual authenticated hello)
  - no HMAC/prefix errors on startup
  - refa's PAIRED=1 trunk reports connected=True
  - both pair members see TRUNK_IT_DE back to refa
  - no twin-related ERRORs in startup logs
  - kill ref2 -> ref1 detects timeout, restart -> re-handshakes
  - kill ref1 -> refa stays connected to the pair via ref2 (failover)
2026-04-15 22:47:05 +02:00
Audric a2b5d448fa docs: TWIN protocol implemented; bump version 2026-04-15 22:29:36 +02:00
Audric 9acb765110 tests: integration tests for TWIN handshake, mirror, failover
Adds tests/test_twin.py with 7 tests covering the TWIN topology:
  1–2. Twin handshake presence and absence of auth errors on ref1/ref2
  3–4. PAIRED=1 trunk (refA↔DE pair) reported connected on all three sides
  5.   Twin wiring smoke test (no ERROR[TWIN], server-listen log present)
  6.   Twin disconnect/recovery: kill ref2, verify ref1 detects timeout,
       verify re-handshake after restart
  7.   PAIRED trunk failover: kill ref1, verify refA still routes via ref2

run_tests.sh extended to tear down the default mesh, regenerate configs
with --topology twin, run test_twin.py, then restore the default topology.
2026-04-15 22:28:42 +02:00
Audric 9cfea32da6 tests: topology schema supports twin_of and paired trunks
Add TWIN_TOPOLOGY data (TWIN_REFLECTORS, TWIN_TRUNKS) to topology.py and
extend generate_configs.py to render [TWIN] sections, TWIN_LISTEN_PORT, and
PAIRED=1 multi-host trunk sections when invoked with --topology twin (or
TOPOLOGY=twin env var).  Default topology and its generated output are
unchanged.
2026-04-15 22:23:48 +02:00
Audric 0d110172ea conf: document [TWIN] section and PAIRED=1 external trunk 2026-04-15 22:20:07 +02:00
Audric e120951382 TrunkLink: sticky per-transmission socket selection with failover (PAIRED=1) 2026-04-15 22:18:32 +02:00
Audric 17bed97d1c TrunkLink: accept multiple inbound connections when PAIRED=1
Add PairedInboundState struct (parallel to PairedClientState) and
m_ib_states vector to track per-inbound heartbeat/hello state.
acceptInboundConnection branches on m_paired: in paired mode, push
each new inbound into m_ib_cons/m_ib_states, wire a lambda frameReceived
handler to onPairedInboundFrame, and send the hello reply immediately.
Non-paired path is unchanged.

Add onPairedInboundFrame (mirrors onPairedOutboundFrame: resets hb_rx_cnt,
dispatches data messages to shared handlers), onPairedInboundDisconnected
(removes by index from both vectors without deleting — Reflector owns the
object), pairedInboundIndex (linear scan), and sendMsgOnPairedInbound
(mirrors sendMsgOnPairedOutbound).

Route onInboundDisconnected through the paired handler when m_paired.
Update sendMsg paired fallback to iterate m_ib_cons instead of calling
the legacy sendMsgOnInbound. Update heartbeatTick paired branch to iterate
m_ib_cons/m_ib_states instead of m_inbound_con scalars. Update
isInboundReady to check m_ib_states in paired mode. Destructor clears
m_ib_cons/m_ib_states without deleting connections.
2026-04-15 22:08:55 +02:00
Audric 70195e10c3 TrunkLink: open one outbound per host when PAIRED=1
For each host in m_peer_hosts, create a FramedTcpClient with its own
connected/disconnected/frameReceived signal wiring and per-client
PairedClientState (hello_received, hb_tx_cnt, hb_rx_cnt).

- onPairedOutboundConnected: resets per-client state, enables heartbeat
  timer, sends MsgTrunkHello on that client
- onPairedOutboundDisconnected: resets per-client state; TcpPrioClient
  auto-reconnects
- onPairedOutboundFrame: per-client RX counter reset; dispatches
  MsgTrunkHello (HMAC verify, sets hello_received) and MsgTrunkHeartbeat
  inline; all other message types forwarded to shared handlers via ss
  (already positioned past header)
- sendMsgOnPairedOutbound(idx): serialises and writes on m_ob_cons[idx]
- pairedClientIndex: linear scan returning SIZE_MAX on miss
- sendMsg: paired branch iterates m_ob_cons in order, picks first with
  connected+hello_received (D4 will make this sticky); falls back to
  inbound
- heartbeatTick: paired branch iterates per-client counters; legacy OB
  block untouched; "disable timer" check uses any_ob_connected flag
- isOutboundReady: returns true if any paired client is ready
- ~TrunkLink: disconnects and deletes all m_ob_cons entries

Single-host path is unchanged; all new code is inside m_paired branches.
2026-04-15 21:54:25 +02:00
Audric adfe04e8b1 TrunkLink: parse PAIRED=1 + multi-host HOST list (no behavior yet) 2026-04-15 21:41:51 +02:00
Audric 6fb5aa4b91 TwinLink: mirror external trunk-talker state to partner
When TrunkLink receives MsgTrunkTalkerStart/Stop from an external peer,
Reflector now forwards those events to TwinLink via
notifyExternalTrunkTalkerStart/Stop.  TwinLink sends MsgTwinExtTalkerStart
(type 123) / MsgTwinExtTalkerStop (type 124) over the twin link, and the
receiving side calls TGHandler::setTrunkTalkerForTGViaPeer so the partner
twin blocks local clients from keying up the TG.  On disconnect,
clearPeerTalkerState iterates held TGs before clearing them so the partner
is also notified.  No echo loop: Reflector::onTrunkTalkerUpdated does not
feed back into TwinLink.
2026-04-15 21:30:14 +02:00
Audric 2554efb392 TwinLink: mirror local-client talker and audio to partner
Outbound: onLocalTalkerUpdated/onLocalAudio/onLocalFlush now send
MsgTrunkTalkerStart/Stop, MsgTrunkAudio, MsgTrunkFlush over the twin
TCP connection when isActive().

Receive-side: handleMsgTrunkTalkerStart/Stop call
TGHandler::setTrunkTalkerForTG / clearTrunkTalkerForTG, which fires
trunkTalkerUpdated → Reflector::onTrunkTalkerUpdated, broadcasting
MsgTalkerStart/Stop to local clients. handleMsgTrunkAudio and
handleMsgTrunkFlush call Reflector::broadcastUdpMsg directly.

Reflector::onTalkerUpdated (talkerUpdated signal handler) now notifies
m_twin_link after the trunk/satellite loops. MsgUdpAudio and
MsgUdpFlushSamples handlers similarly call m_twin_link->onLocalAudio/
onLocalFlush in the non-satellite branch.

No echo loop: trunkTalkerUpdated (twin receive path) is distinct from
talkerUpdated (local-client signal that drives outbound sends).
2026-04-15 21:18:24 +02:00
Audric 9b748d1bdc TWIN inbound: validate HMAC and local_prefix before handoff
Add HMAC verification (msg.verify) and local_prefix equality check in
Reflector::twinPendingFrameReceived, after the role check and before
handing the connection off to TwinLink::acceptInboundConnection.  HMAC
is checked first (fail-fast, avoids leaking prefix info on bad secret).
Expose secret() and localPrefix() as const accessors on TwinLink.
2026-04-15 21:13:58 +02:00
Audric 4b6346d4ab TWIN server: accept inbound twin connections on TWIN_LISTEN_PORT
Replace the initTwinServer() stub with a real Async::TcpServer that
listens on TWIN_LISTEN_PORT (default 5304). Inbound connections are
held in m_twin_pending_cons with a 10-second hello timeout; on receipt
of a valid MsgTrunkHello with ROLE_TWIN the connection is handed off to
TwinLink::acceptInboundConnection(). Pending entries are cleaned up on
timeout, disconnect, and successful handoff. No server is created when
no [TWIN] section is configured.
2026-04-15 20:54:51 +02:00
Audric 9f349fff5c TwinLink: outbound connect, handshake, heartbeat skeleton
Implements TwinLink.cpp with constructor (random priority nonce via
std::random_device, signal wiring), initialize() (parse [TWIN] HOST/PORT/
SECRET and [GLOBAL] LOCAL_PREFIX, addStaticSRVRecord + reconnect policy,
m_con.connect()), onConnected() sending MsgTrunkHello with ROLE_TWIN,
handleMsgTrunkHello() validating role/HMAC/prefix-match, heartbeatTick()
(2s TX / 5s RX thresholds), sendMsg/sendMsgOnOutbound/sendMsgOnInbound,
and acceptInboundConnection().  Phase C handlers (talker mirror, audio,
ext-trunk) are present as empty stubs.

Wires Reflector::initTwinLink() to construct and initialize a real TwinLink
(replaces stub), adds destructor cleanup, and adds TwinLink.cpp to
CMakeLists sources.  Build passes clean.
2026-04-15 20:33:54 +02:00
Audric 074b1aea4c TwinLink.h: align with TrunkLink.h style (GPL header, section comments, heartbeatTick name) 2026-04-15 20:27:33 +02:00
Audric 73aca6decc TwinLink: header skeleton 2026-04-15 20:23:53 +02:00
Audric 3c92de178c Reflector: parse [TWIN] section (stub; no link behavior yet) 2026-04-15 20:08:11 +02:00
Audric c76f07af31 TGHandler: per-peer attribution for trunk-talker state
Add setTrunkTalkerForTGViaPeer, clearTrunkTalkersForPeer, and
peerIdForTG to support selective cleanup of trunk-talker state when
a specific peer disconnects (needed by the TWIN link protocol).
Also ensure clearTrunkTalkerForTG and clearAllTrunkTalkers keep the
new m_trunk_talker_peer_ids map in sync.
2026-04-15 19:57:38 +02:00
Audric e6946d0da8 msg: add ROLE_TWIN and MsgTwinExtTalkerStart/Stop (types 123/124) 2026-04-15 19:43:52 +02:00
Audric 8aecd951da chore: ignore .worktrees/ (and include pre-existing .gitignore self-entry) 2026-04-15 19:33:19 +02:00
Audric 205153ad9c docs(TWIN): resolve open design questions; switch to active/active
Rewrite the TWIN protocol spec around the decisions agreed with the
sysop: active/active external-trunk ownership with sticky per-frame
socket selection (refA holds both TCP sockets, picks one, fails over
instantly), single [TRUNK_x] section with multiple hosts + PAIRED=1
on the external peer side, full TGHandler state mirror across the
twin link (including external-trunk-talker state via new
MsgTwinExtTalkerStart/Stop messages — types 123/124, replacing the
earlier MsgTwinRoleClaim/MsgTwinRoleState), 2s/5s heartbeat cadence,
TCP relay for twin audio, and split-brain tolerated during twin-link
outages with handshake-time state resync on reconnect.

No code yet; this is still a design doc pending implementation.
2026-04-15 19:00:39 +02:00
Audric bb4d058aaa docs(TWIN): note MsgTrunkFilter (122) is unused on twin links
The message-type table jumped from 121 to 123 without explaining why
122 is skipped. Add a row making explicit that MsgTrunkFilter is
satellite-only and not meaningful on a twin link (twins mirror all TGs).
2026-04-15 18:25:25 +02:00
Audric a84cde03a1 docs: add TWIN_PROTOCOL design draft for HA-pair reflector linking
Design-only draft (not yet implemented) introducing a dedicated [TWIN]
link type so two reflectors can act as a redundant pair with a shared
LOCAL_PREFIX — cleaner than abusing overlapping trunk prefixes for HA.
Covers handshake (ROLE_TWIN via MsgTrunkHello), cross-twin talker
arbitration, active/standby external-trunk ownership with priority-nonce
election, and flags 7 open design questions for sysop review before
coding begins.
2026-04-15 18:19:18 +02:00
Audric 21ed18c893 docs(REDIS): add PHP dashboard examples and MySQL→conf migration
REDIS.md previously showed only redis-cli commands. Add two sections
after the minimal working example:

- PHP dashboard example using phpredis (noting Predis as a drop-in):
  connect, user CRUD, cluster TGs, per-trunk filters, dynamic trunk
  peer add/remove, live state reads, live.changed subscribe, and
  invoking --import-conf-to-redis from PHP.

- Migration guide for operators coming from a custom MySQL-backed
  dashboard: an assumed MySQL schema plus a PHP PDO script that
  generates a .conf snippet, piped through --import-conf-to-redis for
  a one-shot migration with an audit step.
2026-04-15 16:27:09 +02:00
Audric 65063fd92a docs: catalogue v1.1 jay additions and v1.2 Redis store in README + protocol doc
README 'What it adds over SvxReflector' was still on the pre-v1.1
surface. Add entries for:
  - per-trunk TG filters (BLACKLIST_TGS/ALLOW_TGS/TG_MAP/PEER_ID) with
    the shared filter syntax
  - node-list broadcasting (MsgTrunkNodeList) and its MQTT republishing
  - PTY admin channel (TRUNK MUTE/UNMUTE/RELOAD/STATUS, CFG)
  - optional Redis-backed config store (points at docs/REDIS.md)

Also refresh the /status and MQTT bullets to mention muted-callsigns,
Redis metrics, node lists, and MQTT_NAME.

TRUNK_PROTOCOL.md protocol-messages table was missing the jayReflector
message types — add 121 MsgTrunkNodeList and 122 MsgTrunkFilter with
their fields, plus a short paragraph explaining each. Also flesh out
MsgTrunkHello's listed fields to include the nonce/hmac/role actually
on the wire.
2026-04-15 16:20:11 +02:00
Audric db9dcf6917 Merge feature/redis-config-store: Redis-backed config store
Adds an optional Redis-backed config store the reflector consults when
[REDIS] is present in svxreflector.conf. When absent, behavior is
byte-identical to master.

When enabled, Redis becomes the source of truth for:
  - [USERS] / [PASSWORDS] (callsign -> password-group -> password)
  - CLUSTER_TGS
  - per-trunk BLACKLIST_TGS / ALLOW_TGS / TG_MAP
  - trunk peer definitions themselves (host/port/secret/remote_prefix/
    peer_id), addable/removable at runtime via pub/sub — no restart

The reflector subscribes to <KEY_PREFIX>:config.changed and reacts per
scope (users, cluster, trunk:<section>, all). Live state (live:client:*,
live:talker:*, live:trunk:*) is pushed through a bounded queue drained
every 75 ms with 60 s TTLs refreshed every 30 s — no Redis call ever
happens on the audio path. Two hiredis async contexts: one pub/sub
subscriber, one for writes. Reconnect with exponential backoff and a
full reload on resume.

Migration tool: svxreflector --import-conf-to-redis [--dry-run]
copies .conf sections into Redis. Idempotent.

Tests: 10 new integration tests (parallel Redis harness with up/test/
down subcommands, separate docker-compose.redis.yml). Legacy trunk
suite fixed: 27/27 pass (was 23/27) — three distinct pre-existing bugs
resolved (missing COMMAND_PTY in generator, statusJson filter dropping
TG_MAP remapped TGs, u32 vs u16 mismatch in Python NodeList parser).

Redis PTY mute plumbing scoped out; mute is local-only and exposed in
/status JSON as a per-trunk 'muted' array. Dashboards drive mutes via
PTY directly.
2026-04-15 16:02:03 +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 16a98f3562 Test + document dynamic trunk add/remove via Redis pub/sub
Add RedisTrunkAddRemoveTest (2 cases: happy-path add/remove and
missing-fields guard) to the Redis integration suite (10 tests total).
Update docs/REDIS.md with trunk:peer key schema, override-semantics
bullet, cookbook add/remove subsections, and static-vs-Redis note.
2026-04-15 15:16:54 +02:00
Audric 1d639dd0b0 Dynamic trunk add/remove via Redis pub/sub
Reflector::onRedisConfigChanged now handles 'trunk:<section>' events by
reading the trunk:<section>:peer hash from Redis:
  - peer present + no local link  -> create new TrunkLink
  - peer absent + local link       -> destroy local TrunkLink (Redis-managed only)
  - both present                   -> reload filters (existing behavior)
  - neither                        -> log and ignore

Tracks which sections were loaded from Redis (m_redis_trunk_sections) so
conf-based test trunks (e.g. TRUNK_TEST) correctly fall back to
reloadConfig() rather than being destroyed on a filter-change event.

Dashboards can now add/remove trunk peers without restarting the reflector.
2026-04-15 15:09:17 +02:00
Audric 9c6f27e12b Load trunk peer definitions from Redis at startup
When [REDIS] is configured, Reflector::initialize synthesizes [TRUNK_*]
sections from 'trunk:<section>:peer' hashes before the trunk discovery
loop. .conf [TRUNK_*] sections are ignored (with a warning) when Redis
is configured. The importer --import-conf-to-redis now also writes peer
definitions into 'trunk:<section>:peer' so existing configs can migrate.
2026-04-15 14:41:18 +02:00
Audric 5cab611ccd docs: remove Redis mute plumbing references; direct to PTY + /status 2026-04-15 13:48:28 +02:00
Audric bc412e1847 Remove Redis mute plumbing; expose mute list in /status JSON
Dashboard will write mutes directly to the PTY rather than Redis; the
Redis addTrunkMute/removeTrunkMute/loadTrunkMutes methods and the PTY
write-through were unused. Mute state is now reflected in the /status
JSON as a per-trunk 'muted' array so operators and dashboards can see
current state without polling Redis.
2026-04-15 13:45:00 +02:00
Audric aed5566956 Split run_redis_tests.sh into up/test/down subcommands
Default 'all' runs the full cycle (CI-friendly). Developers can use
'up' once, 'test' repeatedly as they iterate, 'down' when finished.
Dramatically cuts per-iteration overhead — no rebuild or healthcheck
wait between test runs.
2026-04-15 13:40:44 +02:00
Audric 525bebdd5a Gitignore an internal workflow docs subdirectory 2026-04-15 13:32:45 +02:00
Audric 276aedc3e1 Document Redis-backed config store 2026-04-15 13:14:50 +02:00
Audric a7cd1909f9 Test: --import-conf-to-redis is idempotent 2026-04-15 13:06:30 +02:00
Audric 6036f4903a Test: reflector survives Redis outage and resyncs on restore
Adds RedisOutageTest: stops Redis mid-session, verifies the existing V2
client connection stays alive, then confirms the reflector logs
config.changed: all after reconnect and that post-recovery user writes
take effect.

Fixed callsign N0OTHR to satisfy the reflector's default ACCEPT_CALLSIGN
regex (N0OTHER is 7 chars and fails the pattern).
2026-04-15 13:04:01 +02:00
Audric 9ce6211b03 Test: live:client hash appears/disappears on V2 auth/disconnect
Add RedisLiveStateTest (2 tests) to test_redis.py verifying that
live:client:<callsign> hashes appear in Redis on V2 client auth and
are deleted on disconnect.

Fix a pre-existing bug in RedisStore where drainLiveQueue() sent HSET/
DEL/EXPIRE commands on m_async — the same hiredis context used for
SUBSCRIBE. Redis rejects non-pub/sub commands on a subscribed connection,
causing the repeated "async disconnect" loop seen in logs. Add a second
async context m_async_write exclusively for live-state writes; the sub
context m_async is now used only for SUBSCRIBE/config.changed delivery.

All 7 Redis integration tests pass.
2026-04-15 11:54:48 +02:00
Audric 685696b6b2 Test: PTY MUTE/UNMUTE persists to Redis 2026-04-15 11:09:47 +02:00
Audric ce305e957e Test: verify trunk filter reload via Redis pub/sub
Add [TRUNK_TEST] placeholder trunk section to the Redis test topology so
TrunkLink::reloadConfig() is instantiated. Add RedisTrunkFilterTest with
two tests that SADD/SREM blacklist and allow entries, publish
config.changed, and assert the expected 'Reloaded filters' log line
appears in container stdout within 3 s.
2026-04-15 11:06:51 +02:00
Audric 363648ae43 Add Redis test harness and user add/disable integration tests
Parallel harness (topology_redis.py, generate_redis_configs.py,
docker-compose.redis.yml, run_redis_tests.sh) runs on port range 45xxx
without conflicting with the legacy test stack. test_redis.py adds two
integration tests: user add+auth and user disable rejection, both using
the existing ClientPeer V2 auth from test_trunk.py.
2026-04-15 11:03:09 +02:00
Audric b16653e4df Test harness: add redis service + per-reflector redis flag (infra only)
- topology.py: add REDIS constants and redis_db_index() helper; support a
  'redis' key in REFLECTORS entries (default off — not flipped for any
  reflector here).
- generate_configs.py: emit [REDIS] section per reflector when flagged,
  add redis:7-alpine service to docker-compose when any reflector is
  flagged, add depends_on for redis-enabled reflectors.

No reflector has 'redis: True' set; regenerated configs match master
byte-for-byte. Later tests (F2+) will flip the flag selectively and
handle Redis population via --import-conf-to-redis.
2026-04-15 10:54:02 +02:00
Audric 2981361c6d Redis: reconnect with exponential backoff and full reload on resume 2026-04-15 09:47:04 +02:00
Audric d0b8a44dc7 Refresh live-state TTLs every 30s; expose Redis metrics in /status 2026-04-15 09:34:42 +02:00
Audric 97467a4f70 Push live-state events through queued drain to Redis 2026-04-15 09:25:07 +02:00
Audric 8363e36f6a Add bounded in-memory queue for live-state Redis writes 2026-04-15 09:21:01 +02:00
Audric 92c2a94940 Persist PTY MUTE/UNMUTE to Redis when [REDIS] is configured 2026-04-15 09:10:40 +02:00
Audric 2fc63fc6f3 Extend --import-conf-to-redis to cluster TGs and trunk filters
Imports CLUSTER_TGS from [GLOBAL] into Redis set cluster:tgs,
and per-[TRUNK_*] BLACKLIST_TGS/ALLOW_TGS into sets and TG_MAP
into a hash. Summary line updated with cluster_n and trunks_n counters.
2026-04-15 09:09:15 +02:00
Audric 97ebdeb172 Cluster TGs sourced from Redis when enabled; reload on pub/sub 2026-04-15 09:06:35 +02:00
Audric 11751a08ed TrunkLink reads filters/mutes from Redis when [REDIS] is configured 2026-04-15 09:04:49 +02:00
Audric 2826376070 Add --import-conf-to-redis migration tool (USERS+PASSWORDS) 2026-04-15 09:02:25 +02:00
Audric 977624febf Dispatch Redis config.changed events to per-scope reload paths 2026-04-15 08:57:08 +02:00
Audric 2a3515247c Route auth lookup through RedisStore when [REDIS] is configured 2026-04-15 08:46:39 +02:00
Audric 0de78c459b Add hiredis async adapter and pub/sub subscription 2026-04-15 02:52:03 +02:00
Audric 98b7d0a89e Parse [REDIS] section and connect at startup (sync only) 2026-04-15 02:47:23 +02:00
Audric 6ecbf69bc0 Implement RedisStore sync connect and schema reads/writes 2026-04-15 02:44:01 +02:00
Audric b64b79f2a7 Add RedisStore skeleton (no functionality yet) 2026-04-15 02:41:23 +02:00
Audric 2877d6be79 Add hiredis build/runtime dependency for upcoming Redis backend 2026-04-15 02:38:27 +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 6f5138cd11 Reference WW_DEPLOYMENT.md in README docs list 2026-04-12 23:24:48 +02:00