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