mirror of
https://github.com/nginx/nginx.git
synced 2025-02-25 18:55:26 -06:00
do not resolve SMTP clients by default
This commit is contained in:
parent
0f2e924428
commit
5fa1146dd5
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user