2004-09-01 03:05:39 +08:00
|
|
|
|
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
|
|
|
#include <ngx_event.h>
|
2004-09-07 23:29:22 +08:00
|
|
|
#include <ngx_imap.h>
|
|
|
|
#include <nginx.h>
|
|
|
|
|
|
|
|
|
|
|
|
static void ngx_imap_auth_state(ngx_event_t *rev);
|
|
|
|
|
|
|
|
|
|
|
|
static char pop3_greeting[] = "+OK " NGINX_VER " ready" CRLF;
|
|
|
|
static char imap_greeting[] = "* OK " NGINX_VER " ready" CRLF;
|
2004-09-01 03:05:39 +08:00
|
|
|
|
|
|
|
|
2004-09-06 03:54:02 +08:00
|
|
|
void ngx_imap_init_connection(ngx_connection_t *c)
|
2004-09-01 03:05:39 +08:00
|
|
|
{
|
2004-09-08 13:18:51 +08:00
|
|
|
ngx_int_t n;
|
2004-09-07 23:29:22 +08:00
|
|
|
|
2004-09-01 03:05:39 +08:00
|
|
|
ngx_log_debug0(NGX_LOG_DEBUG_IMAP, c->log, 0,
|
2004-09-06 03:54:02 +08:00
|
|
|
"imap init connection");
|
2004-09-01 03:05:39 +08:00
|
|
|
|
2004-09-07 23:29:22 +08:00
|
|
|
c->log_error = NGX_ERROR_INFO;
|
2004-09-01 03:05:39 +08:00
|
|
|
|
2004-09-08 13:18:51 +08:00
|
|
|
n = ngx_send(c, pop3_greeting, sizeof(pop3_greeting) - 1);
|
2004-09-01 03:05:39 +08:00
|
|
|
|
2004-09-08 13:18:51 +08:00
|
|
|
if (n == NGX_ERROR) {
|
2004-09-07 23:29:22 +08:00
|
|
|
ngx_imap_close_connection(c);
|
|
|
|
return;
|
2004-09-01 03:05:39 +08:00
|
|
|
}
|
2004-09-07 23:29:22 +08:00
|
|
|
|
|
|
|
c->read->event_handler = ngx_imap_auth_state;
|
|
|
|
|
|
|
|
if (ngx_handle_read_event(c->read, 0) == NGX_ERROR) {
|
|
|
|
ngx_imap_close_connection(c);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ngx_imap_auth_state(ngx_event_t *rev)
|
|
|
|
{
|
|
|
|
ngx_connection_t *c;
|
|
|
|
|
|
|
|
c = rev->data;
|
|
|
|
|
|
|
|
ngx_imap_close_connection(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ngx_imap_close_connection(ngx_connection_t *c)
|
|
|
|
{
|
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_IMAP, c->log, 0,
|
|
|
|
"close imap connection: %d", c->fd);
|
|
|
|
|
|
|
|
ngx_close_connection(c);
|
2004-09-01 03:05:39 +08:00
|
|
|
}
|