annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8215
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
1
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
2 /*
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
3 * Copyright (C) Nginx, Inc.
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
4 * Copyright (C) Roman Arutyunyan
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
5 */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
6
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
7
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
8 #include <ngx_config.h>
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
9 #include <ngx_core.h>
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
10 #include <ngx_http.h>
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
11
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
12
8923
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
13 static ngx_int_t ngx_http_v3_variable(ngx_http_request_t *r,
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
14 ngx_http_variable_value_t *v, uintptr_t data);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
15 static ngx_int_t ngx_http_v3_add_variables(ngx_conf_t *cf);
8493
e533a352d118 Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents: 8492
diff changeset
16 static void *ngx_http_v3_create_srv_conf(ngx_conf_t *cf);
e533a352d118 Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents: 8492
diff changeset
17 static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent,
e533a352d118 Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents: 8492
diff changeset
18 void *child);
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
19 static char *ngx_http_quic_mtu(ngx_conf_t *cf, void *post,
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
20 void *data);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
21 static char *ngx_http_quic_host_key(ngx_conf_t *cf, ngx_command_t *cmd,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
22 void *conf);
8497
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
23 static void *ngx_http_v3_create_loc_conf(ngx_conf_t *cf);
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
24 static char *ngx_http_v3_merge_loc_conf(ngx_conf_t *cf, void *parent,
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
25 void *child);
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
26 static char *ngx_http_v3_push(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
8493
e533a352d118 Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents: 8492
diff changeset
27
e533a352d118 Style: moved function declarations to match usual code style.
Roman Arutyunyan <arut@nginx.com>
parents: 8492
diff changeset
28
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
29 static ngx_conf_post_t ngx_http_quic_mtu_post =
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
30 { ngx_http_quic_mtu };
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
31
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
32
8215
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
33 static ngx_command_t ngx_http_v3_commands[] = {
8247
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
34
9081
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
35 { ngx_string("http3"),
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
36 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
37 ngx_conf_set_flag_slot,
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
38 NGX_HTTP_SRV_CONF_OFFSET,
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
39 offsetof(ngx_http_v3_srv_conf_t, enable),
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
40 NULL },
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
41
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
42 { ngx_string("http3_hq"),
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
43 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
44 ngx_conf_set_flag_slot,
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
45 NGX_HTTP_SRV_CONF_OFFSET,
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
46 offsetof(ngx_http_v3_srv_conf_t, enable_hq),
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
47 NULL },
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
48
8497
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
49 { ngx_string("http3_max_concurrent_pushes"),
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
50 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
51 ngx_conf_set_num_slot,
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
52 NGX_HTTP_SRV_CONF_OFFSET,
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
53 offsetof(ngx_http_v3_srv_conf_t, max_concurrent_pushes),
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
54 NULL },
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
55
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
56 { ngx_string("http3_max_concurrent_streams"),
8824
054f9be0aaf9 HTTP/3: http3_max_uni_streams directive.
Roman Arutyunyan <arut@nginx.com>
parents: 8788
diff changeset
57 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
054f9be0aaf9 HTTP/3: http3_max_uni_streams directive.
Roman Arutyunyan <arut@nginx.com>
parents: 8788
diff changeset
58 ngx_conf_set_num_slot,
054f9be0aaf9 HTTP/3: http3_max_uni_streams directive.
Roman Arutyunyan <arut@nginx.com>
parents: 8788
diff changeset
59 NGX_HTTP_SRV_CONF_OFFSET,
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
60 offsetof(ngx_http_v3_srv_conf_t, max_concurrent_streams),
8824
054f9be0aaf9 HTTP/3: http3_max_uni_streams directive.
Roman Arutyunyan <arut@nginx.com>
parents: 8788
diff changeset
61 NULL },
054f9be0aaf9 HTTP/3: http3_max_uni_streams directive.
Roman Arutyunyan <arut@nginx.com>
parents: 8788
diff changeset
62
8497
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
63 { ngx_string("http3_push"),
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
64 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
65 ngx_http_v3_push,
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
66 NGX_HTTP_LOC_CONF_OFFSET,
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
67 0,
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
68 NULL },
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
69
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
70 { ngx_string("http3_push_preload"),
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
71 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
72 ngx_conf_set_flag_slot,
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
73 NGX_HTTP_LOC_CONF_OFFSET,
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
74 offsetof(ngx_http_v3_loc_conf_t, push_preload),
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
75 NULL },
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
76
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
77 { ngx_string("http3_stream_buffer_size"),
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
78 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
79 ngx_conf_set_size_slot,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
80 NGX_HTTP_SRV_CONF_OFFSET,
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
81 offsetof(ngx_http_v3_srv_conf_t, quic.stream_buffer_size),
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
82 NULL },
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
83
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
84 { ngx_string("quic_retry"),
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
85 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
86 ngx_conf_set_flag_slot,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
87 NGX_HTTP_SRV_CONF_OFFSET,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
88 offsetof(ngx_http_v3_srv_conf_t, quic.retry),
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
89 NULL },
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
90
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
91 { ngx_string("quic_gso"),
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
92 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
93 ngx_conf_set_flag_slot,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
94 NGX_HTTP_SRV_CONF_OFFSET,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
95 offsetof(ngx_http_v3_srv_conf_t, quic.gso_enabled),
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
96 NULL },
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
97
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
98 { ngx_string("quic_mtu"),
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
99 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
100 ngx_conf_set_size_slot,
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
101 NGX_HTTP_SRV_CONF_OFFSET,
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
102 offsetof(ngx_http_v3_srv_conf_t, quic.mtu),
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
103 &ngx_http_quic_mtu_post },
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
104
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
105 { ngx_string("quic_host_key"),
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
106 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
107 ngx_http_quic_host_key,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
108 NGX_HTTP_SRV_CONF_OFFSET,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
109 0,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
110 NULL },
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
111
8970
7106a918a277 QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents: 8924
diff changeset
112 { ngx_string("quic_active_connection_id_limit"),
7106a918a277 QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents: 8924
diff changeset
113 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
7106a918a277 QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents: 8924
diff changeset
114 ngx_conf_set_num_slot,
7106a918a277 QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents: 8924
diff changeset
115 NGX_HTTP_SRV_CONF_OFFSET,
7106a918a277 QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents: 8924
diff changeset
116 offsetof(ngx_http_v3_srv_conf_t, quic.active_connection_id_limit),
7106a918a277 QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents: 8924
diff changeset
117 NULL },
7106a918a277 QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents: 8924
diff changeset
118
8215
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
119 ngx_null_command
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
120 };
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
121
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
122
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
123 static ngx_http_module_t ngx_http_v3_module_ctx = {
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
124 ngx_http_v3_add_variables, /* preconfiguration */
8215
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
125 NULL, /* postconfiguration */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
126
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
127 NULL, /* create main configuration */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
128 NULL, /* init main configuration */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
129
8247
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
130 ngx_http_v3_create_srv_conf, /* create server configuration */
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
131 ngx_http_v3_merge_srv_conf, /* merge server configuration */
8215
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
132
8497
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
133 ngx_http_v3_create_loc_conf, /* create location configuration */
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
134 ngx_http_v3_merge_loc_conf /* merge location configuration */
8215
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
135 };
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
136
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
137
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
138 ngx_module_t ngx_http_v3_module = {
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
139 NGX_MODULE_V1,
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
140 &ngx_http_v3_module_ctx, /* module context */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
141 ngx_http_v3_commands, /* module directives */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
142 NGX_HTTP_MODULE, /* module type */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
143 NULL, /* init master */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
144 NULL, /* init module */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
145 NULL, /* init process */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
146 NULL, /* init thread */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
147 NULL, /* exit thread */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
148 NULL, /* exit process */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
149 NULL, /* exit master */
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
150 NGX_MODULE_V1_PADDING
38c0898b6df7 HTTP/3.
Roman Arutyunyan <arut@nginx.com>
parents:
diff changeset
151 };
8247
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
152
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
153
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
154 static ngx_http_variable_t ngx_http_v3_vars[] = {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
155
8923
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
156 { ngx_string("http3"), NULL, ngx_http_v3_variable, 0, 0, 0 },
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
157
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
158 ngx_http_null_variable
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
159 };
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
160
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
161 static ngx_str_t ngx_http_quic_salt = ngx_string("ngx_quic");
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
162
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
163
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
164 static ngx_int_t
8923
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
165 ngx_http_v3_variable(ngx_http_request_t *r,
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
166 ngx_http_variable_value_t *v, uintptr_t data)
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
167 {
9081
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
168 ngx_http_v3_session_t *h3c;
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
169
9081
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
170 if (r->connection->quic) {
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
171 h3c = ngx_http_v3_get_session(r->connection);
8923
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
172
9081
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
173 if (h3c->hq) {
8923
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
174 v->len = sizeof("hq") - 1;
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
175 v->valid = 1;
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
176 v->no_cacheable = 0;
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
177 v->not_found = 0;
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
178 v->data = (u_char *) "hq";
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
179
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
180 return NGX_OK;
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
181 }
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
182
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
183 v->len = sizeof("h3") - 1;
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
184 v->valid = 1;
8923
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
185 v->no_cacheable = 0;
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
186 v->not_found = 0;
8923
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
187 v->data = (u_char *) "h3";
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
188
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
189 return NGX_OK;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
190 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
191
8923
651cc905b7c2 HTTP/3: $http3 variable.
Roman Arutyunyan <arut@nginx.com>
parents: 8922
diff changeset
192 *v = ngx_http_variable_null_value;
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
193
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
194 return NGX_OK;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
195 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
196
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
197
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
198 static ngx_int_t
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
199 ngx_http_v3_add_variables(ngx_conf_t *cf)
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
200 {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
201 ngx_http_variable_t *var, *v;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
202
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
203 for (v = ngx_http_v3_vars; v->name.len; v++) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
204 var = ngx_http_add_variable(cf, &v->name, v->flags);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
205 if (var == NULL) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
206 return NGX_ERROR;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
207 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
208
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
209 var->get_handler = v->get_handler;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
210 var->data = v->data;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
211 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
212
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
213 return NGX_OK;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
214 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
215
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
216
8247
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
217 static void *
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
218 ngx_http_v3_create_srv_conf(ngx_conf_t *cf)
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
219 {
8492
65c1fc5fae15 HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents: 8481
diff changeset
220 ngx_http_v3_srv_conf_t *h3scf;
8247
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
221
8492
65c1fc5fae15 HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents: 8481
diff changeset
222 h3scf = ngx_pcalloc(cf->pool, sizeof(ngx_http_v3_srv_conf_t));
65c1fc5fae15 HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents: 8481
diff changeset
223 if (h3scf == NULL) {
8247
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
224 return NULL;
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
225 }
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
226
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
227 /*
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
228 * set by ngx_pcalloc():
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
229 *
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
230 * h3scf->quic.host_key = { 0, NULL }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
231 * h3scf->quic.stream_reject_code_uni = 0;
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
232 * h3scf->quic.disable_active_migration = 0;
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
233 * h3scf->quic.timeout = 0;
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
234 * h3scf->max_blocked_streams = 0;
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
235 */
9081
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
236
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
237 h3scf->enable = NGX_CONF_UNSET;
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
238 h3scf->enable_hq = NGX_CONF_UNSET;
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
239 h3scf->max_table_capacity = NGX_HTTP_V3_MAX_TABLE_CAPACITY;
8497
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
240 h3scf->max_concurrent_pushes = NGX_CONF_UNSET_UINT;
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
241 h3scf->max_concurrent_streams = NGX_CONF_UNSET_UINT;
8454
032cb35ce758 HTTP/3: http3_max_field_size directive to limit string size.
Roman Arutyunyan <arut@nginx.com>
parents: 8417
diff changeset
242
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
243 h3scf->quic.mtu = NGX_CONF_UNSET_SIZE;
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
244 h3scf->quic.stream_buffer_size = NGX_CONF_UNSET_SIZE;
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
245 h3scf->quic.max_concurrent_streams_bidi = NGX_CONF_UNSET_UINT;
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
246 h3scf->quic.max_concurrent_streams_uni = NGX_HTTP_V3_MAX_UNI_STREAMS;
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
247 h3scf->quic.retry = NGX_CONF_UNSET;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
248 h3scf->quic.gso_enabled = NGX_CONF_UNSET;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
249 h3scf->quic.stream_close_code = NGX_HTTP_V3_ERR_NO_ERROR;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
250 h3scf->quic.stream_reject_code_bidi = NGX_HTTP_V3_ERR_REQUEST_REJECTED;
8970
7106a918a277 QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents: 8924
diff changeset
251 h3scf->quic.active_connection_id_limit = NGX_CONF_UNSET_UINT;
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
252
9058
b0c2234aaa9f QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents: 9055
diff changeset
253 h3scf->quic.init = ngx_http_v3_init;
9055
1192923be0aa QUIC: idle mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents: 8970
diff changeset
254 h3scf->quic.shutdown = ngx_http_v3_shutdown;
1192923be0aa QUIC: idle mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents: 8970
diff changeset
255
8492
65c1fc5fae15 HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents: 8481
diff changeset
256 return h3scf;
8247
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
257 }
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
258
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
259
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
260 static char *
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
261 ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
262 {
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
263 ngx_http_v3_srv_conf_t *prev = parent;
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
264 ngx_http_v3_srv_conf_t *conf = child;
e9891e8ee975 Configurable transport parameters.
Vladimir Homutov <vl@nginx.com>
parents: 8215
diff changeset
265
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
266 ngx_http_ssl_srv_conf_t *sscf;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
267
9081
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
268 ngx_conf_merge_value(conf->enable, prev->enable, 1);
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
269
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
270 ngx_conf_merge_value(conf->enable_hq, prev->enable_hq, 0);
c851a2ed5ce8 HTTP/3: "quic" parameter of "listen" directive.
Roman Arutyunyan <arut@nginx.com>
parents: 9058
diff changeset
271
8497
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
272 ngx_conf_merge_uint_value(conf->max_concurrent_pushes,
8829
4f922f611135 HTTP/3: replaced macros with values.
Roman Arutyunyan <arut@nginx.com>
parents: 8824
diff changeset
273 prev->max_concurrent_pushes, 10);
8497
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
274
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
275 ngx_conf_merge_uint_value(conf->max_concurrent_streams,
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
276 prev->max_concurrent_streams, 128);
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
277
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
278 conf->max_blocked_streams = conf->max_concurrent_streams;
8824
054f9be0aaf9 HTTP/3: http3_max_uni_streams directive.
Roman Arutyunyan <arut@nginx.com>
parents: 8788
diff changeset
279
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
280 ngx_conf_merge_size_value(conf->quic.mtu, prev->quic.mtu,
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
281 NGX_QUIC_MAX_UDP_PAYLOAD_SIZE);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
282
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
283 ngx_conf_merge_size_value(conf->quic.stream_buffer_size,
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
284 prev->quic.stream_buffer_size,
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
285 65536);
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
286
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
287 conf->quic.max_concurrent_streams_bidi = conf->max_concurrent_streams;
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
288
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
289 ngx_conf_merge_value(conf->quic.retry, prev->quic.retry, 0);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
290 ngx_conf_merge_value(conf->quic.gso_enabled, prev->quic.gso_enabled, 0);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
291
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
292 ngx_conf_merge_str_value(conf->quic.host_key, prev->quic.host_key, "");
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
293
8970
7106a918a277 QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents: 8924
diff changeset
294 ngx_conf_merge_uint_value(conf->quic.active_connection_id_limit,
7106a918a277 QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents: 8924
diff changeset
295 prev->quic.active_connection_id_limit,
7106a918a277 QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents: 8924
diff changeset
296 2);
7106a918a277 QUIC: the "quic_active_connection_id_limit" directive.
Vladimir Homutov <vl@nginx.com>
parents: 8924
diff changeset
297
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
298 if (conf->quic.host_key.len == 0) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
299
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
300 conf->quic.host_key.len = NGX_QUIC_DEFAULT_HOST_KEY_LEN;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
301 conf->quic.host_key.data = ngx_palloc(cf->pool,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
302 conf->quic.host_key.len);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
303 if (conf->quic.host_key.data == NULL) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
304 return NGX_CONF_ERROR;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
305 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
306
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
307 if (RAND_bytes(conf->quic.host_key.data, NGX_QUIC_DEFAULT_HOST_KEY_LEN)
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
308 <= 0)
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
309 {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
310 return NGX_CONF_ERROR;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
311 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
312 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
313
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
314 if (ngx_quic_derive_key(cf->log, "av_token_key",
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
315 &conf->quic.host_key, &ngx_http_quic_salt,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
316 conf->quic.av_token_key, NGX_QUIC_AV_KEY_LEN)
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
317 != NGX_OK)
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
318 {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
319 return NGX_CONF_ERROR;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
320 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
321
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
322 if (ngx_quic_derive_key(cf->log, "sr_token_key",
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
323 &conf->quic.host_key, &ngx_http_quic_salt,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
324 conf->quic.sr_token_key, NGX_QUIC_SR_KEY_LEN)
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
325 != NGX_OK)
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
326 {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
327 return NGX_CONF_ERROR;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
328 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
329
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
330 sscf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_ssl_module);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
331 conf->quic.ssl = &sscf->ssl;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
332
8497
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
333 return NGX_CONF_OK;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
334 }
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
335
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
336
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
337 static char *
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
338 ngx_http_quic_mtu(ngx_conf_t *cf, void *post, void *data)
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
339 {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
340 size_t *sp = data;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
341
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
342 if (*sp < NGX_QUIC_MIN_INITIAL_SIZE
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
343 || *sp > NGX_QUIC_MAX_UDP_PAYLOAD_SIZE)
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
344 {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
345 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
8924
d6ef13c5fd8e QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents: 8923
diff changeset
346 "\"quic_mtu\" must be between %d and %d",
8921
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
347 NGX_QUIC_MIN_INITIAL_SIZE,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
348 NGX_QUIC_MAX_UDP_PAYLOAD_SIZE);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
349
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
350 return NGX_CONF_ERROR;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
351 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
352
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
353 return NGX_CONF_OK;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
354 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
355
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
356
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
357 static char *
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
358 ngx_http_quic_host_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
359 {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
360 ngx_http_v3_srv_conf_t *h3scf = conf;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
361
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
362 u_char *buf;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
363 size_t size;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
364 ssize_t n;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
365 ngx_str_t *value;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
366 ngx_file_t file;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
367 ngx_file_info_t fi;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
368 ngx_quic_conf_t *qcf;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
369
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
370 qcf = &h3scf->quic;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
371
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
372 if (qcf->host_key.len) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
373 return "is duplicate";
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
374 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
375
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
376 buf = NULL;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
377 #if (NGX_SUPPRESS_WARN)
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
378 size = 0;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
379 #endif
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
380
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
381 value = cf->args->elts;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
382
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
383 if (ngx_conf_full_name(cf->cycle, &value[1], 1) != NGX_OK) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
384 return NGX_CONF_ERROR;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
385 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
386
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
387 ngx_memzero(&file, sizeof(ngx_file_t));
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
388 file.name = value[1];
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
389 file.log = cf->log;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
390
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
391 file.fd = ngx_open_file(file.name.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
392
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
393 if (file.fd == NGX_INVALID_FILE) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
394 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
395 ngx_open_file_n " \"%V\" failed", &file.name);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
396 return NGX_CONF_ERROR;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
397 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
398
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
399 if (ngx_fd_info(file.fd, &fi) == NGX_FILE_ERROR) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
400 ngx_conf_log_error(NGX_LOG_CRIT, cf, ngx_errno,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
401 ngx_fd_info_n " \"%V\" failed", &file.name);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
402 goto failed;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
403 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
404
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
405 size = ngx_file_size(&fi);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
406
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
407 if (size == 0) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
408 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
409 "\"%V\" zero key size", &file.name);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
410 goto failed;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
411 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
412
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
413 buf = ngx_pnalloc(cf->pool, size);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
414 if (buf == NULL) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
415 goto failed;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
416 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
417
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
418 n = ngx_read_file(&file, buf, size, 0);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
419
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
420 if (n == NGX_ERROR) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
421 ngx_conf_log_error(NGX_LOG_CRIT, cf, ngx_errno,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
422 ngx_read_file_n " \"%V\" failed", &file.name);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
423 goto failed;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
424 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
425
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
426 if ((size_t) n != size) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
427 ngx_conf_log_error(NGX_LOG_CRIT, cf, 0,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
428 ngx_read_file_n " \"%V\" returned only "
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
429 "%z bytes instead of %uz", &file.name, n, size);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
430 goto failed;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
431 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
432
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
433 qcf->host_key.data = buf;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
434 qcf->host_key.len = n;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
435
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
436 if (ngx_close_file(file.fd) == NGX_FILE_ERROR) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
437 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
438 ngx_close_file_n " \"%V\" failed", &file.name);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
439 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
440
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
441 return NGX_CONF_OK;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
442
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
443 failed:
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
444
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
445 if (ngx_close_file(file.fd) == NGX_FILE_ERROR) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
446 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
447 ngx_close_file_n " \"%V\" failed", &file.name);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
448 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
449
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
450 if (buf) {
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
451 ngx_explicit_memzero(buf, size);
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
452 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
453
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
454 return NGX_CONF_ERROR;
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
455 }
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
456
33226ac61076 HTTP/3: merged ngx_http_quic_module into ngx_http_v3_module.
Roman Arutyunyan <arut@nginx.com>
parents: 8829
diff changeset
457
8497
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
458 static void *
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
459 ngx_http_v3_create_loc_conf(ngx_conf_t *cf)
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
460 {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
461 ngx_http_v3_loc_conf_t *h3lcf;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
462
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
463 h3lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_v3_loc_conf_t));
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
464 if (h3lcf == NULL) {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
465 return NULL;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
466 }
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
467
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
468 /*
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
469 * set by ngx_pcalloc():
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
470 *
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
471 * h3lcf->pushes = NULL;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
472 */
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
473
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
474 h3lcf->push_preload = NGX_CONF_UNSET;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
475 h3lcf->push = NGX_CONF_UNSET;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
476
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
477 return h3lcf;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
478 }
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
479
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
480
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
481 static char *
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
482 ngx_http_v3_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
483 {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
484 ngx_http_v3_loc_conf_t *prev = parent;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
485 ngx_http_v3_loc_conf_t *conf = child;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
486
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
487 ngx_conf_merge_value(conf->push, prev->push, 1);
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
488
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
489 if (conf->push && conf->pushes == NULL) {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
490 conf->pushes = prev->pushes;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
491 }
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
492
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
493 ngx_conf_merge_value(conf->push_preload, prev->push_preload, 0);
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
494
8353
036164360fa9 HTTP/3: directives with limited values converted to post handler.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8352
diff changeset
495 return NGX_CONF_OK;
036164360fa9 HTTP/3: directives with limited values converted to post handler.
Sergey Kandaurov <pluknet@nginx.com>
parents: 8352
diff changeset
496 }
8497
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
497
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
498
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
499 static char *
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
500 ngx_http_v3_push(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
501 {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
502 ngx_http_v3_loc_conf_t *h3lcf = conf;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
503
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
504 ngx_str_t *value;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
505 ngx_http_complex_value_t *cv;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
506 ngx_http_compile_complex_value_t ccv;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
507
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
508 value = cf->args->elts;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
509
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
510 if (ngx_strcmp(value[1].data, "off") == 0) {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
511
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
512 if (h3lcf->pushes) {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
513 return "\"off\" parameter cannot be used with URI";
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
514 }
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
515
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
516 if (h3lcf->push == 0) {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
517 return "is duplicate";
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
518 }
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
519
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
520 h3lcf->push = 0;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
521 return NGX_CONF_OK;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
522 }
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
523
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
524 if (h3lcf->push == 0) {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
525 return "URI cannot be used with \"off\" parameter";
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
526 }
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
527
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
528 h3lcf->push = 1;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
529
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
530 if (h3lcf->pushes == NULL) {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
531 h3lcf->pushes = ngx_array_create(cf->pool, 1,
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
532 sizeof(ngx_http_complex_value_t));
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
533 if (h3lcf->pushes == NULL) {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
534 return NGX_CONF_ERROR;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
535 }
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
536 }
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
537
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
538 cv = ngx_array_push(h3lcf->pushes);
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
539 if (cv == NULL) {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
540 return NGX_CONF_ERROR;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
541 }
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
542
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
543 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
544
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
545 ccv.cf = cf;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
546 ccv.value = &value[1];
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
547 ccv.complex_value = cv;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
548
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
549 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
550 return NGX_CONF_ERROR;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
551 }
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
552
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
553 return NGX_CONF_OK;
0596fe1aee16 HTTP/3: server pushes.
Roman Arutyunyan <arut@nginx.com>
parents: 8493
diff changeset
554 }