telize

High performance JSON IP and GeoIP REST API (IP Geolocation)
Log | Files | Refs | README | LICENSE

commit 24659c18dd404e4897db52d3a1161b6f9176dd53
parent 889f7b28fc3f3efbddd6d26e470ffbb52d8bcc8d
Author: Yann VERRY <yann@verry.org>
Date:   Wed,  9 Apr 2014 16:22:24 +0200

add offset feature

Diffstat:
Agen_tz-offset.rb | 22++++++++++++++++++++++
Mtelize | 3++-
Mtelize_x-forwarded-for | 3++-
Mtimezone.conf | 417+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 443 insertions(+), 2 deletions(-)

diff --git a/gen_tz-offset.rb b/gen_tz-offset.rb @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby +# 2014 - Yann Verry +# Generate nginx offset timezone +# +# gem required: tzinfo +# +require 'tzinfo' + +# open file +tz_hdl = File.new('tz_offset.conf','w') +# header +tz_hdl.write("map $geoip_timezone $geoip_timezone_offset {\n") + +TZInfo::Timezone.all_country_zone_identifiers.each do |tzname| + tz = TZInfo::Timezone.get(tzname) + current = tz.current_period + offset = current.utc_total_offset / 3600 + tz_hdl.write("\t\"" + tzname.to_s + '" "' + offset.to_s + "\";\n") +end + +# footer +tz_hdl.write("}\n") diff --git a/telize b/telize @@ -44,7 +44,7 @@ server { location /localize { set_real_ip_from 127.0.0.1; - echo_exec /jsonify ip=$remote_addr&country_code=$geoip_city_country_code&country_code3=$geoip_city_country_code3&country=$geoip_city_country_name&region_code=$geoip_region&region=$geoip_region_name&city=$geoip_city&postal_code=$geoip_postal_code&continent_code=$geoip_city_continent_code&latitude=$geoip_latitude&longitude=$geoip_longitude&dma_code=$geoip_dma_code&area_code=$geoip_area_code&org=$geoip_org&timezone=$geoip_timezone&callback=$arg_callback; + echo_exec /jsonify ip=$remote_addr&country_code=$geoip_city_country_code&country_code3=$geoip_city_country_code3&country=$geoip_city_country_name&region_code=$geoip_region&region=$geoip_region_name&city=$geoip_city&postal_code=$geoip_postal_code&continent_code=$geoip_city_continent_code&latitude=$geoip_latitude&longitude=$geoip_longitude&dma_code=$geoip_dma_code&area_code=$geoip_area_code&org=$geoip_org&timezone=$geoip_timezone&offset=$geoip_timezone_offset&callback=$arg_callback; } location /jsonify { @@ -78,6 +78,7 @@ server { dma_code = ngx.var.arg_dma_code, area_code = ngx.var.arg_area_code, timezone = ngx.var.arg_timezone, + offset = ngx.var.arg_offset, asn = ngx.var.asn, isp = ngx.var.isp } diff --git a/telize_x-forwarded-for b/telize_x-forwarded-for @@ -49,7 +49,7 @@ server { location /localize { set_real_ip_from 127.0.0.1; - echo_exec /jsonify ip=$remote_addr&country_code=$geoip_city_country_code&country_code3=$geoip_city_country_code3&country=$geoip_city_country_name&region_code=$geoip_region&region=$geoip_region_name&city=$geoip_city&postal_code=$geoip_postal_code&continent_code=$geoip_city_continent_code&latitude=$geoip_latitude&longitude=$geoip_longitude&dma_code=$geoip_dma_code&area_code=$geoip_area_code&org=$geoip_org&timezone=$geoip_timezone&callback=$arg_callback; + echo_exec /jsonify ip=$remote_addr&country_code=$geoip_city_country_code&country_code3=$geoip_city_country_code3&country=$geoip_city_country_name&region_code=$geoip_region&region=$geoip_region_name&city=$geoip_city&postal_code=$geoip_postal_code&continent_code=$geoip_city_continent_code&latitude=$geoip_latitude&longitude=$geoip_longitude&dma_code=$geoip_dma_code&area_code=$geoip_area_code&org=$geoip_org&timezone=$geoip_timezone&offset=$geoip_timezone_offset&callback=$arg_callback; } location /jsonify { @@ -83,6 +83,7 @@ server { dma_code = ngx.var.arg_dma_code, area_code = ngx.var.arg_area_code, timezone = ngx.var.arg_timezone, + offset = ngx.var.arg_offset, asn = ngx.var.asn, isp = ngx.var.isp } diff --git a/timezone.conf b/timezone.conf @@ -716,3 +716,420 @@ map $geoip_city_country_code$geoip_region $geoip_timezone { ~ZM "Africa/Lusaka"; ~ZW "Africa/Harare"; } +map $geoip_timezone $geoip_timezone_offset { + "Europe/Andorra" "2"; + "Asia/Dubai" "4"; + "Asia/Kabul" "4"; + "America/Antigua" "-4"; + "America/Anguilla" "-4"; + "Europe/Tirane" "2"; + "Asia/Yerevan" "4"; + "Africa/Luanda" "1"; + "Antarctica/McMurdo" "12"; + "Antarctica/Rothera" "-3"; + "Antarctica/Palmer" "-3"; + "Antarctica/Mawson" "5"; + "Antarctica/Davis" "7"; + "Antarctica/Casey" "8"; + "Antarctica/Vostok" "6"; + "Antarctica/DumontDUrville" "10"; + "Antarctica/Syowa" "3"; + "America/Argentina/Buenos_Aires" "-3"; + "America/Argentina/Cordoba" "-3"; + "America/Argentina/Salta" "-3"; + "America/Argentina/Jujuy" "-3"; + "America/Argentina/Tucuman" "-3"; + "America/Argentina/Catamarca" "-3"; + "America/Argentina/La_Rioja" "-3"; + "America/Argentina/San_Juan" "-3"; + "America/Argentina/Mendoza" "-3"; + "America/Argentina/San_Luis" "-3"; + "America/Argentina/Rio_Gallegos" "-3"; + "America/Argentina/Ushuaia" "-3"; + "Pacific/Pago_Pago" "-11"; + "Europe/Vienna" "2"; + "Australia/Lord_Howe" "10"; + "Antarctica/Macquarie" "11"; + "Australia/Hobart" "10"; + "Australia/Currie" "10"; + "Australia/Melbourne" "10"; + "Australia/Sydney" "10"; + "Australia/Broken_Hill" "9"; + "Australia/Brisbane" "10"; + "Australia/Lindeman" "10"; + "Australia/Adelaide" "9"; + "Australia/Darwin" "9"; + "Australia/Perth" "8"; + "Australia/Eucla" "8"; + "America/Aruba" "-4"; + "Europe/Mariehamn" "3"; + "Asia/Baku" "5"; + "Europe/Sarajevo" "2"; + "America/Barbados" "-4"; + "Asia/Dhaka" "6"; + "Europe/Brussels" "2"; + "Africa/Ouagadougou" "0"; + "Europe/Sofia" "3"; + "Asia/Bahrain" "3"; + "Africa/Bujumbura" "2"; + "Africa/Porto-Novo" "1"; + "America/St_Barthelemy" "-4"; + "Atlantic/Bermuda" "-3"; + "Asia/Brunei" "8"; + "America/La_Paz" "-4"; + "America/Kralendijk" "-4"; + "America/Noronha" "-2"; + "America/Belem" "-3"; + "America/Fortaleza" "-3"; + "America/Recife" "-3"; + "America/Araguaina" "-3"; + "America/Maceio" "-3"; + "America/Bahia" "-3"; + "America/Sao_Paulo" "-3"; + "America/Campo_Grande" "-4"; + "America/Cuiaba" "-4"; + "America/Santarem" "-3"; + "America/Porto_Velho" "-4"; + "America/Boa_Vista" "-4"; + "America/Manaus" "-4"; + "America/Eirunepe" "-5"; + "America/Rio_Branco" "-5"; + "America/Nassau" "-4"; + "Asia/Thimphu" "6"; + "Africa/Gaborone" "2"; + "Europe/Minsk" "3"; + "America/Belize" "-6"; + "America/St_Johns" "-3"; + "America/Halifax" "-3"; + "America/Glace_Bay" "-3"; + "America/Moncton" "-3"; + "America/Goose_Bay" "-3"; + "America/Blanc-Sablon" "-4"; + "America/Toronto" "-4"; + "America/Nipigon" "-4"; + "America/Thunder_Bay" "-4"; + "America/Iqaluit" "-4"; + "America/Pangnirtung" "-4"; + "America/Resolute" "-5"; + "America/Atikokan" "-5"; + "America/Rankin_Inlet" "-5"; + "America/Winnipeg" "-5"; + "America/Rainy_River" "-5"; + "America/Regina" "-6"; + "America/Swift_Current" "-6"; + "America/Edmonton" "-6"; + "America/Cambridge_Bay" "-6"; + "America/Yellowknife" "-6"; + "America/Inuvik" "-6"; + "America/Creston" "-7"; + "America/Dawson_Creek" "-7"; + "America/Vancouver" "-7"; + "America/Whitehorse" "-7"; + "America/Dawson" "-7"; + "Indian/Cocos" "6"; + "Africa/Kinshasa" "1"; + "Africa/Lubumbashi" "2"; + "Africa/Bangui" "1"; + "Africa/Brazzaville" "1"; + "Europe/Zurich" "2"; + "Africa/Abidjan" "0"; + "Pacific/Rarotonga" "-10"; + "America/Santiago" "-3"; + "Pacific/Easter" "-5"; + "Africa/Douala" "1"; + "Asia/Shanghai" "8"; + "Asia/Harbin" "8"; + "Asia/Chongqing" "8"; + "Asia/Urumqi" "8"; + "Asia/Kashgar" "8"; + "America/Bogota" "-5"; + "America/Costa_Rica" "-6"; + "America/Havana" "-4"; + "Atlantic/Cape_Verde" "-1"; + "America/Curacao" "-4"; + "Indian/Christmas" "7"; + "Asia/Nicosia" "3"; + "Europe/Prague" "2"; + "Europe/Berlin" "2"; + "Europe/Busingen" "2"; + "Africa/Djibouti" "3"; + "Europe/Copenhagen" "2"; + "America/Dominica" "-4"; + "America/Santo_Domingo" "-4"; + "Africa/Algiers" "1"; + "America/Guayaquil" "-5"; + "Pacific/Galapagos" "-6"; + "Europe/Tallinn" "3"; + "Africa/Cairo" "2"; + "Africa/El_Aaiun" "1"; + "Africa/Asmara" "3"; + "Europe/Madrid" "2"; + "Africa/Ceuta" "2"; + "Atlantic/Canary" "1"; + "Africa/Addis_Ababa" "3"; + "Europe/Helsinki" "3"; + "Pacific/Fiji" "12"; + "Atlantic/Stanley" "-3"; + "Pacific/Chuuk" "10"; + "Pacific/Pohnpei" "11"; + "Pacific/Kosrae" "11"; + "Atlantic/Faroe" "1"; + "Europe/Paris" "2"; + "Africa/Libreville" "1"; + "Europe/London" "1"; + "America/Grenada" "-4"; + "Asia/Tbilisi" "4"; + "America/Cayenne" "-3"; + "Europe/Guernsey" "1"; + "Africa/Accra" "0"; + "Europe/Gibraltar" "2"; + "America/Godthab" "-2"; + "America/Danmarkshavn" "0"; + "America/Scoresbysund" "0"; + "America/Thule" "-3"; + "Africa/Banjul" "0"; + "Africa/Conakry" "0"; + "America/Guadeloupe" "-4"; + "Africa/Malabo" "1"; + "Europe/Athens" "3"; + "Atlantic/South_Georgia" "-2"; + "America/Guatemala" "-6"; + "Pacific/Guam" "10"; + "Africa/Bissau" "0"; + "America/Guyana" "-4"; + "Asia/Hong_Kong" "8"; + "America/Tegucigalpa" "-6"; + "Europe/Zagreb" "2"; + "America/Port-au-Prince" "-4"; + "Europe/Budapest" "2"; + "Asia/Jakarta" "7"; + "Asia/Pontianak" "7"; + "Asia/Makassar" "8"; + "Asia/Jayapura" "9"; + "Europe/Dublin" "1"; + "Asia/Jerusalem" "3"; + "Europe/Isle_of_Man" "1"; + "Asia/Kolkata" "5"; + "Indian/Chagos" "6"; + "Asia/Baghdad" "3"; + "Asia/Tehran" "4"; + "Atlantic/Reykjavik" "0"; + "Europe/Rome" "2"; + "Europe/Jersey" "1"; + "America/Jamaica" "-5"; + "Asia/Amman" "3"; + "Asia/Tokyo" "9"; + "Africa/Nairobi" "3"; + "Asia/Bishkek" "6"; + "Asia/Phnom_Penh" "7"; + "Pacific/Tarawa" "12"; + "Pacific/Enderbury" "13"; + "Pacific/Kiritimati" "14"; + "Indian/Comoro" "3"; + "America/St_Kitts" "-4"; + "Asia/Pyongyang" "9"; + "Asia/Seoul" "9"; + "Asia/Kuwait" "3"; + "America/Cayman" "-5"; + "Asia/Almaty" "6"; + "Asia/Qyzylorda" "6"; + "Asia/Aqtobe" "5"; + "Asia/Aqtau" "5"; + "Asia/Oral" "5"; + "Asia/Vientiane" "7"; + "Asia/Beirut" "3"; + "America/St_Lucia" "-4"; + "Europe/Vaduz" "2"; + "Asia/Colombo" "5"; + "Africa/Monrovia" "0"; + "Africa/Maseru" "2"; + "Europe/Vilnius" "3"; + "Europe/Luxembourg" "2"; + "Europe/Riga" "3"; + "Africa/Tripoli" "2"; + "Africa/Casablanca" "1"; + "Europe/Monaco" "2"; + "Europe/Chisinau" "3"; + "Europe/Podgorica" "2"; + "America/Marigot" "-4"; + "Indian/Antananarivo" "3"; + "Pacific/Majuro" "12"; + "Pacific/Kwajalein" "12"; + "Europe/Skopje" "2"; + "Africa/Bamako" "0"; + "Asia/Rangoon" "6"; + "Asia/Ulaanbaatar" "8"; + "Asia/Hovd" "7"; + "Asia/Choibalsan" "8"; + "Asia/Macau" "8"; + "Pacific/Saipan" "10"; + "America/Martinique" "-4"; + "Africa/Nouakchott" "0"; + "America/Montserrat" "-4"; + "Europe/Malta" "2"; + "Indian/Mauritius" "4"; + "Indian/Maldives" "5"; + "Africa/Blantyre" "2"; + "America/Mexico_City" "-5"; + "America/Cancun" "-5"; + "America/Merida" "-5"; + "America/Monterrey" "-5"; + "America/Matamoros" "-5"; + "America/Mazatlan" "-6"; + "America/Chihuahua" "-6"; + "America/Ojinaga" "-6"; + "America/Hermosillo" "-7"; + "America/Tijuana" "-7"; + "America/Santa_Isabel" "-7"; + "America/Bahia_Banderas" "-5"; + "Asia/Kuala_Lumpur" "8"; + "Asia/Kuching" "8"; + "Africa/Maputo" "2"; + "Africa/Windhoek" "1"; + "Pacific/Noumea" "11"; + "Africa/Niamey" "1"; + "Pacific/Norfolk" "11"; + "Africa/Lagos" "1"; + "America/Managua" "-6"; + "Europe/Amsterdam" "2"; + "Europe/Oslo" "2"; + "Asia/Kathmandu" "5"; + "Pacific/Nauru" "12"; + "Pacific/Niue" "-11"; + "Pacific/Auckland" "12"; + "Pacific/Chatham" "12"; + "Asia/Muscat" "4"; + "America/Panama" "-5"; + "America/Lima" "-5"; + "Pacific/Tahiti" "-10"; + "Pacific/Marquesas" "-10"; + "Pacific/Gambier" "-9"; + "Pacific/Port_Moresby" "10"; + "Asia/Manila" "8"; + "Asia/Karachi" "5"; + "Europe/Warsaw" "2"; + "America/Miquelon" "-2"; + "Pacific/Pitcairn" "-8"; + "America/Puerto_Rico" "-4"; + "Asia/Gaza" "3"; + "Asia/Hebron" "3"; + "Europe/Lisbon" "1"; + "Atlantic/Madeira" "1"; + "Atlantic/Azores" "0"; + "Pacific/Palau" "9"; + "America/Asuncion" "-4"; + "Asia/Qatar" "3"; + "Indian/Reunion" "4"; + "Europe/Bucharest" "3"; + "Europe/Belgrade" "2"; + "Europe/Kaliningrad" "3"; + "Europe/Moscow" "4"; + "Europe/Volgograd" "4"; + "Europe/Samara" "4"; + "Asia/Yekaterinburg" "6"; + "Asia/Omsk" "7"; + "Asia/Novosibirsk" "7"; + "Asia/Novokuznetsk" "7"; + "Asia/Krasnoyarsk" "8"; + "Asia/Irkutsk" "9"; + "Asia/Yakutsk" "10"; + "Asia/Khandyga" "10"; + "Asia/Vladivostok" "11"; + "Asia/Sakhalin" "11"; + "Asia/Ust-Nera" "11"; + "Asia/Magadan" "12"; + "Asia/Kamchatka" "12"; + "Asia/Anadyr" "12"; + "Africa/Kigali" "2"; + "Asia/Riyadh" "3"; + "Pacific/Guadalcanal" "11"; + "Indian/Mahe" "4"; + "Africa/Khartoum" "3"; + "Europe/Stockholm" "2"; + "Asia/Singapore" "8"; + "Atlantic/St_Helena" "0"; + "Europe/Ljubljana" "2"; + "Arctic/Longyearbyen" "2"; + "Europe/Bratislava" "2"; + "Africa/Freetown" "0"; + "Europe/San_Marino" "2"; + "Africa/Dakar" "0"; + "Africa/Mogadishu" "3"; + "America/Paramaribo" "-3"; + "Africa/Juba" "3"; + "Africa/Sao_Tome" "0"; + "America/El_Salvador" "-6"; + "America/Lower_Princes" "-4"; + "Asia/Damascus" "3"; + "Africa/Mbabane" "2"; + "America/Grand_Turk" "-4"; + "Africa/Ndjamena" "1"; + "Indian/Kerguelen" "5"; + "Africa/Lome" "0"; + "Asia/Bangkok" "7"; + "Asia/Dushanbe" "5"; + "Pacific/Fakaofo" "13"; + "Asia/Dili" "9"; + "Asia/Ashgabat" "5"; + "Africa/Tunis" "1"; + "Pacific/Tongatapu" "13"; + "Europe/Istanbul" "3"; + "America/Port_of_Spain" "-4"; + "Pacific/Funafuti" "12"; + "Asia/Taipei" "8"; + "Africa/Dar_es_Salaam" "3"; + "Europe/Kiev" "3"; + "Europe/Uzhgorod" "3"; + "Europe/Zaporozhye" "3"; + "Europe/Simferopol" "3"; + "Africa/Kampala" "3"; + "Pacific/Johnston" "-10"; + "Pacific/Midway" "-11"; + "Pacific/Wake" "12"; + "America/New_York" "-4"; + "America/Detroit" "-4"; + "America/Kentucky/Louisville" "-4"; + "America/Kentucky/Monticello" "-4"; + "America/Indiana/Indianapolis" "-4"; + "America/Indiana/Vincennes" "-4"; + "America/Indiana/Winamac" "-4"; + "America/Indiana/Marengo" "-4"; + "America/Indiana/Petersburg" "-4"; + "America/Indiana/Vevay" "-4"; + "America/Chicago" "-5"; + "America/Indiana/Tell_City" "-5"; + "America/Indiana/Knox" "-5"; + "America/Menominee" "-5"; + "America/North_Dakota/Center" "-5"; + "America/North_Dakota/New_Salem" "-5"; + "America/North_Dakota/Beulah" "-5"; + "America/Denver" "-6"; + "America/Boise" "-6"; + "America/Phoenix" "-7"; + "America/Los_Angeles" "-7"; + "America/Anchorage" "-8"; + "America/Juneau" "-8"; + "America/Sitka" "-8"; + "America/Yakutat" "-8"; + "America/Nome" "-8"; + "America/Adak" "-9"; + "America/Metlakatla" "-8"; + "Pacific/Honolulu" "-10"; + "America/Montevideo" "-3"; + "Asia/Samarkand" "5"; + "Asia/Tashkent" "5"; + "Europe/Vatican" "2"; + "America/St_Vincent" "-4"; + "America/Caracas" "-5"; + "America/Tortola" "-4"; + "America/St_Thomas" "-4"; + "Asia/Ho_Chi_Minh" "7"; + "Pacific/Efate" "11"; + "Pacific/Wallis" "12"; + "Pacific/Apia" "13"; + "Asia/Aden" "3"; + "Indian/Mayotte" "3"; + "Africa/Johannesburg" "2"; + "Africa/Lusaka" "2"; + "Africa/Harare" "2"; +}