mirror of
https://github.com/joyieldInc/predixy.git
synced 2025-12-24 22:46:41 +08:00
Merge c06b1a7e31 into ca1630a6b4
This commit is contained in:
commit
c9341d1965
@ -10,6 +10,8 @@
|
|||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "String.h"
|
#include "String.h"
|
||||||
#include "Server.h"
|
#include "Server.h"
|
||||||
|
#include "arpa/inet.h"
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
class ClusterNodesParser
|
class ClusterNodesParser
|
||||||
{
|
{
|
||||||
@ -55,6 +57,33 @@ public:
|
|||||||
end = mSlotEnd;
|
end = mSlotEnd;
|
||||||
return begin >= 0 && begin < end;
|
return begin >= 0 && begin < end;
|
||||||
}
|
}
|
||||||
|
bool validAddr() const {
|
||||||
|
if (mAddr.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* host = mAddr.data();
|
||||||
|
const char* port = strrchr(mAddr, ':');
|
||||||
|
if (port) {
|
||||||
|
std::string tmp;
|
||||||
|
tmp.append(mAddr, port - mAddr);
|
||||||
|
host = tmp.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
char dst1[INET_ADDRSTRLEN];
|
||||||
|
int isIpv4 = inet_pton(AF_INET, host, dst1);
|
||||||
|
if (isIpv4) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
char dst2[INET6_ADDRSTRLEN];
|
||||||
|
int isIpv6 = inet_pton(AF_INET6, host, dst2);
|
||||||
|
if (isIpv6) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
enum State
|
enum State
|
||||||
{
|
{
|
||||||
|
|||||||
@ -101,7 +101,7 @@ void ClusterServerPool::handleResponse(Handler* h, ConnectConnection* s, Request
|
|||||||
p.addr().data(),
|
p.addr().data(),
|
||||||
p.flags().data(),
|
p.flags().data(),
|
||||||
p.master().data());
|
p.master().data());
|
||||||
if (p.addr().empty()) {
|
if (!p.validAddr()) {
|
||||||
logWarn("redis cluster nodes get node invalid %s %s %s %s",
|
logWarn("redis cluster nodes get node invalid %s %s %s %s",
|
||||||
p.nodeId().data(),
|
p.nodeId().data(),
|
||||||
p.addr().data(),
|
p.addr().data(),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user