diff options
author | Vladimir Homutov <vl@nginx.com> | 2016-08-26 15:33:07 +0300 |
---|---|---|
committer | Vladimir Homutov <vl@nginx.com> | 2016-08-26 15:33:07 +0300 |
commit | 048ee941302b5476dc69cca6169e03722a2000f5 (patch) | |
tree | 4512dc2fdaffa58c2729cd800e975426b227fd1e /src/stream/ngx_stream_variables.c | |
parent | f04b65358e543275affc4cee13c90cd568ae438a (diff) | |
download | nginx-048ee941302b5476dc69cca6169e03722a2000f5.tar.gz nginx-048ee941302b5476dc69cca6169e03722a2000f5.zip |
Stream: the $protocol variable.
The variable keeps protocol used by the client, "TCP" or "UDP".
Diffstat (limited to 'src/stream/ngx_stream_variables.c')
-rw-r--r-- | src/stream/ngx_stream_variables.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/stream/ngx_stream_variables.c b/src/stream/ngx_stream_variables.c index 40572f2aa..f67d74d52 100644 --- a/src/stream/ngx_stream_variables.c +++ b/src/stream/ngx_stream_variables.c @@ -40,6 +40,8 @@ static ngx_int_t ngx_stream_variable_time_iso8601(ngx_stream_session_t *s, ngx_stream_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_stream_variable_time_local(ngx_stream_session_t *s, ngx_stream_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_stream_variable_protocol(ngx_stream_session_t *s, + ngx_stream_variable_value_t *v, uintptr_t data); static ngx_stream_variable_t ngx_stream_core_variables[] = { @@ -89,6 +91,9 @@ static ngx_stream_variable_t ngx_stream_core_variables[] = { { ngx_string("time_local"), NULL, ngx_stream_variable_time_local, 0, NGX_STREAM_VAR_NOCACHEABLE, 0 }, + { ngx_string("protocol"), NULL, + ngx_stream_variable_protocol, 0, 0, 0 }, + { ngx_null_string, NULL, NULL, 0, 0, 0 } }; @@ -665,6 +670,20 @@ ngx_stream_variable_time_local(ngx_stream_session_t *s, } +static ngx_int_t +ngx_stream_variable_protocol(ngx_stream_session_t *s, + ngx_stream_variable_value_t *v, uintptr_t data) +{ + v->len = 3; + v->valid = 1; + v->no_cacheable = 0; + v->not_found = 0; + v->data = (u_char *) (s->connection->type == SOCK_DGRAM ? "UDP" : "TCP"); + + return NGX_OK; +} + + void * ngx_stream_map_find(ngx_stream_session_t *s, ngx_stream_map_t *map, ngx_str_t *match) |