Mercurial > hg > nginx-vendor-1-0
comparison src/http/modules/ngx_http_geoip_module.c @ 592:09d5f308901f NGINX_0_8_48
nginx 0.8.48
*) Change: now the "server_name" directive default value is an empty
name "".
Thanks to Gena Makhomed.
*) Change: now the "server_name_in_redirect" directive default value is
"off".
*) Feature: the $geoip_dma_code, $geoip_area_code, and
$geoip_region_name variables.
Thanks to Christine McGonagle.
*) Bugfix: the "proxy_pass", "fastcgi_pass", "uwsgi_pass", and
"scgi_pass" directives were not inherited inside "limit_except"
blocks.
*) Bugfix: the "proxy_cache_min_uses", "fastcgi_cache_min_uses"
"uwsgi_cache_min_uses", and "scgi_cache_min_uses" directives did not
work; the bug had appeared in 0.8.46.
*) Bugfix: the "fastcgi_split_path_info" directive used incorrectly
captures, if only parts of an URI were captured.
Thanks to Yuriy Taraday and Frank Enderle.
*) Bugfix: the "rewrite" directive did not escape a ";" character
during copying from URI to query string.
Thanks to Daisuke Murase.
*) Bugfix: the ngx_http_image_filter_module closed a connection, if an
image was larger than "image_filter_buffer" size.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 03 Aug 2010 00:00:00 +0400 |
parents | 2da4537168f8 |
children | 3436cf38d59e |
comparison
equal
deleted
inserted
replaced
591:8b891ad58d6a | 592:09d5f308901f |
---|---|
28 | 28 |
29 static ngx_int_t ngx_http_geoip_country_variable(ngx_http_request_t *r, | 29 static ngx_int_t ngx_http_geoip_country_variable(ngx_http_request_t *r, |
30 ngx_http_variable_value_t *v, uintptr_t data); | 30 ngx_http_variable_value_t *v, uintptr_t data); |
31 static ngx_int_t ngx_http_geoip_city_variable(ngx_http_request_t *r, | 31 static ngx_int_t ngx_http_geoip_city_variable(ngx_http_request_t *r, |
32 ngx_http_variable_value_t *v, uintptr_t data); | 32 ngx_http_variable_value_t *v, uintptr_t data); |
33 static ngx_int_t ngx_http_geoip_region_name_variable(ngx_http_request_t *r, | |
34 ngx_http_variable_value_t *v, uintptr_t data); | |
33 static ngx_int_t ngx_http_geoip_city_float_variable(ngx_http_request_t *r, | 35 static ngx_int_t ngx_http_geoip_city_float_variable(ngx_http_request_t *r, |
36 ngx_http_variable_value_t *v, uintptr_t data); | |
37 static ngx_int_t ngx_http_geoip_city_int_variable(ngx_http_request_t *r, | |
34 ngx_http_variable_value_t *v, uintptr_t data); | 38 ngx_http_variable_value_t *v, uintptr_t data); |
35 static GeoIPRecord *ngx_http_geoip_get_city_record(ngx_http_request_t *r); | 39 static GeoIPRecord *ngx_http_geoip_get_city_record(ngx_http_request_t *r); |
36 | 40 |
37 static ngx_int_t ngx_http_geoip_add_variables(ngx_conf_t *cf); | 41 static ngx_int_t ngx_http_geoip_add_variables(ngx_conf_t *cf); |
38 static void *ngx_http_geoip_create_conf(ngx_conf_t *cf); | 42 static void *ngx_http_geoip_create_conf(ngx_conf_t *cf); |
126 | 130 |
127 { ngx_string("geoip_region"), NULL, | 131 { ngx_string("geoip_region"), NULL, |
128 ngx_http_geoip_city_variable, | 132 ngx_http_geoip_city_variable, |
129 offsetof(GeoIPRecord, region), 0, 0 }, | 133 offsetof(GeoIPRecord, region), 0, 0 }, |
130 | 134 |
135 { ngx_string("geoip_region_name"), NULL, | |
136 ngx_http_geoip_region_name_variable, | |
137 0, 0, 0 }, | |
138 | |
131 { ngx_string("geoip_city"), NULL, | 139 { ngx_string("geoip_city"), NULL, |
132 ngx_http_geoip_city_variable, | 140 ngx_http_geoip_city_variable, |
133 offsetof(GeoIPRecord, city), 0, 0 }, | 141 offsetof(GeoIPRecord, city), 0, 0 }, |
134 | 142 |
135 { ngx_string("geoip_postal_code"), NULL, | 143 { ngx_string("geoip_postal_code"), NULL, |
141 offsetof(GeoIPRecord, latitude), 0, 0 }, | 149 offsetof(GeoIPRecord, latitude), 0, 0 }, |
142 | 150 |
143 { ngx_string("geoip_longitude"), NULL, | 151 { ngx_string("geoip_longitude"), NULL, |
144 ngx_http_geoip_city_float_variable, | 152 ngx_http_geoip_city_float_variable, |
145 offsetof(GeoIPRecord, longitude), 0, 0 }, | 153 offsetof(GeoIPRecord, longitude), 0, 0 }, |
154 | |
155 { ngx_string("geoip_dma_code"), NULL, | |
156 ngx_http_geoip_city_int_variable, | |
157 offsetof(GeoIPRecord, dma_code), 0, 0 }, | |
158 | |
159 { ngx_string("geoip_area_code"), NULL, | |
160 ngx_http_geoip_city_int_variable, | |
161 offsetof(GeoIPRecord, area_code), 0, 0 }, | |
146 | 162 |
147 { ngx_null_string, NULL, NULL, 0, 0, 0 } | 163 { ngx_null_string, NULL, NULL, 0, 0, 0 } |
148 }; | 164 }; |
149 | 165 |
150 | 166 |
243 return NGX_OK; | 259 return NGX_OK; |
244 } | 260 } |
245 | 261 |
246 | 262 |
247 static ngx_int_t | 263 static ngx_int_t |
264 ngx_http_geoip_region_name_variable(ngx_http_request_t *r, | |
265 ngx_http_variable_value_t *v, uintptr_t data) | |
266 { | |
267 size_t len; | |
268 const char *val; | |
269 GeoIPRecord *gr; | |
270 | |
271 gr = ngx_http_geoip_get_city_record(r); | |
272 if (gr == NULL) { | |
273 goto not_found; | |
274 } | |
275 | |
276 val = GeoIP_region_name_by_code(gr->country_code, gr->region); | |
277 | |
278 len = ngx_strlen(val); | |
279 v->data = ngx_pnalloc(r->pool, len); | |
280 | |
281 if (v->data == NULL) { | |
282 GeoIPRecord_delete(gr); | |
283 return NGX_ERROR; | |
284 } | |
285 | |
286 ngx_memcpy(v->data, val, len); | |
287 | |
288 v->len = len; | |
289 v->valid = 1; | |
290 v->no_cacheable = 0; | |
291 v->not_found = 0; | |
292 | |
293 GeoIPRecord_delete(gr); | |
294 | |
295 return NGX_OK; | |
296 | |
297 not_found: | |
298 | |
299 v->not_found = 1; | |
300 | |
301 return NGX_OK; | |
302 } | |
303 | |
304 | |
305 static ngx_int_t | |
248 ngx_http_geoip_city_float_variable(ngx_http_request_t *r, | 306 ngx_http_geoip_city_float_variable(ngx_http_request_t *r, |
249 ngx_http_variable_value_t *v, uintptr_t data) | 307 ngx_http_variable_value_t *v, uintptr_t data) |
250 { | 308 { |
251 float val; | 309 float val; |
252 GeoIPRecord *gr; | 310 GeoIPRecord *gr; |
264 } | 322 } |
265 | 323 |
266 val = *(float *) ((char *) gr + data); | 324 val = *(float *) ((char *) gr + data); |
267 | 325 |
268 v->len = ngx_sprintf(v->data, "%.4f", val) - v->data; | 326 v->len = ngx_sprintf(v->data, "%.4f", val) - v->data; |
327 | |
328 GeoIPRecord_delete(gr); | |
329 | |
330 return NGX_OK; | |
331 } | |
332 | |
333 | |
334 static ngx_int_t | |
335 ngx_http_geoip_city_int_variable(ngx_http_request_t *r, | |
336 ngx_http_variable_value_t *v, uintptr_t data) | |
337 { | |
338 int val; | |
339 GeoIPRecord *gr; | |
340 | |
341 gr = ngx_http_geoip_get_city_record(r); | |
342 if (gr == NULL) { | |
343 v->not_found = 1; | |
344 return NGX_OK; | |
345 } | |
346 | |
347 v->data = ngx_pnalloc(r->pool, NGX_INT64_LEN); | |
348 if (v->data == NULL) { | |
349 GeoIPRecord_delete(gr); | |
350 return NGX_ERROR; | |
351 } | |
352 | |
353 val = *(int *) ((char *) gr + data); | |
354 | |
355 v->len = ngx_sprintf(v->data, "%d", val) - v->data; | |
269 | 356 |
270 GeoIPRecord_delete(gr); | 357 GeoIPRecord_delete(gr); |
271 | 358 |
272 return NGX_OK; | 359 return NGX_OK; |
273 } | 360 } |