From 97ebdeb172f23f7a2aa4830605a1e86af64bdff7 Mon Sep 17 00:00:00 2001 From: Audric Date: Wed, 15 Apr 2026 09:06:35 +0200 Subject: [PATCH] Cluster TGs sourced from Redis when enabled; reload on pub/sub --- src/svxlink/reflector/Reflector.cpp | 58 ++++++++++++++++------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/src/svxlink/reflector/Reflector.cpp b/src/svxlink/reflector/Reflector.cpp index 2fbd97a..f0ae336 100644 --- a/src/svxlink/reflector/Reflector.cpp +++ b/src/svxlink/reflector/Reflector.cpp @@ -471,31 +471,7 @@ bool Reflector::initialize(Async::Config &cfg) m_cfg->valueUpdated.connect(sigc::mem_fun(*this, &Reflector::cfgUpdated)); // Parse CLUSTER_TGS — comma-separated list of TG numbers broadcast to all peers - std::string cluster_tgs_str; - if (cfg.getValue("GLOBAL", "CLUSTER_TGS", cluster_tgs_str)) - { - std::istringstream ctss(cluster_tgs_str); - std::string token; - while (std::getline(ctss, token, ',')) - { - token.erase(0, token.find_first_not_of(" \t")); - token.erase(token.find_last_not_of(" \t") + 1); - if (!token.empty()) - { - uint32_t tg = static_cast(std::stoul(token)); - m_cluster_tgs.insert(tg); - } - } - if (!m_cluster_tgs.empty()) - { - std::cout << "Cluster TGs:"; - for (uint32_t tg : m_cluster_tgs) - { - std::cout << " " << tg; - } - std::cout << std::endl; - } - } + reloadClusterTgs(); // Satellite mode: connect to parent instead of joining the trunk mesh std::string satellite_of; @@ -2732,7 +2708,37 @@ void Reflector::onTrunkTalkerUpdated(uint32_t tg, void Reflector::reloadClusterTgs(void) { - // Stub — populated by Task C2 (Cluster TGs from Redis). + m_cluster_tgs.clear(); + if (m_redis) { + m_cluster_tgs = m_redis->loadClusterTgs(); + } else { + std::string cluster_tgs_str; + if (m_cfg->getValue("GLOBAL", "CLUSTER_TGS", cluster_tgs_str)) + { + std::istringstream ctss(cluster_tgs_str); + std::string token; + while (std::getline(ctss, token, ',')) + { + token.erase(0, token.find_first_not_of(" \t")); + token.erase(token.find_last_not_of(" \t") + 1); + if (!token.empty()) + { + try { + m_cluster_tgs.insert(static_cast(std::stoul(token))); + } catch (...) { /* skip malformed */ } + } + } + } + } + if (!m_cluster_tgs.empty()) + { + std::cout << "Cluster TGs:"; + for (uint32_t tg : m_cluster_tgs) + { + std::cout << " " << tg; + } + std::cout << std::endl; + } }