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