Skip to content

Commit

Permalink
Stream: $server_name.
Browse files Browse the repository at this point in the history
  • Loading branch information
pluknet committed Mar 22, 2024
1 parent 45e166b commit 5e79d98
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/stream/ngx_stream_variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ static ngx_int_t ngx_stream_variable_server_addr(ngx_stream_session_t *s,
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,
Expand Down Expand Up @@ -91,6 +93,9 @@ static ngx_stream_variable_t ngx_stream_core_variables[] = {
{ 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 },

Expand Down Expand Up @@ -721,6 +726,24 @@ ngx_stream_variable_server_port(ngx_stream_session_t *s,
}


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)
Expand Down

0 comments on commit 5e79d98

Please sign in to comment.