Route auth lookup through RedisStore when [REDIS] is configured

This commit is contained in:
Audric committed 2026-04-15 08:46:39 +02:00
1 parent 0de78c459b
commit 2a3515247c
2 files changed
+20

No files matched your search

+11
View File
@@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
****************************************************************************/ ****************************************************************************/
#include <cassert> #include <cassert>
#include <list>
#include <sstream> #include <sstream>
#include <unistd.h> #include <unistd.h>
#include <algorithm> #include <algorithm>
@@ -450,6 +451,16 @@ bool Reflector::initialize(Async::Config &cfg)
<< "Aborting startup." << std::endl; << "Aborting startup." << std::endl;
return false; return false;
} }
auto warn_if_nonempty = [this](const char* section) {
std::list<std::string> keys = m_cfg->listSection(section);
if (!keys.empty()) {
std::cerr << "WARN: [" << section << "] in svxreflector.conf is "
"ignored because [REDIS] is configured. "
<< "Run --import-conf-to-redis to migrate." << std::endl;
}
};
warn_if_nonempty("USERS");
warn_if_nonempty("PASSWORDS");
} }
} }
@@ -63,6 +63,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "ReflectorClient.h" #include "ReflectorClient.h"
#include "Reflector.h" #include "Reflector.h"
#include "TGHandler.h" #include "TGHandler.h"
#include "RedisStore.h"
/**************************************************************************** /****************************************************************************
@@ -1290,6 +1291,14 @@ void ReflectorClient::handleHeartbeat(Async::Timer *t)
std::string ReflectorClient::lookupUserKey(const std::string& callsign) std::string ReflectorClient::lookupUserKey(const std::string& callsign)
{ {
if (m_reflector->redisStore() != nullptr) {
std::string key = m_reflector->redisStore()->lookupUserKey(callsign);
if (key.empty()) {
cout << "*** WARNING: Redis lookup failed for user \""
<< callsign << "\"" << endl;
}
return key;
}
string auth_group; string auth_group;
if (!m_cfg->getValue("USERS", callsign, auth_group) || auth_group.empty()) if (!m_cfg->getValue("USERS", callsign, auth_group) || auth_group.empty())
{ {