summaryrefslogtreecommitdiffhomepage
path: root/src/http
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2019-10-21 18:06:19 +0300
committerRoman Arutyunyan <arut@nginx.com>2019-10-21 18:06:19 +0300
commitbe932e81a1531a3ba032febad968fc2006c4fa48 (patch)
tree582aff75a1bd2b436983740e6dfc76288047e31e /src/http
parent0098761cb8636a6def144445082a0c90d340321c (diff)
downloadnginx-be932e81a1531a3ba032febad968fc2006c4fa48.tar.gz
nginx-be932e81a1531a3ba032febad968fc2006c4fa48.tar.bz2
Core: moved PROXY protocol fields out of ngx_connection_t.
Now a new structure ngx_proxy_protocol_t holds these fields. This allows to add more PROXY protocol fields in the future without modifying the connection structure.
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/ngx_http_realip_module.c7
-rw-r--r--src/http/ngx_http_variables.c23
2 files changed, 22 insertions, 8 deletions
diff --git a/src/http/modules/ngx_http_realip_module.c b/src/http/modules/ngx_http_realip_module.c
index 7d3f2a91d..9586ebe07 100644
--- a/src/http/modules/ngx_http_realip_module.c
+++ b/src/http/modules/ngx_http_realip_module.c
@@ -180,12 +180,11 @@ ngx_http_realip_handler(ngx_http_request_t *r)
case NGX_HTTP_REALIP_PROXY:
- value = &r->connection->proxy_protocol_addr;
-
- if (value->len == 0) {
+ if (r->connection->proxy_protocol == NULL) {
return NGX_DECLINED;
}
+ value = &r->connection->proxy_protocol->src_addr;
xfwd = NULL;
break;
@@ -238,7 +237,7 @@ found:
!= NGX_DECLINED)
{
if (rlcf->type == NGX_HTTP_REALIP_PROXY) {
- ngx_inet_set_port(addr.sockaddr, c->proxy_protocol_port);
+ ngx_inet_set_port(addr.sockaddr, c->proxy_protocol->src_port);
}
return ngx_http_realip_set_addr(r, &addr);
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index aa38ab377..2ae178c30 100644
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -1293,11 +1293,19 @@ 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;
+ ngx_proxy_protocol_t *pp;
+
+ pp = r->connection->proxy_protocol;
+ if (pp == NULL) {
+ v->not_found = 1;
+ return NGX_OK;
+ }
+
+ v->len = pp->src_addr.len;
v->valid = 1;
v->no_cacheable = 0;
v->not_found = 0;
- v->data = r->connection->proxy_protocol_addr.data;
+ v->data = pp->src_addr.data;
return NGX_OK;
}
@@ -1307,7 +1315,14 @@ static ngx_int_t
ngx_http_variable_proxy_protocol_port(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data)
{
- ngx_uint_t port;
+ ngx_uint_t port;
+ ngx_proxy_protocol_t *pp;
+
+ pp = r->connection->proxy_protocol;
+ if (pp == NULL) {
+ v->not_found = 1;
+ return NGX_OK;
+ }
v->len = 0;
v->valid = 1;
@@ -1319,7 +1334,7 @@ ngx_http_variable_proxy_protocol_port(ngx_http_request_t *r,
return NGX_ERROR;
}
- port = r->connection->proxy_protocol_port;
+ port = pp->src_port;
if (port > 0 && port < 65536) {
v->len = ngx_sprintf(v->data, "%ui", port) - v->data;