geoip 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{History.txt → History.rdoc} +0 -0
- data/Rakefile +50 -16
- data/bin/geoip +23 -0
- data/config/website.yml +2 -0
- data/data/geoip/country_code.yml +255 -0
- data/data/geoip/country_code3.yml +255 -0
- data/data/geoip/country_continent.yml +255 -0
- data/data/geoip/country_name.yml +255 -0
- data/data/geoip/time_zone.yml +677 -0
- data/geoip.gemspec +65 -0
- data/lib/geoip.rb +475 -1001
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +67 -0
- data/website/index.txt +79 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +31 -50
- data/Manifest.txt +0 -7
File without changes
|
data/Rakefile
CHANGED
@@ -1,23 +1,57 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
|
3
|
-
|
4
|
-
require '
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
require 'jeweler'
|
5
5
|
require './lib/geoip'
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
9
|
+
gem.name = "geoip"
|
10
|
+
gem.version = GeoIP::VERSION
|
11
|
+
gem.homepage = "http://github.com/cjheath/geoip"
|
12
|
+
gem.license = "MIT"
|
13
|
+
gem.summary = %Q{GeoIP searches a GeoIP database for a given host or IP address, and returns information about the country where the IP address is allocated, and the city, ISP and other information, if you have that database version.}
|
14
|
+
gem.description = %Q{GeoIP searches a GeoIP database for a given host or IP address, and
|
15
|
+
returns information about the country where the IP address is allocated,
|
16
|
+
and the city, ISP and other information, if you have that database version.}
|
17
|
+
gem.email = %w[clifford.heath@gmail.com rmoriz@gmail.com]
|
18
|
+
gem.authors = ["Clifford Heath", "Roland Moriz"]
|
19
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
20
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
21
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
22
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
23
|
+
end
|
24
|
+
Jeweler::RubygemsDotOrgTasks.new
|
25
|
+
|
26
|
+
require 'rake/testtask'
|
27
|
+
Rake::TestTask.new(:test) do |test|
|
28
|
+
test.libs << 'lib' << 'test'
|
29
|
+
test.pattern = 'test/**/test_*.rb'
|
30
|
+
test.verbose = true
|
31
|
+
end
|
32
|
+
task :default => :test
|
9
33
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
34
|
+
require 'rake/rdoctask'
|
35
|
+
Rake::RDocTask.new do |rdoc|
|
36
|
+
rdoc.rdoc_dir = 'rdoc'
|
37
|
+
rdoc.title = "geoip #{GeoIP::VERSION}"
|
38
|
+
rdoc.rdoc_files.include('README.rdoc')
|
39
|
+
rdoc.rdoc_files.include('History.rdoc')
|
40
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
16
41
|
end
|
17
42
|
|
18
|
-
|
19
|
-
|
43
|
+
desc 'Generate website files'
|
44
|
+
task :website_generate do
|
45
|
+
sh %q{ruby script/txt2html website/index.txt > website/index.html}
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'Upload website files via rsync'
|
49
|
+
task :website_upload do
|
50
|
+
local_dir = 'website'
|
51
|
+
website_config = YAML.load(File.read("config/website.yml"))
|
52
|
+
host = website_config["host"]
|
53
|
+
host = host ? "#{host}:" : ""
|
54
|
+
remote_dir = website_config["remote_dir"]
|
55
|
+
sh %{rsync -aCv #{local_dir}/ #{host}#{remote_dir}}
|
56
|
+
end
|
20
57
|
|
21
|
-
# TODO - want other tests/tasks run by default? Add them to the list
|
22
|
-
# remove_task :default
|
23
|
-
# task :default => [:spec, :features]
|
data/bin/geoip
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__),'..','lib'))
|
4
|
+
$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
|
5
|
+
|
6
|
+
require 'geoip'
|
7
|
+
|
8
|
+
data = '/usr/share/GeoIP/GeoIP.dat'
|
9
|
+
data = ARGV.shift if ARGV[0] =~ /\.dat\Z/
|
10
|
+
|
11
|
+
geoip = GeoIP.new data
|
12
|
+
req = ([GeoIP::GEOIP_CITY_EDITION_REV1, GeoIP::GEOIP_CITY_EDITION_REV0].include?(geoip.databaseType)) ? :city : :country
|
13
|
+
|
14
|
+
if ARGV.size > 0
|
15
|
+
ARGV.each { |a| p geoip.send(req, a) }
|
16
|
+
else
|
17
|
+
while (STDIN.isatty && print('geoip> '); ip = gets)
|
18
|
+
ip.chomp!
|
19
|
+
result = geoip.send(req, ip)
|
20
|
+
p result
|
21
|
+
end
|
22
|
+
STDIN.isatty && puts
|
23
|
+
end
|
data/config/website.yml
ADDED
@@ -0,0 +1,255 @@
|
|
1
|
+
# Ordered list of the ISO3166 2-character country codes, ordered by GeoIP ID
|
2
|
+
---
|
3
|
+
- --
|
4
|
+
- AP
|
5
|
+
- EU
|
6
|
+
- AD
|
7
|
+
- AE
|
8
|
+
- AF
|
9
|
+
- AG
|
10
|
+
- AI
|
11
|
+
- AL
|
12
|
+
- AM
|
13
|
+
- AN
|
14
|
+
- AO
|
15
|
+
- AQ
|
16
|
+
- AR
|
17
|
+
- AS
|
18
|
+
- AT
|
19
|
+
- AU
|
20
|
+
- AW
|
21
|
+
- AZ
|
22
|
+
- BA
|
23
|
+
- BB
|
24
|
+
- BD
|
25
|
+
- BE
|
26
|
+
- BF
|
27
|
+
- BG
|
28
|
+
- BH
|
29
|
+
- BI
|
30
|
+
- BJ
|
31
|
+
- BM
|
32
|
+
- BN
|
33
|
+
- BO
|
34
|
+
- BR
|
35
|
+
- BS
|
36
|
+
- BT
|
37
|
+
- BV
|
38
|
+
- BW
|
39
|
+
- BY
|
40
|
+
- BZ
|
41
|
+
- CA
|
42
|
+
- CC
|
43
|
+
- CD
|
44
|
+
- CF
|
45
|
+
- CG
|
46
|
+
- CH
|
47
|
+
- CI
|
48
|
+
- CK
|
49
|
+
- CL
|
50
|
+
- CM
|
51
|
+
- CN
|
52
|
+
- CO
|
53
|
+
- CR
|
54
|
+
- CU
|
55
|
+
- CV
|
56
|
+
- CX
|
57
|
+
- CY
|
58
|
+
- CZ
|
59
|
+
- DE
|
60
|
+
- DJ
|
61
|
+
- DK
|
62
|
+
- DM
|
63
|
+
- DO
|
64
|
+
- DZ
|
65
|
+
- EC
|
66
|
+
- EE
|
67
|
+
- EG
|
68
|
+
- EH
|
69
|
+
- ER
|
70
|
+
- ES
|
71
|
+
- ET
|
72
|
+
- FI
|
73
|
+
- FJ
|
74
|
+
- FK
|
75
|
+
- FM
|
76
|
+
- FO
|
77
|
+
- FR
|
78
|
+
- FX
|
79
|
+
- GA
|
80
|
+
- GB
|
81
|
+
- GD
|
82
|
+
- GE
|
83
|
+
- GF
|
84
|
+
- GH
|
85
|
+
- GI
|
86
|
+
- GL
|
87
|
+
- GM
|
88
|
+
- GN
|
89
|
+
- GP
|
90
|
+
- GQ
|
91
|
+
- GR
|
92
|
+
- GS
|
93
|
+
- GT
|
94
|
+
- GU
|
95
|
+
- GW
|
96
|
+
- GY
|
97
|
+
- HK
|
98
|
+
- HM
|
99
|
+
- HN
|
100
|
+
- HR
|
101
|
+
- HT
|
102
|
+
- HU
|
103
|
+
- ID
|
104
|
+
- IE
|
105
|
+
- IL
|
106
|
+
- IN
|
107
|
+
- IO
|
108
|
+
- IQ
|
109
|
+
- IR
|
110
|
+
- IS
|
111
|
+
- IT
|
112
|
+
- JM
|
113
|
+
- JO
|
114
|
+
- JP
|
115
|
+
- KE
|
116
|
+
- KG
|
117
|
+
- KH
|
118
|
+
- KI
|
119
|
+
- KM
|
120
|
+
- KN
|
121
|
+
- KP
|
122
|
+
- KR
|
123
|
+
- KW
|
124
|
+
- KY
|
125
|
+
- KZ
|
126
|
+
- LA
|
127
|
+
- LB
|
128
|
+
- LC
|
129
|
+
- LI
|
130
|
+
- LK
|
131
|
+
- LR
|
132
|
+
- LS
|
133
|
+
- LT
|
134
|
+
- LU
|
135
|
+
- LV
|
136
|
+
- LY
|
137
|
+
- MA
|
138
|
+
- MC
|
139
|
+
- MD
|
140
|
+
- MG
|
141
|
+
- MH
|
142
|
+
- MK
|
143
|
+
- ML
|
144
|
+
- MM
|
145
|
+
- MN
|
146
|
+
- MO
|
147
|
+
- MP
|
148
|
+
- MQ
|
149
|
+
- MR
|
150
|
+
- MS
|
151
|
+
- MT
|
152
|
+
- MU
|
153
|
+
- MV
|
154
|
+
- MW
|
155
|
+
- MX
|
156
|
+
- MY
|
157
|
+
- MZ
|
158
|
+
- NA
|
159
|
+
- NC
|
160
|
+
- NE
|
161
|
+
- NF
|
162
|
+
- NG
|
163
|
+
- NI
|
164
|
+
- NL
|
165
|
+
- "NO"
|
166
|
+
- NP
|
167
|
+
- NR
|
168
|
+
- NU
|
169
|
+
- NZ
|
170
|
+
- OM
|
171
|
+
- PA
|
172
|
+
- PE
|
173
|
+
- PF
|
174
|
+
- PG
|
175
|
+
- PH
|
176
|
+
- PK
|
177
|
+
- PL
|
178
|
+
- PM
|
179
|
+
- PN
|
180
|
+
- PR
|
181
|
+
- PS
|
182
|
+
- PT
|
183
|
+
- PW
|
184
|
+
- PY
|
185
|
+
- QA
|
186
|
+
- RE
|
187
|
+
- RO
|
188
|
+
- RU
|
189
|
+
- RW
|
190
|
+
- SA
|
191
|
+
- SB
|
192
|
+
- SC
|
193
|
+
- SD
|
194
|
+
- SE
|
195
|
+
- SG
|
196
|
+
- SH
|
197
|
+
- SI
|
198
|
+
- SJ
|
199
|
+
- SK
|
200
|
+
- SL
|
201
|
+
- SM
|
202
|
+
- SN
|
203
|
+
- SO
|
204
|
+
- SR
|
205
|
+
- ST
|
206
|
+
- SV
|
207
|
+
- SY
|
208
|
+
- SZ
|
209
|
+
- TC
|
210
|
+
- TD
|
211
|
+
- TF
|
212
|
+
- TG
|
213
|
+
- TH
|
214
|
+
- TJ
|
215
|
+
- TK
|
216
|
+
- TM
|
217
|
+
- TN
|
218
|
+
- TO
|
219
|
+
- TL
|
220
|
+
- TR
|
221
|
+
- TT
|
222
|
+
- TV
|
223
|
+
- TW
|
224
|
+
- TZ
|
225
|
+
- UA
|
226
|
+
- UG
|
227
|
+
- UM
|
228
|
+
- US
|
229
|
+
- UY
|
230
|
+
- UZ
|
231
|
+
- VA
|
232
|
+
- VC
|
233
|
+
- VE
|
234
|
+
- VG
|
235
|
+
- VI
|
236
|
+
- VN
|
237
|
+
- VU
|
238
|
+
- WF
|
239
|
+
- WS
|
240
|
+
- YE
|
241
|
+
- YT
|
242
|
+
- RS
|
243
|
+
- ZA
|
244
|
+
- ZM
|
245
|
+
- ME
|
246
|
+
- ZW
|
247
|
+
- A1
|
248
|
+
- A2
|
249
|
+
- O1
|
250
|
+
- AX
|
251
|
+
- GG
|
252
|
+
- IM
|
253
|
+
- JE
|
254
|
+
- BL
|
255
|
+
- MF
|
@@ -0,0 +1,255 @@
|
|
1
|
+
# Ordered list of the ISO3166 3-character country codes, ordered by GeoIP ID
|
2
|
+
---
|
3
|
+
- --
|
4
|
+
- AP
|
5
|
+
- EU
|
6
|
+
- AND
|
7
|
+
- ARE
|
8
|
+
- AFG
|
9
|
+
- ATG
|
10
|
+
- AIA
|
11
|
+
- ALB
|
12
|
+
- ARM
|
13
|
+
- ANT
|
14
|
+
- AGO
|
15
|
+
- AQ
|
16
|
+
- ARG
|
17
|
+
- ASM
|
18
|
+
- AUT
|
19
|
+
- AUS
|
20
|
+
- ABW
|
21
|
+
- AZE
|
22
|
+
- BIH
|
23
|
+
- BRB
|
24
|
+
- BGD
|
25
|
+
- BEL
|
26
|
+
- BFA
|
27
|
+
- BGR
|
28
|
+
- BHR
|
29
|
+
- BDI
|
30
|
+
- BEN
|
31
|
+
- BMU
|
32
|
+
- BRN
|
33
|
+
- BOL
|
34
|
+
- BRA
|
35
|
+
- BHS
|
36
|
+
- BTN
|
37
|
+
- BV
|
38
|
+
- BWA
|
39
|
+
- BLR
|
40
|
+
- BLZ
|
41
|
+
- CAN
|
42
|
+
- CC
|
43
|
+
- COD
|
44
|
+
- CAF
|
45
|
+
- COG
|
46
|
+
- CHE
|
47
|
+
- CIV
|
48
|
+
- COK
|
49
|
+
- CHL
|
50
|
+
- CMR
|
51
|
+
- CHN
|
52
|
+
- COL
|
53
|
+
- CRI
|
54
|
+
- CUB
|
55
|
+
- CPV
|
56
|
+
- CX
|
57
|
+
- CYP
|
58
|
+
- CZE
|
59
|
+
- DEU
|
60
|
+
- DJI
|
61
|
+
- DNK
|
62
|
+
- DMA
|
63
|
+
- DOM
|
64
|
+
- DZA
|
65
|
+
- ECU
|
66
|
+
- EST
|
67
|
+
- EGY
|
68
|
+
- ESH
|
69
|
+
- ERI
|
70
|
+
- ESP
|
71
|
+
- ETH
|
72
|
+
- FIN
|
73
|
+
- FJI
|
74
|
+
- FLK
|
75
|
+
- FSM
|
76
|
+
- FRO
|
77
|
+
- FRA
|
78
|
+
- FX
|
79
|
+
- GAB
|
80
|
+
- GBR
|
81
|
+
- GRD
|
82
|
+
- GEO
|
83
|
+
- GUF
|
84
|
+
- GHA
|
85
|
+
- GIB
|
86
|
+
- GRL
|
87
|
+
- GMB
|
88
|
+
- GIN
|
89
|
+
- GLP
|
90
|
+
- GNQ
|
91
|
+
- GRC
|
92
|
+
- GS
|
93
|
+
- GTM
|
94
|
+
- GUM
|
95
|
+
- GNB
|
96
|
+
- GUY
|
97
|
+
- HKG
|
98
|
+
- HM
|
99
|
+
- HND
|
100
|
+
- HRV
|
101
|
+
- HTI
|
102
|
+
- HUN
|
103
|
+
- IDN
|
104
|
+
- IRL
|
105
|
+
- ISR
|
106
|
+
- IND
|
107
|
+
- IO
|
108
|
+
- IRQ
|
109
|
+
- IRN
|
110
|
+
- ISL
|
111
|
+
- ITA
|
112
|
+
- JAM
|
113
|
+
- JOR
|
114
|
+
- JPN
|
115
|
+
- KEN
|
116
|
+
- KGZ
|
117
|
+
- KHM
|
118
|
+
- KIR
|
119
|
+
- COM
|
120
|
+
- KNA
|
121
|
+
- PRK
|
122
|
+
- KOR
|
123
|
+
- KWT
|
124
|
+
- CYM
|
125
|
+
- KAZ
|
126
|
+
- LAO
|
127
|
+
- LBN
|
128
|
+
- LCA
|
129
|
+
- LIE
|
130
|
+
- LKA
|
131
|
+
- LBR
|
132
|
+
- LSO
|
133
|
+
- LTU
|
134
|
+
- LUX
|
135
|
+
- LVA
|
136
|
+
- LBY
|
137
|
+
- MAR
|
138
|
+
- MCO
|
139
|
+
- MDA
|
140
|
+
- MDG
|
141
|
+
- MHL
|
142
|
+
- MKD
|
143
|
+
- MLI
|
144
|
+
- MMR
|
145
|
+
- MNG
|
146
|
+
- MAC
|
147
|
+
- MNP
|
148
|
+
- MTQ
|
149
|
+
- MRT
|
150
|
+
- MSR
|
151
|
+
- MLT
|
152
|
+
- MUS
|
153
|
+
- MDV
|
154
|
+
- MWI
|
155
|
+
- MEX
|
156
|
+
- MYS
|
157
|
+
- MOZ
|
158
|
+
- NAM
|
159
|
+
- NCL
|
160
|
+
- NER
|
161
|
+
- NFK
|
162
|
+
- NGA
|
163
|
+
- NIC
|
164
|
+
- NLD
|
165
|
+
- NOR
|
166
|
+
- NPL
|
167
|
+
- NRU
|
168
|
+
- NIU
|
169
|
+
- NZL
|
170
|
+
- OMN
|
171
|
+
- PAN
|
172
|
+
- PER
|
173
|
+
- PYF
|
174
|
+
- PNG
|
175
|
+
- PHL
|
176
|
+
- PAK
|
177
|
+
- POL
|
178
|
+
- SPM
|
179
|
+
- PCN
|
180
|
+
- PRI
|
181
|
+
- PSE
|
182
|
+
- PRT
|
183
|
+
- PLW
|
184
|
+
- PRY
|
185
|
+
- QAT
|
186
|
+
- REU
|
187
|
+
- ROU
|
188
|
+
- RUS
|
189
|
+
- RWA
|
190
|
+
- SAU
|
191
|
+
- SLB
|
192
|
+
- SYC
|
193
|
+
- SDN
|
194
|
+
- SWE
|
195
|
+
- SGP
|
196
|
+
- SHN
|
197
|
+
- SVN
|
198
|
+
- SJM
|
199
|
+
- SVK
|
200
|
+
- SLE
|
201
|
+
- SMR
|
202
|
+
- SEN
|
203
|
+
- SOM
|
204
|
+
- SUR
|
205
|
+
- STP
|
206
|
+
- SLV
|
207
|
+
- SYR
|
208
|
+
- SWZ
|
209
|
+
- TCA
|
210
|
+
- TCD
|
211
|
+
- TF
|
212
|
+
- TGO
|
213
|
+
- THA
|
214
|
+
- TJK
|
215
|
+
- TKL
|
216
|
+
- TKM
|
217
|
+
- TUN
|
218
|
+
- TON
|
219
|
+
- TLS
|
220
|
+
- TUR
|
221
|
+
- TTO
|
222
|
+
- TUV
|
223
|
+
- TWN
|
224
|
+
- TZA
|
225
|
+
- UKR
|
226
|
+
- UGA
|
227
|
+
- UM
|
228
|
+
- USA
|
229
|
+
- URY
|
230
|
+
- UZB
|
231
|
+
- VAT
|
232
|
+
- VCT
|
233
|
+
- VEN
|
234
|
+
- VGB
|
235
|
+
- VIR
|
236
|
+
- VNM
|
237
|
+
- VUT
|
238
|
+
- WLF
|
239
|
+
- WSM
|
240
|
+
- YEM
|
241
|
+
- YT
|
242
|
+
- SRB
|
243
|
+
- ZAF
|
244
|
+
- ZMB
|
245
|
+
- MNE
|
246
|
+
- ZWE
|
247
|
+
- A1
|
248
|
+
- A2
|
249
|
+
- O1
|
250
|
+
- ALA
|
251
|
+
- GGY
|
252
|
+
- IMN
|
253
|
+
- JEY
|
254
|
+
- BLM
|
255
|
+
- MAF
|