Mercurial > hg > nginx-quic
annotate src/mail/ngx_mail_core_module.c @ 1672:bc93d5ab3e27
fix comment
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 30 Nov 2007 22:06:48 +0000 |
parents | fe11e2a3946d |
children | 057d362ee50e |
rev | line source |
---|---|
521 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 #include <ngx_event.h> | |
1136 | 10 #include <ngx_mail.h> |
521 | 11 |
12 | |
1136 | 13 static void *ngx_mail_core_create_main_conf(ngx_conf_t *cf); |
14 static void *ngx_mail_core_create_srv_conf(ngx_conf_t *cf); | |
15 static char *ngx_mail_core_merge_srv_conf(ngx_conf_t *cf, void *parent, | |
521 | 16 void *child); |
1136 | 17 static char *ngx_mail_core_server(ngx_conf_t *cf, ngx_command_t *cmd, |
521 | 18 void *conf); |
1136 | 19 static char *ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, |
521 | 20 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
|
21 static char *ngx_mail_core_protocol(ngx_conf_t *cf, ngx_command_t *cmd, |
527 | 22 void *conf); |
521 | 23 |
24 | |
1136 | 25 static ngx_command_t ngx_mail_core_commands[] = { |
521 | 26 |
27 { ngx_string("server"), | |
1136 | 28 NGX_MAIL_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, |
29 ngx_mail_core_server, | |
521 | 30 0, |
31 0, | |
32 NULL }, | |
33 | |
34 { ngx_string("listen"), | |
1136 | 35 NGX_MAIL_SRV_CONF|NGX_CONF_TAKE12, |
36 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
|
37 NGX_MAIL_SRV_CONF_OFFSET, |
521 | 38 0, |
39 NULL }, | |
40 | |
41 { ngx_string("protocol"), | |
1136 | 42 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
|
43 ngx_mail_core_protocol, |
1136 | 44 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
|
45 0, |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1323
diff
changeset
|
46 NULL }, |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1323
diff
changeset
|
47 |
587 | 48 { ngx_string("so_keepalive"), |
1136 | 49 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_FLAG, |
587 | 50 ngx_conf_set_flag_slot, |
1136 | 51 NGX_MAIL_SRV_CONF_OFFSET, |
52 offsetof(ngx_mail_core_srv_conf_t, so_keepalive), | |
587 | 53 NULL }, |
54 | |
521 | 55 { ngx_string("timeout"), |
1136 | 56 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1, |
521 | 57 ngx_conf_set_msec_slot, |
1136 | 58 NGX_MAIL_SRV_CONF_OFFSET, |
59 offsetof(ngx_mail_core_srv_conf_t, timeout), | |
521 | 60 NULL }, |
61 | |
800 | 62 { ngx_string("server_name"), |
1136 | 63 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1, |
800 | 64 ngx_conf_set_str_slot, |
1136 | 65 NGX_MAIL_SRV_CONF_OFFSET, |
66 offsetof(ngx_mail_core_srv_conf_t, server_name), | |
800 | 67 NULL }, |
68 | |
521 | 69 ngx_null_command |
70 }; | |
71 | |
72 | |
1136 | 73 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
|
74 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
|
75 |
1136 | 76 ngx_mail_core_create_main_conf, /* create main configuration */ |
521 | 77 NULL, /* init main configuration */ |
78 | |
1136 | 79 ngx_mail_core_create_srv_conf, /* create server configuration */ |
80 ngx_mail_core_merge_srv_conf /* merge server configuration */ | |
521 | 81 }; |
82 | |
83 | |
1136 | 84 ngx_module_t ngx_mail_core_module = { |
521 | 85 NGX_MODULE_V1, |
1136 | 86 &ngx_mail_core_module_ctx, /* module context */ |
87 ngx_mail_core_commands, /* module directives */ | |
88 NGX_MAIL_MODULE, /* module type */ | |
541 | 89 NULL, /* init master */ |
521 | 90 NULL, /* init module */ |
541 | 91 NULL, /* init process */ |
92 NULL, /* init thread */ | |
93 NULL, /* exit thread */ | |
94 NULL, /* exit process */ | |
95 NULL, /* exit master */ | |
96 NGX_MODULE_V1_PADDING | |
521 | 97 }; |
98 | |
99 | |
100 static void * | |
1136 | 101 ngx_mail_core_create_main_conf(ngx_conf_t *cf) |
577 | 102 { |
1136 | 103 ngx_mail_core_main_conf_t *cmcf; |
521 | 104 |
1136 | 105 cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_core_main_conf_t)); |
521 | 106 if (cmcf == NULL) { |
107 return NGX_CONF_ERROR; | |
108 } | |
109 | |
110 if (ngx_array_init(&cmcf->servers, cf->pool, 4, | |
1136 | 111 sizeof(ngx_mail_core_srv_conf_t *)) |
641 | 112 != NGX_OK) |
113 { | |
114 return NGX_CONF_ERROR; | |
115 } | |
116 | |
1136 | 117 if (ngx_array_init(&cmcf->listen, cf->pool, 4, sizeof(ngx_mail_listen_t)) |
641 | 118 != NGX_OK) |
521 | 119 { |
120 return NGX_CONF_ERROR; | |
121 } | |
122 | |
123 return cmcf; | |
124 } | |
125 | |
126 | |
127 static void * | |
1136 | 128 ngx_mail_core_create_srv_conf(ngx_conf_t *cf) |
577 | 129 { |
1136 | 130 ngx_mail_core_srv_conf_t *cscf; |
577 | 131 |
1136 | 132 cscf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_core_srv_conf_t)); |
521 | 133 if (cscf == NULL) { |
527 | 134 return NULL; |
521 | 135 } |
136 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
137 /* |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
138 * 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
|
139 * |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
140 * 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
|
141 */ |
521 | 142 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
143 cscf->timeout = NGX_CONF_UNSET_MSEC; |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
144 cscf->so_keepalive = NGX_CONF_UNSET; |
1136 | 145 |
521 | 146 return cscf; |
147 } | |
148 | |
149 | |
150 static char * | |
1136 | 151 ngx_mail_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) |
521 | 152 { |
1136 | 153 ngx_mail_core_srv_conf_t *prev = parent; |
154 ngx_mail_core_srv_conf_t *conf = child; | |
521 | 155 |
156 ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000); | |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1323
diff
changeset
|
157 |
587 | 158 ngx_conf_merge_value(conf->so_keepalive, prev->so_keepalive, 0); |
521 | 159 |
800 | 160 |
161 ngx_conf_merge_str_value(conf->server_name, prev->server_name, ""); | |
162 | |
163 if (conf->server_name.len == 0) { | |
164 conf->server_name.data = ngx_palloc(cf->pool, NGX_MAXHOSTNAMELEN); | |
165 if (conf->server_name.data == NULL) { | |
166 return NGX_CONF_ERROR; | |
167 } | |
168 | |
169 if (gethostname((char *) conf->server_name.data, NGX_MAXHOSTNAMELEN) | |
170 == -1) | |
171 { | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
172 ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno, |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
173 "gethostname() failed"); |
800 | 174 return NGX_CONF_ERROR; |
175 } | |
176 | |
177 conf->server_name.len = ngx_strlen(conf->server_name.data); | |
178 } | |
179 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
180 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
|
181 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
|
182 "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
|
183 conf->file_name, conf->line); |
583 | 184 return NGX_CONF_ERROR; |
185 } | |
186 | |
521 | 187 return NGX_CONF_OK; |
188 } | |
189 | |
190 | |
191 static char * | |
1136 | 192 ngx_mail_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
521 | 193 { |
194 char *rv; | |
195 void *mconf; | |
196 ngx_uint_t m; | |
197 ngx_conf_t pcf; | |
1136 | 198 ngx_mail_module_t *module; |
199 ngx_mail_conf_ctx_t *ctx, *mail_ctx; | |
200 ngx_mail_core_srv_conf_t *cscf, **cscfp; | |
201 ngx_mail_core_main_conf_t *cmcf; | |
521 | 202 |
1136 | 203 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_mail_conf_ctx_t)); |
521 | 204 if (ctx == NULL) { |
205 return NGX_CONF_ERROR; | |
206 } | |
207 | |
1136 | 208 mail_ctx = cf->ctx; |
209 ctx->main_conf = mail_ctx->main_conf; | |
577 | 210 |
521 | 211 /* the server{}'s srv_conf */ |
212 | |
1136 | 213 ctx->srv_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_mail_max_module); |
521 | 214 if (ctx->srv_conf == NULL) { |
215 return NGX_CONF_ERROR; | |
216 } | |
217 | |
218 for (m = 0; ngx_modules[m]; m++) { | |
1136 | 219 if (ngx_modules[m]->type != NGX_MAIL_MODULE) { |
521 | 220 continue; |
221 } | |
222 | |
223 module = ngx_modules[m]->ctx; | |
224 | |
225 if (module->create_srv_conf) { | |
226 mconf = module->create_srv_conf(cf); | |
227 if (mconf == NULL) { | |
228 return NGX_CONF_ERROR; | |
229 } | |
230 | |
231 ctx->srv_conf[ngx_modules[m]->ctx_index] = mconf; | |
232 } | |
233 } | |
234 | |
235 /* the server configuration context */ | |
236 | |
1136 | 237 cscf = ctx->srv_conf[ngx_mail_core_module.ctx_index]; |
521 | 238 cscf->ctx = ctx; |
239 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
240 cscf->file_name = cf->conf_file->file.name.data; |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
241 cscf->line = cf->conf_file->line; |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
242 |
1136 | 243 cmcf = ctx->main_conf[ngx_mail_core_module.ctx_index]; |
521 | 244 |
245 cscfp = ngx_array_push(&cmcf->servers); | |
246 if (cscfp == NULL) { | |
247 return NGX_CONF_ERROR; | |
248 } | |
249 | |
250 *cscfp = cscf; | |
251 | |
252 | |
253 /* parse inside server{} */ | |
254 | |
255 pcf = *cf; | |
256 cf->ctx = ctx; | |
1136 | 257 cf->cmd_type = NGX_MAIL_SRV_CONF; |
521 | 258 |
259 rv = ngx_conf_parse(cf, NULL); | |
260 | |
261 *cf = pcf; | |
262 | |
263 return rv; | |
264 } | |
265 | |
266 | |
267 /* AF_INET only */ | |
268 | |
269 static char * | |
1136 | 270 ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
521 | 271 { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
272 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
|
273 |
641 | 274 ngx_str_t *value; |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
275 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
|
276 ngx_uint_t i, m; |
1136 | 277 ngx_mail_listen_t *imls; |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
278 ngx_mail_module_t *module; |
1136 | 279 ngx_mail_core_main_conf_t *cmcf; |
521 | 280 |
281 value = cf->args->elts; | |
282 | |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
283 ngx_memzero(&u, sizeof(ngx_url_t)); |
521 | 284 |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
285 u.url = value[1]; |
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
286 u.listen = 1; |
619 | 287 |
1559
fe11e2a3946d
use pool instead of ngx_conf_t
Igor Sysoev <igor@sysoev.ru>
parents:
1487
diff
changeset
|
288 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
|
289 if (u.err) { |
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
290 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
|
291 "%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
|
292 u.err, &u.url); |
521 | 293 } |
294 | |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
295 return NGX_CONF_ERROR; |
521 | 296 } |
297 | |
1136 | 298 cmcf = ngx_mail_conf_get_module_main_conf(cf, ngx_mail_core_module); |
521 | 299 |
641 | 300 imls = cmcf->listen.elts; |
301 | |
302 for (i = 0; i < cmcf->listen.nelts; i++) { | |
303 | |
906 | 304 if (imls[i].addr != u.addr.in_addr || imls[i].port != u.port) { |
641 | 305 continue; |
306 } | |
307 | |
308 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
|
309 "duplicate \"%V\" address and port pair", &u.url); |
577 | 310 return NGX_CONF_ERROR; |
521 | 311 } |
312 | |
641 | 313 imls = ngx_array_push(&cmcf->listen); |
314 if (imls == NULL) { | |
315 return NGX_CONF_ERROR; | |
316 } | |
563 | 317 |
1136 | 318 ngx_memzero(imls, sizeof(ngx_mail_listen_t)); |
641 | 319 |
804
472cd9768ac2
now the "listen" directives use ngx_parse_url()
Igor Sysoev <igor@sysoev.ru>
parents:
800
diff
changeset
|
320 imls->addr = u.addr.in_addr; |
906 | 321 imls->port = u.port; |
641 | 322 imls->family = AF_INET; |
323 imls->ctx = cf->ctx; | |
521 | 324 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
325 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
|
326 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
|
327 continue; |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
328 } |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
329 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
330 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
|
331 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
332 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
|
333 continue; |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
334 } |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
335 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
336 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
|
337 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
|
338 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
|
339 break; |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
340 } |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
341 } |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
342 } |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
343 |
641 | 344 if (cf->args->nelts == 2) { |
345 return NGX_CONF_OK; | |
346 } | |
521 | 347 |
641 | 348 if (ngx_strcmp(value[2].data, "bind") == 0) { |
349 imls->bind = 1; | |
350 return NGX_CONF_OK; | |
351 } | |
521 | 352 |
641 | 353 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
354 "the invalid \"%V\" parameter", &value[2]); | |
355 return NGX_CONF_ERROR; | |
521 | 356 } |
527 | 357 |
358 | |
359 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
|
360 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
|
361 { |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
362 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
|
363 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
364 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
|
365 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
|
366 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
|
367 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
368 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
|
369 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
370 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
|
371 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
|
372 continue; |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
373 } |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
374 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
375 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
|
376 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
377 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
|
378 && 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
|
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 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
|
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 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
|
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 } |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
385 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
386 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
|
387 "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
|
388 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
|
389 } |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
390 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
391 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
392 char * |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1481
diff
changeset
|
393 ngx_mail_capabilities(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
527 | 394 { |
395 char *p = conf; | |
396 | |
397 ngx_str_t *c, *value; | |
398 ngx_uint_t i; | |
399 ngx_array_t *a; | |
400 | |
401 a = (ngx_array_t *) (p + cmd->offset); | |
402 | |
403 value = cf->args->elts; | |
404 | |
405 for (i = 1; i < cf->args->nelts; i++) { | |
406 c = ngx_array_push(a); | |
407 if (c == NULL) { | |
408 return NGX_CONF_ERROR; | |
409 } | |
410 | |
411 *c = value[i]; | |
412 } | |
413 | |
414 return NGX_CONF_OK; | |
415 } |