summaryrefslogtreecommitdiff
path: root/src/http/ngx_http.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-06-14 05:42:04 +0000
committerJonathan Kolb <jon@b0g.us>2007-06-14 05:42:04 +0000
commit65a46859ed997403f7911e0ec29e219876f2a842 (patch)
treed2f0aeda6a73a6d26dd74953475f9b30c2d65ad7 /src/http/ngx_http.c
parent0f2b18e48893729d4d4b261c139b5bbbdbd09506 (diff)
downloadnginx-65a46859ed997403f7911e0ec29e219876f2a842.tar.gz
Changes with nginx 0.6.0 14 Jun 2007v0.6.0
*) Feature: the "server_name", "map", and "valid_referers" directives supports the "www.example.*" wildcards.
Diffstat (limited to 'src/http/ngx_http.c')
-rw-r--r--src/http/ngx_http.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index c6bc6c581..5823a2b91 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -73,7 +73,6 @@ static char *
ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
char *rv;
- u_char ch;
ngx_int_t rc, j;
ngx_uint_t mi, m, s, l, p, a, i, n;
ngx_uint_t find_config_index, use_rewrite, use_access;
@@ -648,40 +647,20 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
name = in_addr[a].names.elts;
- for (s = 0; s < in_addr[a].names.nelts; s++) {
-
- ch = name[s].name.data[0];
- if (ch == '*' || ch == '.') {
- continue;
- }
+ for (s = 0; s < in_addr[a].names.nelts; s++) {
rc = ngx_hash_add_key(&ha, &name[s].name, name[s].core_srv_conf,
- 0);
+ NGX_HASH_WILDCARD_KEY);
if (rc == NGX_ERROR) {
return NGX_CONF_ERROR;
}
- if (rc == NGX_BUSY) {
- ngx_log_error(NGX_LOG_WARN, cf->log, 0,
- "conflicting server name \"%V\" on %s, ignored",
+ if (rc == NGX_DECLINED) {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "invalid server name or wildcard \"%V\" on %s",
&name[s].name, in_addr[a].listen_conf->addr);
- }
- }
-
- for (s = 0; s < in_addr[a].names.nelts; s++) {
-
- ch = name[s].name.data[0];
-
- if (ch != '*' && ch != '.') {
- continue;
- }
-
- rc = ngx_hash_add_key(&ha, &name[s].name, name[s].core_srv_conf,
- NGX_HASH_WILDCARD_KEY);
-
- if (rc == NGX_ERROR) {
return NGX_CONF_ERROR;
}
@@ -709,25 +688,46 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
}
- if (ha.dns_wildcards.nelts) {
+ if (ha.dns_wc_head.nelts) {
+
+ ngx_qsort(ha.dns_wc_head.elts,
+ (size_t) ha.dns_wc_head.nelts,
+ sizeof(ngx_hash_key_t),
+ ngx_http_cmp_dns_wildcards);
+
+ hash.hash = NULL;
+ hash.temp_pool = ha.temp_pool;
+
+ if (ngx_hash_wildcard_init(&hash, ha.dns_wc_head.elts,
+ ha.dns_wc_head.nelts)
+ != NGX_OK)
+ {
+ ngx_destroy_pool(ha.temp_pool);
+ return NGX_CONF_ERROR;
+ }
+
+ in_addr[a].wc_head = (ngx_hash_wildcard_t *) hash.hash;
+ }
+
+ if (ha.dns_wc_tail.nelts) {
- ngx_qsort(ha.dns_wildcards.elts,
- (size_t) ha.dns_wildcards.nelts,
+ ngx_qsort(ha.dns_wc_tail.elts,
+ (size_t) ha.dns_wc_tail.nelts,
sizeof(ngx_hash_key_t),
ngx_http_cmp_dns_wildcards);
hash.hash = NULL;
hash.temp_pool = ha.temp_pool;
- if (ngx_hash_wildcard_init(&hash, ha.dns_wildcards.elts,
- ha.dns_wildcards.nelts)
+ if (ngx_hash_wildcard_init(&hash, ha.dns_wc_tail.elts,
+ ha.dns_wc_tail.nelts)
!= NGX_OK)
{
ngx_destroy_pool(ha.temp_pool);
return NGX_CONF_ERROR;
}
- in_addr[a].dns_wildcards = (ngx_hash_wildcard_t *) hash.hash;
+ in_addr[a].wc_tail = (ngx_hash_wildcard_t *) hash.hash;
}
ngx_destroy_pool(ha.temp_pool);
@@ -848,8 +848,10 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
hip->addrs[i].core_srv_conf = in_addr[i].core_srv_conf;
if (in_addr[i].hash.buckets == NULL
- && (in_addr[i].dns_wildcards == NULL
- || in_addr[i].dns_wildcards->hash.buckets == NULL))
+ && (in_addr[i].wc_head == NULL
+ || in_addr[i].wc_head->hash.buckets == NULL)
+ && (in_addr[i].wc_head == NULL
+ || in_addr[i].wc_head->hash.buckets == NULL))
{
continue;
}
@@ -861,7 +863,8 @@ ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
hip->addrs[i].virtual_names = vn;
vn->hash = in_addr[i].hash;
- vn->dns_wildcards = in_addr[i].dns_wildcards;
+ vn->wc_head = in_addr[i].wc_head;
+ vn->wc_tail = in_addr[i].wc_tail;
}
if (done) {
@@ -934,7 +937,8 @@ ngx_http_add_address(ngx_conf_t *cf, ngx_http_conf_in_port_t *in_port,
in_addr->addr = lscf->addr;
in_addr->hash.buckets = NULL;
in_addr->hash.size = 0;
- in_addr->dns_wildcards = NULL;
+ in_addr->wc_head = NULL;
+ in_addr->wc_tail = NULL;
in_addr->names.elts = NULL;
in_addr->core_srv_conf = cscf;
in_addr->default_server = lscf->conf.default_server;