From ac8bfd1e15f33c01ac0564d1d56618d7d6de20bf Mon Sep 17 00:00:00 2001 From: fortrue Date: Thu, 14 Sep 2017 09:52:09 +0800 Subject: [PATCH] don't use redis-server password for redis-sentinel instances --- src/Conf.cpp | 1 + src/Conf.h | 1 + src/SentinelServerPool.cpp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Conf.cpp b/src/Conf.cpp index 80a6a76..b5d89a3 100644 --- a/src/Conf.cpp +++ b/src/Conf.cpp @@ -312,6 +312,7 @@ void Conf::setSentinelServerPool(const ConfParser::Node* node) Throw(InvalidValue, "%s:%d HashTag invalid", p->file, p->line); } } else if (setServers(mSentinelServerPool.sentinels, "Sentinels", p)) { + mSentinelServerPool.sentinelPassword = p->val; } else if (strcasecmp(p->key.c_str(), "Group") == 0) { mSentinelServerPool.groups.push_back(ServerGroupConf{p->val}); if (p->sub) { diff --git a/src/Conf.h b/src/Conf.h index e1d1dfa..87cbeeb 100644 --- a/src/Conf.h +++ b/src/Conf.h @@ -65,6 +65,7 @@ struct SentinelServerPoolConf : public ServerPoolConf Distribution dist = Distribution::None; Hash hash = Hash::None; char hashTag[2]; + std::string sentinelPassword; std::vector sentinels; std::vector groups; }; diff --git a/src/SentinelServerPool.cpp b/src/SentinelServerPool.cpp index 6ba5a03..cce0c61 100644 --- a/src/SentinelServerPool.cpp +++ b/src/SentinelServerPool.cpp @@ -35,7 +35,7 @@ void SentinelServerPool::init(const SentinelServerPoolConf& conf) for (auto& sc : conf.sentinels) { Server* s = new Server(this, sc.addr, true); s->setRole(Server::Sentinel); - s->setPassword(sc.password.empty() ? conf.password : sc.password); + s->setPassword(sc.password.empty() ? conf.sentinelPassword:sc.password); mSentinels[i++] = s; mServs[s->addr()] = s; }