comparison src/mail/ngx_mail.h @ 336:1c519aff5c0c NGINX_0_6_12

nginx 0.6.12 *) Change: mail proxy was split on three modules: pop3, imap and smtp. *) Feature: the --without-mail_pop3_module, --without-mail_imap_module, and --without-mail_smtp_module configuration parameters. *) Feature: the "smtp_greeting_delay" and "smtp_client_buffer" directives of the ngx_mail_smtp_module. *) Bugfix: the trailing wildcards did not work; bug appeared in 0.6.9. *) Bugfix: nginx could not start on Solaris if the shared PCRE library located in non-standard place was used. *) Bugfix: the "proxy_hide_header" and "fastcgi_hide_header" directives did not hide response header lines whose name was longer than 32 characters. Thanks to Manlio Perillo.
author Igor Sysoev <http://sysoev.ru>
date Fri, 21 Sep 2007 00:00:00 +0400
parents d16d691432c9
children 583decdb82a4
comparison
equal deleted inserted replaced
335:9a32ae248b7a 336:1c519aff5c0c
71 71
72 #define NGX_MAIL_POP3_PROTOCOL 0 72 #define NGX_MAIL_POP3_PROTOCOL 0
73 #define NGX_MAIL_IMAP_PROTOCOL 1 73 #define NGX_MAIL_IMAP_PROTOCOL 1
74 #define NGX_MAIL_SMTP_PROTOCOL 2 74 #define NGX_MAIL_SMTP_PROTOCOL 2
75 75
76 typedef struct { 76
77 typedef struct ngx_mail_protocol_s ngx_mail_protocol_t;
78
79
80 typedef struct {
81 ngx_mail_protocol_t *protocol;
82
77 ngx_msec_t timeout; 83 ngx_msec_t timeout;
78 84
79 size_t imap_client_buffer_size;
80
81 ngx_uint_t protocol;
82
83 ngx_flag_t so_keepalive; 85 ngx_flag_t so_keepalive;
84 86
85 ngx_str_t pop3_capability;
86 ngx_str_t pop3_starttls_capability;
87 ngx_str_t pop3_starttls_only_capability;
88 ngx_str_t pop3_auth_capability;
89
90 ngx_str_t imap_capability;
91 ngx_str_t imap_starttls_capability;
92 ngx_str_t imap_starttls_only_capability;
93
94 ngx_str_t smtp_capability;
95 ngx_str_t smtp_starttls_capability;
96 ngx_str_t smtp_starttls_only_capability;
97
98 ngx_str_t server_name; 87 ngx_str_t server_name;
99 ngx_str_t smtp_server_name; 88
100 ngx_str_t smtp_greeting; 89 u_char *file_name;
101 90 ngx_int_t line;
102 ngx_uint_t pop3_auth_methods;
103 ngx_uint_t imap_auth_methods;
104 ngx_uint_t smtp_auth_methods;
105
106 ngx_array_t pop3_capabilities;
107 ngx_array_t imap_capabilities;
108 ngx_array_t smtp_capabilities;
109 91
110 /* server ctx */ 92 /* server ctx */
111 ngx_mail_conf_ctx_t *ctx; 93 ngx_mail_conf_ctx_t *ctx;
112 } ngx_mail_core_srv_conf_t; 94 } ngx_mail_core_srv_conf_t;
113
114
115 typedef struct {
116 void *(*create_main_conf)(ngx_conf_t *cf);
117 char *(*init_main_conf)(ngx_conf_t *cf, void *conf);
118
119 void *(*create_srv_conf)(ngx_conf_t *cf);
120 char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev,
121 void *conf);
122 } ngx_mail_module_t;
123 95
124 96
125 typedef enum { 97 typedef enum {
126 ngx_pop3_start = 0, 98 ngx_pop3_start = 0,
127 ngx_pop3_user, 99 ngx_pop3_user,
177 149
178 ngx_mail_proxy_ctx_t *proxy; 150 ngx_mail_proxy_ctx_t *proxy;
179 151
180 ngx_uint_t mail_state; 152 ngx_uint_t mail_state;
181 153
154 unsigned protocol:3;
182 unsigned blocked:1; 155 unsigned blocked:1;
183 unsigned quit:1; 156 unsigned quit:1;
184 unsigned protocol:2;
185 unsigned quoted:1; 157 unsigned quoted:1;
186 unsigned backslash:1; 158 unsigned backslash:1;
187 unsigned no_sync_literal:1; 159 unsigned no_sync_literal:1;
188 unsigned starttls:1; 160 unsigned starttls:1;
189 unsigned esmtp:1; 161 unsigned esmtp:1;
194 ngx_str_t passwd; 166 ngx_str_t passwd;
195 167
196 ngx_str_t salt; 168 ngx_str_t salt;
197 ngx_str_t tag; 169 ngx_str_t tag;
198 ngx_str_t tagged_line; 170 ngx_str_t tagged_line;
171 ngx_str_t text;
199 172
200 ngx_str_t *addr_text; 173 ngx_str_t *addr_text;
201 ngx_str_t smtp_helo; 174 ngx_str_t smtp_helo;
202 175
203 ngx_uint_t command; 176 ngx_uint_t command;
204 ngx_array_t args; 177 ngx_array_t args;
205 178
206 ngx_uint_t login_attempt; 179 ngx_uint_t login_attempt;
207 180
208 /* used to parse IMAP/POP3/SMTP command */ 181 /* used to parse POP3/IMAP/SMTP command */
209 182
210 ngx_uint_t state; 183 ngx_uint_t state;
211 u_char *cmd_start; 184 u_char *cmd_start;
212 u_char *arg_start; 185 u_char *arg_start;
213 u_char *arg_end; 186 u_char *arg_end;
277 250
278 251
279 #define NGX_MAIL_PARSE_INVALID_COMMAND 20 252 #define NGX_MAIL_PARSE_INVALID_COMMAND 20
280 253
281 254
282 #define NGX_MAIL_MODULE 0x4C49414D /* "MAIL" */ 255 typedef void (*ngx_mail_init_session_pt)(ngx_mail_session_t *s,
283 256 ngx_connection_t *c);
284 #define NGX_MAIL_MAIN_CONF 0x02000000 257 typedef void (*ngx_mail_init_protocol_pt)(ngx_event_t *rev);
285 #define NGX_MAIL_SRV_CONF 0x04000000 258 typedef void (*ngx_mail_auth_state_pt)(ngx_event_t *rev);
259 typedef ngx_int_t (*ngx_mail_parse_command_pt)(ngx_mail_session_t *s);
260
261
262 struct ngx_mail_protocol_s {
263 ngx_str_t name;
264 in_port_t port[4];
265 ngx_uint_t type;
266
267 ngx_mail_init_session_pt init_session;
268 ngx_mail_init_protocol_pt init_protocol;
269 ngx_mail_parse_command_pt parse_command;
270 ngx_mail_auth_state_pt auth_state;
271
272 ngx_str_t internal_server_error;
273 };
274
275
276 typedef struct {
277 ngx_mail_protocol_t *protocol;
278
279 void *(*create_main_conf)(ngx_conf_t *cf);
280 char *(*init_main_conf)(ngx_conf_t *cf, void *conf);
281
282 void *(*create_srv_conf)(ngx_conf_t *cf);
283 char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev,
284 void *conf);
285 } ngx_mail_module_t;
286
287
288 #define NGX_MAIL_MODULE 0x4C49414D /* "MAIL" */
289
290 #define NGX_MAIL_MAIN_CONF 0x02000000
291 #define NGX_MAIL_SRV_CONF 0x04000000
286 292
287 293
288 #define NGX_MAIL_MAIN_CONF_OFFSET offsetof(ngx_mail_conf_ctx_t, main_conf) 294 #define NGX_MAIL_MAIN_CONF_OFFSET offsetof(ngx_mail_conf_ctx_t, main_conf)
289 #define NGX_MAIL_SRV_CONF_OFFSET offsetof(ngx_mail_conf_ctx_t, srv_conf) 295 #define NGX_MAIL_SRV_CONF_OFFSET offsetof(ngx_mail_conf_ctx_t, srv_conf)
290 296
302 ((ngx_mail_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index] 308 ((ngx_mail_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index]
303 #define ngx_mail_conf_get_module_srv_conf(cf, module) \ 309 #define ngx_mail_conf_get_module_srv_conf(cf, module) \
304 ((ngx_mail_conf_ctx_t *) cf->ctx)->srv_conf[module.ctx_index] 310 ((ngx_mail_conf_ctx_t *) cf->ctx)->srv_conf[module.ctx_index]
305 311
306 312
313 #if (NGX_MAIL_SSL)
314 void ngx_mail_starttls_handler(ngx_event_t *rev);
315 ngx_int_t ngx_mail_starttls_only(ngx_mail_session_t *s, ngx_connection_t *c);
316 #endif
317
318
307 void ngx_mail_init_connection(ngx_connection_t *c); 319 void ngx_mail_init_connection(ngx_connection_t *c);
320
321 ngx_int_t ngx_mail_salt(ngx_mail_session_t *s, ngx_connection_t *c,
322 ngx_mail_core_srv_conf_t *cscf);
323 ngx_int_t ngx_mail_auth_plain(ngx_mail_session_t *s, ngx_connection_t *c,
324 ngx_uint_t n);
325 ngx_int_t ngx_mail_auth_login_username(ngx_mail_session_t *s,
326 ngx_connection_t *c);
327 ngx_int_t ngx_mail_auth_login_password(ngx_mail_session_t *s,
328 ngx_connection_t *c);
329 ngx_int_t ngx_mail_auth_cram_md5_salt(ngx_mail_session_t *s,
330 ngx_connection_t *c, char *prefix, size_t len);
331 ngx_int_t ngx_mail_auth_cram_md5(ngx_mail_session_t *s, ngx_connection_t *c);
332 ngx_int_t ngx_mail_auth_parse(ngx_mail_session_t *s, ngx_connection_t *c);
333
308 void ngx_mail_send(ngx_event_t *wev); 334 void ngx_mail_send(ngx_event_t *wev);
309 void ngx_pop3_auth_state(ngx_event_t *rev); 335 ngx_int_t ngx_mail_read_command(ngx_mail_session_t *s, ngx_connection_t *c);
310 void ngx_imap_auth_state(ngx_event_t *rev); 336 void ngx_mail_auth(ngx_mail_session_t *s, ngx_connection_t *c);
311 void ngx_smtp_auth_state(ngx_event_t *rev);
312 void ngx_mail_close_connection(ngx_connection_t *c); 337 void ngx_mail_close_connection(ngx_connection_t *c);
313 void ngx_mail_session_internal_server_error(ngx_mail_session_t *s); 338 void ngx_mail_session_internal_server_error(ngx_mail_session_t *s);
314 339 u_char *ngx_mail_log_error(ngx_log_t *log, u_char *buf, size_t len);
315 ngx_int_t ngx_pop3_parse_command(ngx_mail_session_t *s); 340
316 ngx_int_t ngx_imap_parse_command(ngx_mail_session_t *s); 341
317 ngx_int_t ngx_smtp_parse_command(ngx_mail_session_t *s); 342 char *ngx_mail_capabilities(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
318 343
319 344
320 /* STUB */ 345 /* STUB */
321 void ngx_mail_proxy_init(ngx_mail_session_t *s, ngx_peer_addr_t *peer); 346 void ngx_mail_proxy_init(ngx_mail_session_t *s, ngx_peer_addr_t *peer);
322 void ngx_mail_auth_http_init(ngx_mail_session_t *s); 347 void ngx_mail_auth_http_init(ngx_mail_session_t *s);