MCPcopy Create free account
hub / github.com/Tencent/phxsql / IsProxyHeaderNeed

Method IsProxyHeaderNeed

phxsqlproxy/proxy_protocol_handler.cpp:117–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117int ProxyProtocolHandler::IsProxyHeaderNeed() { // 1:need, 0:no need, <0:reject
118 std::string src_ip;
119 std::string dst_ip;
120 int src_port;
121 int dst_port;
122
123 if (SockAddrToIPPort((struct sockaddr *) &src_addr_, src_ip, src_port) < 0) {
124 return -__LINE__;
125 }
126 if (SockAddrToIPPort((struct sockaddr *) &dst_addr_, dst_ip, dst_port) < 0) {
127 return -__LINE__;
128 }
129
130 LOG_DEBUG("receive connect from [%s:%d]", src_ip.c_str(), src_port);
131
132 if (dst_port != worker_config_->proxy_port_) {
133 return 0;
134 }
135
136 if (!group_status_cache_->IsMember(src_ip)) {
137 LOG_ERR("non-member ip [%s] connect port [%d], reject", src_ip.c_str(), dst_port);
138 return -__LINE__;
139 }
140
141 return 1;
142}
143
144int ProxyProtocolHandler::ProcessProxyHeader(int fd) {
145 int ret = GetAddrFromFD(fd);

Callers

nothing calls this directly

Calls 2

SockAddrToIPPortFunction · 0.85
IsMemberMethod · 0.80

Tested by

no test coverage detected