diff 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
line wrap: on
line diff
--- a/src/mail/ngx_mail.h
+++ b/src/mail/ngx_mail.h
@@ -73,55 +73,27 @@ typedef struct {
 #define NGX_MAIL_IMAP_PROTOCOL  1
 #define NGX_MAIL_SMTP_PROTOCOL  2
 
-typedef struct {
-    ngx_msec_t              timeout;
+
+typedef struct ngx_mail_protocol_s  ngx_mail_protocol_t;
+
 
-    size_t                  imap_client_buffer_size;
+typedef struct {
+    ngx_mail_protocol_t    *protocol;
 
-    ngx_uint_t              protocol;
+    ngx_msec_t              timeout;
 
     ngx_flag_t              so_keepalive;
 
-    ngx_str_t               pop3_capability;
-    ngx_str_t               pop3_starttls_capability;
-    ngx_str_t               pop3_starttls_only_capability;
-    ngx_str_t               pop3_auth_capability;
-
-    ngx_str_t               imap_capability;
-    ngx_str_t               imap_starttls_capability;
-    ngx_str_t               imap_starttls_only_capability;
+    ngx_str_t               server_name;
 
-    ngx_str_t               smtp_capability;
-    ngx_str_t               smtp_starttls_capability;
-    ngx_str_t               smtp_starttls_only_capability;
-
-    ngx_str_t               server_name;
-    ngx_str_t               smtp_server_name;
-    ngx_str_t               smtp_greeting;
-
-    ngx_uint_t              pop3_auth_methods;
-    ngx_uint_t              imap_auth_methods;
-    ngx_uint_t              smtp_auth_methods;
-
-    ngx_array_t             pop3_capabilities;
-    ngx_array_t             imap_capabilities;
-    ngx_array_t             smtp_capabilities;
+    u_char                 *file_name;
+    ngx_int_t               line;
 
     /* server ctx */
     ngx_mail_conf_ctx_t    *ctx;
 } ngx_mail_core_srv_conf_t;
 
 
-typedef struct {
-    void                 *(*create_main_conf)(ngx_conf_t *cf);
-    char                 *(*init_main_conf)(ngx_conf_t *cf, void *conf);
-
-    void                 *(*create_srv_conf)(ngx_conf_t *cf);
-    char                 *(*merge_srv_conf)(ngx_conf_t *cf, void *prev,
-                                void *conf);
-} ngx_mail_module_t;
-
-
 typedef enum {
     ngx_pop3_start = 0,
     ngx_pop3_user,
@@ -179,9 +151,9 @@ typedef struct {
 
     ngx_uint_t              mail_state;
 
+    unsigned                protocol:3;
     unsigned                blocked:1;
     unsigned                quit:1;
-    unsigned                protocol:2;
     unsigned                quoted:1;
     unsigned                backslash:1;
     unsigned                no_sync_literal:1;
@@ -196,6 +168,7 @@ typedef struct {
     ngx_str_t               salt;
     ngx_str_t               tag;
     ngx_str_t               tagged_line;
+    ngx_str_t               text;
 
     ngx_str_t              *addr_text;
     ngx_str_t               smtp_helo;
@@ -205,7 +178,7 @@ typedef struct {
 
     ngx_uint_t              login_attempt;
 
-    /* used to parse IMAP/POP3/SMTP command */
+    /* used to parse POP3/IMAP/SMTP command */
 
     ngx_uint_t              state;
     u_char                 *cmd_start;
@@ -279,10 +252,43 @@ typedef struct {
 #define NGX_MAIL_PARSE_INVALID_COMMAND  20
 
 
-#define NGX_MAIL_MODULE      0x4C49414D     /* "MAIL" */
+typedef void (*ngx_mail_init_session_pt)(ngx_mail_session_t *s,
+    ngx_connection_t *c);
+typedef void (*ngx_mail_init_protocol_pt)(ngx_event_t *rev);
+typedef void (*ngx_mail_auth_state_pt)(ngx_event_t *rev);
+typedef ngx_int_t (*ngx_mail_parse_command_pt)(ngx_mail_session_t *s);
+
+
+struct ngx_mail_protocol_s {
+    ngx_str_t                   name;
+    in_port_t                   port[4];
+    ngx_uint_t                  type;
+
+    ngx_mail_init_session_pt    init_session;
+    ngx_mail_init_protocol_pt   init_protocol;
+    ngx_mail_parse_command_pt   parse_command;
+    ngx_mail_auth_state_pt      auth_state;
 
-#define NGX_MAIL_MAIN_CONF   0x02000000
-#define NGX_MAIL_SRV_CONF    0x04000000
+    ngx_str_t                   internal_server_error;
+};
+
+
+typedef struct {
+    ngx_mail_protocol_t        *protocol;
+
+    void                       *(*create_main_conf)(ngx_conf_t *cf);
+    char                       *(*init_main_conf)(ngx_conf_t *cf, void *conf);
+
+    void                       *(*create_srv_conf)(ngx_conf_t *cf);
+    char                       *(*merge_srv_conf)(ngx_conf_t *cf, void *prev,
+                                      void *conf);
+} ngx_mail_module_t;
+
+
+#define NGX_MAIL_MODULE         0x4C49414D     /* "MAIL" */
+
+#define NGX_MAIL_MAIN_CONF      0x02000000
+#define NGX_MAIL_SRV_CONF       0x04000000
 
 
 #define NGX_MAIL_MAIN_CONF_OFFSET  offsetof(ngx_mail_conf_ctx_t, main_conf)
@@ -304,17 +310,36 @@ typedef struct {
     ((ngx_mail_conf_ctx_t *) cf->ctx)->srv_conf[module.ctx_index]
 
 
+#if (NGX_MAIL_SSL)
+void ngx_mail_starttls_handler(ngx_event_t *rev);
+ngx_int_t ngx_mail_starttls_only(ngx_mail_session_t *s, ngx_connection_t *c);
+#endif
+
+
 void ngx_mail_init_connection(ngx_connection_t *c);
+
+ngx_int_t ngx_mail_salt(ngx_mail_session_t *s, ngx_connection_t *c,
+    ngx_mail_core_srv_conf_t *cscf);
+ngx_int_t ngx_mail_auth_plain(ngx_mail_session_t *s, ngx_connection_t *c,
+    ngx_uint_t n);
+ngx_int_t ngx_mail_auth_login_username(ngx_mail_session_t *s,
+    ngx_connection_t *c);
+ngx_int_t ngx_mail_auth_login_password(ngx_mail_session_t *s,
+    ngx_connection_t *c);
+ngx_int_t ngx_mail_auth_cram_md5_salt(ngx_mail_session_t *s,
+    ngx_connection_t *c, char *prefix, size_t len);
+ngx_int_t ngx_mail_auth_cram_md5(ngx_mail_session_t *s, ngx_connection_t *c);
+ngx_int_t ngx_mail_auth_parse(ngx_mail_session_t *s, ngx_connection_t *c);
+
 void ngx_mail_send(ngx_event_t *wev);
-void ngx_pop3_auth_state(ngx_event_t *rev);
-void ngx_imap_auth_state(ngx_event_t *rev);
-void ngx_smtp_auth_state(ngx_event_t *rev);
+ngx_int_t ngx_mail_read_command(ngx_mail_session_t *s, ngx_connection_t *c);
+void ngx_mail_auth(ngx_mail_session_t *s, ngx_connection_t *c);
 void ngx_mail_close_connection(ngx_connection_t *c);
 void ngx_mail_session_internal_server_error(ngx_mail_session_t *s);
+u_char *ngx_mail_log_error(ngx_log_t *log, u_char *buf, size_t len);
 
-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);
+
+char *ngx_mail_capabilities(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
 
 
 /* STUB */