]> git.kaiwu.me - nginx.git/commitdiff
ngx_http_variable_binary_remote_addr()
authorIgor Sysoev <igor@sysoev.ru>
Sun, 7 Jan 2007 13:36:56 +0000 (13:36 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Sun, 7 Jan 2007 13:36:56 +0000 (13:36 +0000)
src/http/ngx_http_variables.c

index ffa244650c1e8b598049855348bab8b36f7bf437..ac4a4a2f8c9897b1411f2354c32c1aa80a5ecc01 100644 (file)
@@ -28,6 +28,8 @@ static ngx_int_t ngx_http_variable_unknown_header(ngx_http_variable_value_t *v,
 
 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 @@ static ngx_http_variable_t  ngx_http_core_variables[] = {
     { 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 @@ ngx_http_variable_host(ngx_http_request_t *r, ngx_http_variable_value_t *v,
 
 
 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 */
 
-    } else {
+    sin = (struct sockaddr_in *) r->connection->sockaddr;
 
-        /* AF_INET only */
+    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;
 
-        sin = (struct sockaddr_in *) r->connection->sockaddr;
+    return NGX_OK;
+}
 
-        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;
 }