diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-02-16 13:46:33 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-02-16 13:46:33 +0000 |
commit | 5fa1146dd5bfd68bc8212935a509edb6d2d0a4af (patch) | |
tree | 9277c99fa43a6086dca9cc0c982ebd69f79ae7a7 /src | |
parent | 0f2e924428f0b1ebb6b1e55359d090bc18f91e5a (diff) | |
download | nginx-5fa1146dd5bfd68bc8212935a509edb6d2d0a4af.tar.gz nginx-5fa1146dd5bfd68bc8212935a509edb6d2d0a4af.zip |
do not resolve SMTP clients by default
Diffstat (limited to 'src')
-rw-r--r-- | src/mail/ngx_mail_core_module.c | 14 | ||||
-rw-r--r-- | src/mail/ngx_mail_smtp_handler.c | 10 | ||||
-rw-r--r-- | src/mail/ngx_mail_smtp_module.c | 9 |
3 files changed, 17 insertions, 16 deletions
diff --git a/src/mail/ngx_mail_core_module.c b/src/mail/ngx_mail_core_module.c index ad785fd99..91b425f7f 100644 --- a/src/mail/ngx_mail_core_module.c +++ b/src/mail/ngx_mail_core_module.c @@ -154,13 +154,14 @@ ngx_mail_core_create_srv_conf(ngx_conf_t *cf) * set by ngx_pcalloc(): * * cscf->protocol = NULL; - * cscf->resolver = NULL; */ cscf->timeout = NGX_CONF_UNSET_MSEC; cscf->resolver_timeout = NGX_CONF_UNSET_MSEC; cscf->so_keepalive = NGX_CONF_UNSET; + cscf->resolver = NGX_CONF_UNSET_PTR; + cscf->file_name = cf->conf_file->file.name.data; cscf->line = cf->conf_file->line; @@ -207,9 +208,7 @@ ngx_mail_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) return NGX_CONF_ERROR; } - if (conf->resolver == NULL) { - conf->resolver = prev->resolver; - } + ngx_conf_merge_ptr_value(conf->resolver, prev->resolver, NULL); return NGX_CONF_OK; } @@ -423,6 +422,11 @@ ngx_mail_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) value = cf->args->elts; + if (ngx_strcmp(value[1].data, "off") == 0) { + cscf->resolver = NULL; + return NGX_CONF_OK; + } + ngx_memzero(&u, sizeof(ngx_url_t)); u.host = value[1]; @@ -435,7 +439,7 @@ ngx_mail_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) cscf->resolver = ngx_resolver_create(&u.addrs[0], cf->cycle->new_log); if (cscf->resolver == NULL) { - return NGX_OK; + return NGX_CONF_OK; } return NGX_CONF_OK; diff --git a/src/mail/ngx_mail_smtp_handler.c b/src/mail/ngx_mail_smtp_handler.c index 2d7c24f56..6e944738f 100644 --- a/src/mail/ngx_mail_smtp_handler.c +++ b/src/mail/ngx_mail_smtp_handler.c @@ -54,10 +54,16 @@ ngx_mail_smtp_init_session(ngx_mail_session_t *s, ngx_connection_t *c) ngx_resolver_ctx_t *ctx; ngx_mail_core_srv_conf_t *cscf; - c->log->action = "in resolving client address"; - cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); + if (cscf->resolver == NULL) { + s->host = smtp_unavailable; + ngx_mail_smtp_greeting(s, c); + return; + } + + c->log->action = "in resolving client address"; + ctx = ngx_resolve_start(cscf->resolver, NULL); if (ctx == NULL) { ngx_mail_close_connection(c); diff --git a/src/mail/ngx_mail_smtp_module.c b/src/mail/ngx_mail_smtp_module.c index 71ba3fd9a..5f5ac0567 100644 --- a/src/mail/ngx_mail_smtp_module.c +++ b/src/mail/ngx_mail_smtp_module.c @@ -158,15 +158,6 @@ ngx_mail_smtp_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) cscf = ngx_mail_conf_get_module_srv_conf(cf, ngx_mail_core_module); - if (cscf->protocol->type == NGX_MAIL_SMTP_PROTOCOL - && cscf->resolver == NULL) - { - ngx_log_error(NGX_LOG_EMERG, cf->log, 0, - "undefined resolver for server in %s:%ui", - cscf->file_name, cscf->line); - return NGX_CONF_ERROR; - } - size = sizeof("220 ESMTP ready" CRLF) - 1 + cscf->server_name.len; p = ngx_palloc(cf->pool, size); |