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.
This commit is contained in:
1 parent
7cf6589a3b
commit
88739d160b
3 files changed
+66
-1
No files matched your search
@@ -2073,6 +2073,28 @@ void TrunkLink::handleMsgPeerNodeList(std::istream& is)
|
||||
}
|
||||
e.status = n.status;
|
||||
sanitizeJsonStrings(e.status);
|
||||
|
||||
// Trim non-permitted TGs out of the status blob's monitoredTGs array
|
||||
// with the same per-link gate as the selected TG above. Otherwise a
|
||||
// node kept because its *selected* TG is permitted could still surface
|
||||
// filtered TGs it is only monitoring into /status, MQTT and the Redis
|
||||
// mirror. Values stay in the peer's wire numbering, matching e.tg.
|
||||
if (e.status.isMember("monitoredTGs") && e.status["monitoredTGs"].isArray())
|
||||
{
|
||||
Json::Value kept(Json::arrayValue);
|
||||
for (const auto& mt : e.status["monitoredTGs"])
|
||||
{
|
||||
if (!mt.isUInt()) continue; // drop malformed entries
|
||||
const uint32_t tg = mt.asUInt();
|
||||
if (isBlacklisted(tg) || isBlacklisted(mapTgIn(tg)) || !isAllowed(tg))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
kept.append(tg);
|
||||
}
|
||||
e.status["monitoredTGs"] = kept; // may be empty
|
||||
}
|
||||
|
||||
// Recipient-relative sat_id from the peer. Pass through as-is after
|
||||
// bounded sanitisation: empty = "on the peer itself", non-empty =
|
||||
// "on a satellite attached to the peer".
|
||||
|
||||
Reference in new issue
Block a user