annotate contrib/geo2nginx.pl @ 506:b9fdcaf2062b NGINX_0_7_65

nginx 0.7.65 *) Security: now nginx/Windows ignores trailing spaces in URI. Thanks to Dan Crowley, Core Security Technologies. *) Security: now nginx/Windows ignores short files names. Thanks to Dan Crowley, Core Security Technologies. *) Change: now the "009" status code is written to an access log for proxied HTTP/0.9 responses. *) Change: now the default buffer size of the "large_client_header_buffers" directive is 8K. Thanks to Andrew Cholakian. *) Change: now default SSL ciphers are "HIGH:!ADH:!MD5". *) Change: now SSLv2 protocol is disabled by default. *) Change: now $host variable value is always low case. *) Feature: the conf/fastcgi.conf for simple FastCGI configurations. *) Feature: now URI part is not required a "proxy_pass" directive if variables are used. *) Feature: the $ssl_session_id variable. *) Bugfix: if a proxied or FastCGI request was internally redirected to another proxied or FastCGI location, then $upstream_response_time variable may have abnormally large value; the bug had appeared in 0.7.63. *) Bugfix: if the "expires modified" set date in the past, then a negative number was set in the "Cache-Control" response header line. Thanks to Alex Kapranoff. *) Bugfix: nginx closed a connection if a cached response had an empty body. Thanks to Piotr Sikora. *) Bugfix: nginx cached a 304 response if there was the "If-None-Match" header line in a proxied request. Thanks to Tim Dettrick and David Kostal. *) Bugfix: nginx did not treat a comma as separator in the "Cache-Control" backend response header line. *) Bugfix: cached HTTP/0.9 responses were handled incorrectly. *) Bugfix: nginx sent gzipped responses to clients those do not support gzip, if "gzip_static on" and "gzip_vary off"; the bug had appeared in 0.8.16. *) Bugfix: nginx always added "Content-Encoding: gzip" response header line in 304 responses sent by ngx_http_gzip_static_module. *) Bugfix: the "!-x" operator did not work. Thanks to Maxim Dounin. *) Bugfix: a segmentation fault might occur in a worker process, if limit_rate was used in HTTPS server. Thanks to Maxim Dounin. *) Bugfix: a segmentation fault might occur in a worker process while $limit_rate logging. Thanks to Maxim Dounin. *) Bugfix: nginx did not support dates in 2038 year on 32-bit platforms; *) Bugfix: nginx/Windows tried to delete a temporary file twice if the file should replace an already existent file. *) Bugfix: nginx/Windows tried to rename a temporary file twice if the file should replace an already existent file. *) Bugfix: nginx/Windows might not create temporary file, a cache file, or "proxy/fastcgi_store"d file if a worker had no enough access rights for top level directories. *) Bugfix: in UTF-8 encoding support by "try_files" directive in nginx/Windows. *) Bugfix: UTF-8 encoding usage in the ngx_http_autoindex_module. Thanks to Maxim Dounin. *) Bugfix: the ngx_http_autoindex_module did not show the trailing slash in links to a directory; the bug had appeared in 0.7.15. *) Bugfix: nginx did not close a log file set by the --error-log-path configuration option; the bug had appeared in 0.7.53. *) Bugfix: "addition_types" directive was incorrectly named "addtion_types". *) Bugfix: invalid request line in $request variable was written in access_log only if error_log was set to "info" or "debug" level.
author Igor Sysoev <http://sysoev.ru>
date Mon, 01 Feb 2010 00:00:00 +0000
parents 962c43960644
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
86
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1 #!/usr/bin/perl -w
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
2
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
3 # (c) Andrei Nigmatulin, 2005
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
4 #
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
5 # this script provided "as is", without any warranties. use it at your own risk.
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
6 #
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
7 # special thanx to Andrew Sitnikov for perl port
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
8 #
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
9 # this script converts CSV geoip database (free download at http://www.maxmind.com/app/geoip_country)
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
10 # to format, suitable for use with nginx_http_geo module (http://sysoev.ru/nginx)
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
11 #
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
12 # for example, line with ip range
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
13 #
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
14 # "62.16.68.0","62.16.127.255","1041253376","1041268735","RU","Russian Federation"
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
15 #
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
16 # will be converted to four subnetworks:
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
17 #
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
18 # 62.16.68.0/22 RU;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
19 # 62.16.72.0/21 RU;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
20 # 62.16.80.0/20 RU;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
21 # 62.16.96.0/19 RU;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
22
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
23
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
24 use warnings;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
25 use strict;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
26
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
27 while( <STDIN> ){
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
28 if (/"[^"]+","[^"]+","([^"]+)","([^"]+)","([^"]+)"/){
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
29 print_subnets($1, $2, $3);
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
30 }
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
31 }
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
32
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
33 sub print_subnets {
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
34 my ($a1, $a2, $c) = @_;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
35 my $l;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
36 while ($a1 <= $a2) {
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
37 for ($l = 0; ($a1 & (1 << $l)) == 0 && ($a1 + ((1 << ($l + 1)) - 1)) <= $a2; $l++){};
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
38 print long2ip($a1) . "/" . (32 - $l) . " " . $c . ";\n";
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
39 $a1 += (1 << $l);
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
40 }
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
41 }
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
42
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
43 sub long2ip {
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
44 my $ip = shift;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
45
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
46 my $str = 0;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
47
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
48 $str = ($ip & 255);
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
49
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
50 $ip >>= 8;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
51 $str = ($ip & 255).".$str";
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
52
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
53 $ip >>= 8;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
54 $str = ($ip & 255).".$str";
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
55
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
56 $ip >>= 8;
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
57 $str = ($ip & 255).".$str";
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
58 }