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