mirror of
https://github.com/SunnyQjm/MIRCertificationManager.git
synced 2026-10-05 01:15:41 +08:00
fix: 修改redis连接,带密码链接
This commit is contained in:
1 parent
aceaa52912
commit
62ef8548a4
3 files changed
+8
-3
No files matched your search
@@ -32,7 +32,7 @@ bool NDNCertificationUtil::isValidBlock(const std::string &certStr) {
|
||||
* @return
|
||||
*/
|
||||
bool NDNCertificationUtil::connect(const std::string &host, int port) {
|
||||
return redisUtil.connect(host, port);
|
||||
return redisUtil.connect(host, port, "pkusz26035354");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-1
@@ -19,13 +19,18 @@ RedisUtil::~RedisUtil() {
|
||||
* @param port 端口
|
||||
* @return
|
||||
*/
|
||||
bool RedisUtil::connect(const std::string &host, int port) {
|
||||
bool RedisUtil::connect(const std::string &host, int port, const std::string &passwd) {
|
||||
// 连接到指定的redis服务器
|
||||
this->_connect = redisConnect(host.c_str(), port);
|
||||
if (this->_connect == nullptr || this->_connect->err) {
|
||||
std::cerr << "connect error: " << this->_connect->errstr << std::endl;
|
||||
return false;
|
||||
}
|
||||
auto reply = (redisReply *)redisCommand(this->_connect, "AUTH %s", passwd.c_str());
|
||||
if (reply->type == REDIS_REPLY_ERROR) {
|
||||
std::cerr << "Redis认证失败" << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public:
|
||||
* @param port 端口
|
||||
* @return
|
||||
*/
|
||||
bool connect(const std::string &host, int port);
|
||||
bool connect(const std::string &host, int port, const std::string &passwd);
|
||||
|
||||
/**
|
||||
* 从redis中根据指定的键取到指定的值
|
||||
|
||||
Reference in new issue
Block a user