290
|
1
|
|
2 /*
|
|
3 * Copyright (C) Igor Sysoev
|
|
4 */
|
|
5
|
|
6
|
|
7 #include <ngx_config.h>
|
|
8 #include <ngx_core.h>
|
|
9 #include <ngx_event.h>
|
|
10 #include <ngx_mail.h>
|
|
11
|
|
12
|
|
13 static void *ngx_mail_core_create_main_conf(ngx_conf_t *cf);
|
|
14 static void *ngx_mail_core_create_srv_conf(ngx_conf_t *cf);
|
|
15 static char *ngx_mail_core_merge_srv_conf(ngx_conf_t *cf, void *parent,
|
|
16 void *child);
|
|
17 static char *ngx_mail_core_server(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
18 void *conf);
|
|
19 static char *ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
20 void *conf);
|
336
|
21 static char *ngx_mail_core_protocol(ngx_conf_t *cf, ngx_command_t *cmd,
|
290
|
22 void *conf);
|
366
|
23 static char *ngx_mail_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
24 void *conf);
|
290
|
25
|
|
26
|
654
|
27 static ngx_conf_deprecated_t ngx_conf_deprecated_so_keepalive = {
|
|
28 ngx_conf_deprecated, "so_keepalive",
|
|
29 "so_keepalive\" parameter of the \"listen"
|
|
30 };
|
|
31
|
|
32
|
290
|
33 static ngx_command_t ngx_mail_core_commands[] = {
|
|
34
|
|
35 { ngx_string("server"),
|
|
36 NGX_MAIL_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
|
|
37 ngx_mail_core_server,
|
|
38 0,
|
|
39 0,
|
|
40 NULL },
|
|
41
|
|
42 { ngx_string("listen"),
|
|
43 NGX_MAIL_SRV_CONF|NGX_CONF_TAKE12,
|
|
44 ngx_mail_core_listen,
|
336
|
45 NGX_MAIL_SRV_CONF_OFFSET,
|
290
|
46 0,
|
|
47 NULL },
|
|
48
|
|
49 { ngx_string("protocol"),
|
|
50 NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
|
336
|
51 ngx_mail_core_protocol,
|
290
|
52 NGX_MAIL_SRV_CONF_OFFSET,
|
336
|
53 0,
|
290
|
54 NULL },
|
|
55
|
|
56 { ngx_string("so_keepalive"),
|
|
57 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_FLAG,
|
|
58 ngx_conf_set_flag_slot,
|
|
59 NGX_MAIL_SRV_CONF_OFFSET,
|
|
60 offsetof(ngx_mail_core_srv_conf_t, so_keepalive),
|
654
|
61 &ngx_conf_deprecated_so_keepalive },
|
290
|
62
|
|
63 { ngx_string("timeout"),
|
|
64 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
|
|
65 ngx_conf_set_msec_slot,
|
|
66 NGX_MAIL_SRV_CONF_OFFSET,
|
|
67 offsetof(ngx_mail_core_srv_conf_t, timeout),
|
|
68 NULL },
|
|
69
|
|
70 { ngx_string("server_name"),
|
|
71 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
|
|
72 ngx_conf_set_str_slot,
|
|
73 NGX_MAIL_SRV_CONF_OFFSET,
|
|
74 offsetof(ngx_mail_core_srv_conf_t, server_name),
|
|
75 NULL },
|
|
76
|
366
|
77 { ngx_string("resolver"),
|
646
|
78 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_1MORE,
|
366
|
79 ngx_mail_core_resolver,
|
|
80 NGX_MAIL_SRV_CONF_OFFSET,
|
|
81 0,
|
|
82 NULL },
|
|
83
|
|
84 { ngx_string("resolver_timeout"),
|
|
85 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
|
|
86 ngx_conf_set_msec_slot,
|
|
87 NGX_MAIL_SRV_CONF_OFFSET,
|
|
88 offsetof(ngx_mail_core_srv_conf_t, resolver_timeout),
|
|
89 NULL },
|
|
90
|
290
|
91 ngx_null_command
|
|
92 };
|
|
93
|
|
94
|
|
95 static ngx_mail_module_t ngx_mail_core_module_ctx = {
|
336
|
96 NULL, /* protocol */
|
|
97
|
290
|
98 ngx_mail_core_create_main_conf, /* create main configuration */
|
|
99 NULL, /* init main configuration */
|
|
100
|
|
101 ngx_mail_core_create_srv_conf, /* create server configuration */
|
|
102 ngx_mail_core_merge_srv_conf /* merge server configuration */
|
|
103 };
|
|
104
|
|
105
|
|
106 ngx_module_t ngx_mail_core_module = {
|
|
107 NGX_MODULE_V1,
|
|
108 &ngx_mail_core_module_ctx, /* module context */
|
|
109 ngx_mail_core_commands, /* module directives */
|
|
110 NGX_MAIL_MODULE, /* module type */
|
|
111 NULL, /* init master */
|
|
112 NULL, /* init module */
|
|
113 NULL, /* init process */
|
|
114 NULL, /* init thread */
|
|
115 NULL, /* exit thread */
|
|
116 NULL, /* exit process */
|
|
117 NULL, /* exit master */
|
|
118 NGX_MODULE_V1_PADDING
|
|
119 };
|
|
120
|
|
121
|
|
122 static void *
|
|
123 ngx_mail_core_create_main_conf(ngx_conf_t *cf)
|
|
124 {
|
|
125 ngx_mail_core_main_conf_t *cmcf;
|
|
126
|
|
127 cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_core_main_conf_t));
|
|
128 if (cmcf == NULL) {
|
496
|
129 return NULL;
|
290
|
130 }
|
|
131
|
|
132 if (ngx_array_init(&cmcf->servers, cf->pool, 4,
|
|
133 sizeof(ngx_mail_core_srv_conf_t *))
|
|
134 != NGX_OK)
|
|
135 {
|
496
|
136 return NULL;
|
290
|
137 }
|
|
138
|
|
139 if (ngx_array_init(&cmcf->listen, cf->pool, 4, sizeof(ngx_mail_listen_t))
|
|
140 != NGX_OK)
|
|
141 {
|
496
|
142 return NULL;
|
290
|
143 }
|
|
144
|
|
145 return cmcf;
|
|
146 }
|
|
147
|
|
148
|
|
149 static void *
|
|
150 ngx_mail_core_create_srv_conf(ngx_conf_t *cf)
|
|
151 {
|
|
152 ngx_mail_core_srv_conf_t *cscf;
|
|
153
|
|
154 cscf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_core_srv_conf_t));
|
|
155 if (cscf == NULL) {
|
|
156 return NULL;
|
|
157 }
|
|
158
|
336
|
159 /*
|
|
160 * set by ngx_pcalloc():
|
|
161 *
|
|
162 * cscf->protocol = NULL;
|
|
163 */
|
|
164
|
290
|
165 cscf->timeout = NGX_CONF_UNSET_MSEC;
|
366
|
166 cscf->resolver_timeout = NGX_CONF_UNSET_MSEC;
|
290
|
167 cscf->so_keepalive = NGX_CONF_UNSET;
|
|
168
|
366
|
169 cscf->resolver = NGX_CONF_UNSET_PTR;
|
|
170
|
|
171 cscf->file_name = cf->conf_file->file.name.data;
|
|
172 cscf->line = cf->conf_file->line;
|
|
173
|
290
|
174 return cscf;
|
|
175 }
|
|
176
|
|
177
|
|
178 static char *
|
|
179 ngx_mail_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
|
|
180 {
|
|
181 ngx_mail_core_srv_conf_t *prev = parent;
|
|
182 ngx_mail_core_srv_conf_t *conf = child;
|
|
183
|
|
184 ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000);
|
366
|
185 ngx_conf_merge_msec_value(conf->resolver_timeout, prev->resolver_timeout,
|
|
186 30000);
|
290
|
187
|
336
|
188 ngx_conf_merge_value(conf->so_keepalive, prev->so_keepalive, 0);
|
290
|
189
|
|
190
|
|
191 ngx_conf_merge_str_value(conf->server_name, prev->server_name, "");
|
|
192
|
|
193 if (conf->server_name.len == 0) {
|
376
|
194 conf->server_name = cf->cycle->hostname;
|
290
|
195 }
|
|
196
|
336
|
197 if (conf->protocol == NULL) {
|
|
198 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
|
199 "unknown mail protocol for server in %s:%ui",
|
|
200 conf->file_name, conf->line);
|
290
|
201 return NGX_CONF_ERROR;
|
|
202 }
|
|
203
|
366
|
204 ngx_conf_merge_ptr_value(conf->resolver, prev->resolver, NULL);
|
|
205
|
290
|
206 return NGX_CONF_OK;
|
|
207 }
|
|
208
|
|
209
|
|
210 static char *
|
|
211 ngx_mail_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
212 {
|
|
213 char *rv;
|
|
214 void *mconf;
|
|
215 ngx_uint_t m;
|
|
216 ngx_conf_t pcf;
|
|
217 ngx_mail_module_t *module;
|
|
218 ngx_mail_conf_ctx_t *ctx, *mail_ctx;
|
|
219 ngx_mail_core_srv_conf_t *cscf, **cscfp;
|
|
220 ngx_mail_core_main_conf_t *cmcf;
|
|
221
|
|
222 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_mail_conf_ctx_t));
|
|
223 if (ctx == NULL) {
|
|
224 return NGX_CONF_ERROR;
|
|
225 }
|
|
226
|
|
227 mail_ctx = cf->ctx;
|
|
228 ctx->main_conf = mail_ctx->main_conf;
|
|
229
|
|
230 /* the server{}'s srv_conf */
|
|
231
|
|
232 ctx->srv_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_mail_max_module);
|
|
233 if (ctx->srv_conf == NULL) {
|
|
234 return NGX_CONF_ERROR;
|
|
235 }
|
|
236
|
|
237 for (m = 0; ngx_modules[m]; m++) {
|
|
238 if (ngx_modules[m]->type != NGX_MAIL_MODULE) {
|
|
239 continue;
|
|
240 }
|
|
241
|
|
242 module = ngx_modules[m]->ctx;
|
|
243
|
|
244 if (module->create_srv_conf) {
|
|
245 mconf = module->create_srv_conf(cf);
|
|
246 if (mconf == NULL) {
|
|
247 return NGX_CONF_ERROR;
|
|
248 }
|
|
249
|
|
250 ctx->srv_conf[ngx_modules[m]->ctx_index] = mconf;
|
|
251 }
|
|
252 }
|
|
253
|
|
254 /* the server configuration context */
|
|
255
|
|
256 cscf = ctx->srv_conf[ngx_mail_core_module.ctx_index];
|
|
257 cscf->ctx = ctx;
|
|
258
|
|
259 cmcf = ctx->main_conf[ngx_mail_core_module.ctx_index];
|
|
260
|
|
261 cscfp = ngx_array_push(&cmcf->servers);
|
|
262 if (cscfp == NULL) {
|
|
263 return NGX_CONF_ERROR;
|
|
264 }
|
|
265
|
|
266 *cscfp = cscf;
|
|
267
|
|
268
|
|
269 /* parse inside server{} */
|
|
270
|
|
271 pcf = *cf;
|
|
272 cf->ctx = ctx;
|
|
273 cf->cmd_type = NGX_MAIL_SRV_CONF;
|
|
274
|
|
275 rv = ngx_conf_parse(cf, NULL);
|
|
276
|
|
277 *cf = pcf;
|
|
278
|
|
279 return rv;
|
|
280 }
|
|
281
|
|
282
|
|
283 static char *
|
|
284 ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
285 {
|
336
|
286 ngx_mail_core_srv_conf_t *cscf = conf;
|
|
287
|
492
|
288 size_t len, off;
|
|
289 in_port_t port;
|
290
|
290 ngx_str_t *value;
|
|
291 ngx_url_t u;
|
336
|
292 ngx_uint_t i, m;
|
492
|
293 struct sockaddr *sa;
|
486
|
294 ngx_mail_listen_t *ls;
|
336
|
295 ngx_mail_module_t *module;
|
492
|
296 struct sockaddr_in *sin;
|
290
|
297 ngx_mail_core_main_conf_t *cmcf;
|
492
|
298 #if (NGX_HAVE_INET6)
|
|
299 struct sockaddr_in6 *sin6;
|
|
300 #endif
|
290
|
301
|
|
302 value = cf->args->elts;
|
|
303
|
|
304 ngx_memzero(&u, sizeof(ngx_url_t));
|
|
305
|
|
306 u.url = value[1];
|
|
307 u.listen = 1;
|
|
308
|
340
|
309 if (ngx_parse_url(cf->pool, &u) != NGX_OK) {
|
290
|
310 if (u.err) {
|
|
311 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
312 "%s in \"%V\" of the \"listen\" directive",
|
|
313 u.err, &u.url);
|
|
314 }
|
|
315
|
|
316 return NGX_CONF_ERROR;
|
|
317 }
|
|
318
|
|
319 cmcf = ngx_mail_conf_get_module_main_conf(cf, ngx_mail_core_module);
|
|
320
|
486
|
321 ls = cmcf->listen.elts;
|
290
|
322
|
|
323 for (i = 0; i < cmcf->listen.nelts; i++) {
|
|
324
|
492
|
325 sa = (struct sockaddr *) ls[i].sockaddr;
|
|
326
|
|
327 if (sa->sa_family != u.family) {
|
|
328 continue;
|
|
329 }
|
|
330
|
|
331 switch (sa->sa_family) {
|
|
332
|
|
333 #if (NGX_HAVE_INET6)
|
|
334 case AF_INET6:
|
|
335 off = offsetof(struct sockaddr_in6, sin6_addr);
|
|
336 len = 16;
|
|
337 sin6 = (struct sockaddr_in6 *) sa;
|
|
338 port = sin6->sin6_port;
|
|
339 break;
|
|
340 #endif
|
|
341
|
|
342 default: /* AF_INET */
|
|
343 off = offsetof(struct sockaddr_in, sin_addr);
|
|
344 len = 4;
|
|
345 sin = (struct sockaddr_in *) sa;
|
|
346 port = sin->sin_port;
|
|
347 break;
|
|
348 }
|
|
349
|
|
350 if (ngx_memcmp(ls[i].sockaddr + off, u.sockaddr + off, len) != 0) {
|
|
351 continue;
|
|
352 }
|
|
353
|
|
354 if (port != u.port) {
|
290
|
355 continue;
|
|
356 }
|
|
357
|
|
358 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
359 "duplicate \"%V\" address and port pair", &u.url);
|
|
360 return NGX_CONF_ERROR;
|
|
361 }
|
|
362
|
486
|
363 ls = ngx_array_push(&cmcf->listen);
|
|
364 if (ls == NULL) {
|
290
|
365 return NGX_CONF_ERROR;
|
|
366 }
|
|
367
|
486
|
368 ngx_memzero(ls, sizeof(ngx_mail_listen_t));
|
290
|
369
|
492
|
370 ngx_memcpy(ls->sockaddr, u.sockaddr, u.socklen);
|
|
371
|
|
372 ls->socklen = u.socklen;
|
|
373 ls->wildcard = u.wildcard;
|
486
|
374 ls->ctx = cf->ctx;
|
290
|
375
|
336
|
376 for (m = 0; ngx_modules[m]; m++) {
|
|
377 if (ngx_modules[m]->type != NGX_MAIL_MODULE) {
|
|
378 continue;
|
|
379 }
|
|
380
|
|
381 module = ngx_modules[m]->ctx;
|
|
382
|
|
383 if (module->protocol == NULL) {
|
|
384 continue;
|
|
385 }
|
|
386
|
|
387 for (i = 0; module->protocol->port[i]; i++) {
|
|
388 if (module->protocol->port[i] == u.port) {
|
|
389 cscf->protocol = module->protocol;
|
|
390 break;
|
|
391 }
|
|
392 }
|
|
393 }
|
|
394
|
404
|
395 for (i = 2; i < cf->args->nelts; i++) {
|
|
396
|
|
397 if (ngx_strcmp(value[i].data, "bind") == 0) {
|
486
|
398 ls->bind = 1;
|
404
|
399 continue;
|
|
400 }
|
|
401
|
492
|
402 if (ngx_strncmp(value[i].data, "ipv6only=o", 10) == 0) {
|
|
403 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
|
|
404 struct sockaddr *sa;
|
|
405 u_char buf[NGX_SOCKADDR_STRLEN];
|
|
406
|
|
407 sa = (struct sockaddr *) ls->sockaddr;
|
|
408
|
|
409 if (sa->sa_family == AF_INET6) {
|
|
410
|
|
411 if (ngx_strcmp(&value[i].data[10], "n") == 0) {
|
|
412 ls->ipv6only = 1;
|
|
413
|
|
414 } else if (ngx_strcmp(&value[i].data[10], "ff") == 0) {
|
|
415 ls->ipv6only = 2;
|
|
416
|
|
417 } else {
|
|
418 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
419 "invalid ipv6only flags \"%s\"",
|
|
420 &value[i].data[9]);
|
|
421 return NGX_CONF_ERROR;
|
|
422 }
|
|
423
|
|
424 ls->bind = 1;
|
|
425
|
|
426 } else {
|
|
427 len = ngx_sock_ntop(sa, buf, NGX_SOCKADDR_STRLEN, 1);
|
|
428
|
|
429 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
430 "ipv6only is not supported "
|
|
431 "on addr \"%*s\", ignored", len, buf);
|
|
432 }
|
|
433
|
|
434 continue;
|
|
435 #else
|
|
436 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
437 "bind ipv6only is not supported "
|
|
438 "on this platform");
|
|
439 return NGX_CONF_ERROR;
|
|
440 #endif
|
|
441 }
|
|
442
|
404
|
443 if (ngx_strcmp(value[i].data, "ssl") == 0) {
|
|
444 #if (NGX_MAIL_SSL)
|
486
|
445 ls->ssl = 1;
|
404
|
446 continue;
|
|
447 #else
|
|
448 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
449 "the \"ssl\" parameter requires "
|
|
450 "ngx_mail_ssl_module");
|
|
451 return NGX_CONF_ERROR;
|
|
452 #endif
|
|
453 }
|
|
454
|
654
|
455 if (ngx_strncmp(value[i].data, "so_keepalive=", 13) == 0) {
|
|
456
|
|
457 if (ngx_strcmp(&value[i].data[13], "on") == 0) {
|
|
458 ls->so_keepalive = 1;
|
|
459
|
|
460 } else if (ngx_strcmp(&value[i].data[13], "off") == 0) {
|
|
461 ls->so_keepalive = 2;
|
|
462
|
|
463 } else {
|
|
464
|
|
465 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
|
|
466 u_char *p, *end;
|
|
467 ngx_str_t s;
|
|
468
|
|
469 end = value[i].data + value[i].len;
|
|
470 s.data = value[i].data + 13;
|
|
471
|
|
472 p = ngx_strlchr(s.data, end, ':');
|
|
473 if (p == NULL) {
|
|
474 p = end;
|
|
475 }
|
|
476
|
|
477 if (p > s.data) {
|
|
478 s.len = p - s.data;
|
|
479
|
|
480 ls->tcp_keepidle = ngx_parse_time(&s, 1);
|
|
481 if (ls->tcp_keepidle == NGX_ERROR) {
|
|
482 goto invalid_so_keepalive;
|
|
483 }
|
|
484 }
|
|
485
|
|
486 s.data = (p < end) ? (p + 1) : end;
|
|
487
|
|
488 p = ngx_strlchr(s.data, end, ':');
|
|
489 if (p == NULL) {
|
|
490 p = end;
|
|
491 }
|
|
492
|
|
493 if (p > s.data) {
|
|
494 s.len = p - s.data;
|
|
495
|
|
496 ls->tcp_keepintvl = ngx_parse_time(&s, 1);
|
|
497 if (ls->tcp_keepintvl == NGX_ERROR) {
|
|
498 goto invalid_so_keepalive;
|
|
499 }
|
|
500 }
|
|
501
|
|
502 s.data = (p < end) ? (p + 1) : end;
|
|
503
|
|
504 if (s.data < end) {
|
|
505 s.len = end - s.data;
|
|
506
|
|
507 ls->tcp_keepcnt = ngx_atoi(s.data, s.len);
|
|
508 if (ls->tcp_keepcnt == NGX_ERROR) {
|
|
509 goto invalid_so_keepalive;
|
|
510 }
|
|
511 }
|
|
512
|
|
513 if (ls->tcp_keepidle == 0 && ls->tcp_keepintvl == 0
|
|
514 && ls->tcp_keepcnt == 0)
|
|
515 {
|
|
516 goto invalid_so_keepalive;
|
|
517 }
|
|
518
|
|
519 ls->so_keepalive = 1;
|
|
520
|
|
521 #else
|
|
522
|
|
523 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
524 "the \"so_keepalive\" parameter accepts "
|
|
525 "only \"on\" or \"off\" on this platform");
|
|
526 return NGX_CONF_ERROR;
|
|
527
|
|
528 #endif
|
|
529 }
|
|
530
|
|
531 ls->bind = 1;
|
|
532
|
|
533 continue;
|
|
534
|
|
535 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
|
|
536 invalid_so_keepalive:
|
|
537
|
|
538 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
539 "invalid so_keepalive value: \"%s\"",
|
|
540 &value[i].data[13]);
|
|
541 return NGX_CONF_ERROR;
|
|
542 #endif
|
|
543 }
|
|
544
|
404
|
545 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
546 "the invalid \"%V\" parameter", &value[i]);
|
|
547 return NGX_CONF_ERROR;
|
290
|
548 }
|
|
549
|
404
|
550 return NGX_CONF_OK;
|
290
|
551 }
|
|
552
|
|
553
|
|
554 static char *
|
336
|
555 ngx_mail_core_protocol(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
556 {
|
|
557 ngx_mail_core_srv_conf_t *cscf = conf;
|
|
558
|
|
559 ngx_str_t *value;
|
|
560 ngx_uint_t m;
|
|
561 ngx_mail_module_t *module;
|
|
562
|
|
563 value = cf->args->elts;
|
|
564
|
|
565 for (m = 0; ngx_modules[m]; m++) {
|
|
566 if (ngx_modules[m]->type != NGX_MAIL_MODULE) {
|
|
567 continue;
|
|
568 }
|
|
569
|
|
570 module = ngx_modules[m]->ctx;
|
|
571
|
|
572 if (module->protocol
|
|
573 && ngx_strcmp(module->protocol->name.data, value[1].data) == 0)
|
|
574 {
|
|
575 cscf->protocol = module->protocol;
|
|
576
|
|
577 return NGX_CONF_OK;
|
|
578 }
|
|
579 }
|
|
580
|
|
581 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
582 "unknown protocol \"%V\"", &value[1]);
|
|
583 return NGX_CONF_ERROR;
|
|
584 }
|
|
585
|
|
586
|
366
|
587 static char *
|
|
588 ngx_mail_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
589 {
|
|
590 ngx_mail_core_srv_conf_t *cscf = conf;
|
|
591
|
|
592 ngx_str_t *value;
|
|
593
|
|
594 value = cf->args->elts;
|
|
595
|
|
596 if (cscf->resolver != NGX_CONF_UNSET_PTR) {
|
|
597 return "is duplicate";
|
|
598 }
|
|
599
|
|
600 if (ngx_strcmp(value[1].data, "off") == 0) {
|
|
601 cscf->resolver = NULL;
|
|
602 return NGX_CONF_OK;
|
|
603 }
|
|
604
|
646
|
605 cscf->resolver = ngx_resolver_create(cf, &value[1], cf->args->nelts - 1);
|
|
606 if (cscf->resolver == NULL) {
|
366
|
607 return NGX_CONF_ERROR;
|
|
608 }
|
|
609
|
|
610 return NGX_CONF_OK;
|
|
611 }
|
|
612
|
|
613
|
336
|
614 char *
|
|
615 ngx_mail_capabilities(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
290
|
616 {
|
|
617 char *p = conf;
|
|
618
|
|
619 ngx_str_t *c, *value;
|
|
620 ngx_uint_t i;
|
|
621 ngx_array_t *a;
|
|
622
|
|
623 a = (ngx_array_t *) (p + cmd->offset);
|
|
624
|
|
625 value = cf->args->elts;
|
|
626
|
|
627 for (i = 1; i < cf->args->nelts; i++) {
|
|
628 c = ngx_array_push(a);
|
|
629 if (c == NULL) {
|
|
630 return NGX_CONF_ERROR;
|
|
631 }
|
|
632
|
|
633 *c = value[i];
|
|
634 }
|
|
635
|
|
636 return NGX_CONF_OK;
|
|
637 }
|