vendor/nginx/src/http/ngx_http_variables.c in nginxtra-1.4.7.9 vs vendor/nginx/src/http/ngx_http_variables.c in nginxtra-1.6.0.9
- old
+ new
@@ -52,10 +52,12 @@
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,
ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_variable_proxy_protocol_addr(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_server_addr(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_server_port(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_scheme(ngx_http_request_t *r,
@@ -181,10 +183,13 @@
{ ngx_string("remote_addr"), NULL, ngx_http_variable_remote_addr, 0, 0, 0 },
{ ngx_string("remote_port"), NULL, ngx_http_variable_remote_port, 0, 0, 0 },
+ { ngx_string("proxy_protocol_addr"), NULL,
+ ngx_http_variable_proxy_protocol_addr, 0, 0, 0 },
+
{ ngx_string("server_addr"), NULL, ngx_http_variable_server_addr, 0, 0, 0 },
{ ngx_string("server_port"), NULL, ngx_http_variable_server_port, 0, 0, 0 },
{ ngx_string("server_protocol"), NULL, ngx_http_variable_request,
@@ -485,11 +490,11 @@
cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
if (cmcf->variables.nelts <= index) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
- "unknown variable index: %d", index);
+ "unknown variable index: %ui", index);
return NULL;
}
if (r->variables[index].not_found || r->variables[index].valid) {
return &r->variables[index];
@@ -1183,10 +1188,16 @@
sin6 = (struct sockaddr_in6 *) r->connection->sockaddr;
port = ntohs(sin6->sin6_port);
break;
#endif
+#if (NGX_HAVE_UNIX_DOMAIN)
+ case AF_UNIX:
+ port = 0;
+ break;
+#endif
+
default: /* AF_INET */
sin = (struct sockaddr_in *) r->connection->sockaddr;
port = ntohs(sin->sin_port);
break;
}
@@ -1198,10 +1209,24 @@
return NGX_OK;
}
static ngx_int_t
+ngx_http_variable_proxy_protocol_addr(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ v->len = r->connection->proxy_protocol_addr.len;
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+ v->data = r->connection->proxy_protocol_addr.data;
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
ngx_http_variable_server_addr(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data)
{
ngx_str_t s;
u_char addr[NGX_SOCKADDR_STRLEN];
@@ -1261,10 +1286,16 @@
sin6 = (struct sockaddr_in6 *) r->connection->local_sockaddr;
port = ntohs(sin6->sin6_port);
break;
#endif
+#if (NGX_HAVE_UNIX_DOMAIN)
+ case AF_UNIX:
+ port = 0;
+ break;
+#endif
+
default: /* AF_INET */
sin = (struct sockaddr_in *) r->connection->local_sockaddr;
port = ntohs(sin->sin_port);
break;
}
@@ -1372,11 +1403,13 @@
== NULL)
{
return NGX_ERROR;
}
- if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &path, 0) != NGX_OK) {
+ if (ngx_get_full_name(r->pool, (ngx_str_t *) &ngx_cycle->prefix, &path)
+ != NGX_OK)
+ {
return NGX_ERROR;
}
v->len = path.len;
v->valid = 1;
@@ -1414,11 +1447,13 @@
return NGX_ERROR;
}
path.data[path.len - 1] = '\0';
- if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &path, 0) != NGX_OK) {
+ if (ngx_get_full_name(r->pool, (ngx_str_t *) &ngx_cycle->prefix, &path)
+ != NGX_OK)
+ {
return NGX_ERROR;
}
}
#if (NGX_HAVE_MAX_PATH)
@@ -1738,12 +1773,11 @@
return NGX_OK;
}
if (r->headers_out.last_modified_time >= 0) {
- p = ngx_pnalloc(r->pool,
- sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT") - 1);
+ p = ngx_pnalloc(r->pool, sizeof("Mon, 28 Sep 1970 06:00:00 GMT") - 1);
if (p == NULL) {
return NGX_ERROR;
}
v->len = ngx_http_time(p, r->headers_out.last_modified_time) - p;
@@ -2255,10 +2289,11 @@
return NULL;
}
re->regex = rc->regex;
re->ncaptures = rc->captures;
+ re->name = rc->pattern;
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
cmcf->ncaptures = ngx_max(cmcf->ncaptures, re->ncaptures);
n = (ngx_uint_t) rc->named_captures;
@@ -2272,10 +2307,9 @@
return NULL;
}
re->variables = rv;
re->nvariables = n;
- re->name = rc->pattern;
size = rc->name_size;
p = rc->names;
for (i = 0; i < n; i++) {