aboutsummaryrefslogtreecommitdiff
path: root/src/mail/ngx_mail_parse.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-09-13 21:24:27 +0000
committerIgor Sysoev <igor@sysoev.ru>2007-09-13 21:24:27 +0000
commit5fbe12146e84860a1e7cea077b1b2c705bacfed1 (patch)
tree0bc45f945103ac77a96fcde0881a5b47cf82b950 /src/mail/ngx_mail_parse.c
parent05d1de757f08cfe8d7fe8f5e14e98032477e178e (diff)
downloadnginx-5fbe12146e84860a1e7cea077b1b2c705bacfed1.tar.gz
nginx-5fbe12146e84860a1e7cea077b1b2c705bacfed1.zip
optimizations
Diffstat (limited to 'src/mail/ngx_mail_parse.c')
-rw-r--r--src/mail/ngx_mail_parse.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/mail/ngx_mail_parse.c b/src/mail/ngx_mail_parse.c
index d282a55ad..e558d2f48 100644
--- a/src/mail/ngx_mail_parse.c
+++ b/src/mail/ngx_mail_parse.c
@@ -825,3 +825,56 @@ invalid:
return NGX_MAIL_PARSE_INVALID_COMMAND;
}
+
+
+ngx_int_t
+ngx_mail_auth_parse(ngx_mail_session_t *s, ngx_connection_t *c)
+{
+ ngx_str_t *arg;
+
+#if (NGX_MAIL_SSL)
+ if (ngx_mail_starttls_only(s, c)) {
+ return NGX_MAIL_PARSE_INVALID_COMMAND;
+ }
+#endif
+
+ arg = s->args.elts;
+
+ if (arg[0].len == 5) {
+
+ if (ngx_strncasecmp(arg[0].data, (u_char *) "LOGIN", 5) == 0) {
+
+ if (s->args.nelts == 1) {
+ return NGX_MAIL_AUTH_LOGIN;
+ }
+
+ return NGX_MAIL_PARSE_INVALID_COMMAND;
+ }
+
+ if (ngx_strncasecmp(arg[0].data, (u_char *) "PLAIN", 5) == 0) {
+
+ if (s->args.nelts == 1) {
+ return NGX_MAIL_AUTH_PLAIN;
+ }
+
+ if (s->args.nelts == 2) {
+ return ngx_mail_auth_plain(s, c, 1);
+ }
+ }
+
+ return NGX_MAIL_PARSE_INVALID_COMMAND;
+ }
+
+ if (arg[0].len == 8) {
+
+ if (s->args.nelts != 1) {
+ return NGX_MAIL_PARSE_INVALID_COMMAND;
+ }
+
+ if (ngx_strncasecmp(arg[0].data, (u_char *) "CRAM-MD5", 8) == 0) {
+ return NGX_MAIL_AUTH_CRAM_MD5;
+ }
+ }
+
+ return NGX_MAIL_PARSE_INVALID_COMMAND;
+}