修正在指定配置文件forwarded_ip_header的值后,无法获取不通过代理播放的客户端IP。

This commit is contained in:
WuPeng 2022-09-06 21:13:11 +08:00
parent 4f47b7a5fe
commit f765e5365b

View File

@ -674,7 +674,10 @@ bool HttpSession::emitHttpEvent(bool doInvoke){
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];
if(!forwarded_ip_header.empty() && !_parser.getHeader()[forwarded_ip_header].empty()){
return _parser.getHeader()[forwarded_ip_header];
}
return TcpSession::get_peer_ip();
}
void HttpSession::Handle_Req_POST(ssize_t &content_len) {