diff options
author | Graham Leggett <minfrin@apache.org> | 2011-11-22 13:10:39 +0000 |
---|---|---|
committer | Graham Leggett <minfrin@apache.org> | 2011-11-22 13:10:39 +0000 |
commit | 4ee7eea4cf60fad5fca9fe9c39d306ae870b5907 (patch) | |
tree | 26ad4d77ee36f67a65343a1d5a13cc31ecc458e8 /server/log.c | |
parent | e68738b5dcfc7d243b3eb91b541b9739910a34ce (diff) | |
download | httpd-4ee7eea4cf60fad5fca9fe9c39d306ae870b5907.tar.gz |
Introduce a per request version of the remote IP address, which can be
optionally modified by a module when the effective IP of the client
is not the same as the real IP of the client (such as a load balancer).
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1204968 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/log.c')
-rw-r--r-- | server/log.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/server/log.c b/server/log.c index 605d75bbea..641d256af6 100644 --- a/server/log.c +++ b/server/log.c @@ -561,7 +561,10 @@ static int cpystrn(char *buf, const char *arg, int buflen) static int log_remote_address(const ap_errorlog_info *info, const char *arg, char *buf, int buflen) { - if (info->c) + if (info->r) + return apr_snprintf(buf, buflen, "%s:%d", info->r->remote_ip, + info->r->remote_addr->port); + else if (info->c) return apr_snprintf(buf, buflen, "%s:%d", info->c->remote_ip, info->c->remote_addr->port); else @@ -578,6 +581,16 @@ static int log_local_address(const ap_errorlog_info *info, const char *arg, return 0; } +static int log_conn_remote_address(const ap_errorlog_info *info, const char *arg, + char *buf, int buflen) +{ + if (info->c) + return apr_snprintf(buf, buflen, "%s:%d", info->c->remote_ip, + info->c->remote_addr->port); + else + return 0; +} + static int log_pid(const ap_errorlog_info *info, const char *arg, char *buf, int buflen) { @@ -897,6 +910,7 @@ AP_DECLARE(void) ap_register_log_hooks(apr_pool_t *p) ap_register_errorlog_handler(p, "T", log_tid, 0); ap_register_errorlog_handler(p, "v", log_virtual_host, 0); ap_register_errorlog_handler(p, "V", log_server_name, 0); + ap_register_errorlog_handler(p, "d", log_conn_remote_address, 0); } /* @@ -958,11 +972,16 @@ static int do_errorlog_default(const ap_errorlog_info *info, char *buf, } } - if (info->c) { - /* - * remote_ip can be client or backend server. If we have a scoreboard - * handle, it is likely a client. - */ + /* + * remote_ip can be client or backend server. If we have a scoreboard + * handle, it is likely a client. + */ + if (info->r) { + len += apr_snprintf(buf + len, buflen - len, + info->r->connection->sbh ? "[client %s:%d] " : "[remote %s:%d] ", + info->r->remote_ip, info->r->remote_addr->port); + } + else if (info->c) { len += apr_snprintf(buf + len, buflen - len, info->c->sbh ? "[client %s:%d] " : "[remote %s:%d] ", info->c->remote_ip, info->c->remote_addr->port); |