mirror of
https://github.com/minetest/minetest.git
synced 2024-12-28 00:47:29 +01:00
database-redis: Support password authentication
This commit is contained in:
parent
d34f149bdc
commit
f83d8687a7
@ -53,6 +53,18 @@ Database_Redis::Database_Redis(Settings &conf)
|
||||
redisFree(ctx);
|
||||
throw DatabaseException(err);
|
||||
}
|
||||
if (conf.exists("redis_password")) {
|
||||
tmp = conf.get("redis_password");
|
||||
redisReply *reply = static_cast<redisReply *>(redisCommand(ctx, "AUTH %s", tmp.c_str()));
|
||||
if (!reply)
|
||||
throw DatabaseException("Redis authentication failed");
|
||||
if (reply->type == REDIS_REPLY_ERROR) {
|
||||
std::string err = "Redis authentication failed: " + std::string(reply->str, reply->len);
|
||||
freeReplyObject(reply);
|
||||
throw DatabaseException(err);
|
||||
}
|
||||
freeReplyObject(reply);
|
||||
}
|
||||
}
|
||||
|
||||
Database_Redis::~Database_Redis()
|
||||
|
Loading…
Reference in New Issue
Block a user