支持获取http反向代理真实客户端ip: #1388

This commit is contained in:
xiongziliang
2022-06-18 22:10:46 +08:00
parent 6291ee704c
commit d30869d0c9
5 changed files with 16 additions and 1 deletions

View File

@@ -670,6 +670,11 @@ bool HttpSession::emitHttpEvent(bool doInvoke){
return consumed;
}
std::string HttpSession::get_peer_ip() {
GET_CONFIG(string, forwarded_ip_header, Http::kForwardedIpHeader);
return forwarded_ip_header.empty() ? TcpSession::get_peer_ip() : _parser.getHeader()[forwarded_ip_header];
}
void HttpSession::Handle_Req_POST(ssize_t &content_len) {
GET_CONFIG(size_t,maxReqSize,Http::kMaxReqSize);

View File

@@ -97,6 +97,9 @@ protected:
*/
void onWebSocketDecodeComplete(const WebSocketHeader &header_in) override;
//重载获取客户端ip
std::string get_peer_ip() override;
private:
void Handle_Req_GET(ssize_t &content_len);
void Handle_Req_GET_l(ssize_t &content_len, bool sendBody);