Mercurial > hg > nginx
comparison src/http/v3/ngx_http_v3_module.c @ 9081:c851a2ed5ce8 quic
HTTP/3: "quic" parameter of "listen" directive.
Now "listen" directve has a new "quic" parameter which enables QUIC protocol
for the address. Further, to enable HTTP/3, a new directive "http3" is
introduced. The hq-interop protocol is enabled by "http3_hq" as before.
Now application protocol is chosen by ALPN.
Previously used "http3" parameter of "listen" is deprecated.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Mon, 27 Feb 2023 14:00:56 +0400 |
parents | b0c2234aaa9f |
children | b9230e37b8a1 |
comparison
equal
deleted
inserted
replaced
9080:7da4791e0264 | 9081:c851a2ed5ce8 |
---|---|
30 { ngx_http_quic_mtu }; | 30 { ngx_http_quic_mtu }; |
31 | 31 |
32 | 32 |
33 static ngx_command_t ngx_http_v3_commands[] = { | 33 static ngx_command_t ngx_http_v3_commands[] = { |
34 | 34 |
35 { ngx_string("http3"), | |
36 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, | |
37 ngx_conf_set_flag_slot, | |
38 NGX_HTTP_SRV_CONF_OFFSET, | |
39 offsetof(ngx_http_v3_srv_conf_t, enable), | |
40 NULL }, | |
41 | |
42 { ngx_string("http3_hq"), | |
43 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, | |
44 ngx_conf_set_flag_slot, | |
45 NGX_HTTP_SRV_CONF_OFFSET, | |
46 offsetof(ngx_http_v3_srv_conf_t, enable_hq), | |
47 NULL }, | |
48 | |
35 { ngx_string("http3_max_concurrent_pushes"), | 49 { ngx_string("http3_max_concurrent_pushes"), |
36 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | 50 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
37 ngx_conf_set_num_slot, | 51 ngx_conf_set_num_slot, |
38 NGX_HTTP_SRV_CONF_OFFSET, | 52 NGX_HTTP_SRV_CONF_OFFSET, |
39 offsetof(ngx_http_v3_srv_conf_t, max_concurrent_pushes), | 53 offsetof(ngx_http_v3_srv_conf_t, max_concurrent_pushes), |
43 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | 57 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
44 ngx_conf_set_num_slot, | 58 ngx_conf_set_num_slot, |
45 NGX_HTTP_SRV_CONF_OFFSET, | 59 NGX_HTTP_SRV_CONF_OFFSET, |
46 offsetof(ngx_http_v3_srv_conf_t, max_concurrent_streams), | 60 offsetof(ngx_http_v3_srv_conf_t, max_concurrent_streams), |
47 NULL }, | 61 NULL }, |
48 | |
49 #if (NGX_HTTP_V3_HQ) | |
50 { ngx_string("http3_hq"), | |
51 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, | |
52 ngx_conf_set_flag_slot, | |
53 NGX_HTTP_SRV_CONF_OFFSET, | |
54 offsetof(ngx_http_v3_srv_conf_t, hq), | |
55 NULL }, | |
56 #endif | |
57 | 62 |
58 { ngx_string("http3_push"), | 63 { ngx_string("http3_push"), |
59 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 64 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
60 ngx_http_v3_push, | 65 ngx_http_v3_push, |
61 NGX_HTTP_LOC_CONF_OFFSET, | 66 NGX_HTTP_LOC_CONF_OFFSET, |
158 | 163 |
159 static ngx_int_t | 164 static ngx_int_t |
160 ngx_http_v3_variable(ngx_http_request_t *r, | 165 ngx_http_v3_variable(ngx_http_request_t *r, |
161 ngx_http_variable_value_t *v, uintptr_t data) | 166 ngx_http_variable_value_t *v, uintptr_t data) |
162 { | 167 { |
168 ngx_http_v3_session_t *h3c; | |
169 | |
163 if (r->connection->quic) { | 170 if (r->connection->quic) { |
164 #if (NGX_HTTP_V3_HQ) | 171 h3c = ngx_http_v3_get_session(r->connection); |
165 | 172 |
166 ngx_http_v3_srv_conf_t *h3scf; | 173 if (h3c->hq) { |
167 | |
168 h3scf = ngx_http_get_module_srv_conf(r, ngx_http_v3_module); | |
169 | |
170 if (h3scf->hq) { | |
171 v->len = sizeof("hq") - 1; | 174 v->len = sizeof("hq") - 1; |
172 v->valid = 1; | 175 v->valid = 1; |
173 v->no_cacheable = 0; | 176 v->no_cacheable = 0; |
174 v->not_found = 0; | 177 v->not_found = 0; |
175 v->data = (u_char *) "hq"; | 178 v->data = (u_char *) "hq"; |
176 | 179 |
177 return NGX_OK; | 180 return NGX_OK; |
178 } | 181 } |
179 | |
180 #endif | |
181 | 182 |
182 v->len = sizeof("h3") - 1; | 183 v->len = sizeof("h3") - 1; |
183 v->valid = 1; | 184 v->valid = 1; |
184 v->no_cacheable = 0; | 185 v->no_cacheable = 0; |
185 v->not_found = 0; | 186 v->not_found = 0; |
230 * h3scf->quic.stream_reject_code_uni = 0; | 231 * h3scf->quic.stream_reject_code_uni = 0; |
231 * h3scf->quic.disable_active_migration = 0; | 232 * h3scf->quic.disable_active_migration = 0; |
232 * h3scf->quic.timeout = 0; | 233 * h3scf->quic.timeout = 0; |
233 * h3scf->max_blocked_streams = 0; | 234 * h3scf->max_blocked_streams = 0; |
234 */ | 235 */ |
236 | |
237 h3scf->enable = NGX_CONF_UNSET; | |
238 h3scf->enable_hq = NGX_CONF_UNSET; | |
235 h3scf->max_table_capacity = NGX_HTTP_V3_MAX_TABLE_CAPACITY; | 239 h3scf->max_table_capacity = NGX_HTTP_V3_MAX_TABLE_CAPACITY; |
236 h3scf->max_concurrent_pushes = NGX_CONF_UNSET_UINT; | 240 h3scf->max_concurrent_pushes = NGX_CONF_UNSET_UINT; |
237 h3scf->max_concurrent_streams = NGX_CONF_UNSET_UINT; | 241 h3scf->max_concurrent_streams = NGX_CONF_UNSET_UINT; |
238 #if (NGX_HTTP_V3_HQ) | |
239 h3scf->hq = NGX_CONF_UNSET; | |
240 #endif | |
241 | 242 |
242 h3scf->quic.mtu = NGX_CONF_UNSET_SIZE; | 243 h3scf->quic.mtu = NGX_CONF_UNSET_SIZE; |
243 h3scf->quic.stream_buffer_size = NGX_CONF_UNSET_SIZE; | 244 h3scf->quic.stream_buffer_size = NGX_CONF_UNSET_SIZE; |
244 h3scf->quic.max_concurrent_streams_bidi = NGX_CONF_UNSET_UINT; | 245 h3scf->quic.max_concurrent_streams_bidi = NGX_CONF_UNSET_UINT; |
245 h3scf->quic.max_concurrent_streams_uni = NGX_HTTP_V3_MAX_UNI_STREAMS; | 246 h3scf->quic.max_concurrent_streams_uni = NGX_HTTP_V3_MAX_UNI_STREAMS; |
262 ngx_http_v3_srv_conf_t *prev = parent; | 263 ngx_http_v3_srv_conf_t *prev = parent; |
263 ngx_http_v3_srv_conf_t *conf = child; | 264 ngx_http_v3_srv_conf_t *conf = child; |
264 | 265 |
265 ngx_http_ssl_srv_conf_t *sscf; | 266 ngx_http_ssl_srv_conf_t *sscf; |
266 | 267 |
268 ngx_conf_merge_value(conf->enable, prev->enable, 1); | |
269 | |
270 ngx_conf_merge_value(conf->enable_hq, prev->enable_hq, 0); | |
271 | |
267 ngx_conf_merge_uint_value(conf->max_concurrent_pushes, | 272 ngx_conf_merge_uint_value(conf->max_concurrent_pushes, |
268 prev->max_concurrent_pushes, 10); | 273 prev->max_concurrent_pushes, 10); |
269 | 274 |
270 ngx_conf_merge_uint_value(conf->max_concurrent_streams, | 275 ngx_conf_merge_uint_value(conf->max_concurrent_streams, |
271 prev->max_concurrent_streams, 128); | 276 prev->max_concurrent_streams, 128); |
272 | 277 |
273 conf->max_blocked_streams = conf->max_concurrent_streams; | 278 conf->max_blocked_streams = conf->max_concurrent_streams; |
274 | |
275 #if (NGX_HTTP_V3_HQ) | |
276 ngx_conf_merge_value(conf->hq, prev->hq, 0); | |
277 #endif | |
278 | |
279 | 279 |
280 ngx_conf_merge_size_value(conf->quic.mtu, prev->quic.mtu, | 280 ngx_conf_merge_size_value(conf->quic.mtu, prev->quic.mtu, |
281 NGX_QUIC_MAX_UDP_PAYLOAD_SIZE); | 281 NGX_QUIC_MAX_UDP_PAYLOAD_SIZE); |
282 | 282 |
283 ngx_conf_merge_size_value(conf->quic.stream_buffer_size, | 283 ngx_conf_merge_size_value(conf->quic.stream_buffer_size, |