changed: config parameters: log_check_proxy_ip_header -> check_proxy_ip_header and log_proxy_ip_header -> proxy_ip_header
added: Request::ip_str (std::wstring) (string of the client's IP address) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1105 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
ba7d55b7c1
commit
3f29cdc01e
|
@ -779,7 +779,6 @@ void App::ReadEnvVariables()
|
|||
{
|
||||
SetEnv("REQUEST_METHOD", cur.request->env_request_method);
|
||||
SetEnv("REQUEST_URI", cur.request->env_request_uri);
|
||||
SetEnv("REMOTE_ADDR", cur.request->env_remote_addr);
|
||||
SetEnv("FCGI_ROLE", cur.request->env_fcgi_role);
|
||||
SetEnv("CONTENT_TYPE", cur.request->env_content_type);
|
||||
SetEnv("HTTPS", cur.request->env_https);
|
||||
|
@ -878,11 +877,26 @@ bool App::SaveEnvHTTPVariable(const char * env)
|
|||
|
||||
void App::ReadEnvRemoteIP()
|
||||
{
|
||||
const char * v = FCGX_GetParam("REMOTE_ADDR", fcgi_request.envp);
|
||||
const char * v = nullptr;
|
||||
|
||||
if( config.check_proxy_ip_header )
|
||||
{
|
||||
http_header = L"HTTP_";
|
||||
http_header += config.proxy_ip_header;
|
||||
ToCapital(http_header);
|
||||
|
||||
PT::WideToUTF8(http_header, http_header_8bit);
|
||||
v = FCGX_GetParam(http_header_8bit.c_str(), fcgi_request.envp);
|
||||
}
|
||||
else
|
||||
{
|
||||
v = FCGX_GetParam("REMOTE_ADDR", fcgi_request.envp);
|
||||
}
|
||||
|
||||
if( v )
|
||||
{
|
||||
cur.request->ip = (int)inet_addr(v);
|
||||
PT::UTF8ToWide(v, cur.request->ip_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -936,14 +950,8 @@ void App::LogAccess()
|
|||
log << log1;
|
||||
log.PrintDate(cur.request->start_date, config.log_time_zone_id);
|
||||
|
||||
log << ' ';
|
||||
|
||||
if( config.log_check_proxy_ip_header )
|
||||
log << cur.request->headers_in.Text(config.log_proxy_ip_header, L"no-log_proxy_ip_header");
|
||||
else
|
||||
log << cur.request->env_remote_addr;
|
||||
|
||||
log << ' '
|
||||
<< cur.request->ip_str << ' '
|
||||
<< cur.request->env_request_method << ' '
|
||||
<< cur.request->env_http_host
|
||||
<< cur.request->env_request_uri << ' '
|
||||
|
|
|
@ -160,6 +160,7 @@ private:
|
|||
BinaryPage compressed_output;
|
||||
std::wstring cookie_id_string;
|
||||
std::wstring http_header;
|
||||
std::string http_header_8bit;
|
||||
|
||||
|
||||
bool InitFCGI(char * sock, char * sock_user, char * sock_group);
|
||||
|
|
|
@ -149,8 +149,6 @@ void Config::AssignValues(bool stdout_is_closed)
|
|||
log_env_variables = Bool(L"log_env_variables", false);
|
||||
log_env_http_variables = Bool(L"log_env_http_variables", false);
|
||||
log_http_answer_headers = Bool(L"log_http_answer_headers", false);
|
||||
log_check_proxy_ip_header = Bool(L"log_check_proxy_ip_header", false);
|
||||
log_proxy_ip_header = Text(L"log_proxy_ip_header", L"X-Real-IP");
|
||||
|
||||
post_file_max = Size(L"post_file_max", 8388608); // 8 MB
|
||||
|
||||
|
@ -311,6 +309,10 @@ void Config::AssignValues(bool stdout_is_closed)
|
|||
|
||||
pid_file = Text(L"pid_file", L"");
|
||||
allow_ezc_out_in_executable_items = Bool(L"allow_ezc_out_in_executable_items", false);
|
||||
|
||||
check_proxy_ip_header = Bool(L"check_proxy_ip_header", false);
|
||||
proxy_ip_header = Text(L"proxy_ip_header", L"X_Real_IP");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -122,15 +122,6 @@ public:
|
|||
// default: false
|
||||
bool log_plugin_call;
|
||||
|
||||
// check whether there is a 'log_proxy_ip_header' header
|
||||
// and if so then log the IP address from it
|
||||
// default: false
|
||||
bool log_check_proxy_ip_header;
|
||||
|
||||
// proxy header representing the real IP address of a client
|
||||
// default: X-Real-IP
|
||||
std::wstring log_proxy_ip_header;
|
||||
|
||||
|
||||
// how many characters in values should be logged from POST parameters
|
||||
// default: 80
|
||||
|
@ -766,6 +757,17 @@ public:
|
|||
bool allow_ezc_out_in_executable_items;
|
||||
|
||||
|
||||
// check whether there is a 'log_proxy_ip_header' header
|
||||
// and if so then log the IP address from it
|
||||
// default: false
|
||||
bool check_proxy_ip_header;
|
||||
|
||||
// proxy header representing the real IP address of a client
|
||||
// default: X_Real_IP
|
||||
std::wstring proxy_ip_header;
|
||||
|
||||
|
||||
|
||||
Config();
|
||||
bool ReadConfig(bool errors_to_stdout_, bool stdout_is_closed = true);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -806,6 +806,24 @@ std::wstring::size_type i;
|
|||
}
|
||||
|
||||
|
||||
wchar_t ToCapital(wchar_t c)
|
||||
{
|
||||
if( c>='a' && c<='z' )
|
||||
c = c - 'a' + 'A';
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
void ToCapital(std::wstring & s)
|
||||
{
|
||||
std::wstring::size_type i;
|
||||
|
||||
for(i=0 ; i<s.size() ; ++i)
|
||||
s[i] = ToCapital(s[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool IsEmailCorrectChar(wchar_t c)
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008-2014, Tomasz Sowa
|
||||
* Copyright (c) 2008-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -381,6 +381,8 @@ bool was_comma = false;
|
|||
wchar_t ToSmall(wchar_t c);
|
||||
void ToSmall(std::wstring & s);
|
||||
|
||||
wchar_t ToCapital(wchar_t c);
|
||||
void ToCapital(std::wstring & s);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -108,7 +108,6 @@ void Request::Clear()
|
|||
env_request_method.clear();
|
||||
env_request_uri.clear();
|
||||
env_http_cookie.clear();
|
||||
env_remote_addr.clear();
|
||||
env_http_host.clear();
|
||||
env_http_user_agent.clear();
|
||||
env_http_accept_encoding.clear();
|
||||
|
@ -152,6 +151,7 @@ void Request::Clear()
|
|||
gen_use_special_chars = false;
|
||||
|
||||
ip = 0;
|
||||
ip_str.clear();
|
||||
use_200_status_for_not_found_and_permission_denied = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -148,7 +148,6 @@ struct Request
|
|||
std::wstring env_request_method;
|
||||
std::wstring env_request_uri;
|
||||
std::wstring env_http_cookie;
|
||||
std::wstring env_remote_addr;
|
||||
std::wstring env_http_host;
|
||||
std::wstring env_http_user_agent;
|
||||
std::wstring env_http_accept_encoding;
|
||||
|
@ -156,9 +155,12 @@ struct Request
|
|||
std::wstring env_content_type;
|
||||
std::wstring env_https;
|
||||
|
||||
// current IP address of the remote host (read from REMOTE_ADDR environment variable)
|
||||
// current IP address of the remote host
|
||||
// (read either from REMOTE_ADDR environment variable or from config.proxy_ip_header HTTP variable if config.check_proxy_ip_header is set to true)
|
||||
// (at the moment only IPv4 are supported)
|
||||
int ip;
|
||||
std::wstring ip_str; // ip_str can be ipv6 now
|
||||
|
||||
|
||||
// true if the browser is Microsoft Internet Explorer
|
||||
bool browser_msie;
|
||||
|
|
Loading…
Reference in New Issue