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