Peer node lists (MsgTrunkNodeList, type 121) now propagate into Redis alongside the existing MQTT publish, so dashboards reading Redis see a complete view of local + peer rosters. Each remote entry is stored as live:peer_node:<peer_id>:<callsign> with 60s TTL; a per-peer cache diffs incoming snapshots so dropped callsigns are DEL'd, and a full trunk-down deletes all of that peer's entries. All untrusted strings arriving via the trunk (peer_id from the hello, plus callsign/qth/lat/lon in node lists) are now sanitized at receive: control chars + ':' stripped, length bounded (32 callsign, 64 peer_id and qth), non-finite and out-of-range coordinates cleared. Entries whose callsign becomes empty after sanitization are dropped. Also reorders TrunkLink in/outbound onDisconnected so the state-change notification fires after the per-direction state is cleared, letting consumers that inspect isActive() (like the Redis peer-node cleanup) see the correct post-disconnect state. Adds RedisPeerNodeTest (3 cases: populate+diff, sanitization, trunk- down cleanup) and a build_node_list wire helper in test_trunk.py. Exposes the trunk port in docker-compose.redis.yml so the host can inject trunk frames against the r1 test reflector.
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
"""Minimal topology for Redis-backed test harness.
|
|
|
|
Edit here, then run `python3 generate_redis_configs.py` to regenerate
|
|
configs-redis/ and docker-compose.redis.yml.
|
|
"""
|
|
|
|
# Single Redis-enabled reflector for the Redis test suite.
|
|
REFLECTORS = {
|
|
"r1": {"prefix": ["1"], "trunk_port_base": 45000, "redis": True},
|
|
}
|
|
|
|
REDIS = {
|
|
"host": "redis",
|
|
"port": 6379,
|
|
}
|
|
|
|
# V2 test client credentials (populated into Redis by tests themselves).
|
|
TEST_CLIENTS = [
|
|
{"callsign": "N0TEST", "group": "TestGroup", "password": "testpass"},
|
|
{"callsign": "N0OTHER", "group": "OtherGroup", "password": "otherpass"},
|
|
]
|
|
|
|
# Placeholder trunk peer — no real peer is running, but its [TRUNK_TEST]
|
|
# section makes the reflector instantiate a TrunkLink whose reloadConfig()
|
|
# we can trigger via pub/sub and verify via container logs.
|
|
TRUNK_TEST = {
|
|
"section": "TRUNK_TEST",
|
|
"host": "192.0.2.1", # TEST-NET-1 — guaranteed unroutable
|
|
"port": 59302,
|
|
"secret": "test_secret",
|
|
"remote_prefix": "9",
|
|
}
|
|
|
|
# Internal container ports (same as legacy harness so the reflector
|
|
# binary's defaults don't change).
|
|
INTERNAL_CLIENT_PORT = 5300
|
|
INTERNAL_TRUNK_PORT = 5302
|
|
INTERNAL_HTTP_PORT = 8080
|
|
|
|
def service_name(name: str) -> str:
|
|
return f"reflector-{name}"
|
|
|
|
def mapped_client_port(name: str) -> int:
|
|
return REFLECTORS[name]["trunk_port_base"] + 300
|
|
|
|
def mapped_trunk_port(name: str) -> int:
|
|
return REFLECTORS[name]["trunk_port_base"] + 302
|
|
|
|
def mapped_http_port(name: str) -> int:
|
|
return REFLECTORS[name]["trunk_port_base"] + 3080
|
|
|
|
def redis_port() -> int:
|
|
return 46379
|
|
|
|
def redis_db_index(name: str) -> int:
|
|
return sorted(REFLECTORS).index(name)
|