diff --git a/src/svxlink/reflector/TrunkLink.cpp b/src/svxlink/reflector/TrunkLink.cpp index 402d50f..c874c26 100644 --- a/src/svxlink/reflector/TrunkLink.cpp +++ b/src/svxlink/reflector/TrunkLink.cpp @@ -372,14 +372,18 @@ Json::Value TrunkLink::statusJson(void) const for (const auto& p : m_remote_prefix) remote_arr.append(p); obj["remote_prefix"] = remote_arr; - // active_talkers: TGs held by trunk that match remote prefix or are cluster TGs + // active_talkers: per-peer active TGs (already post-TG_MAP remap). + // We use m_peer_active_tgs directly instead of filtering the global + // trunk-talker map by isSharedTG, because a TG_MAP entry can remap a + // peer-owned wire TG to a local-owned TG that no longer matches the + // peer's remote prefix — that TG must still appear in this peer's view. Json::Value talkers(Json::objectValue); - const auto& trunk_map = TGHandler::instance()->trunkTalkersSnapshot(); - for (auto& kv : trunk_map) + for (uint32_t tg : m_peer_active_tgs) { - if (isSharedTG(kv.first) || m_reflector->isClusterTG(kv.first)) + const std::string cs = TGHandler::instance()->trunkTalkerForTG(tg); + if (!cs.empty()) { - talkers[std::to_string(kv.first)] = kv.second; + talkers[std::to_string(tg)] = cs; } } obj["active_talkers"] = talkers; diff --git a/tests/generate_configs.py b/tests/generate_configs.py index bffbf7f..16ffcb4 100644 --- a/tests/generate_configs.py +++ b/tests/generate_configs.py @@ -24,6 +24,7 @@ def generate_reflector_conf(name: str) -> str: f"CLUSTER_TGS={cluster_str}", f"TRUNK_LISTEN_PORT={T.INTERNAL_TRUNK_PORT}", f"HTTP_SRV_PORT={T.INTERNAL_HTTP_PORT}", + "COMMAND_PTY=/dev/shm/reflector_ctrl", "TRUNK_DEBUG=1", "", "[SERVER_CERT]", diff --git a/tests/test_trunk.py b/tests/test_trunk.py index 5dc91e6..a8171d2 100644 --- a/tests/test_trunk.py +++ b/tests/test_trunk.py @@ -205,8 +205,10 @@ def parse_msg(data: bytes): elif msg_type == MSG_TRUNK_NODE_LIST: # vec callsigns, vec tgs, vec lat, vec lon, # vec qth_names. Each vector is u32-prefixed length. + # Vector length prefixes are u16 (MsgPacker in + # AsyncMsg.h uses uint16_t for element counts). def read_vec_str(off): - n = struct.unpack_from("!I", data, off)[0]; off += 4 + n = struct.unpack_from("!H", data, off)[0]; off += 2 out = [] for _ in range(n): s, off = unpack_string(data, off) @@ -214,13 +216,13 @@ def parse_msg(data: bytes): return out, off def read_vec_u32(off): - n = struct.unpack_from("!I", data, off)[0]; off += 4 + n = struct.unpack_from("!H", data, off)[0]; off += 2 out = list(struct.unpack_from(f"!{n}I", data, off)) off += 4 * n return out, off def read_vec_f32(off): - n = struct.unpack_from("!I", data, off)[0]; off += 4 + n = struct.unpack_from("!H", data, off)[0]; off += 2 out = list(struct.unpack_from(f"!{n}f", data, off)) off += 4 * n return out, off