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.
This commit is contained in:
1 parent
e3b0b6f3df
commit
7cf6589a3b
4 files changed
+66
-1
No files matched your search
@@ -1669,6 +1669,48 @@ class TestTrunkIntegration(unittest.TestCase):
|
||||
finally:
|
||||
peer.close()
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Test 21b: per-link TG filter trims the node roster in /status
|
||||
# ------------------------------------------------------------------
|
||||
def test_21b_filter_drops_nodes_from_roster(self):
|
||||
"""A peer-advertised node whose selected TG is blacklisted (or not in
|
||||
ALLOW_TGS) must NOT appear under /status.trunks[X].nodes — the same
|
||||
per-link filter that gates audio/active_talkers also trims the roster.
|
||||
"""
|
||||
peer = TrunkPeer()
|
||||
peer.connect(*_trunk(self.PRIMARY))
|
||||
peer.handshake(trunk_id="TRUNK_TEST_FILTER",
|
||||
local_prefix=FILTER_PREFIX,
|
||||
secret=FILTER_SECRET)
|
||||
try:
|
||||
blocked_tg = int(T.TEST_PEER_FILTER["blacklist_tgs"]) # 12345
|
||||
allowed_tg = 7100 # matches ALLOW_TGS "7*"
|
||||
disallowed_tg = 99 # matches neither "7*" nor "1220"
|
||||
peer.send_node_list([
|
||||
("N0ROK", allowed_tg),
|
||||
("N0RBL", blocked_tg),
|
||||
("N0RDIS", disallowed_tg),
|
||||
])
|
||||
|
||||
def roster_callsigns():
|
||||
status = get_status(*_http(self.PRIMARY))
|
||||
nodes = status["trunks"].get(
|
||||
"TRUNK_TEST_FILTER", {}).get("nodes", [])
|
||||
return {n.get("callsign") for n in nodes}
|
||||
|
||||
# The allowed-TG node must appear (proves the roster was ingested)
|
||||
wait_until(lambda: "N0ROK" in roster_callsigns(),
|
||||
timeout=5.0, interval=0.25,
|
||||
msg="Allowed-TG node N0ROK missing from trunk roster")
|
||||
|
||||
cs = roster_callsigns()
|
||||
self.assertNotIn("N0RBL", cs,
|
||||
f"Blacklisted-TG ({blocked_tg}) node leaked into roster: {cs}")
|
||||
self.assertNotIn("N0RDIS", cs,
|
||||
f"Disallowed-TG ({disallowed_tg}) node leaked into roster: {cs}")
|
||||
finally:
|
||||
peer.close()
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Test 22: TG_MAP remaps incoming TGs
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user