Welcome! Log In Create A New Profile

Advanced

[nginx] Stream: the $protocol variable.

Vladimir Homutov
August 26, 2016 08:36AM
details: http://hg.nginx.org/nginx/rev/c6372a40c2a7
branches:
changeset: 6670:c6372a40c2a7
user: Vladimir Homutov <vl@nginx.com>
date: Fri Aug 26 15:33:07 2016 +0300
description:
Stream: the $protocol variable.

The variable keeps protocol used by the client, "TCP" or "UDP".

diffstat:

src/stream/ngx_stream_variables.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)

diffs (43 lines):

diff -r 164a0824ce20 -r c6372a40c2a7 src/stream/ngx_stream_variables.c
--- a/src/stream/ngx_stream_variables.c Fri Aug 26 15:33:04 2016 +0300
+++ b/src/stream/ngx_stream_variables.c Fri Aug 26 15:33:07 2016 +0300
@@ -40,6 +40,8 @@ static ngx_int_t ngx_stream_variable_tim
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
{ 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_strea
}


+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)

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Stream: the $protocol variable.

Vladimir Homutov 474 August 26, 2016 08:36AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 104
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready