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
@@ -545,6 +545,17 @@ or TG change, debounced to 500 ms, and broadcast to every trunk peer. Peers
|
|||||||
republish it via MQTT under `nodes/<peer_id>` so a central dashboard can see
|
republish it via MQTT under `nodes/<peer_id>` so a central dashboard can see
|
||||||
who is connected to each reflector.
|
who is connected to each reflector.
|
||||||
|
|
||||||
|
On ingest the receiver applies that link's per-trunk TG filter
|
||||||
|
(`BLACKLIST_TGS` / `ALLOW_TGS`) to every entry, using the same match as the
|
||||||
|
audio/talker receive gate (`isBlacklisted(tg) || isBlacklisted(mapTgIn(tg))
|
||||||
|
|| !isAllowed(tg)`, so `TG_MAP` translation is honoured). A node whose
|
||||||
|
selected TG is blacklisted or outside `ALLOW_TGS` is dropped from the roster
|
||||||
|
entirely, so it never appears under `/status.trunks[<section>].nodes`, MQTT
|
||||||
|
`nodes/<peer_id>`, or the Redis mirror — a filtered TG's roster is trimmed on
|
||||||
|
this link just like its audio, even though the full snapshot is sent on the
|
||||||
|
wire. (Satellite links filter on the *send* side via `SATELLITE_FILTER`; trunk
|
||||||
|
links have no roster filtering on send, so the trim happens on receive.)
|
||||||
|
|
||||||
The optional `status_blobs[i]` field carries the source reflector's
|
The optional `status_blobs[i]` field carries the source reflector's
|
||||||
`m_status["nodes"][callsign]` JSON serialised verbatim — the same rich
|
`m_status["nodes"][callsign]` JSON serialised verbatim — the same rich
|
||||||
per-client status that local clients expose (rx/tx config, qth array,
|
per-client status that local clients expose (rx/tx config, qth array,
|
||||||
|
|||||||
@@ -2044,6 +2044,16 @@ void TrunkLink::handleMsgPeerNodeList(std::istream& is)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
e.tg = n.tg;
|
e.tg = n.tg;
|
||||||
|
|
||||||
|
// Per-link TG filter: a node whose selected TG is blacklisted or falls
|
||||||
|
// outside ALLOW_TGS on this link is dropped from the roster entirely,
|
||||||
|
// mirroring the audio/talker receive gate (handleMsgPeerTalkerStart).
|
||||||
|
// This keeps filtered TGs out of /status, MQTT and the Redis mirror —
|
||||||
|
// m_partner_nodes feeds statusJson() and onPeerNodeList() only.
|
||||||
|
if (isBlacklisted(e.tg) || isBlacklisted(mapTgIn(e.tg)) || !isAllowed(e.tg))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
e.qth_name = sanitizeText(n.qth_name, 64);
|
e.qth_name = sanitizeText(n.qth_name, 64);
|
||||||
|
|
||||||
// Lat/lon: reject non-finite; drop out-of-range values by zeroing
|
// Lat/lon: reject non-finite; drop out-of-range values by zeroing
|
||||||
|
|||||||
@@ -121,7 +121,9 @@ CERT_CA_HOOK=@SVX_SHARE_INSTALL_DIR@/ca-hook.py
|
|||||||
# component for this link, so set it to a stable, broker-friendly name.
|
# component for this link, so set it to a stable, broker-friendly name.
|
||||||
#PEER_ID=reflector-a
|
#PEER_ID=reflector-a
|
||||||
# Optional per-trunk TG filters (syntax: exact "26200", prefix "24*",
|
# Optional per-trunk TG filters (syntax: exact "26200", prefix "24*",
|
||||||
# range "2427-2438", comma-separated):
|
# range "2427-2438", comma-separated). These gate audio/talker traffic AND
|
||||||
|
# trim the peer's node roster shown under /status.trunks[<section>].nodes
|
||||||
|
# (and its MQTT/Redis mirror), so a filtered TG never pollutes the roster.
|
||||||
#BLACKLIST_TGS=666,777* # never carried in either direction on this link
|
#BLACKLIST_TGS=666,777* # never carried in either direction on this link
|
||||||
#ALLOW_TGS=24*,2624123 # if set, ONLY these TGs are exchanged
|
#ALLOW_TGS=24*,2624123 # if set, ONLY these TGs are exchanged
|
||||||
# Optional bidirectional TG remap (peer_tg:local_tg, comma-separated).
|
# Optional bidirectional TG remap (peer_tg:local_tg, comma-separated).
|
||||||
|
|||||||
@@ -1669,6 +1669,48 @@ class TestTrunkIntegration(unittest.TestCase):
|
|||||||
finally:
|
finally:
|
||||||
peer.close()
|
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
|
# Test 22: TG_MAP remaps incoming TGs
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
Reference in new issue
Block a user