diff options
author | Roman Arutyunyan <arut@nginx.com> | 2019-10-21 18:06:19 +0300 |
---|---|---|
committer | Roman Arutyunyan <arut@nginx.com> | 2019-10-21 18:06:19 +0300 |
commit | be932e81a1531a3ba032febad968fc2006c4fa48 (patch) | |
tree | 582aff75a1bd2b436983740e6dfc76288047e31e /src/stream/ngx_stream_variables.c | |
parent | 0098761cb8636a6def144445082a0c90d340321c (diff) | |
download | nginx-be932e81a1531a3ba032febad968fc2006c4fa48.tar.gz nginx-be932e81a1531a3ba032febad968fc2006c4fa48.zip |
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/stream/ngx_stream_variables.c')
-rw-r--r-- | src/stream/ngx_stream_variables.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/stream/ngx_stream_variables.c b/src/stream/ngx_stream_variables.c index d1526a96a..995e23a4b 100644 --- a/src/stream/ngx_stream_variables.c +++ b/src/stream/ngx_stream_variables.c @@ -557,11 +557,19 @@ static ngx_int_t ngx_stream_variable_proxy_protocol_addr(ngx_stream_session_t *s, ngx_stream_variable_value_t *v, uintptr_t data) { - v->len = s->connection->proxy_protocol_addr.len; + ngx_proxy_protocol_t *pp; + + pp = s->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 = s->connection->proxy_protocol_addr.data; + v->data = pp->src_addr.data; return NGX_OK; } @@ -571,7 +579,14 @@ static ngx_int_t ngx_stream_variable_proxy_protocol_port(ngx_stream_session_t *s, ngx_stream_variable_value_t *v, uintptr_t data) { - ngx_uint_t port; + ngx_uint_t port; + ngx_proxy_protocol_t *pp; + + pp = s->connection->proxy_protocol; + if (pp == NULL) { + v->not_found = 1; + return NGX_OK; + } v->len = 0; v->valid = 1; @@ -583,7 +598,7 @@ ngx_stream_variable_proxy_protocol_port(ngx_stream_session_t *s, return NGX_ERROR; } - port = s->connection->proxy_protocol_port; + port = pp->src_port; if (port > 0 && port < 65536) { v->len = ngx_sprintf(v->data, "%ui", port) - v->data; |