diff options
author | Igor Sysoev <igor@sysoev.ru> | 2005-02-16 13:40:36 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2005-02-16 13:40:36 +0000 |
commit | 1ebfead9da0596e8e84231f7ea8ba25a650a4d1e (patch) | |
tree | 15e18d104477e04ffb5fcb31b3fb43f20dcfe996 /src/http/modules/ngx_http_geo_module.c | |
parent | 675cc5a855cec4acaae2937cb832c424e4d3bacf (diff) | |
download | nginx-release-0.1.19.tar.gz nginx-release-0.1.19.zip |
nginx-0.1.19-RELEASE importrelease-0.1.19
*) 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.
Diffstat (limited to 'src/http/modules/ngx_http_geo_module.c')
-rw-r--r-- | src/http/modules/ngx_http_geo_module.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c index 7d17f03ca..0d8267d8e 100644 --- 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_http_geo_null_value = /* 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_t *cf, ngx_command_t *cmd, void *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_t *cf, ngx_command_t *cmd, void *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; |