don't use redis-server password for redis-sentinel instances

This commit is contained in:
fortrue 2017-09-14 09:52:09 +08:00
parent 345ff2c20f
commit ac8bfd1e15
3 changed files with 3 additions and 1 deletions

View File

@ -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) {

View File

@ -65,6 +65,7 @@ struct SentinelServerPoolConf : public ServerPoolConf
Distribution dist = Distribution::None;
Hash hash = Hash::None;
char hashTag[2];
std::string sentinelPassword;
std::vector<ServerConf> sentinels;
std::vector<ServerGroupConf> groups;
};

View File

@ -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;
}