Mercurial > hg > nginx-quic
diff src/mail/ngx_mail_auth_http_module.c @ 1487:f69493e8faab
ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 15 Sep 2007 16:51:16 +0000 |
parents | d0cce8369848 |
children | fe11e2a3946d |
line wrap: on
line diff
--- a/src/mail/ngx_mail_auth_http_module.c +++ b/src/mail/ngx_mail_auth_http_module.c @@ -111,6 +111,8 @@ static ngx_command_t ngx_mail_auth_http static ngx_mail_module_t ngx_mail_auth_http_module_ctx = { + NULL, /* protocol */ + NULL, /* create main configuration */ NULL, /* init main configuration */ @@ -135,7 +137,6 @@ ngx_module_t ngx_mail_auth_http_module }; -static char *ngx_mail_auth_http_protocol[] = { "pop3", "imap", "smtp" }; static ngx_str_t ngx_mail_auth_http_method[] = { ngx_string("plain"), ngx_string("plain"), @@ -145,18 +146,6 @@ static ngx_str_t ngx_mail_auth_http_me static ngx_str_t ngx_mail_smtp_errcode = ngx_string("535 5.7.0"); -static ngx_uint_t ngx_mail_start_states[] = { - ngx_pop3_start, - ngx_imap_start, - ngx_smtp_start -}; - -static ngx_mail_auth_state_pt ngx_mail_auth_states[] = { - ngx_mail_pop3_auth_state, - ngx_mail_imap_auth_state, - ngx_mail_smtp_auth_state -}; - void ngx_mail_auth_http_init(ngx_mail_session_t *s) @@ -762,7 +751,8 @@ ngx_mail_auth_http_process_headers(ngx_m return; } - if (s->passwd.data == NULL && s->protocol != NGX_MAIL_SMTP_PROTOCOL) + if (s->passwd.data == NULL + && s->protocol != NGX_MAIL_SMTP_PROTOCOL) { ngx_log_error(NGX_LOG_ERR, s->connection->log, 0, "auth http server %V did not send password", @@ -881,9 +871,11 @@ ngx_mail_auth_sleep_handler(ngx_event_t return; } - s->mail_state = ngx_mail_start_states[s->protocol]; - rev->handler = ngx_mail_auth_states[s->protocol]; + cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); + rev->handler = cscf->protocol->auth_state; + + s->mail_state = 0; s->auth_method = NGX_MAIL_AUTH_PLAIN; c->log->action = "in auth state"; @@ -894,8 +886,6 @@ ngx_mail_auth_sleep_handler(ngx_event_t return; } - cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); - ngx_add_timer(rev, cscf->timeout); if (rev->ready) { @@ -1145,9 +1135,10 @@ static ngx_buf_t * ngx_mail_auth_http_create_request(ngx_mail_session_t *s, ngx_pool_t *pool, ngx_mail_auth_http_conf_t *ahcf) { - size_t len; - ngx_buf_t *b; - ngx_str_t login, passwd; + size_t len; + ngx_buf_t *b; + ngx_str_t login, passwd; + ngx_mail_core_srv_conf_t *cscf; if (ngx_mail_auth_http_escape(pool, &s->login, &login) != NGX_OK) { return NULL; @@ -1157,6 +1148,8 @@ ngx_mail_auth_http_create_request(ngx_ma return NULL; } + cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); + len = sizeof("GET ") - 1 + ahcf->uri.len + sizeof(" HTTP/1.0" CRLF) - 1 + sizeof("Host: ") - 1 + ahcf->host_header.len + sizeof(CRLF) - 1 + sizeof("Auth-Method: ") - 1 @@ -1165,7 +1158,8 @@ ngx_mail_auth_http_create_request(ngx_ma + sizeof("Auth-User: ") - 1 + login.len + sizeof(CRLF) - 1 + sizeof("Auth-Pass: ") - 1 + passwd.len + sizeof(CRLF) - 1 + sizeof("Auth-Salt: ") - 1 + s->salt.len - + sizeof("Auth-Protocol: imap" CRLF) - 1 + + sizeof("Auth-Protocol: ") - 1 + cscf->protocol->name.len + + sizeof(CRLF) - 1 + sizeof("Auth-Login-Attempt: ") - 1 + NGX_INT_T_LEN + sizeof(CRLF) - 1 + sizeof("Client-IP: ") - 1 + s->connection->addr_text.len @@ -1212,8 +1206,8 @@ ngx_mail_auth_http_create_request(ngx_ma b->last = ngx_cpymem(b->last, "Auth-Protocol: ", sizeof("Auth-Protocol: ") - 1); - b->last = ngx_cpymem(b->last, ngx_mail_auth_http_protocol[s->protocol], - sizeof("imap") - 1); + b->last = ngx_cpymem(b->last, cscf->protocol->name.data, + cscf->protocol->name.len); *b->last++ = CR; *b->last++ = LF; b->last = ngx_sprintf(b->last, "Auth-Login-Attempt: %ui" CRLF,