Commit Graph
74 Commits
Author SHA1 Message Date
Audric dbad88e8c3 docs(install): fix clone URL and directory name
The clone command pointed at github.com/IW1GEU/geureflector, which does
not exist -- IW1GEU is the callsign in the attribution line, not the
GitHub account. An anonymous HTTPS clone of a missing repo gets the same
404 GitHub returns for a private one, so git falls back to prompting for
a username and password. That reads as "the repo is private" to anyone
following the install guide, when in fact there was nothing to clone.

Point at github.com/audric/GeuReflector, matching the URL already used
in README.md and docs/TOPOLOGY_EXAMPLES.md, and verified public. Fix the
directory name in both INSTALL.md and README.md to match: git derives it
from the repo name, so the clone lands in GeuReflector/ and the build
steps that follow are relative to it.
2026-07-16 14:14:15 +02:00
Audric 6fcf2fcfdc docs(faq): add FAQ for SvxReflector sysops
Answers the questions SvxReflector operators actually ask when first
looking at GeuReflector: config and node compatibility, ports/NAT,
bandwidth, prefix ownership and longest-prefix routing, LOCAL_ALIASES vs
CLUSTER_TGS, TG interest, trunk vs node connections, twin pairs, trunk
status, /status exposure, and MQTT.

Answers were checked against the code rather than the existing docs.
Notably: peers exchange rosters over the peer link, so /status is not
required by the mesh and can be firewalled; client failover across
HOSTS=ref1,ref2 is stock SvxLink, not something the twin protocol adds.
2026-07-14 14:48:56 +02:00
Audric 003e1f4dcd docs(alias): record why rewrite-on-select redirects instead of refusing
The alias number is reserved by folding a client's selection onto the
short number rather than rejecting it. That is forced, not chosen:
handleSelectTG always honors the requested TG, there is no
"selection denied" message in the protocol, and adding one would not
help because the client is vanilla upstream svxlink and cannot be
changed to react to a refusal -- the operator would just see a dead TG.

This rationale lived only in an untracked working note (now removed);
capture it next to the behaviour it explains so it is not re-litigated.
2026-07-13 10:56:28 +02:00
Audric 238126ab33 docs(concepts): note that ROUTABLE_PREFIXES=* forwards unowned TGs
CONCEPTS.md stated that a TG matching no mesh prefix is "never sent over
any trunk". That is false on a link configured with ROUTABLE_PREFIXES=*:
the wildcard is a zero-length match in TrunkLink::isSharedTG, so when no
real prefix matches it still claims the TG and the audio is forwarded up
the uplink. The peer then drops it (it matches neither its LOCAL_PREFIX
nor the link's REMOTE_PREFIX), so nobody hears it -- but it does cross
the wire, which matters for a TG intended to stay private.

Qualify both places that promised local-only behaviour, and point at an
explicit ROUTABLE_PREFIXES list as the way to keep a TG from egressing.
2026-07-13 10:52:44 +02:00
Audric 76a7f3dce0 docs(topology): document LOCAL_ALIASES, fix stale and incorrect claims
The PDF is built from docs/topology_pdf/ (HTML + Graphviz), not from
TOPOLOGY_EXAMPLES.md, so the two prose copies had drifted. Resync them
and correct several claims that no longer matched the code.

- Add a LOCAL_ALIASES overlay section (+ diagram 6): re-home a short local
  TG under an owned prefix so the mesh routes the long number while local
  clients keep dialing the short one. Translation happens at the trunk
  boundary only -- clients and satellites see the short number.

- Peer interest: MsgPeerTgInterest (type 129) lets a passive listener
  register interest without keying. The HTML still claimed the owner
  cannot fan a TG back until the peer transmits; corrected in the
  Background, the section-2 return leg, and the Properties list.

- Satellite trust model: per-satellite SECRET_<id> is implemented
  (Reflector::resolveSatelliteSecret); drop the "future work" note.

- SATELLITE_FILTER: filter entries are exact unless suffixed with "*"
  (TgFilter::parse), so the documented bare 2222/2224 values matched only
  those literal TGs. Use 2222* and document the syntax.

- Zones are no longer drawn as satellites. A satellite owns no prefix and
  inherits its parent's identity, so a prefix-owning Zone cannot be one.
  Zones now hang off IT 222 as sub-trunks (REMOTE_PREFIX supports a
  comma-separated list), shown with a mix of owned, local-only and aliased
  TGs. Note that ROUTABLE_PREFIXES=* forwards unowned TGs to the uplink,
  where the peer drops them.

- Merge the old section 3 into section 2 as a "sub-trunk star" variant --
  it was the same two-domain topology with a star instead of a full mesh.
  Satellite becomes section 3, twin section 4.

- Disable code-font ligatures: JetBrains Mono rendered SECRET_<id>= as
  SECRET_<id>= with the ">" swallowed by a ">=" ligature.
2026-07-13 10:26:23 +02:00
Audric 0885352b1c feat(status): expose per-trunk routable_prefixes and routable_wildcard
Surface the ROUTABLE_PREFIXES configuration in the trunk /status JSON (and
therefore the MQTT retained status and Redis snapshots) so operators can see,
per trunk, which pass-through prefixes the link carries and whether it is a
default (*) route. Read-only exposure of existing state — no routing change.

- routable_prefixes: gateway-routed prefixes reachable via the peer but not
  owned by it (from m_routable_prefixes).
- routable_wildcard: true when the link is configured as a * default route.

Documented in docs/PEER_PROTOCOL.md.
2026-07-03 19:11:47 +02:00
Audric 5da075f150 feat(alias): add LOCAL_ALIASES to re-home short local TGs under an owned prefix
Re-home a short local talk group (e.g. 8) under the reflector's own owned
prefix as a globally-unique number (e.g. 2620008) via a single [GLOBAL]
LOCAL_ALIASES entry, so it routes across the trunk mesh like any owned TG
while local users keep dialing the short number.

- Config: LOCAL_ALIASES=localTG:aliasTG[/dir] (dir in|out, omitted = two-way);
  aliasTG must be owned by a LOCAL_PREFIX. Rejects unowned alias, an owned
  short side, duplicate short keys, and numeric overflow.
- Boundary rewrite: prefix routing / owner-relay / peer-interest run on the
  long owned number; local delivery and talker arbitration run on the short
  number, bridged in the four inbound trunk handlers.
- Rewrite-on-select folds a client that dials the long number onto the short
  number (select + monitor), so the two are one conversation locally and on
  the mesh.
- Twin: external-talker notify uses the short number to match the audio
  mirror; disconnect cleanup folds to short so an aliased TG cannot wedge.
- /status exposes local_aliases; satellite nodes warn that the setting is
  ignored (a local alias belongs on the mesh parent that owns the prefix).
- Docs (PEER_PROTOCOL, CONCEPTS, conf template) and integration tests
  (tests/test_alias.py): two-way / in / out, rewrite-on-select, status,
  validation, disconnect-wedge, and duplicate-key coverage.
2026-07-03 18:17:16 +02:00
Audric 7e625dd514 docs: note [SERVER_CERT] COMMON_NAME is required to start
Verified by building the Docker image and running it: a reflector with no
SERVER_CERT/COMMON_NAME aborts at startup ('SERVER_CERT/COMMON_NAME is unset
... Initialization failed') and, under restart: unless-stopped, crash-loops.
Setting COMMON_NAME lets it auto-generate its CA + server cert and start
cleanly (/status responds). The earlier minimal configs omitted it.

- README quick start: add [SERVER_CERT] COMMON_NAME to the minimal config with
  a 'required — aborts without it' note.
- docs/DOCKER.md: flag COMMON_NAME as required in step 1 and note the
  crash-loop failure mode.
2026-06-17 18:26:55 +02:00
Audric 594eee2056 docs: fix Docker quick starts and document routable-prefix intl reach
README:
- Quick start: drop the Docker command block. The repo ships no ready-to-run
  svxreflector.conf (only the .conf.in template) and the compose bind-mount
  hits the 'auto-create a directory' trap, so the inline 'docker compose up'
  steps fail for a newcomer. Point step 1 at the template and step 2 at
  INSTALL.md / DOCKER.md instead.
- Section 5 routable example: use real countries with ISO-alphabetical section
  names (TRUNK_DE_IT, TRUNK_DE_FR) per the naming standard, plus a clearly
  sub-national name for the regional uplink; real MCCs (IT 222, DE 262, FR 208).

docs/DOCKER.md:
- Rewrite step 1: you must create config/svxreflector.conf before first start;
  warn about the bind-mount directory trap and how to recover; copy from the
  .conf.in template; link the README quick start and INSTALL.md.

docs/DEPLOYMENT_ITALY.md + _IT.md:
- Add a 'Reaching international TGs' section (EN + IT): the national mesh needs
  an international gateway plus ROUTABLE_PREFIXES on each region's gateway trunk
  to reach foreign TGs; notes on '*' for a single-uplink leaf and BLACKLIST
  precedence.
2026-06-17 18:04:40 +02:00
Audric 0f83a25e50 docs(topology): explain ROUTABLE_PREFIXES for Zone->international reach
The gateway example (section 2) only traced the foreign->Zone direction,
which works via gateway prefix routing because the gateway holds the direct
trunk. The reverse — a regional Zone client calling an international TG —
does NOT work by default: the Zone's prefix table has only 222 + Zone
prefixes, so a foreign TG matches nothing and stays local. Without
ROUTABLE_PREFIXES a regional reflector can never call an international TG.

Add a subsection to section 2 (in both TOPOLOGY_EXAMPLES.md and the PDF
source topology.html) showing the Zone uplink config
(ROUTABLE_PREFIXES=262,240 alongside REMOTE_PREFIX=222), the explicit-prefix
rule for a multi-trunk Zone vs the '*' default route for a single-uplink
leaf, and the multi-trunk '*' warning. Cross-links to README section 5 and
CONCEPTS.md. Rebuilt TOPOLOGY_EXAMPLES.pdf.
2026-06-17 17:33:05 +02:00
Audric e35cf42b27 docs: clarify that local TG numbering is opt-in and routing follows the number
A reflector does not impose the prefix convention on its nodes. Make explicit
the third routing case (previously undocumented): a TG matching no prefix in
the mesh has no owner and stays local-only (relayed among the reflector's own
nodes, never trunked), exactly like stock SvxReflector.

Routing is decided solely by longest-prefix-match on the number itself,
regardless of length: a conforming number is routable wherever its prefix
points *if that prefix is owned by a reflector in the mesh* (e.g. 22210->222
Italy, 26201->262 Germany); a non-matching number (e.g. short 1-199 in a
typical MCC scheme) stays local and is unreachable by international traffic.
Conversely a 'local' number that happens to match a configured prefix will be
routed to that owner.

Use real in-repo MCC examples (222/262) instead of unassigned 201/401, and
state the 'if owned in the mesh' precondition. Updated README (How TG
ownership works), CONCEPTS.md (section 2), and TOPOLOGY_EXAMPLES.md; rebuilt
TOPOLOGY_EXAMPLES.pdf from the matching topology.html change.
2026-06-17 17:28:42 +02:00
Audric 70de93f19e docs: state the international trunk section-name standard
International trunk sections are named TRUNK_<ISO>_<ISO> using each
country's ISO 3166-1 alpha-2 code with the two codes in alphabetical order
(e.g. TRUNK_DE_FR, TRUNK_DE_IT). Sorting alphabetically makes the name
deterministic so both sysops independently arrive at the same section name
with no 'my country first' dispute.

This convention was already used and explained in WW_DEPLOYMENT.md but was
only a passing 'readable convention' note in INSTALL.md and absent from the
README section-name rule (the most-read spot). State it as the standard in
README section 4 and INSTALL.md section 6b, with the rationale.
2026-06-17 17:18:41 +02:00
Audric 09db2b5326 docs(troubleshooting): correct ROUTABLE_PREFIXES per-link/per-direction semantics
ROUTABLE_PREFIXES is read and applied locally per link (matchesRoutable /
isSharedTG / collectAllTrunkPrefixes); it is never sent on the wire
(absent from ReflectorMsg.h / MsgPeerHello) and is not validated against the
peer. It therefore does NOT need to be identical on both ends of a link -
only the section name and SECRET must match. The previous wording implied
forward-path symmetry and that the return leg relies solely on interest;
both were imprecise. Clarify the per-direction model and the return-leg
options (downstream ROUTABLE_PREFIXES or peer interest; * leaf via interest
+ wildcard accept).
2026-06-17 17:15:36 +02:00
Audric 53749ffec0 docs: add CONCEPTS and TROUBLESHOOTING guides, plus README navigation
Additive newcomer docs building on the onboarding intro:

- docs/CONCEPTS.md: the bridge between the README glossary and the wire-level
  PEER_PROTOCOL.md. Explains TG-ownership/longest-prefix-match, owner-relay,
  peer interest (+10-min timeout), cluster TGs (single-hop), and talker
  arbitration (lower nonce wins), with a worked three-way-QSO walkthrough.
- docs/TROUBLESHOOTING.md: symptom-first checklists (trunk won't connect,
  audio won't cross, one-way audio, satellite/twin issues, flapping links),
  grounded in the real connect/routing rules and pointing at /status + logging.
- README: add a Contents TOC, a 'Which setup fits my deployment?' table that
  surfaces the topology decision guide near the top, and index both new docs.

All in-page anchors and cross-doc links verified.
2026-06-17 17:11:07 +02:00
Audric 66f88a2f00 docs(routable): fix README link section-name match; note restart semantics; tighten wildcard wording 2026-06-15 21:49:19 +02:00
Audric 013040d1fb docs(routable): fix routing example, delegation note, return-leg accept, test refs
- Replace wrong "ownership caveat" in all three files with a neutral
  delegation note: a more specific routable prefix intentionally delegates
  that sub-range via longest-prefix-match; point it at the reflector that
  actually owns those TGs.
- Fix the README example: align it with the actual test topology
  (leaf 222100 → natlit 222 → natlde 262 → far 263, two transit nodes,
  three trunk links); every REMOTE_PREFIX now equals the peer's LOCAL_PREFIX
  with no collisions; add the natlde return-path trunk section.
- Add a sentence in both README and PEER_PROTOCOL.md explaining that the
  *-leaf accepts returning audio via matchesRoutable on its inbound-accept
  gate (hasPrefixRoute cannot serve this role since * is not in m_all_prefixes).
- Fix tests/TESTS.md: remove non-existent topology_routable.py reference
  (routable topology lives in topology.py/ROUTABLE_REFLECTORS, generated by
  python3 generate_configs.py → docker-compose.routable.yml); correct
  "two hops away" to "two transit nodes away (three trunk links)".
2026-06-15 21:42:28 +02:00
Audric b18f3e8141 docs(routable): document ROUTABLE_PREFIXES across conf, README, protocol, tests 2026-06-15 19:48:30 +02:00
Audric 88739d160b feat(trunk): apply per-link TG filter to monitoredTGs in peer roster
The roster trim added in 7cf6589 dropped a peer node entirely when its
*selected* TG was filtered, but a kept node (selected on a permitted TG)
still carried its full monitoredTGs list verbatim in the status blob, so
blacklisted / non-ALLOW_TGS TGs it was only monitoring leaked into
/status.trunks[<section>].nodes[*].monitoredTGs and the MQTT/Redis mirrors.

Filter each entry's monitoredTGs array in TrunkLink::handleMsgPeerNodeList
with the same composite gate as the selected TG and the audio receive path
(isBlacklisted(tg) || isBlacklisted(mapTgIn(tg)) || !isAllowed(tg)), so
TG_MAP translation is honoured and the blacklist wins over an allow-prefix.
Non-permitted and malformed (non-uint) entries are dropped; the array may
become empty. Visibility-only: m_partner_nodes feeds statusJson() and
onPeerNodeList() (MQTT/Redis), never routing.

Adds test_21c_filter_trims_monitored_tgs_in_blob and documents the
monitor-list trim in PEER_PROTOCOL.md.
2026-05-27 13:06:23 +02:00
Audric 7cf6589a3b feat(trunk): apply per-link TG filter to peer node roster on ingest
BLACKLIST_TGS / ALLOW_TGS previously gated only audio and active-talker traffic on a trunk link; the full client roster (MsgPeerNodeList) was stored verbatim, so a peer node parked on a filtered TG still appeared in /status.trunks[<section>].nodes and the MQTT/Redis mirrors.

Filter each node-list entry in TrunkLink::handleMsgPeerNodeList using the same composite gate as the audio receive path (isBlacklisted(tg) || isBlacklisted(mapTgIn(tg)) || !isAllowed(tg)), so TG_MAP translation is honoured. Filtered entries are dropped entirely. Safe because m_partner_nodes feeds only statusJson() and onPeerNodeList() (MQTT/Redis) -- no routing depends on it.

Adds test_21b_filter_drops_nodes_from_roster and documents the receive-side trim in PEER_PROTOCOL.md and svxreflector.conf.in.
2026-05-25 20:43:09 +02:00
Audric e3b0b6f3df docs: refresh test docs and complete MsgTrunk* -> MsgPeer* rename
- TWIN_PROTOCOL.md: note that the trunk->twin mirror delivers to selected
  AND monitoring clients (the composite selected-OR-monitor filter),
  pairing with the TwinLink fix in f1d4afd; complete the MsgTrunk* ->
  MsgPeer* rename in the steady-state message table and design narrative.
- TESTS.md: bring in line with the current suite — trunk 35->50, twin
  11->17. Document test_trunk 33-47 (satellite cross-visibility, prefix
  routing/cluster fanout, monitor-TG fanout, trunk resilience) and the
  test_twin X1-X5 series including the new X5 monitor regression; add the
  mqtt-deltas, satellite-secrets, and logging suites to the run sequence;
  update the five-client roster.
- Rename stale MsgTrunk* references to MsgPeer* (wire IDs unchanged, per
  18d92a2) across README, DEPLOYMENT_ITALY{,_IT}, WW_DEPLOYMENT,
  JAY-additions, and DESIGN_SATELLITE_AND_CLUSTER. PEER_PROTOCOL.md keeps
  its two MsgTrunk* mentions — they document the rename itself.
2026-05-24 12:42:53 +02:00
Audric edd188b457 docs(topology): expand international mesh diagrams to 5 countries
- §1 (01_intl_mesh.dot): full mesh now includes ES (214), SE (240),
  DE (262), IT (222), UA (255) — 5-node pentagon with 10 edges.
- §2 (02_flat_mesh.dot): international side likewise widened to the
  5-country full mesh; IT 222 stays as the rightmost gateway vertex.
  National-side Zones spread into a 2x2 block mirroring the
  international layout so the 10 national edges have room to breathe.
- ASCII art in TOPOLOGY_EXAMPLES.md §1 and §2 updated to match.
- TOPOLOGY_EXAMPLES.pdf rebuilt via docs/build_topology_pdf.sh.
2026-05-17 13:26:21 +02:00
Audric de7e4648ea docs: add MCC country-codes reference; MCC-anchor remaining bare prefix examples
- New docs/MCC_COUNTRY_CODES.md: 25-country table with ISO codes and
  MCC(s), notes on countries with multiple MCC allocations, and a
  pointer to the ITU-T E.212 source for everything else.
- INSTALL.md §6a/6b: replace toy single-digit LOCAL_PREFIX/REMOTE_PREFIX
  examples with MCC-anchored ones (LOCAL_PREFIX=262, REMOTE_PREFIX=240,
  TRUNK_DE_SE) plus a cross-reference to the new MCC table.
- DESIGN_SATELLITE_AND_CLUSTER.md: MCC-anchor the two stale config
  snippets (LOCAL_PREFIX 01->22201, REMOTE_PREFIX 02->22202) so the
  historical design doc no longer teaches the bare-regional-digit
  anti-pattern.
2026-05-17 13:26:15 +02:00
Audric 61aafc1c0c docs(italy): MCC-prefix LOCAL_PREFIX and REMOTE_PREFIX with 222
Bare 2-digit regional codes (e.g. LOCAL_PREFIX=01) carried no country
namespace and would collide with any other country picking the same
regional digits. Prefix every LOCAL_PREFIX and REMOTE_PREFIX with the
Italy MCC (222), so each value sits inside the 222 prefix space
(e.g. Lazio = 22201, Lombardia = 22221). Section names
[TRUNK_xx_yy] and SECRET=IT_xx_yy keep the 2-digit form as readable
identifiers — only the prefix values themselves are MCC-anchored.
Inventory table, prose explanation, complete Lazio config block,
per-region checklist, and the parallel Italian translation all
updated in lockstep.
2026-05-17 11:14:11 +02:00
Audric a9691cdf4e docs: remove handoff doc — contained third-party private chat 2026-05-17 10:56:45 +02:00
Audric f9bd1bd3cf docs: drop stale provenance line from monitor-tg handoff doc 2026-05-17 10:55:15 +02:00
Audric 28525b03d5 docs(satellite): document per-id SECRET_<id>= across deployment and design docs
- WW_DEPLOYMENT.md, DEPLOYMENT_ITALY.md (+ IT translation): add the
  per-id SECRET_<id>= snippet alongside the existing single-secret
  example so operators see both forms.
- TOPOLOGY_EXAMPLES.md: rewrite the obsolete 'future work:
  per-satellite secrets' callout in §3 to reflect the shipped feature;
  touch up §4 reference to the parent's SECRET.
- DESIGN_SATELLITE_AND_CLUSTER.md: preserve the original design body;
  add a brief postscript pointing readers to the per-id form in the
  README.
2026-05-17 10:55:13 +02:00
Audric 6a6cfadd95 fix(twin): mirror inbound trunk audio across the twin link
When an external PAIRED=1 peer transmits to a twin pair, it picks a
single sticky socket per transmission and sends every frame on it. The
sticky-selected twin's TrunkLink::handleMsgPeerAudio used to broadcast
locally and to satellites but never relayed to the partner twin — so
local clients on the non-sticky twin were deaf to the audio even though
the talker state was mirrored correctly. The satellite-receive path
already had the symmetric forwarder (forwardSatelliteRawAudioToTwin);
the trunk path was just missing it.

Add Reflector::forwardTrunkAudioToTwin and forwardTrunkFlushToTwin,
modelled on the satellite variants, and invoke them from
TrunkLink::handleMsgPeerAudio and handleMsgPeerFlush after the local +
satellite broadcasts. Loop safety: TwinLink::handleMsgPeerAudio does
not re-forward to trunks, so there is no echo back to the originating
peer. Requires the external peer to use PAIRED=1 with both twin
hostnames in a single section — two independent trunk sections would
defeat the source-trunk exclusion at the external owner and cause
duplicates/echo. The docs now flag PAIRED=1 as mandatory for this
topology.

Test: test_twin.py::test_X4_paired_inbound_reaches_both_twins drives a
refa client on TG 26201 and asserts both ref1 and ref2 receive audio
frames and flush. Also rewrite test_01_twin_handshake and
test_05_twin_wiring_no_errors to read /status.twin instead of scraping
a 120s docker-logs window — the previous form flaked when the mesh had
been up long enough for boot-time log lines to scroll off.
2026-05-14 19:37:44 +02:00
Audric ef42da52de docs(install): document config-dir override at build and runtime
Add a subsection to "Build" covering CMAKE_INSTALL_SYSCONFDIR for
baking a custom config directory into the binary (the common case:
-DCMAKE_INSTALL_SYSCONFDIR=/etc to read /etc/svxlink/svxreflector.conf),
the --config runtime override, and the full lookup order at startup.
2026-05-12 16:48:59 +02:00
Audric 93f0274b9e docs(peer-protocol): list type 129 in upstream-vs-fork file table 2026-05-10 23:29:56 +02:00
Audric 987353853c docs: refresh peer/twin protocol docs for recent fixes
PEER_PROTOCOL.md: UDP monitor-fanout filter is now gated by
SelectedTgIdleFilter (commit dc3a8c0).

TWIN_PROTOCOL.md: satellite-originated traffic now reaches the twin
partner via forwardSatellite*ToTwin (commit ace9da6).
2026-05-10 23:09:22 +02:00
Audric 66de2966d8 docs(reflector): handoff diagnosis for v1.3.10 monitor-TG audio mix bug
Verified-facts diagnostic doc for the audio mixing bug reported by
 2026-05-10 and fixed in dc3a8c0. Captures: the seven
UDP fanout sites a661879 widened (§2.1), TwinLink's bare-TgFilter
asymmetry (§2.2), TCP MsgTalkerStart/Stop OR-filter history (§2.3),
the symptom mechanism (§2.9), constraints driving the fix (§3),
and resolved verification questions (§4).
2026-05-10 21:22:10 +02:00
Audric e9bb1a9e2d fix(peer): heartbeat MsgPeerTgInterest re-sends to keep TTL alive
The 60 s heartbeat path was inheriting the skip-when-unchanged gate
from the 500 ms debounce path. Result: after the initial
edge-triggered advertisement, an idle reflector with a stable monitor
list would silently no-op every 60 s, the receiver's
m_peer_interested_tgs[tg] timestamp never got refreshed, and its
600 s TTL elapsed. A passive monitor would go deaf 10 minutes after
adding a foreign TG to monitoredTGs.

Split the two call sites: heartbeat passes force=true (always send),
debounce keeps force=false (skip when unchanged). The steady-state
heartbeat is one frame per trunk per minute, which is what the
receiver TTL needs.

Doc note in PEER_PROTOCOL.md was wrong (claimed both timers skipped
unchanged sends); corrected.

Affects v1.3.9; ship as v1.3.10.
2026-05-08 21:03:41 +02:00
Audric a6618790bb feat(peer): passive-monitor support via MsgPeerTgInterest
A node that has selected a TG without keying, or marked it in
monitoredTGs, never received any audio: peer interest was only
populated by talker activity, and the local UDP fanout filtered by
TgFilter alone (current TG match), ignoring monitor entries.

Adds:

- MsgPeerTgInterest (wire ID 129, peer_id + vector<uint32_t>) — each
  trunk peer advertises the union of its local clients' selected TG
  and monitoredTGs to peers whose prefix is the longest-prefix-match
  for the TG. Edge-triggered (500 ms debounce) on client connect /
  disconnect, MsgSelectTG, MsgTgMonitor, and trunk hello completion;
  60 s periodic refresh as a safety net, skipping when the outgoing
  set is unchanged. The receiver writes mapTgIn(tg) into
  m_peer_interested_tgs so the existing send-side gates
  (isPeerInterestedTG, shouldRelayInbound + forwardTrunkAudioToOther
  Trunks) deliver audio without requiring a PTT to bootstrap.

- Multi-hop propagation. Receivers re-advertise interest from other
  peers, prefix-filtered for the destination link and source-link
  excluded, so country-gateway-into-national-mesh layouts (§2)
  converge in one debounce per hop. Closes the gap where SE
  monitoring an Italian regional TG would never reach Z1 without
  IT 222 explicitly forwarding interest.

- TgMonitorFilter applied at every local UDP fanout (audio +
  MsgUdpFlushSamples) — Reflector::onUdpFrameReceived and the local
  talker stop, the trunk receive path, and both directions of the
  satellite mirror. Without this, the protocol-level interest
  arrives at the right reflector but stops at its UDP fanout — the
  passive monitor still hears nothing. Strict superset: no existing
  delivery path is removed.

Loop safety relies on filtering local-side MsgPeerTgInterest by
isSharedTG (same gate as audio fanout). Advertising to non-owner
peers would register ghost interest there, which gateway prefix
routing would then relay back across the mesh. Verified by
test_32_three_way_conversation (full mesh, no echo loops).

Tests: new test_39_passive_monitor_multihop covers the §2 chain
(SE-style monitor on a, talker on d, gateway b). All existing
tests pass: 42 trunk + 7 mqtt-deltas + 6 logging + 14 twin = 69/69.

Builds on the idea originally proposed in #4 by @sa2blv; the
single-hop and wire-ID-collision issues described in the close
comment are addressed in this rewrite.
2026-05-08 20:38:14 +02:00
Audric ccf34adbe6 feat(mqtt): add ts and duration_ms to talker start/stop events
Talker MQTT payloads now carry a Unix-epoch-ms `ts` field on both start
and stop. Stop additionally carries `duration_ms` whenever a matching
start was observed by the same MqttPublisher instance and the resulting
duration is non-negative. Both fields are additive — older consumers
that only read `callsign` continue to work unchanged.

Implementation
- MqttPublisher tracks per-(peer_id, tg) start_ms in a small std::map.
  Local talkers use peer_id="" as the map key. The entry is consumed on
  the matching stop.
- On stop, duration_ms is computed as `now - start_ms`. The field is
  omitted when:
  * no matching start was recorded (e.g. reflector restarted mid-talker)
  * the resulting duration is negative (backwards NTP correction during
    the transmission)
  Both edge cases are documented in docs/MQTT.md.
- Applies symmetrically across the four publish paths:
  onTalkerStart / onTalkerStop / onPeerTalkerStart / onPeerTalkerStop.

Tests
- test_trunk.py::test_18_mqtt_talker_event extended:
  * asserts `ts` is present on start, parses as int, lies within a
    +/- 60s window of the test's local clock.
  * asserts `ts` on stop is >= start ts.
  * asserts `duration_ms` on stop is present, >= the held-talker time
    (~500 ms), and equals stop_ts - start_ts.
- Edge-case behaviour (no-start, backwards clock jump) is guarded in
  code and documented; reaching it from the integration suite would
  require restarting the reflector mid-talker or injecting a clock
  step, so it is not asserted from outside.

Docs
- docs/MQTT.md: payload examples updated for both flat and
  peer-namespaced talker topics; new paragraph spelling out the two
  conditions under which duration_ms is omitted.
- docs/MESSAGING_IDEAS.md: Telegram-bot example extended to also
  handle /stop with a `duration_ms >= 1000` filter (kerchunk
  suppression) and a short note on how `ts`/`duration_ms` map to
  end-to-end pipeline latency and session length.
2026-05-07 17:02:39 +02:00
Audric 52b5e4f3cf feat(reflector): gateway prefix routing via shouldRelayInbound
A non-owner reflector with two trunk legs (a country gateway sitting
between an international mesh and a national mesh) now forwards inbound
trunk traffic toward the actual prefix owner — automatically, via
longest-prefix-match in its own [TRUNK_x] table. Cluster TGs keep their
deliberate single-hop semantic to prevent loops in cyclic meshes.

Implementation
- Reflector::shouldRelayInbound(tg) composes the inbound relay decision:
  * isLocalTG          -> fan out (existing owner-relay)
  * isClusterTG        -> stop (anti-loop; cluster TGs broadcast outbound
                                from local clients only)
  * hasPrefixRoute     -> gateway forwarding via per-trunk isSharedTG
- The four isLocalTG gates in TrunkLink::handleMsgPeer{TalkerStart,
  TalkerStop,Audio,Flush} are replaced by shouldRelayInbound. Source
  exclusion in forwardTrunk*ToOtherTrunks plus per-link interest
  tracking keep the topology naturally loop-free.

Tests
- topology.py: per-reflector `peers` filter for sparse layouts; new
  reflector `d` (prefix 1219, trunked only to `b`) demonstrating
  gateway-only reachability from `a` to `d`.
- generate_configs.py: honours the peers filter.
- test_trunk.py:
  * setUpClass and test_01 skip non-existent pairs in sparse layouts.
  * test_37_gateway_prefix_routing: a-client (122) <-> d-client (1219)
    over TG 121950 in both directions, no CLUSTER_TGS.
  * test_38_cluster_tg_local_client_broadcast: explicit coverage for
    the outbound local-client cluster broadcast path.
- All previously passing tests still pass: 41/41 trunk + 7/7
  mqtt-deltas + 14/14 twin.

Docs
- docs/TOPOLOGY_EXAMPLES.md (new) + .pdf + topology_pdf/ build sources +
  build_topology_pdf.sh: visual cookbook of the five topology shapes
  (international full-mesh, national mesh joined at gateway, satellite
  tree, hybrid satellite-under-regional, HA twin pair). Includes an
  MCC-range appendix with the recommendation to draw cluster TGs from
  100-199 / 800-999 to avoid country-prefix collisions.
- docs/PEER_PROTOCOL.md: rewrote the "Owner-Relay Fanout" section as
  "Inbound Relay (shouldRelayInbound)" with the three-regime
  composition and clarified the single-mesh fanout caveat.
- README.md: feature bullet now describes gateway prefix routing and
  links to TOPOLOGY_EXAMPLES.md (also added to the documentation list).
2026-05-07 16:12:14 +02:00
Audric c19f7d7752 docs: peer-client liveness MQTT topics + protocol additions
- docs/MQTT.md: new peer/<id>/client/<call>/* topics, retained-rx
  migration, MQTT_NAME twin-mode requirement, retained-store
  growth note (housekeeping deferred per Task 11).
- docs/PEER_PROTOCOL.md: MsgPeerClient* types 125-128 with routing
  (satellite+twin only, not trunk).
- CLAUDE.md: refresh trunk/peer message overview to reflect rename
  and new types.
2026-04-29 17:50:31 +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 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 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 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 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 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 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 a2b5d448fa docs: TWIN protocol implemented; bump version 2026-04-15 22:29:36 +02:00