Mercurial > hg > nginx
diff src/http/modules/ngx_http_geo_module.c @ 489:45a460f82aec release-0.1.19
nginx-0.1.19-RELEASE import
*) Bugfix: now, if request contains the zero, then the 404 error is
returned for the local requests.
*) Bugfix: nginx could not be built on NetBSD 2.0.
*) Bugfix: the timeout may occur while reading of the the client
request body via SSL connections.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 16 Feb 2005 13:40:36 +0000 |
parents | 31ff3e943e16 |
children | d4ea69372b94 |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_geo_module.c +++ b/src/http/modules/ngx_http_geo_module.c @@ -10,9 +10,9 @@ typedef struct { - ngx_radix_tree_t *tree; - ngx_pool_t *pool; - ngx_array_t values; + ngx_radix_tree_t *tree; + ngx_pool_t *pool; + ngx_array_t values; } ngx_http_geo_conf_t; @@ -63,21 +63,31 @@ static ngx_http_variable_value_t ngx_ht /* AF_INET only */ -static ngx_http_variable_value_t *ngx_http_geo_variable(ngx_http_request_t *r, - void *data) +static ngx_http_variable_value_t * +ngx_http_geo_variable(ngx_http_request_t *r, void *data) { ngx_radix_tree_t *tree = data; - struct sockaddr_in *sin; + struct sockaddr_in *sin; + ngx_http_variable_value_t *var; sin = (struct sockaddr_in *) r->connection->sockaddr; - return (ngx_http_variable_value_t *) + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http geo started"); + + var = (ngx_http_variable_value_t *) ngx_radix32tree_find(tree, ntohl(sin->sin_addr.s_addr)); + + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http geo: %V %V", &r->connection->addr_text, &var->text); + + return var; } -static char *ngx_http_geo_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) +static char * +ngx_http_geo_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { char *rv; ngx_str_t *value; @@ -91,7 +101,7 @@ static char *ngx_http_geo_block(ngx_conf return NGX_CONF_ERROR; } - if (!(tree = ngx_radix_tree_create(cf->pool, 8))) { + if (!(tree = ngx_radix_tree_create(cf->pool, -1))) { return NGX_CONF_ERROR; } @@ -148,7 +158,8 @@ static char *ngx_http_geo_block(ngx_conf /* AF_INET only */ -static char *ngx_http_geo(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) +static char * +ngx_http_geo(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) { ngx_int_t rc, n; ngx_uint_t i;