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.
This commit is contained in:
Audric committed 2026-04-19 00:02:58 +02:00
1 parent cadc5c5aa2
commit bf5af3eca0
3 files changed
+73

No files matched your search

+5
View File
@@ -204,6 +204,11 @@ class TrunkLink : public sigc::trackable
// TGs currently held by this specific trunk peer (for scoped cleanup)
std::set<uint32_t> m_peer_active_tgs;
// Most recent MsgTrunkNodeList we received from the peer, sanitized.
// Surfaced in statusJson() so /status can attribute nodes to a peer.
// Cleared when the link goes fully inactive.
std::vector<MsgTrunkNodeList::NodeEntry> m_partner_nodes;
// TGs the peer has shown interest in (sent TalkerStart for).
// Maps TG number to last activity timestamp. Entries expire after
// PEER_INTEREST_TIMEOUT_S seconds of inactivity.