TrunkLink reads filters/mutes from Redis when [REDIS] is configured

This commit is contained in:
Audric committed 2026-04-15 09:04:49 +02:00
1 parent 2826376070
commit 11751a08ed
1 file changed
+30 -4
+30 -4
View File
@@ -60,6 +60,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Reflector.h" #include "Reflector.h"
#include "TGHandler.h" #include "TGHandler.h"
#include "ReflectorClient.h" #include "ReflectorClient.h"
#include "RedisStore.h"
#include <json/json.h> #include <json/json.h>
@@ -1098,19 +1099,37 @@ void TrunkLink::reloadConfig(void)
m_tg_map_in.clear(); m_tg_map_in.clear();
m_tg_map_out.clear(); m_tg_map_out.clear();
RedisStore* rs = m_reflector->redisStore();
std::string blacklist_str; std::string blacklist_str;
if (m_cfg.getValue(m_section, "BLACKLIST_TGS", blacklist_str) if (rs) {
&& !blacklist_str.empty()) blacklist_str = rs->loadTrunkFilter(m_section, "blacklist");
} else {
m_cfg.getValue(m_section, "BLACKLIST_TGS", blacklist_str);
}
if (!blacklist_str.empty())
{ {
m_blacklist_filter = TgFilter::parse(blacklist_str); m_blacklist_filter = TgFilter::parse(blacklist_str);
} }
std::string allow_str; std::string allow_str;
if (m_cfg.getValue(m_section, "ALLOW_TGS", allow_str) && !allow_str.empty()) if (rs) {
allow_str = rs->loadTrunkFilter(m_section, "allow");
} else {
m_cfg.getValue(m_section, "ALLOW_TGS", allow_str);
}
if (!allow_str.empty())
{ {
m_allow_filter = TgFilter::parse(allow_str); m_allow_filter = TgFilter::parse(allow_str);
} }
if (rs) {
auto tgmap = rs->loadTrunkTgMap(m_section);
for (auto& kv : tgmap) {
m_tg_map_in[kv.first] = kv.second;
m_tg_map_out[kv.second] = kv.first;
}
} else {
std::string tgmap_str; std::string tgmap_str;
if (m_cfg.getValue(m_section, "TG_MAP", tgmap_str) && !tgmap_str.empty()) if (m_cfg.getValue(m_section, "TG_MAP", tgmap_str) && !tgmap_str.empty())
{ {
@@ -1128,13 +1147,20 @@ void TrunkLink::reloadConfig(void)
} catch (...) { /* skip malformed */ } } catch (...) { /* skip malformed */ }
} }
} }
}
if (rs) {
m_muted_callsigns = rs->loadTrunkMutes(m_section);
}
cout << m_section << ": Reloaded filters" cout << m_section << ": Reloaded filters"
<< (m_blacklist_filter.empty() ? "" : << (m_blacklist_filter.empty() ? "" :
" blacklist=" + m_blacklist_filter.toString()) " blacklist=" + m_blacklist_filter.toString())
<< (m_allow_filter.empty() ? "" : << (m_allow_filter.empty() ? "" :
" allow=" + m_allow_filter.toString()) " allow=" + m_allow_filter.toString())
<< " tg_map_entries=" << m_tg_map_in.size() << endl; << " tg_map_entries=" << m_tg_map_in.size();
if (rs) cout << " mutes=" << m_muted_callsigns.size();
cout << endl;
} /* TrunkLink::reloadConfig */ } /* TrunkLink::reloadConfig */