Mercurial > hg > nginx-mail
comparison src/mail/ngx_mail.h @ 394:a96157df5186
Mail: extensibility.
- If mail module enabled, honor mail dependencies while building addons.
- Introduce handlers for external mail modules: handler_init_session,
handler_init_protocol, handler_read.
- Parse some additional smtp commands, fix generic handler to live with
it.
- Some missing macros, some functions (notably command parsing) non-static.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 18 Jul 2007 00:47:55 +0000 |
parents | f745bf973510 |
children | e2d916d7e50f |
comparison
equal
deleted
inserted
replaced
320:95183808f549 | 394:a96157df5186 |
---|---|
66 typedef struct { | 66 typedef struct { |
67 ngx_array_t servers; /* ngx_mail_core_srv_conf_t */ | 67 ngx_array_t servers; /* ngx_mail_core_srv_conf_t */ |
68 ngx_array_t listen; /* ngx_mail_listen_t */ | 68 ngx_array_t listen; /* ngx_mail_listen_t */ |
69 } ngx_mail_core_main_conf_t; | 69 } ngx_mail_core_main_conf_t; |
70 | 70 |
71 typedef void (*ngx_mail_handler_pt)(ngx_connection_t *c); | |
71 | 72 |
72 #define NGX_MAIL_POP3_PROTOCOL 0 | 73 #define NGX_MAIL_POP3_PROTOCOL 0 |
73 #define NGX_MAIL_IMAP_PROTOCOL 1 | 74 #define NGX_MAIL_IMAP_PROTOCOL 1 |
74 #define NGX_MAIL_SMTP_PROTOCOL 2 | 75 #define NGX_MAIL_SMTP_PROTOCOL 2 |
75 | 76 |
101 ngx_uint_t smtp_auth_methods; | 102 ngx_uint_t smtp_auth_methods; |
102 | 103 |
103 ngx_array_t pop3_capabilities; | 104 ngx_array_t pop3_capabilities; |
104 ngx_array_t imap_capabilities; | 105 ngx_array_t imap_capabilities; |
105 ngx_array_t smtp_capabilities; | 106 ngx_array_t smtp_capabilities; |
107 | |
108 /* | |
109 * Handlers: | |
110 * | |
111 * - handler_init_session | |
112 * | |
113 * Init new session after client connects. Protocol greetings printed | |
114 * from here, so you need to define this if you need custom greeting | |
115 * (or pause before greeting printed). | |
116 * | |
117 * - handler_init_protocol | |
118 * | |
119 * Initialize protocol-specific data after client sent first command. | |
120 * Notably, this is re-called after STARTTLS negotiation. | |
121 * | |
122 * - handler_read | |
123 * | |
124 * Read client command. Could be the only handler used by simple | |
125 * modules. | |
126 * | |
127 * NB: handler_read is re-used after auth_http module work (if it was | |
128 * called throgh ngx_mail_auth_http_init()) in case of error returned | |
129 * by auth server, so you should set this if you use auth_http. | |
130 */ | |
131 | |
132 ngx_mail_handler_pt handler_init_session; | |
133 ngx_event_handler_pt handler_init_protocol; | |
134 ngx_event_handler_pt handler_read; | |
106 | 135 |
107 /* server ctx */ | 136 /* server ctx */ |
108 ngx_mail_conf_ctx_t *ctx; | 137 ngx_mail_conf_ctx_t *ctx; |
109 } ngx_mail_core_srv_conf_t; | 138 } ngx_mail_core_srv_conf_t; |
110 | 139 |
245 #define NGX_SMTP_AUTH 3 | 274 #define NGX_SMTP_AUTH 3 |
246 #define NGX_SMTP_QUIT 4 | 275 #define NGX_SMTP_QUIT 4 |
247 #define NGX_SMTP_NOOP 5 | 276 #define NGX_SMTP_NOOP 5 |
248 #define NGX_SMTP_MAIL 6 | 277 #define NGX_SMTP_MAIL 6 |
249 #define NGX_SMTP_RSET 7 | 278 #define NGX_SMTP_RSET 7 |
279 #define NGX_SMTP_RCPT 8 | |
280 #define NGX_SMTP_DATA 9 | |
281 #define NGX_SMTP_VRFY 10 | |
282 #define NGX_SMTP_EXPN 11 | |
283 #define NGX_SMTP_HELP 12 | |
284 #define NGX_SMTP_STARTTLS 13 | |
250 | 285 |
251 | 286 |
252 #define NGX_MAIL_AUTH_PLAIN 0 | 287 #define NGX_MAIL_AUTH_PLAIN 0 |
253 #define NGX_MAIL_AUTH_LOGIN 1 | 288 #define NGX_MAIL_AUTH_LOGIN 1 |
254 #define NGX_MAIL_AUTH_APOP 2 | 289 #define NGX_MAIL_AUTH_APOP 2 |
283 (s)->main_conf[module.ctx_index] | 318 (s)->main_conf[module.ctx_index] |
284 #define ngx_mail_get_module_srv_conf(s, module) (s)->srv_conf[module.ctx_index] | 319 #define ngx_mail_get_module_srv_conf(s, module) (s)->srv_conf[module.ctx_index] |
285 | 320 |
286 #define ngx_mail_conf_get_module_main_conf(cf, module) \ | 321 #define ngx_mail_conf_get_module_main_conf(cf, module) \ |
287 ((ngx_mail_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index] | 322 ((ngx_mail_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index] |
323 #define ngx_mail_conf_get_module_srv_conf(cf, module) \ | |
324 ((ngx_mail_conf_ctx_t *) cf->ctx)->srv_conf[module.ctx_index] | |
288 | 325 |
289 | 326 |
290 void ngx_mail_init_connection(ngx_connection_t *c); | 327 void ngx_mail_init_connection(ngx_connection_t *c); |
291 void ngx_mail_send(ngx_event_t *wev); | 328 void ngx_mail_send(ngx_event_t *wev); |
292 void ngx_pop3_auth_state(ngx_event_t *rev); | 329 void ngx_pop3_auth_state(ngx_event_t *rev); |
293 void ngx_imap_auth_state(ngx_event_t *rev); | 330 void ngx_imap_auth_state(ngx_event_t *rev); |
294 void ngx_smtp_auth_state(ngx_event_t *rev); | 331 void ngx_smtp_auth_state(ngx_event_t *rev); |
295 void ngx_mail_close_connection(ngx_connection_t *c); | 332 void ngx_mail_close_connection(ngx_connection_t *c); |
296 void ngx_mail_session_internal_server_error(ngx_mail_session_t *s); | 333 void ngx_mail_session_internal_server_error(ngx_mail_session_t *s); |
297 | 334 |
335 ngx_int_t ngx_mail_read_command(ngx_mail_session_t *s); | |
336 | |
298 ngx_int_t ngx_pop3_parse_command(ngx_mail_session_t *s); | 337 ngx_int_t ngx_pop3_parse_command(ngx_mail_session_t *s); |
299 ngx_int_t ngx_imap_parse_command(ngx_mail_session_t *s); | 338 ngx_int_t ngx_imap_parse_command(ngx_mail_session_t *s); |
300 ngx_int_t ngx_smtp_parse_command(ngx_mail_session_t *s); | 339 ngx_int_t ngx_smtp_parse_command(ngx_mail_session_t *s); |
301 | 340 |
341 #if (NGX_MAIL_SSL) | |
342 void ngx_mail_starttls_handler(ngx_event_t *rev); | |
343 #endif | |
302 | 344 |
303 /* STUB */ | 345 /* STUB */ |
304 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); |
305 void ngx_mail_auth_http_init(ngx_mail_session_t *s); | 347 void ngx_mail_auth_http_init(ngx_mail_session_t *s); |
306 /**/ | 348 /**/ |