| 115 | } |
| 116 | |
| 117 | int 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 | |
| 144 | int ProxyProtocolHandler::ProcessProxyHeader(int fd) { |
| 145 | int ret = GetAddrFromFD(fd); |
nothing calls this directly
no test coverage detected