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