Commit Graph
11 Commits
Author SHA1 Message Date
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 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 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 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 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