Mercurial > hg > nginx-quic
comparison src/stream/ngx_stream_variables.c @ 8957:3be953161026 quic
Merged with the default branch.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 20 Oct 2022 16:41:36 +0400 |
parents | cca4c8a715de |
children |
comparison
equal
deleted
inserted
replaced
8956:79cd6993a3e3 | 8957:3be953161026 |
---|---|
21 ngx_stream_variable_value_t *v, uintptr_t data); | 21 ngx_stream_variable_value_t *v, uintptr_t data); |
22 static ngx_int_t ngx_stream_variable_proxy_protocol_addr( | 22 static ngx_int_t ngx_stream_variable_proxy_protocol_addr( |
23 ngx_stream_session_t *s, ngx_stream_variable_value_t *v, uintptr_t data); | 23 ngx_stream_session_t *s, ngx_stream_variable_value_t *v, uintptr_t data); |
24 static ngx_int_t ngx_stream_variable_proxy_protocol_port( | 24 static ngx_int_t ngx_stream_variable_proxy_protocol_port( |
25 ngx_stream_session_t *s, ngx_stream_variable_value_t *v, uintptr_t data); | 25 ngx_stream_session_t *s, ngx_stream_variable_value_t *v, uintptr_t data); |
26 static ngx_int_t ngx_stream_variable_proxy_protocol_tlv( | |
27 ngx_stream_session_t *s, ngx_stream_variable_value_t *v, uintptr_t data); | |
26 static ngx_int_t ngx_stream_variable_server_addr(ngx_stream_session_t *s, | 28 static ngx_int_t ngx_stream_variable_server_addr(ngx_stream_session_t *s, |
27 ngx_stream_variable_value_t *v, uintptr_t data); | 29 ngx_stream_variable_value_t *v, uintptr_t data); |
28 static ngx_int_t ngx_stream_variable_server_port(ngx_stream_session_t *s, | 30 static ngx_int_t ngx_stream_variable_server_port(ngx_stream_session_t *s, |
29 ngx_stream_variable_value_t *v, uintptr_t data); | 31 ngx_stream_variable_value_t *v, uintptr_t data); |
30 static ngx_int_t ngx_stream_variable_bytes(ngx_stream_session_t *s, | 32 static ngx_int_t ngx_stream_variable_bytes(ngx_stream_session_t *s, |
76 offsetof(ngx_proxy_protocol_t, dst_addr), 0, 0 }, | 78 offsetof(ngx_proxy_protocol_t, dst_addr), 0, 0 }, |
77 | 79 |
78 { ngx_string("proxy_protocol_server_port"), NULL, | 80 { ngx_string("proxy_protocol_server_port"), NULL, |
79 ngx_stream_variable_proxy_protocol_port, | 81 ngx_stream_variable_proxy_protocol_port, |
80 offsetof(ngx_proxy_protocol_t, dst_port), 0, 0 }, | 82 offsetof(ngx_proxy_protocol_t, dst_port), 0, 0 }, |
83 | |
84 { ngx_string("proxy_protocol_tlv_"), NULL, | |
85 ngx_stream_variable_proxy_protocol_tlv, | |
86 0, NGX_STREAM_VAR_PREFIX, 0 }, | |
81 | 87 |
82 { ngx_string("server_addr"), NULL, | 88 { ngx_string("server_addr"), NULL, |
83 ngx_stream_variable_server_addr, 0, 0, 0 }, | 89 ngx_stream_variable_server_addr, 0, 0, 0 }, |
84 | 90 |
85 { ngx_string("server_port"), NULL, | 91 { ngx_string("server_port"), NULL, |
614 port = *(in_port_t *) ((char *) pp + data); | 620 port = *(in_port_t *) ((char *) pp + data); |
615 | 621 |
616 if (port > 0 && port < 65536) { | 622 if (port > 0 && port < 65536) { |
617 v->len = ngx_sprintf(v->data, "%ui", port) - v->data; | 623 v->len = ngx_sprintf(v->data, "%ui", port) - v->data; |
618 } | 624 } |
625 | |
626 return NGX_OK; | |
627 } | |
628 | |
629 | |
630 static ngx_int_t | |
631 ngx_stream_variable_proxy_protocol_tlv(ngx_stream_session_t *s, | |
632 ngx_stream_variable_value_t *v, uintptr_t data) | |
633 { | |
634 ngx_str_t *name = (ngx_str_t *) data; | |
635 | |
636 ngx_int_t rc; | |
637 ngx_str_t tlv, value; | |
638 | |
639 tlv.len = name->len - (sizeof("proxy_protocol_tlv_") - 1); | |
640 tlv.data = name->data + sizeof("proxy_protocol_tlv_") - 1; | |
641 | |
642 rc = ngx_proxy_protocol_get_tlv(s->connection, &tlv, &value); | |
643 | |
644 if (rc == NGX_ERROR) { | |
645 return NGX_ERROR; | |
646 } | |
647 | |
648 if (rc == NGX_DECLINED) { | |
649 v->not_found = 1; | |
650 return NGX_OK; | |
651 } | |
652 | |
653 v->len = value.len; | |
654 v->valid = 1; | |
655 v->no_cacheable = 0; | |
656 v->not_found = 0; | |
657 v->data = value.data; | |
619 | 658 |
620 return NGX_OK; | 659 return NGX_OK; |
621 } | 660 } |
622 | 661 |
623 | 662 |