2005-06-07 11:56:31 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) Igor Sysoev
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
|
|
|
#include <ngx_event.h>
|
2007-03-19 09:36:56 -04:00
|
|
|
#include <ngx_mail.h>
|
2005-06-07 11:56:31 -04:00
|
|
|
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
static void *ngx_mail_core_create_main_conf(ngx_conf_t *cf);
|
|
|
|
static void *ngx_mail_core_create_srv_conf(ngx_conf_t *cf);
|
|
|
|
static char *ngx_mail_core_merge_srv_conf(ngx_conf_t *cf, void *parent,
|
2005-06-07 11:56:31 -04:00
|
|
|
void *child);
|
2007-03-19 09:36:56 -04:00
|
|
|
static char *ngx_mail_core_server(ngx_conf_t *cf, ngx_command_t *cmd,
|
2005-06-07 11:56:31 -04:00
|
|
|
void *conf);
|
2007-03-19 09:36:56 -04:00
|
|
|
static char *ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd,
|
2005-06-07 11:56:31 -04:00
|
|
|
void *conf);
|
2007-09-15 12:51:16 -04:00
|
|
|
static char *ngx_mail_core_protocol(ngx_conf_t *cf, ngx_command_t *cmd,
|
2005-07-08 10:34:20 -04:00
|
|
|
void *conf);
|
2008-02-13 10:50:04 -03:00
|
|
|
static char *ngx_mail_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
|
|
void *conf);
|
2005-06-07 11:56:31 -04:00
|
|
|
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
static ngx_command_t ngx_mail_core_commands[] = {
|
2005-06-07 11:56:31 -04:00
|
|
|
|
|
|
|
{ ngx_string("server"),
|
2007-03-19 09:36:56 -04:00
|
|
|
NGX_MAIL_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
|
|
|
|
ngx_mail_core_server,
|
2005-06-07 11:56:31 -04:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL },
|
|
|
|
|
|
|
|
{ ngx_string("listen"),
|
2007-03-19 09:36:56 -04:00
|
|
|
NGX_MAIL_SRV_CONF|NGX_CONF_TAKE12,
|
|
|
|
ngx_mail_core_listen,
|
2007-09-15 12:51:16 -04:00
|
|
|
NGX_MAIL_SRV_CONF_OFFSET,
|
2005-06-07 11:56:31 -04:00
|
|
|
0,
|
|
|
|
NULL },
|
|
|
|
|
|
|
|
{ ngx_string("protocol"),
|
2007-03-19 09:36:56 -04:00
|
|
|
NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
|
2007-09-15 12:51:16 -04:00
|
|
|
ngx_mail_core_protocol,
|
2007-03-19 09:36:56 -04:00
|
|
|
NGX_MAIL_SRV_CONF_OFFSET,
|
2007-09-15 12:51:16 -04:00
|
|
|
0,
|
2007-09-14 09:58:49 -04:00
|
|
|
NULL },
|
|
|
|
|
2005-12-07 11:51:31 -03:00
|
|
|
{ ngx_string("so_keepalive"),
|
2007-03-19 09:36:56 -04:00
|
|
|
NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_FLAG,
|
2005-12-07 11:51:31 -03:00
|
|
|
ngx_conf_set_flag_slot,
|
2007-03-19 09:36:56 -04:00
|
|
|
NGX_MAIL_SRV_CONF_OFFSET,
|
|
|
|
offsetof(ngx_mail_core_srv_conf_t, so_keepalive),
|
2005-12-07 11:51:31 -03:00
|
|
|
NULL },
|
|
|
|
|
2005-06-07 11:56:31 -04:00
|
|
|
{ ngx_string("timeout"),
|
2007-03-19 09:36:56 -04:00
|
|
|
NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
|
2005-06-07 11:56:31 -04:00
|
|
|
ngx_conf_set_msec_slot,
|
2007-03-19 09:36:56 -04:00
|
|
|
NGX_MAIL_SRV_CONF_OFFSET,
|
|
|
|
offsetof(ngx_mail_core_srv_conf_t, timeout),
|
2005-06-07 11:56:31 -04:00
|
|
|
NULL },
|
|
|
|
|
2006-10-23 10:10:10 -03:00
|
|
|
{ ngx_string("server_name"),
|
2007-03-19 09:36:56 -04:00
|
|
|
NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
|
2006-10-23 10:10:10 -03:00
|
|
|
ngx_conf_set_str_slot,
|
2007-03-19 09:36:56 -04:00
|
|
|
NGX_MAIL_SRV_CONF_OFFSET,
|
|
|
|
offsetof(ngx_mail_core_srv_conf_t, server_name),
|
2006-10-23 10:10:10 -03:00
|
|
|
NULL },
|
|
|
|
|
2008-02-13 10:50:04 -03:00
|
|
|
{ ngx_string("resolver"),
|
|
|
|
NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
|
|
|
|
ngx_mail_core_resolver,
|
|
|
|
NGX_MAIL_SRV_CONF_OFFSET,
|
|
|
|
0,
|
|
|
|
NULL },
|
|
|
|
|
|
|
|
{ ngx_string("resolver_timeout"),
|
|
|
|
NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
|
|
|
|
ngx_conf_set_msec_slot,
|
|
|
|
NGX_MAIL_SRV_CONF_OFFSET,
|
|
|
|
offsetof(ngx_mail_core_srv_conf_t, resolver_timeout),
|
|
|
|
NULL },
|
|
|
|
|
2005-06-07 11:56:31 -04:00
|
|
|
ngx_null_command
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
static ngx_mail_module_t ngx_mail_core_module_ctx = {
|
2007-09-15 12:51:16 -04:00
|
|
|
NULL, /* protocol */
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_core_create_main_conf, /* create main configuration */
|
2005-06-07 11:56:31 -04:00
|
|
|
NULL, /* init main configuration */
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_core_create_srv_conf, /* create server configuration */
|
|
|
|
ngx_mail_core_merge_srv_conf /* merge server configuration */
|
2005-06-07 11:56:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_module_t ngx_mail_core_module = {
|
2005-06-07 11:56:31 -04:00
|
|
|
NGX_MODULE_V1,
|
2007-03-19 09:36:56 -04:00
|
|
|
&ngx_mail_core_module_ctx, /* module context */
|
|
|
|
ngx_mail_core_commands, /* module directives */
|
|
|
|
NGX_MAIL_MODULE, /* module type */
|
2005-09-08 10:36:09 -04:00
|
|
|
NULL, /* init master */
|
2005-06-07 11:56:31 -04:00
|
|
|
NULL, /* init module */
|
2005-09-08 10:36:09 -04:00
|
|
|
NULL, /* init process */
|
|
|
|
NULL, /* init thread */
|
|
|
|
NULL, /* exit thread */
|
|
|
|
NULL, /* exit process */
|
|
|
|
NULL, /* exit master */
|
|
|
|
NGX_MODULE_V1_PADDING
|
2005-06-07 11:56:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_core_create_main_conf(ngx_conf_t *cf)
|
2005-11-15 10:30:52 -03:00
|
|
|
{
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_core_main_conf_t *cmcf;
|
2005-06-07 11:56:31 -04:00
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_core_main_conf_t));
|
2005-06-07 11:56:31 -04:00
|
|
|
if (cmcf == NULL) {
|
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_array_init(&cmcf->servers, cf->pool, 4,
|
2007-03-19 09:36:56 -04:00
|
|
|
sizeof(ngx_mail_core_srv_conf_t *))
|
2006-04-26 05:52:47 -04:00
|
|
|
!= NGX_OK)
|
|
|
|
{
|
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
if (ngx_array_init(&cmcf->listen, cf->pool, 4, sizeof(ngx_mail_listen_t))
|
2006-04-26 05:52:47 -04:00
|
|
|
!= NGX_OK)
|
2005-06-07 11:56:31 -04:00
|
|
|
{
|
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmcf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_core_create_srv_conf(ngx_conf_t *cf)
|
2005-11-15 10:30:52 -03:00
|
|
|
{
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_core_srv_conf_t *cscf;
|
2005-11-15 10:30:52 -03:00
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
cscf = ngx_pcalloc(cf->pool, sizeof(ngx_mail_core_srv_conf_t));
|
2005-06-07 11:56:31 -04:00
|
|
|
if (cscf == NULL) {
|
2005-07-08 10:34:20 -04:00
|
|
|
return NULL;
|
2005-06-07 11:56:31 -04:00
|
|
|
}
|
|
|
|
|
2007-09-15 12:51:16 -04:00
|
|
|
/*
|
|
|
|
* set by ngx_pcalloc():
|
|
|
|
*
|
|
|
|
* cscf->protocol = NULL;
|
2008-02-13 10:50:04 -03:00
|
|
|
* cscf->resolver = NULL;
|
2007-09-15 12:51:16 -04:00
|
|
|
*/
|
|
|
|
|
2005-12-07 11:51:31 -03:00
|
|
|
cscf->timeout = NGX_CONF_UNSET_MSEC;
|
2008-02-13 10:50:04 -03:00
|
|
|
cscf->resolver_timeout = NGX_CONF_UNSET_MSEC;
|
2005-12-07 11:51:31 -03:00
|
|
|
cscf->so_keepalive = NGX_CONF_UNSET;
|
2005-06-07 11:56:31 -04:00
|
|
|
|
2008-02-13 10:50:04 -03:00
|
|
|
cscf->file_name = cf->conf_file->file.name.data;
|
|
|
|
cscf->line = cf->conf_file->line;
|
|
|
|
|
2005-06-07 11:56:31 -04:00
|
|
|
return cscf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
|
2005-06-07 11:56:31 -04:00
|
|
|
{
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_core_srv_conf_t *prev = parent;
|
|
|
|
ngx_mail_core_srv_conf_t *conf = child;
|
2005-06-07 11:56:31 -04:00
|
|
|
|
|
|
|
ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000);
|
2008-02-13 10:50:04 -03:00
|
|
|
ngx_conf_merge_msec_value(conf->resolver_timeout, prev->resolver_timeout,
|
|
|
|
30000);
|
2007-09-14 09:58:49 -04:00
|
|
|
|
2005-12-07 11:51:31 -03:00
|
|
|
ngx_conf_merge_value(conf->so_keepalive, prev->so_keepalive, 0);
|
2005-06-07 11:56:31 -04:00
|
|
|
|
2006-10-23 10:10:10 -03:00
|
|
|
|
|
|
|
ngx_conf_merge_str_value(conf->server_name, prev->server_name, "");
|
|
|
|
|
|
|
|
if (conf->server_name.len == 0) {
|
|
|
|
conf->server_name.data = ngx_palloc(cf->pool, NGX_MAXHOSTNAMELEN);
|
|
|
|
if (conf->server_name.data == NULL) {
|
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gethostname((char *) conf->server_name.data, NGX_MAXHOSTNAMELEN)
|
|
|
|
== -1)
|
|
|
|
{
|
2007-09-15 12:51:16 -04:00
|
|
|
ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
|
|
|
|
"gethostname() failed");
|
2006-10-23 10:10:10 -03:00
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
conf->server_name.len = ngx_strlen(conf->server_name.data);
|
|
|
|
}
|
|
|
|
|
2007-09-15 12:51:16 -04:00
|
|
|
if (conf->protocol == NULL) {
|
|
|
|
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
|
|
|
"unknown mail protocol for server in %s:%ui",
|
|
|
|
conf->file_name, conf->line);
|
2007-03-19 09:36:56 -04:00
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
2008-02-13 10:50:04 -03:00
|
|
|
if (conf->resolver == NULL) {
|
|
|
|
conf->resolver = prev->resolver;
|
|
|
|
}
|
|
|
|
|
2005-06-07 11:56:31 -04:00
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
2005-06-07 11:56:31 -04:00
|
|
|
{
|
|
|
|
char *rv;
|
|
|
|
void *mconf;
|
|
|
|
ngx_uint_t m;
|
|
|
|
ngx_conf_t pcf;
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_module_t *module;
|
|
|
|
ngx_mail_conf_ctx_t *ctx, *mail_ctx;
|
|
|
|
ngx_mail_core_srv_conf_t *cscf, **cscfp;
|
|
|
|
ngx_mail_core_main_conf_t *cmcf;
|
2005-06-07 11:56:31 -04:00
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
ctx = ngx_pcalloc(cf->pool, sizeof(ngx_mail_conf_ctx_t));
|
2005-06-07 11:56:31 -04:00
|
|
|
if (ctx == NULL) {
|
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
mail_ctx = cf->ctx;
|
|
|
|
ctx->main_conf = mail_ctx->main_conf;
|
2005-11-15 10:30:52 -03:00
|
|
|
|
2005-06-07 11:56:31 -04:00
|
|
|
/* the server{}'s srv_conf */
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
ctx->srv_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_mail_max_module);
|
2005-06-07 11:56:31 -04:00
|
|
|
if (ctx->srv_conf == NULL) {
|
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (m = 0; ngx_modules[m]; m++) {
|
2007-03-19 09:36:56 -04:00
|
|
|
if (ngx_modules[m]->type != NGX_MAIL_MODULE) {
|
2005-06-07 11:56:31 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
module = ngx_modules[m]->ctx;
|
|
|
|
|
|
|
|
if (module->create_srv_conf) {
|
|
|
|
mconf = module->create_srv_conf(cf);
|
|
|
|
if (mconf == NULL) {
|
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->srv_conf[ngx_modules[m]->ctx_index] = mconf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the server configuration context */
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
cscf = ctx->srv_conf[ngx_mail_core_module.ctx_index];
|
2005-06-07 11:56:31 -04:00
|
|
|
cscf->ctx = ctx;
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
cmcf = ctx->main_conf[ngx_mail_core_module.ctx_index];
|
2005-06-07 11:56:31 -04:00
|
|
|
|
|
|
|
cscfp = ngx_array_push(&cmcf->servers);
|
|
|
|
if (cscfp == NULL) {
|
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
*cscfp = cscf;
|
|
|
|
|
|
|
|
|
|
|
|
/* parse inside server{} */
|
|
|
|
|
|
|
|
pcf = *cf;
|
|
|
|
cf->ctx = ctx;
|
2007-03-19 09:36:56 -04:00
|
|
|
cf->cmd_type = NGX_MAIL_SRV_CONF;
|
2005-06-07 11:56:31 -04:00
|
|
|
|
|
|
|
rv = ngx_conf_parse(cf, NULL);
|
|
|
|
|
|
|
|
*cf = pcf;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* AF_INET only */
|
|
|
|
|
|
|
|
static char *
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
2005-06-07 11:56:31 -04:00
|
|
|
{
|
2007-09-15 12:51:16 -04:00
|
|
|
ngx_mail_core_srv_conf_t *cscf = conf;
|
|
|
|
|
2006-04-26 05:52:47 -04:00
|
|
|
ngx_str_t *value;
|
2006-10-24 10:06:55 -03:00
|
|
|
ngx_url_t u;
|
2007-09-15 12:51:16 -04:00
|
|
|
ngx_uint_t i, m;
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_listen_t *imls;
|
2007-09-15 12:51:16 -04:00
|
|
|
ngx_mail_module_t *module;
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_mail_core_main_conf_t *cmcf;
|
2005-06-07 11:56:31 -04:00
|
|
|
|
|
|
|
value = cf->args->elts;
|
|
|
|
|
2006-10-24 10:06:55 -03:00
|
|
|
ngx_memzero(&u, sizeof(ngx_url_t));
|
2005-06-07 11:56:31 -04:00
|
|
|
|
2006-10-24 10:06:55 -03:00
|
|
|
u.url = value[1];
|
|
|
|
u.listen = 1;
|
2005-06-07 11:56:31 -04:00
|
|
|
|
2007-10-08 04:55:12 -04:00
|
|
|
if (ngx_parse_url(cf->pool, &u) != NGX_OK) {
|
2006-10-24 10:06:55 -03:00
|
|
|
if (u.err) {
|
|
|
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
|
|
"%s in \"%V\" of the \"listen\" directive",
|
|
|
|
u.err, &u.url);
|
2005-06-07 11:56:31 -04:00
|
|
|
}
|
|
|
|
|
2006-10-24 10:06:55 -03:00
|
|
|
return NGX_CONF_ERROR;
|
2005-06-07 11:56:31 -04:00
|
|
|
}
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
cmcf = ngx_mail_conf_get_module_main_conf(cf, ngx_mail_core_module);
|
2006-04-26 05:52:47 -04:00
|
|
|
|
|
|
|
imls = cmcf->listen.elts;
|
|
|
|
|
|
|
|
for (i = 0; i < cmcf->listen.nelts; i++) {
|
2005-06-07 11:56:31 -04:00
|
|
|
|
2006-12-12 13:46:16 -03:00
|
|
|
if (imls[i].addr != u.addr.in_addr || imls[i].port != u.port) {
|
2006-04-26 05:52:47 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
2006-10-24 10:06:55 -03:00
|
|
|
"duplicate \"%V\" address and port pair", &u.url);
|
2006-04-26 05:52:47 -04:00
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
imls = ngx_array_push(&cmcf->listen);
|
|
|
|
if (imls == NULL) {
|
2005-11-15 10:30:52 -03:00
|
|
|
return NGX_CONF_ERROR;
|
2005-06-07 11:56:31 -04:00
|
|
|
}
|
|
|
|
|
2007-03-19 09:36:56 -04:00
|
|
|
ngx_memzero(imls, sizeof(ngx_mail_listen_t));
|
2005-10-19 09:33:58 -03:00
|
|
|
|
2006-10-24 10:06:55 -03:00
|
|
|
imls->addr = u.addr.in_addr;
|
2006-12-12 13:46:16 -03:00
|
|
|
imls->port = u.port;
|
2006-04-26 05:52:47 -04:00
|
|
|
imls->family = AF_INET;
|
|
|
|
imls->ctx = cf->ctx;
|
2005-06-07 11:56:31 -04:00
|
|
|
|
2007-09-15 12:51:16 -04:00
|
|
|
for (m = 0; ngx_modules[m]; m++) {
|
|
|
|
if (ngx_modules[m]->type != NGX_MAIL_MODULE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
module = ngx_modules[m]->ctx;
|
|
|
|
|
|
|
|
if (module->protocol == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; module->protocol->port[i]; i++) {
|
|
|
|
if (module->protocol->port[i] == u.port) {
|
|
|
|
cscf->protocol = module->protocol;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-26 05:52:47 -04:00
|
|
|
if (cf->args->nelts == 2) {
|
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
2005-06-07 11:56:31 -04:00
|
|
|
|
2006-04-26 05:52:47 -04:00
|
|
|
if (ngx_strcmp(value[2].data, "bind") == 0) {
|
|
|
|
imls->bind = 1;
|
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
2005-06-07 11:56:31 -04:00
|
|
|
|
2006-04-26 05:52:47 -04:00
|
|
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
|
|
"the invalid \"%V\" parameter", &value[2]);
|
|
|
|
return NGX_CONF_ERROR;
|
2005-06-07 11:56:31 -04:00
|
|
|
}
|
2005-07-08 10:34:20 -04:00
|
|
|
|
|
|
|
|
|
|
|
static char *
|
2007-09-15 12:51:16 -04:00
|
|
|
ngx_mail_core_protocol(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
|
|
{
|
|
|
|
ngx_mail_core_srv_conf_t *cscf = conf;
|
|
|
|
|
|
|
|
ngx_str_t *value;
|
|
|
|
ngx_uint_t m;
|
|
|
|
ngx_mail_module_t *module;
|
|
|
|
|
|
|
|
value = cf->args->elts;
|
|
|
|
|
|
|
|
for (m = 0; ngx_modules[m]; m++) {
|
|
|
|
if (ngx_modules[m]->type != NGX_MAIL_MODULE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
module = ngx_modules[m]->ctx;
|
|
|
|
|
|
|
|
if (module->protocol
|
|
|
|
&& ngx_strcmp(module->protocol->name.data, value[1].data) == 0)
|
|
|
|
{
|
|
|
|
cscf->protocol = module->protocol;
|
|
|
|
|
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
|
|
"unknown protocol \"%V\"", &value[1]);
|
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-13 10:50:04 -03:00
|
|
|
static char *
|
|
|
|
ngx_mail_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
|
|
{
|
|
|
|
ngx_mail_core_srv_conf_t *cscf = conf;
|
|
|
|
|
|
|
|
ngx_url_t u;
|
|
|
|
ngx_str_t *value;
|
|
|
|
|
|
|
|
value = cf->args->elts;
|
|
|
|
|
|
|
|
ngx_memzero(&u, sizeof(ngx_url_t));
|
|
|
|
|
|
|
|
u.host = value[1];
|
|
|
|
u.port = 53;
|
|
|
|
|
|
|
|
if (ngx_inet_resolve_host(cf->pool, &u) != NGX_OK) {
|
|
|
|
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V: %s", &u.host, u.err);
|
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
cscf->resolver = ngx_resolver_create(&u.addrs[0], cf->cycle->new_log);
|
|
|
|
if (cscf->resolver == NULL) {
|
|
|
|
return NGX_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-15 12:51:16 -04:00
|
|
|
char *
|
|
|
|
ngx_mail_capabilities(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
2005-07-08 10:34:20 -04:00
|
|
|
{
|
|
|
|
char *p = conf;
|
|
|
|
|
|
|
|
ngx_str_t *c, *value;
|
|
|
|
ngx_uint_t i;
|
|
|
|
ngx_array_t *a;
|
|
|
|
|
|
|
|
a = (ngx_array_t *) (p + cmd->offset);
|
|
|
|
|
|
|
|
value = cf->args->elts;
|
|
|
|
|
|
|
|
for (i = 1; i < cf->args->nelts; i++) {
|
|
|
|
c = ngx_array_push(a);
|
|
|
|
if (c == NULL) {
|
|
|
|
return NGX_CONF_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
*c = value[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|