Mercurial > hg > nginx-quic
annotate src/mail/ngx_mail_smtp_handler.c @ 2765:6d358aeaa989
ngx_log_errno()
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 27 Apr 2009 13:17:33 +0000 |
parents | a59b26eee816 |
children | a96a8c916b0c |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
423
diff
changeset
|
5 |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_event.h> |
1136 | 10 #include <ngx_mail.h> |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
11 #include <ngx_mail_smtp_module.h> |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
12 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
13 |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
14 static void ngx_mail_smtp_resolve_addr_handler(ngx_resolver_ctx_t *ctx); |
2488
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
15 static void ngx_mail_smtp_resolve_name(ngx_event_t *rev); |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
16 static void ngx_mail_smtp_resolve_name_handler(ngx_resolver_ctx_t *ctx); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
17 static void ngx_mail_smtp_greeting(ngx_mail_session_t *s, ngx_connection_t *c); |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
18 static void ngx_mail_smtp_invalid_pipelining(ngx_event_t *rev); |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
19 static ngx_int_t ngx_mail_smtp_create_buffer(ngx_mail_session_t *s, |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
20 ngx_connection_t *c); |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
21 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
22 static ngx_int_t ngx_mail_smtp_helo(ngx_mail_session_t *s, ngx_connection_t *c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
23 static ngx_int_t ngx_mail_smtp_auth(ngx_mail_session_t *s, ngx_connection_t *c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
24 static ngx_int_t ngx_mail_smtp_mail(ngx_mail_session_t *s, ngx_connection_t *c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
25 static ngx_int_t ngx_mail_smtp_starttls(ngx_mail_session_t *s, |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
26 ngx_connection_t *c); |
2309 | 27 static ngx_int_t ngx_mail_smtp_rset(ngx_mail_session_t *s, ngx_connection_t *c); |
28 static ngx_int_t ngx_mail_smtp_rcpt(ngx_mail_session_t *s, ngx_connection_t *c); | |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
30 static ngx_int_t ngx_mail_smtp_discard_command(ngx_mail_session_t *s, |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
31 ngx_connection_t *c, char *err); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
32 static void ngx_mail_smtp_log_rejected_command(ngx_mail_session_t *s, |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
33 ngx_connection_t *c, char *err); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
34 |
527 | 35 |
1136 | 36 static u_char smtp_ok[] = "250 2.0.0 OK" CRLF; |
37 static u_char smtp_bye[] = "221 2.0.0 Bye" CRLF; | |
1762 | 38 static u_char smtp_starttls[] = "220 2.0.0 Start TLS" CRLF; |
1136 | 39 static u_char smtp_next[] = "334 " CRLF; |
40 static u_char smtp_username[] = "334 VXNlcm5hbWU6" CRLF; | |
41 static u_char smtp_password[] = "334 UGFzc3dvcmQ6" CRLF; | |
42 static u_char smtp_invalid_command[] = "500 5.5.1 Invalid command" CRLF; | |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
43 static u_char smtp_invalid_pipelining[] = |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
44 "503 5.5.0 Improper use of SMTP command pipelining" CRLF; |
1136 | 45 static u_char smtp_invalid_argument[] = "501 5.5.4 Invalid argument" CRLF; |
46 static u_char smtp_auth_required[] = "530 5.7.1 Authentication required" CRLF; | |
2309 | 47 static u_char smtp_bad_sequence[] = "503 5.5.1 Bad sequence of commands" CRLF; |
1136 | 48 |
521 | 49 |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
50 static ngx_str_t smtp_unavailable = ngx_string("[UNAVAILABLE]"); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
51 static ngx_str_t smtp_tempunavail = ngx_string("[TEMPUNAVAIL]"); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
52 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
53 |
521 | 54 void |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
55 ngx_mail_smtp_init_session(ngx_mail_session_t *s, ngx_connection_t *c) |
413
de9d4726e28a
nginx-0.0.10-2004-08-31-23:05:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
56 { |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
57 struct sockaddr_in *sin; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
58 ngx_resolver_ctx_t *ctx; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
59 ngx_mail_core_srv_conf_t *cscf; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
60 |
1896
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
61 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
62 |
1896
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
63 if (cscf->resolver == NULL) { |
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
64 s->host = smtp_unavailable; |
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
65 ngx_mail_smtp_greeting(s, c); |
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
66 return; |
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
67 } |
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
68 |
4c060e30476b
do not resolve SMTP clients by default
Igor Sysoev <igor@sysoev.ru>
parents:
1892
diff
changeset
|
69 c->log->action = "in resolving client address"; |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
70 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
71 ctx = ngx_resolve_start(cscf->resolver, NULL); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
72 if (ctx == NULL) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
73 ngx_mail_close_connection(c); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
74 return; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
75 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
76 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
77 /* AF_INET only */ |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
78 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
79 sin = (struct sockaddr_in *) c->sockaddr; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
80 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
81 ctx->addr = sin->sin_addr.s_addr; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
82 ctx->handler = ngx_mail_smtp_resolve_addr_handler; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
83 ctx->data = s; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
84 ctx->timeout = cscf->resolver_timeout; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
85 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
86 if (ngx_resolve_addr(ctx) != NGX_OK) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
87 ngx_mail_close_connection(c); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
88 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
89 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
90 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
91 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
92 static void |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
93 ngx_mail_smtp_resolve_addr_handler(ngx_resolver_ctx_t *ctx) |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
94 { |
2488
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
95 ngx_connection_t *c; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
96 ngx_mail_session_t *s; |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
97 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
98 s = ctx->data; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
99 c = s->connection; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
100 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
101 if (ctx->state) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
102 ngx_log_error(NGX_LOG_ERR, c->log, 0, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
103 "%V could not be resolved (%i: %s)", |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
104 &c->addr_text, ctx->state, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
105 ngx_resolver_strerror(ctx->state)); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
106 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
107 if (ctx->state == NGX_RESOLVE_NXDOMAIN) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
108 s->host = smtp_unavailable; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
109 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
110 } else { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
111 s->host = smtp_tempunavail; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
112 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
113 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
114 ngx_resolve_addr_done(ctx); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
115 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
116 ngx_mail_smtp_greeting(s, s->connection); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
117 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
118 return; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
119 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
120 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
121 c->log->action = "in resolving client hostname"; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
122 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
123 s->host.data = ngx_pstrdup(c->pool, &ctx->name); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
124 if (s->host.data == NULL) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
125 ngx_resolve_addr_done(ctx); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
126 ngx_mail_close_connection(c); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
127 return; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
128 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
129 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
130 s->host.len = ctx->name.len; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
131 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
132 ngx_resolve_addr_done(ctx); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
133 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
134 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
135 "address resolved: %V", &s->host); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
136 |
2488
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
137 c->read->handler = ngx_mail_smtp_resolve_name; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
138 |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
139 ngx_post_event(c->read, &ngx_posted_events); |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
140 } |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
141 |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
142 |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
143 static void |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
144 ngx_mail_smtp_resolve_name(ngx_event_t *rev) |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
145 { |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
146 ngx_connection_t *c; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
147 ngx_mail_session_t *s; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
148 ngx_resolver_ctx_t *ctx; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
149 ngx_mail_core_srv_conf_t *cscf; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
150 |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
151 c = rev->data; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
152 s = c->data; |
ac695b3e981c
avoid deep nested calls, flatten call tree
Igor Sysoev <igor@sysoev.ru>
parents:
2388
diff
changeset
|
153 |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
154 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
155 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
156 ctx = ngx_resolve_start(cscf->resolver, NULL); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
157 if (ctx == NULL) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
158 ngx_mail_close_connection(c); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
159 return; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
160 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
161 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
162 ctx->name = s->host; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
163 ctx->type = NGX_RESOLVE_A; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
164 ctx->handler = ngx_mail_smtp_resolve_name_handler; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
165 ctx->data = s; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
166 ctx->timeout = cscf->resolver_timeout; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
167 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
168 if (ngx_resolve_name(ctx) != NGX_OK) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
169 ngx_mail_close_connection(c); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
170 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
171 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
172 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
173 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
174 static void |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
175 ngx_mail_smtp_resolve_name_handler(ngx_resolver_ctx_t *ctx) |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
176 { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
177 in_addr_t addr; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
178 ngx_uint_t i; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
179 ngx_connection_t *c; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
180 struct sockaddr_in *sin; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
181 ngx_mail_session_t *s; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
182 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
183 s = ctx->data; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
184 c = s->connection; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
185 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
186 if (ctx->state) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
187 ngx_log_error(NGX_LOG_ERR, c->log, 0, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
188 "%V could not be resolved (%i: %s)", |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
189 &ctx->name, ctx->state, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
190 ngx_resolver_strerror(ctx->state)); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
191 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
192 if (ctx->state == NGX_RESOLVE_NXDOMAIN) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
193 s->host = smtp_unavailable; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
194 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
195 } else { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
196 s->host = smtp_tempunavail; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
197 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
198 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
199 } else { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
200 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
201 /* AF_INET only */ |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
202 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
203 sin = (struct sockaddr_in *) c->sockaddr; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
204 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
205 for (i = 0; i < ctx->naddrs; i++) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
206 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
207 addr = ctx->addrs[i]; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
208 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
209 ngx_log_debug4(NGX_LOG_DEBUG_MAIL, c->log, 0, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
210 "name was resolved to %ud.%ud.%ud.%ud", |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
211 (ntohl(addr) >> 24) & 0xff, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
212 (ntohl(addr) >> 16) & 0xff, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
213 (ntohl(addr) >> 8) & 0xff, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
214 ntohl(addr) & 0xff); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
215 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
216 if (addr == sin->sin_addr.s_addr) { |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
217 goto found; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
218 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
219 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
220 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
221 s->host = smtp_unavailable; |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
222 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
223 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
224 found: |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
225 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
226 ngx_resolve_name_done(ctx); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
227 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
228 ngx_mail_smtp_greeting(s, c); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
229 } |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
230 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
231 |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
232 static void |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
233 ngx_mail_smtp_greeting(ngx_mail_session_t *s, ngx_connection_t *c) |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
234 { |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
235 ngx_msec_t timeout; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
236 ngx_mail_core_srv_conf_t *cscf; |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
237 ngx_mail_smtp_srv_conf_t *sscf; |
641 | 238 |
1892
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
239 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
240 "smtp greeting for \"%V\"", &s->host); |
057d362ee50e
resolver in smtp proxy module
Igor Sysoev <igor@sysoev.ru>
parents:
1762
diff
changeset
|
241 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
242 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
243 sscf = ngx_mail_get_module_srv_conf(s, ngx_mail_smtp_module); |
541 | 244 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
245 timeout = sscf->greeting_delay ? sscf->greeting_delay : cscf->timeout; |
1486
0e7074ef7303
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1485
diff
changeset
|
246 ngx_add_timer(c->read, timeout); |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
247 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2309
diff
changeset
|
248 if (ngx_handle_read_event(c->read, 0) != NGX_OK) { |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
249 ngx_mail_close_connection(c); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
250 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
251 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
252 if (sscf->greeting_delay) { |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
253 c->read->handler = ngx_mail_smtp_invalid_pipelining; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
254 return; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
255 } |
1480
a231e37a19ab
move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents:
1479
diff
changeset
|
256 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
257 c->read->handler = ngx_mail_smtp_init_protocol; |
583 | 258 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
259 s->out = sscf->greeting; |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
260 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
261 ngx_mail_send(c->write); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
262 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
263 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
264 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
265 static void |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
266 ngx_mail_smtp_invalid_pipelining(ngx_event_t *rev) |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
267 { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
268 ngx_connection_t *c; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
269 ngx_mail_session_t *s; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
270 ngx_mail_core_srv_conf_t *cscf; |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
271 ngx_mail_smtp_srv_conf_t *sscf; |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
272 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
273 c = rev->data; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
274 s = c->data; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
275 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
276 c->log->action = "in delay pipelining state"; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
277 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
278 if (rev->timedout) { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
279 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
280 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "delay greeting"); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
281 |
1484 | 282 rev->timedout = 0; |
283 | |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
284 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
1480
a231e37a19ab
move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents:
1479
diff
changeset
|
285 |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
286 c->read->handler = ngx_mail_smtp_init_protocol; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
287 |
1486
0e7074ef7303
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1485
diff
changeset
|
288 ngx_add_timer(c->read, cscf->timeout); |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
289 |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2309
diff
changeset
|
290 if (ngx_handle_read_event(c->read, 0) != NGX_OK) { |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
291 ngx_mail_close_connection(c); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
292 return; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
293 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
294 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
295 sscf = ngx_mail_get_module_srv_conf(s, ngx_mail_smtp_module); |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
296 |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
297 s->out = sscf->greeting; |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
298 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
299 } else { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
300 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
301 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "invalid pipelining"); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
302 |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
303 if (s->buffer == NULL) { |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
304 if (ngx_mail_smtp_create_buffer(s, c) != NGX_OK) { |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
305 return; |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
306 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
307 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
308 |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
309 if (ngx_mail_smtp_discard_command(s, c, |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
310 "client was rejected before greeting: \"%V\"") |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
311 != NGX_OK) |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
312 { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
313 return; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
314 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
315 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
316 s->out.len = sizeof(smtp_invalid_pipelining) - 1; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
317 s->out.data = smtp_invalid_pipelining; |
1480
a231e37a19ab
move event handling to protocol specific code,
Igor Sysoev <igor@sysoev.ru>
parents:
1479
diff
changeset
|
318 } |
539 | 319 |
1136 | 320 ngx_mail_send(c->write); |
539 | 321 } |
322 | |
323 | |
324 void | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
325 ngx_mail_smtp_init_protocol(ngx_event_t *rev) |
539 | 326 { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
327 ngx_connection_t *c; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
328 ngx_mail_session_t *s; |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
329 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
330 c = rev->data; |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
331 |
541 | 332 c->log->action = "in auth state"; |
333 | |
423
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
334 if (rev->timedout) { |
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
335 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
577 | 336 c->timedout = 1; |
1136 | 337 ngx_mail_close_connection(c); |
423
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
338 return; |
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
339 } |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
340 |
539 | 341 s = c->data; |
521 | 342 |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
343 if (s->buffer == NULL) { |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
344 if (ngx_mail_smtp_create_buffer(s, c) != NGX_OK) { |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
345 return; |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
346 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
347 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
348 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
349 s->mail_state = ngx_smtp_start; |
1477 | 350 c->read->handler = ngx_mail_smtp_auth_state; |
1136 | 351 |
1477 | 352 ngx_mail_smtp_auth_state(rev); |
521 | 353 } |
354 | |
355 | |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
356 static ngx_int_t |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
357 ngx_mail_smtp_create_buffer(ngx_mail_session_t *s, ngx_connection_t *c) |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
358 { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
359 ngx_mail_smtp_srv_conf_t *sscf; |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
360 |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
361 if (ngx_array_init(&s->args, c->pool, 2, sizeof(ngx_str_t)) == NGX_ERROR) { |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
362 ngx_mail_session_internal_server_error(s); |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
363 return NGX_ERROR; |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
364 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
365 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
366 sscf = ngx_mail_get_module_srv_conf(s, ngx_mail_smtp_module); |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
367 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
368 s->buffer = ngx_create_temp_buf(c->pool, sscf->client_buffer_size); |
1483
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
369 if (s->buffer == NULL) { |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
370 ngx_mail_session_internal_server_error(s); |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
371 return NGX_ERROR; |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
372 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
373 |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
374 return NGX_OK; |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
375 } |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
376 |
46f364406994
ngx_mail_smtp_create_buffer()
Igor Sysoev <igor@sysoev.ru>
parents:
1482
diff
changeset
|
377 |
527 | 378 void |
1477 | 379 ngx_mail_smtp_auth_state(ngx_event_t *rev) |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
380 { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
381 ngx_int_t rc; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
382 ngx_connection_t *c; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
383 ngx_mail_session_t *s; |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
384 |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
385 c = rev->data; |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
386 s = c->data; |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
387 |
1136 | 388 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "smtp auth state"); |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
389 |
423
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
390 if (rev->timedout) { |
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
391 ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out"); |
577 | 392 c->timedout = 1; |
1136 | 393 ngx_mail_close_connection(c); |
423
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
394 return; |
fda5987b188d
nginx-0.0.10-2004-09-13-20:18:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
422
diff
changeset
|
395 } |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
396 |
539 | 397 if (s->out.len) { |
1136 | 398 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "smtp send handler busy"); |
539 | 399 s->blocked = 1; |
400 return; | |
401 } | |
402 | |
403 s->blocked = 0; | |
404 | |
1482 | 405 rc = ngx_mail_read_command(s, c); |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
406 |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
407 if (rc == NGX_AGAIN || rc == NGX_ERROR) { |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
408 return; |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
409 } |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
410 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
411 s->out.len = sizeof(smtp_ok) - 1; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
412 s->out.data = smtp_ok; |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
413 |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
414 if (rc == NGX_OK) { |
1136 | 415 switch (s->mail_state) { |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
416 |
1136 | 417 case ngx_smtp_start: |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
418 |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
419 switch (s->command) { |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
420 |
1136 | 421 case NGX_SMTP_HELO: |
422 case NGX_SMTP_EHLO: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
423 rc = ngx_mail_smtp_helo(s, c); |
809 | 424 break; |
425 | |
1136 | 426 case NGX_SMTP_AUTH: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
427 rc = ngx_mail_smtp_auth(s, c); |
800 | 428 break; |
429 | |
1136 | 430 case NGX_SMTP_QUIT: |
539 | 431 s->quit = 1; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
432 s->out.len = sizeof(smtp_bye) - 1; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
433 s->out.data = smtp_bye; |
527 | 434 break; |
435 | |
1136 | 436 case NGX_SMTP_MAIL: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
437 rc = ngx_mail_smtp_mail(s, c); |
583 | 438 break; |
439 | |
2309 | 440 case NGX_SMTP_RCPT: |
441 rc = ngx_mail_smtp_rcpt(s, c); | |
442 break; | |
443 | |
444 case NGX_SMTP_RSET: | |
445 rc = ngx_mail_smtp_rset(s, c); | |
446 break; | |
447 | |
1136 | 448 case NGX_SMTP_NOOP: |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
449 break; |
1322 | 450 |
451 case NGX_SMTP_STARTTLS: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
452 rc = ngx_mail_smtp_starttls(s, c); |
1762 | 453 s->out.len = sizeof(smtp_starttls) - 1; |
454 s->out.data = smtp_starttls; | |
1322 | 455 break; |
456 | |
457 default: | |
458 rc = NGX_MAIL_PARSE_INVALID_COMMAND; | |
459 break; | |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
460 } |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
461 |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
462 break; |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
463 |
1136 | 464 case ngx_smtp_auth_login_username: |
2495
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
465 rc = ngx_mail_auth_login_username(s, c, 0); |
809 | 466 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
467 s->out.len = sizeof(smtp_password) - 1; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
468 s->out.data = smtp_password; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
469 s->mail_state = ngx_smtp_auth_login_password; |
809 | 470 break; |
471 | |
1136 | 472 case ngx_smtp_auth_login_password: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
473 rc = ngx_mail_auth_login_password(s, c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
474 break; |
809 | 475 |
1136 | 476 case ngx_smtp_auth_plain: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
477 rc = ngx_mail_auth_plain(s, c, 0); |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
478 break; |
809 | 479 |
1136 | 480 case ngx_smtp_auth_cram_md5: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
481 rc = ngx_mail_auth_cram_md5(s, c); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
482 break; |
421
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
483 } |
01456a419cf9
nginx-0.0.10-2004-09-10-18:32:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
420
diff
changeset
|
484 } |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
485 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
486 switch (rc) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
487 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
488 case NGX_DONE: |
1482 | 489 ngx_mail_auth(s, c); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
490 return; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
491 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
492 case NGX_ERROR: |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
493 ngx_mail_session_internal_server_error(s); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
494 return; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
495 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
496 case NGX_MAIL_PARSE_INVALID_COMMAND: |
1136 | 497 s->mail_state = ngx_smtp_start; |
1486
0e7074ef7303
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1485
diff
changeset
|
498 s->state = 0; |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
499 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
500 s->out.len = sizeof(smtp_invalid_command) - 1; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
501 s->out.data = smtp_invalid_command; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
502 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
503 /* fall through */ |
539 | 504 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
505 case NGX_OK: |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
506 s->args.nelts = 0; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
507 s->buffer->pos = s->buffer->start; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
508 s->buffer->last = s->buffer->start; |
810 | 509 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
510 if (s->state) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
511 s->arg_start = s->buffer->start; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
512 } |
539 | 513 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
514 ngx_mail_send(c->write); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
515 } |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
516 } |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
517 |
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
518 |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
519 static ngx_int_t |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
520 ngx_mail_smtp_helo(ngx_mail_session_t *s, ngx_connection_t *c) |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
521 { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
522 ngx_str_t *arg; |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
523 ngx_mail_smtp_srv_conf_t *sscf; |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
524 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
525 if (s->args.nelts != 1) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
526 s->out.len = sizeof(smtp_invalid_argument) - 1; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
527 s->out.data = smtp_invalid_argument; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
528 s->state = 0; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
529 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
530 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
531 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
532 arg = s->args.elts; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
533 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
534 s->smtp_helo.len = arg[0].len; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
535 |
2049 | 536 s->smtp_helo.data = ngx_pnalloc(c->pool, arg[0].len); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
537 if (s->smtp_helo.data == NULL) { |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
538 return NGX_ERROR; |
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
539 } |
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
540 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
541 ngx_memcpy(s->smtp_helo.data, arg[0].data, arg[0].len); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
542 |
2309 | 543 s->smtp_from.len = 0; |
544 s->smtp_from.data = NULL; | |
545 s->smtp_to.len = 0; | |
546 s->smtp_to.data = NULL; | |
547 | |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
548 sscf = ngx_mail_get_module_srv_conf(s, ngx_mail_smtp_module); |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
549 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
550 if (s->command == NGX_SMTP_HELO) { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
551 s->out = sscf->server_name; |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
552 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
553 } else { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
554 s->esmtp = 1; |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
555 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
556 #if (NGX_MAIL_SSL) |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
557 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
558 if (c->ssl == NULL) { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1493
diff
changeset
|
559 ngx_mail_ssl_conf_t *sslcf; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1493
diff
changeset
|
560 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
561 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
562 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
563 if (sslcf->starttls == NGX_MAIL_STARTTLS_ON) { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
564 s->out = sscf->starttls_capability; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
565 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
566 } |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
567 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
568 if (sslcf->starttls == NGX_MAIL_STARTTLS_ONLY) { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
569 s->out = sscf->starttls_only_capability; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
570 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
571 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
572 } |
894
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
573 #endif |
4f7dca9c37f0
workaround for Eudora for Mac: it sends
Igor Sysoev <igor@sysoev.ru>
parents:
884
diff
changeset
|
574 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
575 s->out = sscf->capability; |
420
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
576 } |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
577 |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
578 return NGX_OK; |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
579 } |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
580 |
33a8253115b4
nginx-0.0.10-2004-09-09-22:55:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
419
diff
changeset
|
581 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
582 static ngx_int_t |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
583 ngx_mail_smtp_auth(ngx_mail_session_t *s, ngx_connection_t *c) |
525 | 584 { |
1479 | 585 ngx_int_t rc; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
586 ngx_mail_core_srv_conf_t *cscf; |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
587 ngx_mail_smtp_srv_conf_t *sscf; |
525 | 588 |
1479 | 589 #if (NGX_MAIL_SSL) |
590 if (ngx_mail_starttls_only(s, c)) { | |
591 return NGX_MAIL_PARSE_INVALID_COMMAND; | |
539 | 592 } |
593 #endif | |
594 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
595 if (s->args.nelts == 0) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
596 s->out.len = sizeof(smtp_invalid_argument) - 1; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
597 s->out.data = smtp_invalid_argument; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
598 s->state = 0; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
599 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
600 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
601 |
1479 | 602 rc = ngx_mail_auth_parse(s, c); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
603 |
1479 | 604 switch (rc) { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
605 |
1479 | 606 case NGX_MAIL_AUTH_LOGIN: |
1472
32450a2bbdf4
decrement active connection counter in mail proxy
Igor Sysoev <igor@sysoev.ru>
parents:
1323
diff
changeset
|
607 |
1479 | 608 s->out.len = sizeof(smtp_username) - 1; |
609 s->out.data = smtp_username; | |
610 s->mail_state = ngx_smtp_auth_login_username; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
611 |
1479 | 612 return NGX_OK; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
613 |
2495
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
614 case NGX_MAIL_AUTH_LOGIN_USERNAME: |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
615 |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
616 s->out.len = sizeof(smtp_password) - 1; |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
617 s->out.data = smtp_password; |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
618 s->mail_state = ngx_smtp_auth_login_password; |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
619 |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
620 return ngx_mail_auth_login_username(s, c, 1); |
a59b26eee816
compatibility with Microsoft's
Igor Sysoev <igor@sysoev.ru>
parents:
2488
diff
changeset
|
621 |
1479 | 622 case NGX_MAIL_AUTH_PLAIN: |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
623 |
1479 | 624 s->out.len = sizeof(smtp_next) - 1; |
625 s->out.data = smtp_next; | |
626 s->mail_state = ngx_smtp_auth_plain; | |
543 | 627 |
1479 | 628 return NGX_OK; |
629 | |
630 case NGX_MAIL_AUTH_CRAM_MD5: | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
631 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
632 sscf = ngx_mail_get_module_srv_conf(s, ngx_mail_smtp_module); |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
633 |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
634 if (!(sscf->auth_methods & NGX_MAIL_AUTH_CRAM_MD5_ENABLED)) { |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
635 return NGX_MAIL_PARSE_INVALID_COMMAND; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
636 } |
479 | 637 |
1485
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1484
diff
changeset
|
638 if (s->salt.data == NULL) { |
1487
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
639 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); |
f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
Igor Sysoev <igor@sysoev.ru>
parents:
1486
diff
changeset
|
640 |
1485
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1484
diff
changeset
|
641 if (ngx_mail_salt(s, c, cscf) != NGX_OK) { |
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1484
diff
changeset
|
642 return NGX_ERROR; |
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1484
diff
changeset
|
643 } |
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1484
diff
changeset
|
644 } |
b3488fc2675a
create salt just before it will be used
Igor Sysoev <igor@sysoev.ru>
parents:
1484
diff
changeset
|
645 |
1479 | 646 if (ngx_mail_auth_cram_md5_salt(s, c, "334 ", 4) == NGX_OK) { |
647 s->mail_state = ngx_smtp_auth_cram_md5; | |
648 return NGX_OK; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
649 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
650 |
1479 | 651 return NGX_ERROR; |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
652 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
653 |
1479 | 654 return rc; |
417
0526206251f6
nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
655 } |
539 | 656 |
657 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
658 static ngx_int_t |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
659 ngx_mail_smtp_mail(ngx_mail_session_t *s, ngx_connection_t *c) |
541 | 660 { |
2309 | 661 u_char ch; |
662 ngx_str_t l; | |
663 ngx_uint_t i; | |
664 ngx_mail_smtp_srv_conf_t *sscf; | |
665 | |
666 sscf = ngx_mail_get_module_srv_conf(s, ngx_mail_smtp_module); | |
667 | |
668 if (!(sscf->auth_methods & NGX_MAIL_AUTH_NONE_ENABLED)) { | |
669 ngx_mail_smtp_log_rejected_command(s, c, "client was rejected: \"%V\""); | |
670 | |
671 s->out.len = sizeof(smtp_auth_required) - 1; | |
672 s->out.data = smtp_auth_required; | |
673 | |
674 return NGX_OK; | |
675 } | |
676 | |
677 /* auth none */ | |
678 | |
679 if (s->smtp_from.len) { | |
680 s->out.len = sizeof(smtp_bad_sequence) - 1; | |
681 s->out.data = smtp_bad_sequence; | |
682 return NGX_OK; | |
683 } | |
684 | |
685 l.len = s->buffer->last - s->buffer->start; | |
686 l.data = s->buffer->start; | |
687 | |
688 for (i = 0; i < l.len; i++) { | |
689 ch = l.data[i]; | |
690 | |
691 if (ch != CR && ch != LF) { | |
692 continue; | |
693 } | |
694 | |
695 l.data[i] = ' '; | |
696 } | |
697 | |
698 while (i) { | |
699 if (l.data[i - 1] != ' ') { | |
700 break; | |
701 } | |
702 | |
703 i--; | |
704 } | |
705 | |
706 l.len = i; | |
707 | |
708 s->smtp_from.len = l.len; | |
709 | |
710 s->smtp_from.data = ngx_pnalloc(c->pool, l.len); | |
711 if (s->smtp_from.data == NULL) { | |
712 return NGX_ERROR; | |
713 } | |
714 | |
715 ngx_memcpy(s->smtp_from.data, l.data, l.len); | |
716 | |
717 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, | |
718 "smtp mail from:\"%V\"", &s->smtp_from); | |
719 | |
720 s->out.len = sizeof(smtp_ok) - 1; | |
721 s->out.data = smtp_ok; | |
722 | |
723 return NGX_OK; | |
724 } | |
577 | 725 |
2309 | 726 |
727 static ngx_int_t | |
728 ngx_mail_smtp_rcpt(ngx_mail_session_t *s, ngx_connection_t *c) | |
729 { | |
730 u_char ch; | |
731 ngx_str_t l; | |
732 ngx_uint_t i; | |
733 | |
734 if (s->smtp_from.len == 0) { | |
735 s->out.len = sizeof(smtp_bad_sequence) - 1; | |
736 s->out.data = smtp_bad_sequence; | |
737 return NGX_OK; | |
738 } | |
739 | |
740 l.len = s->buffer->last - s->buffer->start; | |
741 l.data = s->buffer->start; | |
742 | |
743 for (i = 0; i < l.len; i++) { | |
744 ch = l.data[i]; | |
745 | |
746 if (ch != CR && ch != LF) { | |
747 continue; | |
748 } | |
749 | |
750 l.data[i] = ' '; | |
751 } | |
752 | |
753 while (i) { | |
754 if (l.data[i - 1] != ' ') { | |
755 break; | |
756 } | |
757 | |
758 i--; | |
759 } | |
760 | |
761 l.len = i; | |
762 | |
763 s->smtp_to.len = l.len; | |
764 | |
765 s->smtp_to.data = ngx_pnalloc(c->pool, l.len); | |
766 if (s->smtp_to.data == NULL) { | |
767 return NGX_ERROR; | |
768 } | |
769 | |
770 ngx_memcpy(s->smtp_to.data, l.data, l.len); | |
771 | |
772 ngx_log_debug1(NGX_LOG_DEBUG_MAIL, c->log, 0, | |
773 "smtp rcpt to:\"%V\"", &s->smtp_to); | |
774 | |
775 s->auth_method = NGX_MAIL_AUTH_NONE; | |
776 | |
777 return NGX_DONE; | |
778 } | |
779 | |
780 | |
781 static ngx_int_t | |
782 ngx_mail_smtp_rset(ngx_mail_session_t *s, ngx_connection_t *c) | |
783 { | |
784 s->smtp_from.len = 0; | |
785 s->smtp_from.data = NULL; | |
786 s->smtp_to.len = 0; | |
787 s->smtp_to.data = NULL; | |
788 | |
789 s->out.len = sizeof(smtp_ok) - 1; | |
790 s->out.data = smtp_ok; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
791 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
792 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
793 } |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
794 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
795 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
796 static ngx_int_t |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
797 ngx_mail_smtp_starttls(ngx_mail_session_t *s, ngx_connection_t *c) |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
798 { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
799 #if (NGX_MAIL_SSL) |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
800 ngx_mail_ssl_conf_t *sslcf; |
541 | 801 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
802 if (c->ssl == NULL) { |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
803 sslcf = ngx_mail_get_module_srv_conf(s, ngx_mail_ssl_module); |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
804 if (sslcf->starttls) { |
541 | 805 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
806 /* |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
807 * RFC3207 requires us to discard any knowledge |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
808 * obtained from client before STARTTLS. |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
809 */ |
541 | 810 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
811 s->smtp_helo.len = 0; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
812 s->smtp_helo.data = NULL; |
2309 | 813 s->smtp_from.len = 0; |
814 s->smtp_from.data = NULL; | |
815 s->smtp_to.len = 0; | |
816 s->smtp_to.data = NULL; | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
817 |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
818 c->read->handler = ngx_mail_starttls_handler; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
819 return NGX_OK; |
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
820 } |
541 | 821 } |
822 | |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
823 #endif |
541 | 824 |
1476
67578e966dcc
split pop3, imap, and smtp handlers
Igor Sysoev <igor@sysoev.ru>
parents:
1472
diff
changeset
|
825 return NGX_MAIL_PARSE_INVALID_COMMAND; |
541 | 826 } |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
827 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
828 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
829 static ngx_int_t |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
830 ngx_mail_smtp_discard_command(ngx_mail_session_t *s, ngx_connection_t *c, |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
831 char *err) |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
832 { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
833 ssize_t n; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
834 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
835 n = c->recv(c, s->buffer->last, s->buffer->end - s->buffer->last); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
836 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
837 if (n == NGX_ERROR || n == 0) { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
838 ngx_mail_close_connection(c); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
839 return NGX_ERROR; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
840 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
841 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
842 if (n > 0) { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
843 s->buffer->last += n; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
844 } |
1486
0e7074ef7303
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
1485
diff
changeset
|
845 |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
846 if (n == NGX_AGAIN) { |
2388
722b5aff05ae
use "!= NGX_OK" instead of "== NGX_ERROR"
Igor Sysoev <igor@sysoev.ru>
parents:
2309
diff
changeset
|
847 if (ngx_handle_read_event(c->read, 0) != NGX_OK) { |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
848 ngx_mail_session_internal_server_error(s); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
849 return NGX_ERROR; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
850 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
851 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
852 return NGX_AGAIN; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
853 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
854 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
855 ngx_mail_smtp_log_rejected_command(s, c, err); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
856 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
857 s->buffer->pos = s->buffer->start; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
858 s->buffer->last = s->buffer->start; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
859 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
860 return NGX_OK; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
861 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
862 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
863 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
864 static void |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
865 ngx_mail_smtp_log_rejected_command(ngx_mail_session_t *s, ngx_connection_t *c, |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
866 char *err) |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
867 { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
868 u_char ch; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
869 ngx_str_t cmd; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
870 ngx_uint_t i; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
871 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
872 if (c->log->log_level < NGX_LOG_INFO) { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
873 return; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
874 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
875 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
876 cmd.len = s->buffer->last - s->buffer->start; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
877 cmd.data = s->buffer->start; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
878 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
879 for (i = 0; i < cmd.len; i++) { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
880 ch = cmd.data[i]; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
881 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
882 if (ch != CR && ch != LF) { |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
883 continue; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
884 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
885 |
1493
3c4111e07b58
use "_" instead of " " as new line substitute, do not delete trailing new line
Igor Sysoev <igor@sysoev.ru>
parents:
1487
diff
changeset
|
886 cmd.data[i] = '_'; |
1481
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
887 } |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
888 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
889 cmd.len = i; |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
890 |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
891 ngx_log_error(NGX_LOG_INFO, c->log, 0, err, &cmd); |
b58ce1cf66da
smtp_client_buffer and smtp_greeting_delay
Igor Sysoev <igor@sysoev.ru>
parents:
1480
diff
changeset
|
892 } |