Merge pull request #1940 from AlphaWu/master

修正在指定配置文件forwarded_ip_header的值后,无法获取不通过代理播放的客户端IP。
This commit is contained in:
夏楚 2022-09-07 15:09:24 +08:00 committed by GitHub
commit 6ca736f88a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -674,7 +674,10 @@ bool HttpSession::emitHttpEvent(bool doInvoke){
std::string HttpSession::get_peer_ip() { std::string HttpSession::get_peer_ip() {
GET_CONFIG(string, forwarded_ip_header, Http::kForwardedIpHeader); 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) { void HttpSession::Handle_Req_POST(ssize_t &content_len) {