Mercurial > hg > nginx-mail
diff 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 |
line wrap: on
line diff
--- a/src/mail/ngx_mail.h +++ b/src/mail/ngx_mail.h @@ -68,6 +68,7 @@ typedef struct { ngx_array_t listen; /* ngx_mail_listen_t */ } ngx_mail_core_main_conf_t; +typedef void (*ngx_mail_handler_pt)(ngx_connection_t *c); #define NGX_MAIL_POP3_PROTOCOL 0 #define NGX_MAIL_IMAP_PROTOCOL 1 @@ -104,6 +105,34 @@ typedef struct { ngx_array_t imap_capabilities; ngx_array_t smtp_capabilities; + /* + * Handlers: + * + * - handler_init_session + * + * Init new session after client connects. Protocol greetings printed + * from here, so you need to define this if you need custom greeting + * (or pause before greeting printed). + * + * - handler_init_protocol + * + * Initialize protocol-specific data after client sent first command. + * Notably, this is re-called after STARTTLS negotiation. + * + * - handler_read + * + * Read client command. Could be the only handler used by simple + * modules. + * + * NB: handler_read is re-used after auth_http module work (if it was + * called throgh ngx_mail_auth_http_init()) in case of error returned + * by auth server, so you should set this if you use auth_http. + */ + + ngx_mail_handler_pt handler_init_session; + ngx_event_handler_pt handler_init_protocol; + ngx_event_handler_pt handler_read; + /* server ctx */ ngx_mail_conf_ctx_t *ctx; } ngx_mail_core_srv_conf_t; @@ -247,6 +276,12 @@ typedef struct { #define NGX_SMTP_NOOP 5 #define NGX_SMTP_MAIL 6 #define NGX_SMTP_RSET 7 +#define NGX_SMTP_RCPT 8 +#define NGX_SMTP_DATA 9 +#define NGX_SMTP_VRFY 10 +#define NGX_SMTP_EXPN 11 +#define NGX_SMTP_HELP 12 +#define NGX_SMTP_STARTTLS 13 #define NGX_MAIL_AUTH_PLAIN 0 @@ -285,6 +320,8 @@ typedef struct { #define ngx_mail_conf_get_module_main_conf(cf, module) \ ((ngx_mail_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index] +#define ngx_mail_conf_get_module_srv_conf(cf, module) \ + ((ngx_mail_conf_ctx_t *) cf->ctx)->srv_conf[module.ctx_index] void ngx_mail_init_connection(ngx_connection_t *c); @@ -295,10 +332,15 @@ void ngx_smtp_auth_state(ngx_event_t *re void ngx_mail_close_connection(ngx_connection_t *c); void ngx_mail_session_internal_server_error(ngx_mail_session_t *s); +ngx_int_t ngx_mail_read_command(ngx_mail_session_t *s); + ngx_int_t ngx_pop3_parse_command(ngx_mail_session_t *s); ngx_int_t ngx_imap_parse_command(ngx_mail_session_t *s); ngx_int_t ngx_smtp_parse_command(ngx_mail_session_t *s); +#if (NGX_MAIL_SSL) +void ngx_mail_starttls_handler(ngx_event_t *rev); +#endif /* STUB */ void ngx_mail_proxy_init(ngx_mail_session_t *s, ngx_peer_addr_t *peer);