Welcome! Log In Create A New Profile

Advanced

[PATCH] Stream: $server_name

Sergey Kandaurov
March 22, 2024 10:42AM
# HG changeset patch
# User Sergey Kandaurov <pluknet@nginx.com>
# Date 1711118390 -14400
# Fri Mar 22 18:39:50 2024 +0400
# Node ID 96ff3f8b7e508a345c18bb1e1071f248f1e5a75c
# Parent 6317e21a15e083a215b52480b8ef473fdfe34158
Stream: $server_name.

diff --git a/src/stream/ngx_stream_variables.c b/src/stream/ngx_stream_variables.c
--- a/src/stream/ngx_stream_variables.c
+++ b/src/stream/ngx_stream_variables.c
@@ -29,6 +29,8 @@ static ngx_int_t ngx_stream_variable_ser
ngx_stream_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_stream_variable_server_port(ngx_stream_session_t *s,
ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_server_name(ngx_stream_session_t *s,
+ ngx_stream_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_stream_variable_bytes(ngx_stream_session_t *s,
ngx_stream_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_stream_variable_session_time(ngx_stream_session_t *s,
@@ -91,6 +93,9 @@ static ngx_stream_variable_t ngx_stream
{ ngx_string("server_port"), NULL,
ngx_stream_variable_server_port, 0, 0, 0 },

+ { ngx_string("server_name"), NULL, ngx_stream_variable_server_name,
+ 0, 0, 0 },
+
{ ngx_string("bytes_sent"), NULL, ngx_stream_variable_bytes,
0, 0, 0 },

@@ -722,6 +727,24 @@ ngx_stream_variable_server_port(ngx_stre


static ngx_int_t
+ngx_stream_variable_server_name(ngx_stream_session_t *s,
+ ngx_stream_variable_value_t *v, uintptr_t data)
+{
+ ngx_stream_core_srv_conf_t *cscf;
+
+ cscf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module);
+
+ v->len = cscf->server_name.len;
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+ v->data = cscf->server_name.data;
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
ngx_stream_variable_bytes(ngx_stream_session_t *s,
ngx_stream_variable_value_t *v, uintptr_t data)
{
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Stream: $server_name

Sergey Kandaurov 254 March 22, 2024 10:42AM

Re: [PATCH] Stream: $server_name

Roman Arutyunyan 93 March 23, 2024 03:28AM



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

Online Users

Guests: 103
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready