geoip 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -3
- data/Rakefile +1 -1
- data/geoip.gemspec +2 -2
- data/lib/geoip.rb +14 -10
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -85,9 +85,12 @@ This version Copyright (C) 2005 Clifford Heath
|
|
85
85
|
Derived from the C version, Copyright (C) 2003 MaxMind LLC
|
86
86
|
|
87
87
|
This library is free software; you can redistribute it and/or
|
88
|
-
modify it under the terms of the GNU General Public
|
89
|
-
|
90
|
-
|
88
|
+
modify it under the terms of the GNU Lesser General Public License,
|
89
|
+
as published by the Free Software Foundation; either version 2.1 of
|
90
|
+
the License, or (at your option) any later version. This follows the
|
91
|
+
license applied by Maxmind to their C library, for example in the
|
92
|
+
version here:
|
93
|
+
<http://www.maxmind.com/download/geoip/api/c/GeoIP-1.4.2.tar.gz>.
|
91
94
|
|
92
95
|
This library is distributed in the hope that it will be useful,
|
93
96
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
data/Rakefile
CHANGED
data/geoip.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "geoip"
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Clifford Heath", "Roland Moriz"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-12-18"
|
13
13
|
s.description = "GeoIP searches a GeoIP database for a given host or IP address, and\nreturns information about the country where the IP address is allocated,\nand the city, ISP and other information, if you have that database version."
|
14
14
|
s.email = ["clifford.heath@gmail.com", "rmoriz@gmail.com"]
|
15
15
|
s.executables = ["geoip"]
|
data/lib/geoip.rb
CHANGED
@@ -59,7 +59,7 @@ require 'yaml'
|
|
59
59
|
class GeoIP
|
60
60
|
|
61
61
|
# The GeoIP GEM version number
|
62
|
-
VERSION = "1.2.
|
62
|
+
VERSION = "1.2.1"
|
63
63
|
|
64
64
|
# The +data/+ directory for geoip
|
65
65
|
DATA_DIR = File.expand_path(File.join(File.dirname(__FILE__),'..','data','geoip'))
|
@@ -92,6 +92,7 @@ class GeoIP
|
|
92
92
|
GEOIP_PROXY_EDITION = 8
|
93
93
|
GEOIP_ASNUM_EDITION = 9
|
94
94
|
GEOIP_NETSPEED_EDITION = 10
|
95
|
+
GEOIP_COUNTRY_EDITION_V6 = 12
|
95
96
|
GEOIP_CITY_EDITION_REV1_V6 = 30
|
96
97
|
|
97
98
|
COUNTRY_BEGIN = 16776960 #:nodoc:
|
@@ -182,18 +183,20 @@ class GeoIP
|
|
182
183
|
return city(hostname)
|
183
184
|
end
|
184
185
|
|
185
|
-
|
186
|
-
|
187
|
-
@database_type
|
186
|
+
ip = lookup_ip(hostname)
|
187
|
+
if (@database_type == GEOIP_COUNTRY_EDITION ||
|
188
|
+
@database_type == GEOIP_PROXY_EDITION ||
|
189
|
+
@database_type == GEOIP_NETSPEED_EDITION)
|
190
|
+
# Convert numeric IP address to an integer
|
191
|
+
ipnum = iptonum(ip)
|
192
|
+
code = (seek_record(ipnum) - COUNTRY_BEGIN)
|
193
|
+
elsif @database_type == GEOIP_COUNTRY_EDITION_V6
|
194
|
+
ipaddr = IPAddr.new ip
|
195
|
+
code = (seek_record_v6(ipaddr.to_i) - COUNTRY_BEGIN)
|
196
|
+
else
|
188
197
|
throw "Invalid GeoIP database type, can't look up Country by IP"
|
189
198
|
end
|
190
199
|
|
191
|
-
ip = lookup_ip(hostname)
|
192
|
-
|
193
|
-
ipnum = iptonum(ip) # Convert numeric IP address to an integer
|
194
|
-
|
195
|
-
code = (seek_record(ipnum) - COUNTRY_BEGIN)
|
196
|
-
|
197
200
|
Country.new(
|
198
201
|
hostname, # Requested hostname
|
199
202
|
ip, # Ip address as dotted quad
|
@@ -393,6 +396,7 @@ class GeoIP
|
|
393
396
|
|
394
397
|
if (@database_type == GEOIP_COUNTRY_EDITION ||
|
395
398
|
@database_type == GEOIP_PROXY_EDITION ||
|
399
|
+
@database_type == GEOIP_COUNTRY_EDITION_V6 ||
|
396
400
|
@database_type == GEOIP_NETSPEED_EDITION)
|
397
401
|
@database_segments = [COUNTRY_BEGIN]
|
398
402
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-12-18 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: ! 'GeoIP searches a GeoIP database for a given host or IP address, and
|
16
16
|
|