Mercurial > hg > nginx
changeset 983:7a8ca436d611
ngx_http_variable_binary_remote_addr()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 07 Jan 2007 13:36:56 +0000 |
parents | 664afe2c1480 |
children | dd128232e6ba |
files | src/http/ngx_http_variables.c |
diffstat | 1 files changed, 23 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/ngx_http_variables.c Sun Jan 07 13:35:08 2007 +0000 +++ b/src/http/ngx_http_variables.c Sun Jan 07 13:36:56 2007 +0000 @@ -28,6 +28,8 @@ static ngx_int_t ngx_http_variable_host(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_http_variable_binary_remote_addr(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_remote_addr(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_remote_port(ngx_http_request_t *r, @@ -116,7 +118,7 @@ { ngx_string("host"), NULL, ngx_http_variable_host, 0, 0, 0 }, { ngx_string("binary_remote_addr"), NULL, - ngx_http_variable_remote_addr, 1, 0, 0 }, + ngx_http_variable_binary_remote_addr, 0, 0, 0 }, { ngx_string("remote_addr"), NULL, ngx_http_variable_remote_addr, 0, 0, 0 }, @@ -699,30 +701,34 @@ static ngx_int_t -ngx_http_variable_remote_addr(ngx_http_request_t *r, +ngx_http_variable_binary_remote_addr(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { struct sockaddr_in *sin; - if (data == 0) { - v->len = r->connection->addr_text.len; - v->valid = 1; - v->no_cachable = 0; - v->not_found = 0; - v->data = r->connection->addr_text.data; + /* AF_INET only */ + + sin = (struct sockaddr_in *) r->connection->sockaddr; - } else { + v->len = sizeof(in_addr_t); + v->valid = 1; + v->no_cachable = 0; + v->not_found = 0; + v->data = (u_char *) &sin->sin_addr.s_addr; - /* AF_INET only */ + return NGX_OK; +} - sin = (struct sockaddr_in *) r->connection->sockaddr; - v->len = sizeof(in_addr_t); - v->valid = 1; - v->no_cachable = 0; - v->not_found = 0; - v->data = (u_char *) &sin->sin_addr.s_addr; - } +static ngx_int_t +ngx_http_variable_remote_addr(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ + v->len = r->connection->addr_text.len; + v->valid = 1; + v->no_cachable = 0; + v->not_found = 0; + v->data = r->connection->addr_text.data; return NGX_OK; }