Mercurial > hg > nginx
annotate src/stream/ngx_stream_core_module.c @ 8620:d10118e38943 quic
QUIC: refactored SSL_do_handshake() handling.
No functional changes.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 29 Oct 2020 21:50:49 +0000 |
parents | 893b3313f53c |
children | 279ad36f2f4b |
rev | line source |
---|---|
6115 | 1 |
2 /* | |
3 * Copyright (C) Roman Arutyunyan | |
4 * Copyright (C) Nginx, Inc. | |
5 */ | |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 #include <ngx_stream.h> | |
11 | |
12 | |
6607
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
13 static ngx_int_t ngx_stream_core_preconfiguration(ngx_conf_t *cf); |
6115 | 14 static void *ngx_stream_core_create_main_conf(ngx_conf_t *cf); |
6607
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
15 static char *ngx_stream_core_init_main_conf(ngx_conf_t *cf, void *conf); |
6115 | 16 static void *ngx_stream_core_create_srv_conf(ngx_conf_t *cf); |
17 static char *ngx_stream_core_merge_srv_conf(ngx_conf_t *cf, void *parent, | |
18 void *child); | |
19 static char *ngx_stream_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, | |
20 void *conf); | |
21 static char *ngx_stream_core_server(ngx_conf_t *cf, ngx_command_t *cmd, | |
22 void *conf); | |
23 static char *ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, | |
24 void *conf); | |
6618 | 25 static char *ngx_stream_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, |
26 void *conf); | |
6115 | 27 |
28 | |
29 static ngx_command_t ngx_stream_core_commands[] = { | |
30 | |
6607
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
31 { ngx_string("variables_hash_max_size"), |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
32 NGX_STREAM_MAIN_CONF|NGX_CONF_TAKE1, |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
33 ngx_conf_set_num_slot, |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
34 NGX_STREAM_MAIN_CONF_OFFSET, |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
35 offsetof(ngx_stream_core_main_conf_t, variables_hash_max_size), |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
36 NULL }, |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
37 |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
38 { ngx_string("variables_hash_bucket_size"), |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
39 NGX_STREAM_MAIN_CONF|NGX_CONF_TAKE1, |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
40 ngx_conf_set_num_slot, |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
41 NGX_STREAM_MAIN_CONF_OFFSET, |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
42 offsetof(ngx_stream_core_main_conf_t, variables_hash_bucket_size), |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
43 NULL }, |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
44 |
6115 | 45 { ngx_string("server"), |
46 NGX_STREAM_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, | |
47 ngx_stream_core_server, | |
48 0, | |
49 0, | |
50 NULL }, | |
51 | |
52 { ngx_string("listen"), | |
53 NGX_STREAM_SRV_CONF|NGX_CONF_1MORE, | |
54 ngx_stream_core_listen, | |
55 NGX_STREAM_SRV_CONF_OFFSET, | |
56 0, | |
57 NULL }, | |
58 | |
59 { ngx_string("error_log"), | |
60 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_1MORE, | |
61 ngx_stream_core_error_log, | |
62 NGX_STREAM_SRV_CONF_OFFSET, | |
63 0, | |
64 NULL }, | |
65 | |
6618 | 66 { ngx_string("resolver"), |
67 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_1MORE, | |
68 ngx_stream_core_resolver, | |
69 NGX_STREAM_SRV_CONF_OFFSET, | |
70 0, | |
71 NULL }, | |
72 | |
73 { ngx_string("resolver_timeout"), | |
74 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1, | |
75 ngx_conf_set_msec_slot, | |
76 NGX_STREAM_SRV_CONF_OFFSET, | |
77 offsetof(ngx_stream_core_srv_conf_t, resolver_timeout), | |
78 NULL }, | |
79 | |
6680
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
80 { ngx_string("proxy_protocol_timeout"), |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
81 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1, |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
82 ngx_conf_set_msec_slot, |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
83 NGX_STREAM_SRV_CONF_OFFSET, |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
84 offsetof(ngx_stream_core_srv_conf_t, proxy_protocol_timeout), |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
85 NULL }, |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
86 |
6221
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6174
diff
changeset
|
87 { ngx_string("tcp_nodelay"), |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6174
diff
changeset
|
88 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_FLAG, |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6174
diff
changeset
|
89 ngx_conf_set_flag_slot, |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6174
diff
changeset
|
90 NGX_STREAM_SRV_CONF_OFFSET, |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6174
diff
changeset
|
91 offsetof(ngx_stream_core_srv_conf_t, tcp_nodelay), |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6174
diff
changeset
|
92 NULL }, |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6174
diff
changeset
|
93 |
6694 | 94 { ngx_string("preread_buffer_size"), |
95 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1, | |
96 ngx_conf_set_size_slot, | |
97 NGX_STREAM_SRV_CONF_OFFSET, | |
98 offsetof(ngx_stream_core_srv_conf_t, preread_buffer_size), | |
99 NULL }, | |
100 | |
101 { ngx_string("preread_timeout"), | |
102 NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1, | |
103 ngx_conf_set_msec_slot, | |
104 NGX_STREAM_SRV_CONF_OFFSET, | |
105 offsetof(ngx_stream_core_srv_conf_t, preread_timeout), | |
106 NULL }, | |
107 | |
6115 | 108 ngx_null_command |
109 }; | |
110 | |
111 | |
112 static ngx_stream_module_t ngx_stream_core_module_ctx = { | |
6607
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
113 ngx_stream_core_preconfiguration, /* preconfiguration */ |
6174
68c106e6fa0a
Stream: added postconfiguration method to stream modules.
Vladimir Homutov <vl@nginx.com>
parents:
6172
diff
changeset
|
114 NULL, /* postconfiguration */ |
68c106e6fa0a
Stream: added postconfiguration method to stream modules.
Vladimir Homutov <vl@nginx.com>
parents:
6172
diff
changeset
|
115 |
6115 | 116 ngx_stream_core_create_main_conf, /* create main configuration */ |
6607
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
117 ngx_stream_core_init_main_conf, /* init main configuration */ |
6115 | 118 |
119 ngx_stream_core_create_srv_conf, /* create server configuration */ | |
120 ngx_stream_core_merge_srv_conf /* merge server configuration */ | |
121 }; | |
122 | |
123 | |
124 ngx_module_t ngx_stream_core_module = { | |
125 NGX_MODULE_V1, | |
126 &ngx_stream_core_module_ctx, /* module context */ | |
127 ngx_stream_core_commands, /* module directives */ | |
128 NGX_STREAM_MODULE, /* module type */ | |
129 NULL, /* init master */ | |
130 NULL, /* init module */ | |
131 NULL, /* init process */ | |
132 NULL, /* init thread */ | |
133 NULL, /* exit thread */ | |
134 NULL, /* exit process */ | |
135 NULL, /* exit master */ | |
136 NGX_MODULE_V1_PADDING | |
137 }; | |
138 | |
139 | |
6693 | 140 void |
141 ngx_stream_core_run_phases(ngx_stream_session_t *s) | |
142 { | |
143 ngx_int_t rc; | |
144 ngx_stream_phase_handler_t *ph; | |
145 ngx_stream_core_main_conf_t *cmcf; | |
146 | |
147 cmcf = ngx_stream_get_module_main_conf(s, ngx_stream_core_module); | |
148 | |
149 ph = cmcf->phase_engine.handlers; | |
150 | |
151 while (ph[s->phase_handler].checker) { | |
152 | |
153 rc = ph[s->phase_handler].checker(s, &ph[s->phase_handler]); | |
154 | |
155 if (rc == NGX_OK) { | |
156 return; | |
157 } | |
158 } | |
159 } | |
160 | |
161 | |
162 ngx_int_t | |
163 ngx_stream_core_generic_phase(ngx_stream_session_t *s, | |
164 ngx_stream_phase_handler_t *ph) | |
165 { | |
166 ngx_int_t rc; | |
167 | |
168 /* | |
169 * generic phase checker, | |
6694 | 170 * used by all phases, except for preread and content |
6693 | 171 */ |
172 | |
173 ngx_log_debug1(NGX_LOG_DEBUG_STREAM, s->connection->log, 0, | |
174 "generic phase: %ui", s->phase_handler); | |
175 | |
176 rc = ph->handler(s); | |
177 | |
178 if (rc == NGX_OK) { | |
179 s->phase_handler = ph->next; | |
180 return NGX_AGAIN; | |
181 } | |
182 | |
183 if (rc == NGX_DECLINED) { | |
184 s->phase_handler++; | |
185 return NGX_AGAIN; | |
186 } | |
187 | |
188 if (rc == NGX_AGAIN || rc == NGX_DONE) { | |
189 return NGX_OK; | |
190 } | |
191 | |
192 if (rc == NGX_ERROR) { | |
193 rc = NGX_STREAM_INTERNAL_SERVER_ERROR; | |
194 } | |
195 | |
196 ngx_stream_finalize_session(s, rc); | |
197 | |
198 return NGX_OK; | |
199 } | |
200 | |
201 | |
202 ngx_int_t | |
6694 | 203 ngx_stream_core_preread_phase(ngx_stream_session_t *s, |
204 ngx_stream_phase_handler_t *ph) | |
205 { | |
206 size_t size; | |
207 ssize_t n; | |
208 ngx_int_t rc; | |
209 ngx_connection_t *c; | |
210 ngx_stream_core_srv_conf_t *cscf; | |
211 | |
212 c = s->connection; | |
213 | |
214 c->log->action = "prereading client data"; | |
215 | |
216 cscf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module); | |
217 | |
218 if (c->read->timedout) { | |
219 rc = NGX_STREAM_OK; | |
220 | |
221 } else if (c->read->timer_set) { | |
222 rc = NGX_AGAIN; | |
223 | |
224 } else { | |
225 rc = ph->handler(s); | |
226 } | |
227 | |
228 while (rc == NGX_AGAIN) { | |
229 | |
230 if (c->buffer == NULL) { | |
231 c->buffer = ngx_create_temp_buf(c->pool, cscf->preread_buffer_size); | |
232 if (c->buffer == NULL) { | |
233 rc = NGX_ERROR; | |
234 break; | |
235 } | |
236 } | |
237 | |
238 size = c->buffer->end - c->buffer->last; | |
239 | |
240 if (size == 0) { | |
241 ngx_log_error(NGX_LOG_ERR, c->log, 0, "preread buffer full"); | |
242 rc = NGX_STREAM_BAD_REQUEST; | |
243 break; | |
244 } | |
245 | |
246 if (c->read->eof) { | |
247 rc = NGX_STREAM_OK; | |
248 break; | |
249 } | |
250 | |
251 if (!c->read->ready) { | |
7345
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
252 break; |
6694 | 253 } |
254 | |
255 n = c->recv(c, c->buffer->last, size); | |
256 | |
7345
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
257 if (n == NGX_ERROR || n == 0) { |
6694 | 258 rc = NGX_STREAM_OK; |
259 break; | |
260 } | |
261 | |
7345
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
262 if (n == NGX_AGAIN) { |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
263 break; |
6694 | 264 } |
265 | |
7345
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
266 c->buffer->last += n; |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
267 |
6694 | 268 rc = ph->handler(s); |
269 } | |
270 | |
7345
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
271 if (rc == NGX_AGAIN) { |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
272 if (ngx_handle_read_event(c->read, 0) != NGX_OK) { |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
273 ngx_stream_finalize_session(s, NGX_STREAM_INTERNAL_SERVER_ERROR); |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
274 return NGX_OK; |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
275 } |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
276 |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
277 if (!c->read->timer_set) { |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
278 ngx_add_timer(c->read, cscf->preread_timeout); |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
279 } |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
280 |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
281 c->read->handler = ngx_stream_session_handler; |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
282 |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
283 return NGX_OK; |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
284 } |
fe767c99c2ad
Stream: avoid potential infinite loop at preread phase.
Roman Arutyunyan <arut@nginx.com>
parents:
7269
diff
changeset
|
285 |
6694 | 286 if (c->read->timer_set) { |
287 ngx_del_timer(c->read); | |
288 } | |
289 | |
290 if (rc == NGX_OK) { | |
291 s->phase_handler = ph->next; | |
292 return NGX_AGAIN; | |
293 } | |
294 | |
295 if (rc == NGX_DECLINED) { | |
296 s->phase_handler++; | |
297 return NGX_AGAIN; | |
298 } | |
299 | |
300 if (rc == NGX_DONE) { | |
301 return NGX_OK; | |
302 } | |
303 | |
304 if (rc == NGX_ERROR) { | |
305 rc = NGX_STREAM_INTERNAL_SERVER_ERROR; | |
306 } | |
307 | |
308 ngx_stream_finalize_session(s, rc); | |
309 | |
310 return NGX_OK; | |
311 } | |
312 | |
313 | |
314 ngx_int_t | |
6693 | 315 ngx_stream_core_content_phase(ngx_stream_session_t *s, |
316 ngx_stream_phase_handler_t *ph) | |
317 { | |
318 ngx_connection_t *c; | |
319 ngx_stream_core_srv_conf_t *cscf; | |
320 | |
321 c = s->connection; | |
322 | |
323 c->log->action = NULL; | |
324 | |
325 cscf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module); | |
326 | |
327 if (c->type == SOCK_STREAM | |
8482
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
328 #if (NGX_STREAM_QUIC) |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
329 && c->qs == NULL |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
330 #endif |
6693 | 331 && cscf->tcp_nodelay |
7007
ed1101bbf19f
Introduced ngx_tcp_nodelay().
Ruslan Ermilov <ru@nginx.com>
parents:
6975
diff
changeset
|
332 && ngx_tcp_nodelay(c) != NGX_OK) |
6693 | 333 { |
7007
ed1101bbf19f
Introduced ngx_tcp_nodelay().
Ruslan Ermilov <ru@nginx.com>
parents:
6975
diff
changeset
|
334 ngx_stream_finalize_session(s, NGX_STREAM_INTERNAL_SERVER_ERROR); |
ed1101bbf19f
Introduced ngx_tcp_nodelay().
Ruslan Ermilov <ru@nginx.com>
parents:
6975
diff
changeset
|
335 return NGX_OK; |
6693 | 336 } |
337 | |
338 cscf->handler(s); | |
339 | |
340 return NGX_OK; | |
341 } | |
342 | |
343 | |
6607
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
344 static ngx_int_t |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
345 ngx_stream_core_preconfiguration(ngx_conf_t *cf) |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
346 { |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
347 return ngx_stream_variables_add_core_vars(cf); |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
348 } |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
349 |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
350 |
6115 | 351 static void * |
352 ngx_stream_core_create_main_conf(ngx_conf_t *cf) | |
353 { | |
354 ngx_stream_core_main_conf_t *cmcf; | |
355 | |
356 cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_stream_core_main_conf_t)); | |
357 if (cmcf == NULL) { | |
358 return NULL; | |
359 } | |
360 | |
361 if (ngx_array_init(&cmcf->servers, cf->pool, 4, | |
362 sizeof(ngx_stream_core_srv_conf_t *)) | |
363 != NGX_OK) | |
364 { | |
365 return NULL; | |
366 } | |
367 | |
368 if (ngx_array_init(&cmcf->listen, cf->pool, 4, sizeof(ngx_stream_listen_t)) | |
369 != NGX_OK) | |
370 { | |
371 return NULL; | |
372 } | |
373 | |
6607
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
374 cmcf->variables_hash_max_size = NGX_CONF_UNSET_UINT; |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
375 cmcf->variables_hash_bucket_size = NGX_CONF_UNSET_UINT; |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
376 |
6115 | 377 return cmcf; |
378 } | |
379 | |
380 | |
6607
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
381 static char * |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
382 ngx_stream_core_init_main_conf(ngx_conf_t *cf, void *conf) |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
383 { |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
384 ngx_stream_core_main_conf_t *cmcf = conf; |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
385 |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
386 ngx_conf_init_uint_value(cmcf->variables_hash_max_size, 1024); |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
387 ngx_conf_init_uint_value(cmcf->variables_hash_bucket_size, 64); |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
388 |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
389 cmcf->variables_hash_bucket_size = |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
390 ngx_align(cmcf->variables_hash_bucket_size, ngx_cacheline_size); |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
391 |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
392 if (cmcf->ncaptures) { |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
393 cmcf->ncaptures = (cmcf->ncaptures + 1) * 3; |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
394 } |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
395 |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
396 return NGX_CONF_OK; |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
397 } |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
398 |
c70b7f4537e1
Stream: variables and script.
Vladimir Homutov <vl@nginx.com>
parents:
6606
diff
changeset
|
399 |
6115 | 400 static void * |
401 ngx_stream_core_create_srv_conf(ngx_conf_t *cf) | |
402 { | |
403 ngx_stream_core_srv_conf_t *cscf; | |
404 | |
405 cscf = ngx_pcalloc(cf->pool, sizeof(ngx_stream_core_srv_conf_t)); | |
406 if (cscf == NULL) { | |
407 return NULL; | |
408 } | |
409 | |
410 /* | |
411 * set by ngx_pcalloc(): | |
412 * | |
413 * cscf->handler = NULL; | |
414 * cscf->error_log = NULL; | |
415 */ | |
416 | |
417 cscf->file_name = cf->conf_file->file.name.data; | |
418 cscf->line = cf->conf_file->line; | |
6618 | 419 cscf->resolver_timeout = NGX_CONF_UNSET_MSEC; |
6680
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
420 cscf->proxy_protocol_timeout = NGX_CONF_UNSET_MSEC; |
6221
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6174
diff
changeset
|
421 cscf->tcp_nodelay = NGX_CONF_UNSET; |
6694 | 422 cscf->preread_buffer_size = NGX_CONF_UNSET_SIZE; |
423 cscf->preread_timeout = NGX_CONF_UNSET_MSEC; | |
6115 | 424 |
425 return cscf; | |
426 } | |
427 | |
428 | |
429 static char * | |
430 ngx_stream_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) | |
431 { | |
432 ngx_stream_core_srv_conf_t *prev = parent; | |
433 ngx_stream_core_srv_conf_t *conf = child; | |
434 | |
6618 | 435 ngx_conf_merge_msec_value(conf->resolver_timeout, |
436 prev->resolver_timeout, 30000); | |
437 | |
438 if (conf->resolver == NULL) { | |
439 | |
440 if (prev->resolver == NULL) { | |
441 | |
442 /* | |
443 * create dummy resolver in stream {} context | |
444 * to inherit it in all servers | |
445 */ | |
446 | |
447 prev->resolver = ngx_resolver_create(cf, NULL, 0); | |
448 if (prev->resolver == NULL) { | |
449 return NGX_CONF_ERROR; | |
450 } | |
451 } | |
452 | |
453 conf->resolver = prev->resolver; | |
454 } | |
455 | |
6115 | 456 if (conf->handler == NULL) { |
457 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | |
458 "no handler for server in %s:%ui", | |
459 conf->file_name, conf->line); | |
460 return NGX_CONF_ERROR; | |
461 } | |
462 | |
463 if (conf->error_log == NULL) { | |
464 if (prev->error_log) { | |
465 conf->error_log = prev->error_log; | |
466 } else { | |
467 conf->error_log = &cf->cycle->new_log; | |
468 } | |
469 } | |
470 | |
6680
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
471 ngx_conf_merge_msec_value(conf->proxy_protocol_timeout, |
6685
4a16fceea03b
Stream: increase default value for proxy_protocol_timeout to 30s.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6680
diff
changeset
|
472 prev->proxy_protocol_timeout, 30000); |
6680
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
473 |
6221
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6174
diff
changeset
|
474 ngx_conf_merge_value(conf->tcp_nodelay, prev->tcp_nodelay, 1); |
7565e056fad6
Stream: the "tcp_nodelay" directive.
Vladimir Homutov <vl@nginx.com>
parents:
6174
diff
changeset
|
475 |
6694 | 476 ngx_conf_merge_size_value(conf->preread_buffer_size, |
477 prev->preread_buffer_size, 16384); | |
478 | |
479 ngx_conf_merge_msec_value(conf->preread_timeout, | |
480 prev->preread_timeout, 30000); | |
481 | |
6115 | 482 return NGX_CONF_OK; |
483 } | |
484 | |
485 | |
486 static char * | |
487 ngx_stream_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
488 { | |
489 ngx_stream_core_srv_conf_t *cscf = conf; | |
490 | |
491 return ngx_log_set_log(cf, &cscf->error_log); | |
492 } | |
493 | |
494 | |
495 static char * | |
496 ngx_stream_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
497 { | |
498 char *rv; | |
499 void *mconf; | |
500 ngx_uint_t m; | |
501 ngx_conf_t pcf; | |
502 ngx_stream_module_t *module; | |
503 ngx_stream_conf_ctx_t *ctx, *stream_ctx; | |
504 ngx_stream_core_srv_conf_t *cscf, **cscfp; | |
505 ngx_stream_core_main_conf_t *cmcf; | |
506 | |
507 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_stream_conf_ctx_t)); | |
508 if (ctx == NULL) { | |
509 return NGX_CONF_ERROR; | |
510 } | |
511 | |
512 stream_ctx = cf->ctx; | |
513 ctx->main_conf = stream_ctx->main_conf; | |
514 | |
515 /* the server{}'s srv_conf */ | |
516 | |
517 ctx->srv_conf = ngx_pcalloc(cf->pool, | |
518 sizeof(void *) * ngx_stream_max_module); | |
519 if (ctx->srv_conf == NULL) { | |
520 return NGX_CONF_ERROR; | |
521 } | |
522 | |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6230
diff
changeset
|
523 for (m = 0; cf->cycle->modules[m]; m++) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6230
diff
changeset
|
524 if (cf->cycle->modules[m]->type != NGX_STREAM_MODULE) { |
6115 | 525 continue; |
526 } | |
527 | |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6230
diff
changeset
|
528 module = cf->cycle->modules[m]->ctx; |
6115 | 529 |
530 if (module->create_srv_conf) { | |
531 mconf = module->create_srv_conf(cf); | |
532 if (mconf == NULL) { | |
533 return NGX_CONF_ERROR; | |
534 } | |
535 | |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6230
diff
changeset
|
536 ctx->srv_conf[cf->cycle->modules[m]->ctx_index] = mconf; |
6115 | 537 } |
538 } | |
539 | |
540 /* the server configuration context */ | |
541 | |
542 cscf = ctx->srv_conf[ngx_stream_core_module.ctx_index]; | |
543 cscf->ctx = ctx; | |
544 | |
545 cmcf = ctx->main_conf[ngx_stream_core_module.ctx_index]; | |
546 | |
547 cscfp = ngx_array_push(&cmcf->servers); | |
548 if (cscfp == NULL) { | |
549 return NGX_CONF_ERROR; | |
550 } | |
551 | |
552 *cscfp = cscf; | |
553 | |
554 | |
555 /* parse inside server{} */ | |
556 | |
557 pcf = *cf; | |
558 cf->ctx = ctx; | |
559 cf->cmd_type = NGX_STREAM_SRV_CONF; | |
560 | |
561 rv = ngx_conf_parse(cf, NULL); | |
562 | |
563 *cf = pcf; | |
564 | |
6657
3d5202c71f94
Ensure "listen" exists in a mail or stream server (ticket #1049).
Roman Arutyunyan <arut@nginx.com>
parents:
6618
diff
changeset
|
565 if (rv == NGX_CONF_OK && !cscf->listen) { |
3d5202c71f94
Ensure "listen" exists in a mail or stream server (ticket #1049).
Roman Arutyunyan <arut@nginx.com>
parents:
6618
diff
changeset
|
566 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, |
3d5202c71f94
Ensure "listen" exists in a mail or stream server (ticket #1049).
Roman Arutyunyan <arut@nginx.com>
parents:
6618
diff
changeset
|
567 "no \"listen\" is defined for server in %s:%ui", |
3d5202c71f94
Ensure "listen" exists in a mail or stream server (ticket #1049).
Roman Arutyunyan <arut@nginx.com>
parents:
6618
diff
changeset
|
568 cscf->file_name, cscf->line); |
3d5202c71f94
Ensure "listen" exists in a mail or stream server (ticket #1049).
Roman Arutyunyan <arut@nginx.com>
parents:
6618
diff
changeset
|
569 return NGX_CONF_ERROR; |
3d5202c71f94
Ensure "listen" exists in a mail or stream server (ticket #1049).
Roman Arutyunyan <arut@nginx.com>
parents:
6618
diff
changeset
|
570 } |
3d5202c71f94
Ensure "listen" exists in a mail or stream server (ticket #1049).
Roman Arutyunyan <arut@nginx.com>
parents:
6618
diff
changeset
|
571 |
6115 | 572 return rv; |
573 } | |
574 | |
575 | |
576 static char * | |
577 ngx_stream_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
578 { | |
6657
3d5202c71f94
Ensure "listen" exists in a mail or stream server (ticket #1049).
Roman Arutyunyan <arut@nginx.com>
parents:
6618
diff
changeset
|
579 ngx_stream_core_srv_conf_t *cscf = conf; |
3d5202c71f94
Ensure "listen" exists in a mail or stream server (ticket #1049).
Roman Arutyunyan <arut@nginx.com>
parents:
6618
diff
changeset
|
580 |
6975
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
581 ngx_str_t *value, size; |
6115 | 582 ngx_url_t u; |
7478
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
583 ngx_uint_t i, n, backlog; |
6558
68854ce64ec7
Stream: fixed duplicate listen address detection.
Ruslan Ermilov <ru@nginx.com>
parents:
6557
diff
changeset
|
584 ngx_stream_listen_t *ls, *als; |
6115 | 585 ngx_stream_core_main_conf_t *cmcf; |
586 | |
6657
3d5202c71f94
Ensure "listen" exists in a mail or stream server (ticket #1049).
Roman Arutyunyan <arut@nginx.com>
parents:
6618
diff
changeset
|
587 cscf->listen = 1; |
3d5202c71f94
Ensure "listen" exists in a mail or stream server (ticket #1049).
Roman Arutyunyan <arut@nginx.com>
parents:
6618
diff
changeset
|
588 |
6115 | 589 value = cf->args->elts; |
590 | |
591 ngx_memzero(&u, sizeof(ngx_url_t)); | |
592 | |
593 u.url = value[1]; | |
594 u.listen = 1; | |
595 | |
596 if (ngx_parse_url(cf->pool, &u) != NGX_OK) { | |
597 if (u.err) { | |
598 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
599 "%s in \"%V\" of the \"listen\" directive", | |
600 u.err, &u.url); | |
601 } | |
602 | |
603 return NGX_CONF_ERROR; | |
604 } | |
605 | |
606 cmcf = ngx_stream_conf_get_module_main_conf(cf, ngx_stream_core_module); | |
607 | |
7478
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
608 ls = ngx_array_push_n(&cmcf->listen, u.naddrs); |
6115 | 609 if (ls == NULL) { |
610 return NGX_CONF_ERROR; | |
611 } | |
612 | |
613 ngx_memzero(ls, sizeof(ngx_stream_listen_t)); | |
614 | |
6172 | 615 ls->backlog = NGX_LISTEN_BACKLOG; |
6975
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
616 ls->rcvbuf = -1; |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
617 ls->sndbuf = -1; |
6436 | 618 ls->type = SOCK_STREAM; |
6115 | 619 ls->ctx = cf->ctx; |
620 | |
6719
cebf5fed00bf
Modules compatibility: removed unneeded IPV6_V6ONLY checks.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6694
diff
changeset
|
621 #if (NGX_HAVE_INET6) |
6115 | 622 ls->ipv6only = 1; |
623 #endif | |
624 | |
6436 | 625 backlog = 0; |
626 | |
6115 | 627 for (i = 2; i < cf->args->nelts; i++) { |
628 | |
6436 | 629 #if !(NGX_WIN32) |
630 if (ngx_strcmp(value[i].data, "udp") == 0) { | |
631 ls->type = SOCK_DGRAM; | |
632 continue; | |
633 } | |
634 #endif | |
635 | |
6115 | 636 if (ngx_strcmp(value[i].data, "bind") == 0) { |
637 ls->bind = 1; | |
638 continue; | |
639 } | |
640 | |
6172 | 641 if (ngx_strncmp(value[i].data, "backlog=", 8) == 0) { |
642 ls->backlog = ngx_atoi(value[i].data + 8, value[i].len - 8); | |
643 ls->bind = 1; | |
644 | |
645 if (ls->backlog == NGX_ERROR || ls->backlog == 0) { | |
646 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
647 "invalid backlog \"%V\"", &value[i]); | |
648 return NGX_CONF_ERROR; | |
649 } | |
650 | |
6436 | 651 backlog = 1; |
652 | |
6172 | 653 continue; |
654 } | |
655 | |
6975
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
656 if (ngx_strncmp(value[i].data, "rcvbuf=", 7) == 0) { |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
657 size.len = value[i].len - 7; |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
658 size.data = value[i].data + 7; |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
659 |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
660 ls->rcvbuf = ngx_parse_size(&size); |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
661 ls->bind = 1; |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
662 |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
663 if (ls->rcvbuf == NGX_ERROR) { |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
664 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
665 "invalid rcvbuf \"%V\"", &value[i]); |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
666 return NGX_CONF_ERROR; |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
667 } |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
668 |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
669 continue; |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
670 } |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
671 |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
672 if (ngx_strncmp(value[i].data, "sndbuf=", 7) == 0) { |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
673 size.len = value[i].len - 7; |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
674 size.data = value[i].data + 7; |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
675 |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
676 ls->sndbuf = ngx_parse_size(&size); |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
677 ls->bind = 1; |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
678 |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
679 if (ls->sndbuf == NGX_ERROR) { |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
680 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
681 "invalid sndbuf \"%V\"", &value[i]); |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
682 return NGX_CONF_ERROR; |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
683 } |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
684 |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
685 continue; |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
686 } |
d7ce41bdf050
Stream: configurable socket buffer sizes.
Vladimir Homutov <vl@nginx.com>
parents:
6719
diff
changeset
|
687 |
6115 | 688 if (ngx_strncmp(value[i].data, "ipv6only=o", 10) == 0) { |
689 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) | |
7478
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
690 if (ngx_strcmp(&value[i].data[10], "n") == 0) { |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
691 ls->ipv6only = 1; |
6115 | 692 |
7478
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
693 } else if (ngx_strcmp(&value[i].data[10], "ff") == 0) { |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
694 ls->ipv6only = 0; |
6115 | 695 |
696 } else { | |
697 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
7478
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
698 "invalid ipv6only flags \"%s\"", |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
699 &value[i].data[9]); |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
700 return NGX_CONF_ERROR; |
6115 | 701 } |
702 | |
7478
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
703 ls->bind = 1; |
6115 | 704 continue; |
705 #else | |
706 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
707 "bind ipv6only is not supported " | |
708 "on this platform"); | |
709 return NGX_CONF_ERROR; | |
710 #endif | |
711 } | |
712 | |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6115
diff
changeset
|
713 if (ngx_strcmp(value[i].data, "reuseport") == 0) { |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6115
diff
changeset
|
714 #if (NGX_HAVE_REUSEPORT) |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6115
diff
changeset
|
715 ls->reuseport = 1; |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6115
diff
changeset
|
716 ls->bind = 1; |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6115
diff
changeset
|
717 #else |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6115
diff
changeset
|
718 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6115
diff
changeset
|
719 "reuseport is not supported " |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6115
diff
changeset
|
720 "on this platform, ignored"); |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6115
diff
changeset
|
721 #endif |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6115
diff
changeset
|
722 continue; |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6115
diff
changeset
|
723 } |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6115
diff
changeset
|
724 |
6115 | 725 if (ngx_strcmp(value[i].data, "ssl") == 0) { |
726 #if (NGX_STREAM_SSL) | |
7269
7f955d3b9a0d
SSL: detect "listen ... ssl" without certificates (ticket #178).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
727 ngx_stream_ssl_conf_t *sslcf; |
7f955d3b9a0d
SSL: detect "listen ... ssl" without certificates (ticket #178).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
728 |
7f955d3b9a0d
SSL: detect "listen ... ssl" without certificates (ticket #178).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
729 sslcf = ngx_stream_conf_get_module_srv_conf(cf, |
7f955d3b9a0d
SSL: detect "listen ... ssl" without certificates (ticket #178).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
730 ngx_stream_ssl_module); |
7f955d3b9a0d
SSL: detect "listen ... ssl" without certificates (ticket #178).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
731 |
7f955d3b9a0d
SSL: detect "listen ... ssl" without certificates (ticket #178).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
732 sslcf->listen = 1; |
7f955d3b9a0d
SSL: detect "listen ... ssl" without certificates (ticket #178).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
733 sslcf->file = cf->conf_file->file.name.data; |
7f955d3b9a0d
SSL: detect "listen ... ssl" without certificates (ticket #178).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
734 sslcf->line = cf->conf_file->line; |
7f955d3b9a0d
SSL: detect "listen ... ssl" without certificates (ticket #178).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
735 |
6115 | 736 ls->ssl = 1; |
7269
7f955d3b9a0d
SSL: detect "listen ... ssl" without certificates (ticket #178).
Maxim Dounin <mdounin@mdounin.ru>
parents:
7007
diff
changeset
|
737 |
6115 | 738 continue; |
739 #else | |
740 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
741 "the \"ssl\" parameter requires " | |
742 "ngx_stream_ssl_module"); | |
743 return NGX_CONF_ERROR; | |
744 #endif | |
745 } | |
746 | |
8482
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
747 if (ngx_strcmp(value[i].data, "quic") == 0) { |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
748 #if (NGX_STREAM_QUIC) |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
749 ngx_stream_ssl_conf_t *sslcf; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
750 |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
751 sslcf = ngx_stream_conf_get_module_srv_conf(cf, |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
752 ngx_stream_ssl_module); |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
753 |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
754 sslcf->listen = 1; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
755 sslcf->file = cf->conf_file->file.name.data; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
756 sslcf->line = cf->conf_file->line; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
757 |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
758 ls->quic = 1; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
759 ls->type = SOCK_DGRAM; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
760 |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
761 continue; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
762 #else |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
763 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
764 "the \"quic\" parameter requires " |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
765 "ngx_stream_quic_module"); |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
766 return NGX_CONF_ERROR; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
767 #endif |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
768 } |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
769 |
6115 | 770 if (ngx_strncmp(value[i].data, "so_keepalive=", 13) == 0) { |
771 | |
772 if (ngx_strcmp(&value[i].data[13], "on") == 0) { | |
773 ls->so_keepalive = 1; | |
774 | |
775 } else if (ngx_strcmp(&value[i].data[13], "off") == 0) { | |
776 ls->so_keepalive = 2; | |
777 | |
778 } else { | |
779 | |
780 #if (NGX_HAVE_KEEPALIVE_TUNABLE) | |
781 u_char *p, *end; | |
782 ngx_str_t s; | |
783 | |
784 end = value[i].data + value[i].len; | |
785 s.data = value[i].data + 13; | |
786 | |
787 p = ngx_strlchr(s.data, end, ':'); | |
788 if (p == NULL) { | |
789 p = end; | |
790 } | |
791 | |
792 if (p > s.data) { | |
793 s.len = p - s.data; | |
794 | |
795 ls->tcp_keepidle = ngx_parse_time(&s, 1); | |
796 if (ls->tcp_keepidle == (time_t) NGX_ERROR) { | |
797 goto invalid_so_keepalive; | |
798 } | |
799 } | |
800 | |
801 s.data = (p < end) ? (p + 1) : end; | |
802 | |
803 p = ngx_strlchr(s.data, end, ':'); | |
804 if (p == NULL) { | |
805 p = end; | |
806 } | |
807 | |
808 if (p > s.data) { | |
809 s.len = p - s.data; | |
810 | |
811 ls->tcp_keepintvl = ngx_parse_time(&s, 1); | |
812 if (ls->tcp_keepintvl == (time_t) NGX_ERROR) { | |
813 goto invalid_so_keepalive; | |
814 } | |
815 } | |
816 | |
817 s.data = (p < end) ? (p + 1) : end; | |
818 | |
819 if (s.data < end) { | |
820 s.len = end - s.data; | |
821 | |
822 ls->tcp_keepcnt = ngx_atoi(s.data, s.len); | |
823 if (ls->tcp_keepcnt == NGX_ERROR) { | |
824 goto invalid_so_keepalive; | |
825 } | |
826 } | |
827 | |
828 if (ls->tcp_keepidle == 0 && ls->tcp_keepintvl == 0 | |
829 && ls->tcp_keepcnt == 0) | |
830 { | |
831 goto invalid_so_keepalive; | |
832 } | |
833 | |
834 ls->so_keepalive = 1; | |
835 | |
836 #else | |
837 | |
838 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
839 "the \"so_keepalive\" parameter accepts " | |
840 "only \"on\" or \"off\" on this platform"); | |
841 return NGX_CONF_ERROR; | |
842 | |
843 #endif | |
844 } | |
845 | |
846 ls->bind = 1; | |
847 | |
848 continue; | |
849 | |
850 #if (NGX_HAVE_KEEPALIVE_TUNABLE) | |
851 invalid_so_keepalive: | |
852 | |
853 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
854 "invalid so_keepalive value: \"%s\"", | |
855 &value[i].data[13]); | |
856 return NGX_CONF_ERROR; | |
857 #endif | |
858 } | |
859 | |
6680
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
860 if (ngx_strcmp(value[i].data, "proxy_protocol") == 0) { |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
861 ls->proxy_protocol = 1; |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
862 continue; |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
863 } |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
864 |
6115 | 865 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
866 "the invalid \"%V\" parameter", &value[i]); | |
867 return NGX_CONF_ERROR; | |
868 } | |
869 | |
6436 | 870 if (ls->type == SOCK_DGRAM) { |
871 if (backlog) { | |
872 return "\"backlog\" parameter is incompatible with \"udp\""; | |
873 } | |
874 | |
875 #if (NGX_STREAM_SSL) | |
876 if (ls->ssl) { | |
877 return "\"ssl\" parameter is incompatible with \"udp\""; | |
878 } | |
879 #endif | |
880 | |
8482
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
881 #if (NGX_STREAM_SSL && NGX_STREAM_QUIC) |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
882 if (ls->ssl && ls->quic) { |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
883 return "\"ssl\" parameter is incompatible with \"quic\""; |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
884 } |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
885 #endif |
893b3313f53c
QUIC: added "quic" listen parameter in Stream.
Roman Arutyunyan <arut@nginx.com>
parents:
7478
diff
changeset
|
886 |
6436 | 887 if (ls->so_keepalive) { |
888 return "\"so_keepalive\" parameter is incompatible with \"udp\""; | |
889 } | |
6680
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
890 |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
891 if (ls->proxy_protocol) { |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
892 return "\"proxy_protocol\" parameter is incompatible with \"udp\""; |
7357abd1fa8c
Stream: the "proxy_protocol" parameter of the "listen" directive.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6657
diff
changeset
|
893 } |
6436 | 894 } |
895 | |
6558
68854ce64ec7
Stream: fixed duplicate listen address detection.
Ruslan Ermilov <ru@nginx.com>
parents:
6557
diff
changeset
|
896 als = cmcf->listen.elts; |
68854ce64ec7
Stream: fixed duplicate listen address detection.
Ruslan Ermilov <ru@nginx.com>
parents:
6557
diff
changeset
|
897 |
7478
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
898 for (n = 0; n < u.naddrs; n++) { |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
899 ls[n] = ls[0]; |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
900 |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
901 ls[n].sockaddr = u.addrs[n].sockaddr; |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
902 ls[n].socklen = u.addrs[n].socklen; |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
903 ls[n].addr_text = u.addrs[n].name; |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
904 ls[n].wildcard = ngx_inet_wildcard(ls[n].sockaddr); |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
905 |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
906 for (i = 0; i < cmcf->listen.nelts - u.naddrs + n; i++) { |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
907 if (ls[n].type != als[i].type) { |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
908 continue; |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
909 } |
6558
68854ce64ec7
Stream: fixed duplicate listen address detection.
Ruslan Ermilov <ru@nginx.com>
parents:
6557
diff
changeset
|
910 |
7478
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
911 if (ngx_cmp_sockaddr(als[i].sockaddr, als[i].socklen, |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
912 ls[n].sockaddr, ls[n].socklen, 1) |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
913 != NGX_OK) |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
914 { |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
915 continue; |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
916 } |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
917 |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
918 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
919 "duplicate \"%V\" address and port pair", |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
920 &ls[n].addr_text); |
4f9b72a229c1
Multiple addresses in "listen".
Roman Arutyunyan <arut@nginx.com>
parents:
7345
diff
changeset
|
921 return NGX_CONF_ERROR; |
6558
68854ce64ec7
Stream: fixed duplicate listen address detection.
Ruslan Ermilov <ru@nginx.com>
parents:
6557
diff
changeset
|
922 } |
68854ce64ec7
Stream: fixed duplicate listen address detection.
Ruslan Ermilov <ru@nginx.com>
parents:
6557
diff
changeset
|
923 } |
68854ce64ec7
Stream: fixed duplicate listen address detection.
Ruslan Ermilov <ru@nginx.com>
parents:
6557
diff
changeset
|
924 |
6115 | 925 return NGX_CONF_OK; |
926 } | |
6618 | 927 |
928 | |
929 static char * | |
930 ngx_stream_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
931 { | |
932 ngx_stream_core_srv_conf_t *cscf = conf; | |
933 | |
934 ngx_str_t *value; | |
935 | |
936 if (cscf->resolver) { | |
937 return "is duplicate"; | |
938 } | |
939 | |
940 value = cf->args->elts; | |
941 | |
942 cscf->resolver = ngx_resolver_create(cf, &value[1], cf->args->nelts - 1); | |
943 if (cscf->resolver == NULL) { | |
944 return NGX_CONF_ERROR; | |
945 } | |
946 | |
947 return NGX_CONF_OK; | |
948 } |