Mercurial > hg > nginx
comparison src/imap/ngx_imap_core_module.c @ 527:7fa11e5c6e96 release-0.1.38
nginx-0.1.38-RELEASE import
*) Feature: the "limit_rate" directive is supported in in proxy and
FastCGI mode.
*) Feature: the "X-Accel-Limit-Rate" response header line is supported
in proxy and FastCGI mode.
*) Feature: the "break" directive.
*) Feature: the "log_not_found" directive.
*) Bugfix: the response status code was not changed when request was
redirected by the ""X-Accel-Redirect" header line.
*) Bugfix: the variables set by the "set" directive could not be used
in SSI.
*) Bugfix: the segmentation fault may occurred if the SSI page has more
than one remote subrequest.
*) Bugfix: nginx treated the backend response as invalid if the status
line in the header was transferred in two packets; the bug had
appeared in 0.1.29.
*) Feature: the "ssi_types" directive.
*) Feature: the "autoindex_exact_size" directive.
*) Bugfix: the ngx_http_autoindex_module did not support the long file
names in UTF-8.
*) Feature: the IMAP/POP3 proxy.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 08 Jul 2005 14:34:20 +0000 |
parents | 2019117e6b38 |
children | 371c1cee100d |
comparison
equal
deleted
inserted
replaced
526:e31ce4d8b8e6 | 527:7fa11e5c6e96 |
---|---|
16 void *child); | 16 void *child); |
17 static char *ngx_imap_core_server(ngx_conf_t *cf, ngx_command_t *cmd, | 17 static char *ngx_imap_core_server(ngx_conf_t *cf, ngx_command_t *cmd, |
18 void *conf); | 18 void *conf); |
19 static char *ngx_imap_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, | 19 static char *ngx_imap_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, |
20 void *conf); | 20 void *conf); |
21 static char *ngx_imap_core_capability(ngx_conf_t *cf, ngx_command_t *cmd, | |
22 void *conf); | |
21 | 23 |
22 | 24 |
23 static ngx_conf_enum_t ngx_imap_core_procotol[] = { | 25 static ngx_conf_enum_t ngx_imap_core_procotol[] = { |
24 { ngx_string("pop3"), NGX_IMAP_POP3_PROTOCOL }, | 26 { ngx_string("pop3"), NGX_IMAP_POP3_PROTOCOL }, |
25 { ngx_string("imap"), NGX_IMAP_IMAP_PROTOCOL }, | 27 { ngx_string("imap"), NGX_IMAP_IMAP_PROTOCOL }, |
26 { ngx_null_string, 0 } | 28 { ngx_null_string, 0 } |
29 }; | |
30 | |
31 | |
32 static ngx_str_t ngx_pop3_default_capabilities[] = { | |
33 ngx_string("TOP"), | |
34 ngx_string("USER"), | |
35 ngx_string("UIDL"), | |
36 ngx_null_string | |
37 }; | |
38 | |
39 | |
40 static ngx_str_t ngx_imap_default_capabilities[] = { | |
41 ngx_string("IMAP4"), | |
42 ngx_string("IMAP4rev1"), | |
43 ngx_string("UIDPLUS"), | |
44 ngx_null_string | |
27 }; | 45 }; |
28 | 46 |
29 | 47 |
30 static ngx_command_t ngx_imap_core_commands[] = { | 48 static ngx_command_t ngx_imap_core_commands[] = { |
31 | 49 |
67 { ngx_string("timeout"), | 85 { ngx_string("timeout"), |
68 NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_TAKE1, | 86 NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_TAKE1, |
69 ngx_conf_set_msec_slot, | 87 ngx_conf_set_msec_slot, |
70 NGX_IMAP_SRV_CONF_OFFSET, | 88 NGX_IMAP_SRV_CONF_OFFSET, |
71 offsetof(ngx_imap_core_srv_conf_t, timeout), | 89 offsetof(ngx_imap_core_srv_conf_t, timeout), |
90 NULL }, | |
91 | |
92 { ngx_string("pop3_capabilities"), | |
93 NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_1MORE, | |
94 ngx_imap_core_capability, | |
95 NGX_IMAP_SRV_CONF_OFFSET, | |
96 offsetof(ngx_imap_core_srv_conf_t, pop3_capabilities), | |
97 NULL }, | |
98 | |
99 { ngx_string("imap_capabilities"), | |
100 NGX_IMAP_MAIN_CONF|NGX_IMAP_SRV_CONF|NGX_CONF_1MORE, | |
101 ngx_imap_core_capability, | |
102 NGX_IMAP_SRV_CONF_OFFSET, | |
103 offsetof(ngx_imap_core_srv_conf_t, imap_capabilities), | |
72 NULL }, | 104 NULL }, |
73 | 105 |
74 ngx_null_command | 106 ngx_null_command |
75 }; | 107 }; |
76 | 108 |
119 { | 151 { |
120 ngx_imap_core_srv_conf_t *cscf; | 152 ngx_imap_core_srv_conf_t *cscf; |
121 | 153 |
122 cscf = ngx_pcalloc(cf->pool, sizeof(ngx_imap_core_srv_conf_t)); | 154 cscf = ngx_pcalloc(cf->pool, sizeof(ngx_imap_core_srv_conf_t)); |
123 if (cscf == NULL) { | 155 if (cscf == NULL) { |
124 return NGX_CONF_ERROR; | 156 return NULL; |
125 } | 157 } |
126 | 158 |
127 cscf->imap_client_buffer_size = NGX_CONF_UNSET_SIZE; | 159 cscf->imap_client_buffer_size = NGX_CONF_UNSET_SIZE; |
128 cscf->proxy_buffer_size = NGX_CONF_UNSET_SIZE; | 160 cscf->proxy_buffer_size = NGX_CONF_UNSET_SIZE; |
129 cscf->timeout = NGX_CONF_UNSET_MSEC; | 161 cscf->timeout = NGX_CONF_UNSET_MSEC; |
130 cscf->protocol = NGX_CONF_UNSET_UINT; | 162 cscf->protocol = NGX_CONF_UNSET_UINT; |
163 | |
164 if (ngx_array_init(&cscf->pop3_capabilities, cf->pool, 4, sizeof(ngx_str_t)) | |
165 != NGX_OK) | |
166 { | |
167 return NULL; | |
168 } | |
169 | |
170 if (ngx_array_init(&cscf->imap_capabilities, cf->pool, 4, sizeof(ngx_str_t)) | |
171 != NGX_OK) | |
172 { | |
173 return NULL; | |
174 } | |
131 | 175 |
132 return cscf; | 176 return cscf; |
133 } | 177 } |
134 | 178 |
135 | 179 |
136 static char * | 180 static char * |
137 ngx_imap_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) | 181 ngx_imap_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) |
138 { | 182 { |
139 ngx_imap_core_srv_conf_t *prev = parent; | 183 ngx_imap_core_srv_conf_t *prev = parent; |
140 ngx_imap_core_srv_conf_t *conf = child; | 184 ngx_imap_core_srv_conf_t *conf = child; |
185 | |
186 size_t size; | |
187 ngx_buf_t *b; | |
188 ngx_str_t *c, *d; | |
189 ngx_uint_t i; | |
141 | 190 |
142 ngx_conf_merge_size_value(conf->imap_client_buffer_size, | 191 ngx_conf_merge_size_value(conf->imap_client_buffer_size, |
143 prev->imap_client_buffer_size, | 192 prev->imap_client_buffer_size, |
144 (size_t) ngx_pagesize); | 193 (size_t) ngx_pagesize); |
145 ngx_conf_merge_size_value(conf->proxy_buffer_size, prev->proxy_buffer_size, | 194 ngx_conf_merge_size_value(conf->proxy_buffer_size, prev->proxy_buffer_size, |
146 (size_t) ngx_pagesize); | 195 (size_t) ngx_pagesize); |
147 ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000); | 196 ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000); |
148 ngx_conf_merge_unsigned_value(conf->protocol, prev->protocol, | 197 ngx_conf_merge_unsigned_value(conf->protocol, prev->protocol, |
149 NGX_IMAP_IMAP_PROTOCOL); | 198 NGX_IMAP_IMAP_PROTOCOL); |
199 | |
200 | |
201 if (conf->pop3_capabilities.nelts == 0) { | |
202 conf->pop3_capabilities = prev->pop3_capabilities; | |
203 } | |
204 | |
205 if (conf->pop3_capabilities.nelts == 0) { | |
206 | |
207 for (d = ngx_pop3_default_capabilities; d->len; d++) { | |
208 c = ngx_array_push(&conf->pop3_capabilities); | |
209 if (c == NULL) { | |
210 return NGX_CONF_ERROR; | |
211 } | |
212 | |
213 *c = *d; | |
214 } | |
215 } | |
216 | |
217 size = sizeof("+OK Capability list follows" CRLF) - 1 | |
218 + sizeof("." CRLF) - 1; | |
219 | |
220 c = conf->pop3_capabilities.elts; | |
221 for (i = 0; i < conf->pop3_capabilities.nelts; i++) { | |
222 size += c[i].len + sizeof(CRLF) - 1; | |
223 } | |
224 | |
225 b = ngx_create_temp_buf(cf->pool, size); | |
226 if (b == NULL) { | |
227 return NGX_CONF_ERROR; | |
228 } | |
229 | |
230 b->last = ngx_cpymem(b->last, "+OK Capability list follows" CRLF, | |
231 sizeof("+OK Capability list follows" CRLF) - 1); | |
232 | |
233 for (i = 0; i < conf->pop3_capabilities.nelts; i++) { | |
234 b->last = ngx_cpymem(b->last, c[i].data, c[i].len); | |
235 *b->last++ = CR; *b->last++ = LF; | |
236 } | |
237 | |
238 *b->last++ = '.'; *b->last++ = CR; *b->last++ = LF; | |
239 | |
240 conf->pop3_capability = b; | |
241 | |
242 | |
243 if (conf->imap_capabilities.nelts == 0) { | |
244 conf->imap_capabilities = prev->imap_capabilities; | |
245 } | |
246 | |
247 if (conf->imap_capabilities.nelts == 0) { | |
248 | |
249 for (d = ngx_imap_default_capabilities; d->len; d++) { | |
250 c = ngx_array_push(&conf->imap_capabilities); | |
251 if (c == NULL) { | |
252 return NGX_CONF_ERROR; | |
253 } | |
254 | |
255 *c = *d; | |
256 } | |
257 } | |
258 | |
259 size = sizeof("* CAPABILITY") - 1 + sizeof(CRLF) - 1; | |
260 | |
261 c = conf->imap_capabilities.elts; | |
262 for (i = 0; i < conf->imap_capabilities.nelts; i++) { | |
263 size += 1 + c[i].len; | |
264 } | |
265 | |
266 b = ngx_create_temp_buf(cf->pool, size); | |
267 if (b == NULL) { | |
268 return NGX_CONF_ERROR; | |
269 } | |
270 | |
271 b->last = ngx_cpymem(b->last, "* CAPABILITY", sizeof("* CAPABILITY") - 1); | |
272 | |
273 for (i = 0; i < conf->imap_capabilities.nelts; i++) { | |
274 *b->last++ = ' '; | |
275 b->last = ngx_cpymem(b->last, c[i].data, c[i].len); | |
276 } | |
277 | |
278 *b->last++ = CR; *b->last++ = LF; | |
279 | |
280 conf->imap_capability = b; | |
150 | 281 |
151 return NGX_CONF_OK; | 282 return NGX_CONF_OK; |
152 } | 283 } |
153 | 284 |
154 | 285 |
294 ls->log = cf->cycle->new_log; | 425 ls->log = cf->cycle->new_log; |
295 /**/ | 426 /**/ |
296 | 427 |
297 return NGX_CONF_OK; | 428 return NGX_CONF_OK; |
298 } | 429 } |
430 | |
431 | |
432 static char * | |
433 ngx_imap_core_capability(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
434 { | |
435 char *p = conf; | |
436 | |
437 ngx_str_t *c, *value; | |
438 ngx_uint_t i; | |
439 ngx_array_t *a; | |
440 | |
441 a = (ngx_array_t *) (p + cmd->offset); | |
442 | |
443 value = cf->args->elts; | |
444 | |
445 for (i = 1; i < cf->args->nelts; i++) { | |
446 c = ngx_array_push(a); | |
447 if (c == NULL) { | |
448 return NGX_CONF_ERROR; | |
449 } | |
450 | |
451 *c = value[i]; | |
452 } | |
453 | |
454 return NGX_CONF_OK; | |
455 } |