comparison src/http/modules/ngx_http_geoip_module.c @ 676:bfa81a0490a2 NGINX_1_3_1

nginx 1.3.1 *) Security: now nginx/Windows ignores trailing dot in URI path component, and does not allow URIs with ":$" in it. Thanks to Vladimir Kochetkov, Positive Research Center. *) Feature: the "proxy_pass", "fastcgi_pass", "scgi_pass", "uwsgi_pass" directives, and the "server" directive inside the "upstream" block, now support IPv6 addresses. *) Feature: the "resolver" directive now support IPv6 addresses and an optional port specification. *) Feature: the "least_conn" directive inside the "upstream" block. *) Feature: it is now possible to specify a weight for servers while using the "ip_hash" directive. *) Bugfix: a segmentation fault might occur in a worker process if the "image_filter" directive was used; the bug had appeared in 1.3.0. *) Bugfix: nginx could not be built with ngx_cpp_test_module; the bug had appeared in 1.1.12. *) Bugfix: access to variables from SSI and embedded perl module might not work after reconfiguration. Thanks to Yichun Zhang. *) Bugfix: in the ngx_http_xslt_filter_module. Thanks to Kuramoto Eiji. *) Bugfix: memory leak if $geoip_org variable was used. Thanks to Denis F. Latypoff. *) Bugfix: in the "proxy_cookie_domain" and "proxy_cookie_path" directives.
author Igor Sysoev <http://sysoev.ru>
date Tue, 05 Jun 2012 00:00:00 +0400
parents 4dcaf40cc702
children 2e8a942c8872
comparison
equal deleted inserted replaced
675:7052a9379344 676:bfa81a0490a2
26 ngx_str_t *name; 26 ngx_str_t *name;
27 uintptr_t data; 27 uintptr_t data;
28 } ngx_http_geoip_var_t; 28 } ngx_http_geoip_var_t;
29 29
30 30
31 typedef const char *(*ngx_http_geoip_variable_handler_pt)(GeoIP *, u_long addr); 31 typedef char *(*ngx_http_geoip_variable_handler_pt)(GeoIP *, u_long addr);
32 32
33 static u_long ngx_http_geoip_addr(ngx_http_request_t *r, 33 static u_long ngx_http_geoip_addr(ngx_http_request_t *r,
34 ngx_http_geoip_conf_t *gcf); 34 ngx_http_geoip_conf_t *gcf);
35 static ngx_int_t ngx_http_geoip_country_variable(ngx_http_request_t *r, 35 static ngx_int_t ngx_http_geoip_country_variable(ngx_http_request_t *r,
36 ngx_http_variable_value_t *v, uintptr_t data); 36 ngx_http_variable_value_t *v, uintptr_t data);
289 ngx_http_variable_value_t *v, uintptr_t data) 289 ngx_http_variable_value_t *v, uintptr_t data)
290 { 290 {
291 ngx_http_geoip_variable_handler_pt handler = 291 ngx_http_geoip_variable_handler_pt handler =
292 (ngx_http_geoip_variable_handler_pt) data; 292 (ngx_http_geoip_variable_handler_pt) data;
293 293
294 const char *val; 294 size_t len;
295 char *val;
295 ngx_http_geoip_conf_t *gcf; 296 ngx_http_geoip_conf_t *gcf;
296 297
297 gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module); 298 gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module);
298 299
299 if (gcf->org == NULL) { 300 if (gcf->org == NULL) {
304 305
305 if (val == NULL) { 306 if (val == NULL) {
306 goto not_found; 307 goto not_found;
307 } 308 }
308 309
309 v->len = ngx_strlen(val); 310 len = ngx_strlen(val);
311 v->data = ngx_pnalloc(r->pool, len);
312 if (v->data == NULL) {
313 ngx_free(val);
314 return NGX_ERROR;
315 }
316
317 ngx_memcpy(v->data, val, len);
318
319 v->len = len;
310 v->valid = 1; 320 v->valid = 1;
311 v->no_cacheable = 0; 321 v->no_cacheable = 0;
312 v->not_found = 0; 322 v->not_found = 0;
313 v->data = (u_char *) val; 323
324 ngx_free(val);
314 325
315 return NGX_OK; 326 return NGX_OK;
316 327
317 not_found: 328 not_found:
318 329