Mercurial > hg > nginx-quic
comparison src/http/ngx_http_core_module.c @ 4225:016352c19049
Support of several servers in the "resolver" directive.
Patch by Kirill A. Korinskiy.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 24 Oct 2011 16:09:05 +0000 |
parents | c8f6248566aa |
children | 4c45306936bb |
comparison
equal
deleted
inserted
replaced
4224:4c4997de65b8 | 4225:016352c19049 |
---|---|
716 NGX_HTTP_LOC_CONF_OFFSET, | 716 NGX_HTTP_LOC_CONF_OFFSET, |
717 offsetof(ngx_http_core_loc_conf_t, open_file_cache_events), | 717 offsetof(ngx_http_core_loc_conf_t, open_file_cache_events), |
718 NULL }, | 718 NULL }, |
719 | 719 |
720 { ngx_string("resolver"), | 720 { ngx_string("resolver"), |
721 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 721 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
722 ngx_http_core_resolver, | 722 ngx_http_core_resolver, |
723 NGX_HTTP_LOC_CONF_OFFSET, | 723 NGX_HTTP_LOC_CONF_OFFSET, |
724 0, | 724 0, |
725 NULL }, | 725 NULL }, |
726 | 726 |
3533 /* | 3533 /* |
3534 * create dummy resolver in http {} context | 3534 * create dummy resolver in http {} context |
3535 * to inherit it in all servers | 3535 * to inherit it in all servers |
3536 */ | 3536 */ |
3537 | 3537 |
3538 prev->resolver = ngx_resolver_create(cf, NULL); | 3538 prev->resolver = ngx_resolver_create(cf, NULL, 0); |
3539 if (prev->resolver == NULL) { | 3539 if (prev->resolver == NULL) { |
3540 return NGX_CONF_ERROR; | 3540 return NGX_CONF_ERROR; |
3541 } | 3541 } |
3542 } | 3542 } |
3543 | 3543 |
4538 static char * | 4538 static char * |
4539 ngx_http_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 4539 ngx_http_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
4540 { | 4540 { |
4541 ngx_http_core_loc_conf_t *clcf = conf; | 4541 ngx_http_core_loc_conf_t *clcf = conf; |
4542 | 4542 |
4543 ngx_url_t u; | |
4544 ngx_str_t *value; | 4543 ngx_str_t *value; |
4545 | 4544 |
4546 if (clcf->resolver) { | 4545 if (clcf->resolver) { |
4547 return "is duplicate"; | 4546 return "is duplicate"; |
4548 } | 4547 } |
4549 | 4548 |
4550 value = cf->args->elts; | 4549 value = cf->args->elts; |
4551 | 4550 |
4552 ngx_memzero(&u, sizeof(ngx_url_t)); | 4551 clcf->resolver = ngx_resolver_create(cf, &value[1], cf->args->nelts - 1); |
4553 | 4552 if (clcf->resolver == NULL) { |
4554 u.host = value[1]; | |
4555 u.port = 53; | |
4556 | |
4557 if (ngx_inet_resolve_host(cf->pool, &u) != NGX_OK) { | |
4558 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V: %s", &u.host, u.err); | |
4559 return NGX_CONF_ERROR; | 4553 return NGX_CONF_ERROR; |
4560 } | |
4561 | |
4562 clcf->resolver = ngx_resolver_create(cf, &u.addrs[0]); | |
4563 if (clcf->resolver == NULL) { | |
4564 return NGX_OK; | |
4565 } | 4554 } |
4566 | 4555 |
4567 return NGX_CONF_OK; | 4556 return NGX_CONF_OK; |
4568 } | 4557 } |
4569 | 4558 |