geoip-c 0.7.2 → 0.8.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +14 -8
- data/Rakefile +6 -6
- data/extconf.rb +6 -0
- data/geoip.c +16 -5
- metadata +19 -14
data/README.md
CHANGED
@@ -75,17 +75,23 @@ Some variation of the following should work.
|
|
75
75
|
./configure --prefix=/opt/GeoIP
|
76
76
|
make && sudo make install
|
77
77
|
|
78
|
-
On Mac OS X, you can install using
|
78
|
+
On Mac OS X, you can install using [homebrew](http://github.com/mxcl/homebrew):
|
79
79
|
|
80
|
-
|
80
|
+
brew install geoip
|
81
81
|
|
82
|
-
|
82
|
+
Linux platforms utilizing Apt have several packages available:
|
83
83
|
|
84
|
-
|
84
|
+
geoip-bin
|
85
|
+
geoip-database
|
86
|
+
libgeoip-dev
|
85
87
|
|
86
|
-
|
88
|
+
2. Now install the `geoip` gem
|
87
89
|
|
88
|
-
|
90
|
+
gem install geoip-c -- --with-geoip-dir=/opt/GeoIP
|
91
|
+
|
92
|
+
Alternatively, if you installed libgeoip using homebrew:
|
93
|
+
|
94
|
+
gem install geoip-c
|
89
95
|
|
90
96
|
3. Download the GeoLite City database file in binary format at http://www.maxmind.com/app/geolitecity
|
91
97
|
Maybe this [direct link](http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz) will work.
|
@@ -93,7 +99,7 @@ Some variation of the following should work.
|
|
93
99
|
|
94
100
|
/opt/GeoIP/share/GeoIP/GeoLiteCity.dat
|
95
101
|
|
96
|
-
If you installed libgeoip using
|
102
|
+
If you installed libgeoip using homebrew then put it in:
|
97
103
|
|
98
104
|
/opt/local/share/GeoIP/GeoLiteCity.dat
|
99
105
|
|
@@ -118,7 +124,7 @@ Hints
|
|
118
124
|
|
119
125
|
Example:
|
120
126
|
|
121
|
-
env ARCHFLAGS="-arch i386" gem install
|
127
|
+
env ARCHFLAGS="-arch i386" gem install geoip-c -- --with-geoip-dir=/opt/GeoIP
|
122
128
|
|
123
129
|
2. You might find [this shell script](http://github.com/grimen/my_shell_scripts/blob/8cf04cb6829e68a47f2d6f9d9e057766ea72beb4/install_geoip-city.sh)
|
124
130
|
helpful to install the C library.
|
data/Rakefile
CHANGED
@@ -16,24 +16,24 @@ Rake::RDocTask.new do |rdoc|
|
|
16
16
|
end
|
17
17
|
|
18
18
|
Rake::TestTask.new do |t|
|
19
|
-
t.test_files = 'test.rb'
|
19
|
+
t.test_files = ['test.rb']
|
20
20
|
t.verbose = true
|
21
21
|
end
|
22
22
|
|
23
23
|
spec = Gem::Specification.new do |s|
|
24
24
|
s.name = 'geoip-c'
|
25
|
-
s.version = "0.
|
25
|
+
s.version = "0.8.0.rc1"
|
26
26
|
|
27
|
-
s.authors = ['Ryah Dahl', 'Matt Todd']
|
28
|
-
s.email = 'mtodd@highgroove.com'
|
27
|
+
s.authors = ['Ryah Dahl', 'Matt Todd', 'Andy Lindeman']
|
28
|
+
s.email = ['alindeman@gmail.com', 'mtodd@highgroove.com']
|
29
29
|
|
30
30
|
s.summary = "A Binding to the GeoIP C library"
|
31
31
|
s.description = 'Generic GeoIP lookup tool. Based on the geoip_city RubyGem by Ryah Dahl'
|
32
32
|
s.homepage = "http://github.com/mtodd/geoip"
|
33
33
|
|
34
34
|
s.files = ["Rakefile", "extconf.rb", "test.rb", "geoip.c", "README.md"]
|
35
|
-
s.test_files = 'test.rb'
|
36
|
-
s.extensions = 'extconf.rb'
|
35
|
+
s.test_files = ['test.rb']
|
36
|
+
s.extensions = ['extconf.rb']
|
37
37
|
s.require_path = '.'
|
38
38
|
end
|
39
39
|
|
data/extconf.rb
CHANGED
@@ -7,6 +7,12 @@ unless have_func('iconv_open', 'iconv.h') or have_library('iconv', 'iconv_open',
|
|
7
7
|
end
|
8
8
|
|
9
9
|
if have_library('GeoIP', 'GeoIP_record_by_ipnum') and have_header('GeoIPCity.h')
|
10
|
+
# Defines HAVE_GEOIP_ADDR_TO_NUM
|
11
|
+
have_func('GeoIP_addr_to_num', 'GeoIP.h')
|
12
|
+
|
13
|
+
# Defines HAVE_GEOIP_NUM_TO_ADDR
|
14
|
+
have_func('GeoIP_num_to_addr', 'GeoIP.h')
|
15
|
+
|
10
16
|
create_makefile('geoip')
|
11
17
|
else
|
12
18
|
abort("you must have geoip c library installed!")
|
data/geoip.c
CHANGED
@@ -21,6 +21,20 @@ static VALUE rb_geoip_memory;
|
|
21
21
|
static VALUE rb_geoip_filesystem;
|
22
22
|
static VALUE rb_geoip_index;
|
23
23
|
|
24
|
+
#ifndef HAVE_GEOIP_ADDR_TO_NUM
|
25
|
+
// Support geoip <= 1.4.6
|
26
|
+
#define GeoIP_addr_to_num _GeoIP_addr_to_num
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#ifndef HAVE_GEOIP_NUM_TO_ADDR
|
30
|
+
// Support geoip <= 1.4.6
|
31
|
+
|
32
|
+
// Fixes a bug with 64bit architectures where this delcaration doesn't exist
|
33
|
+
// in the GeoIP library causing segmentation faults.
|
34
|
+
char *_GeoIP_num_to_addr(GeoIP* gi, unsigned long ipnum);
|
35
|
+
#define GeoIP_num_to_addr(ipnum) _GeoIP_num_to_addr(NULL, ipnum)
|
36
|
+
#endif
|
37
|
+
|
24
38
|
/* helpers */
|
25
39
|
void rb_hash_sset(VALUE hash, const char *str, VALUE v) {
|
26
40
|
rb_hash_aset(hash, ID2SYM(rb_intern(str)), v);
|
@@ -320,12 +334,9 @@ VALUE rb_geoip_domain_look_up(VALUE self, VALUE addr) {
|
|
320
334
|
*/
|
321
335
|
VALUE rb_geoip_addr_to_num(VALUE self, VALUE addr) {
|
322
336
|
Check_Type(addr, T_STRING);
|
323
|
-
return UINT2NUM((unsigned int)
|
337
|
+
return UINT2NUM((unsigned int)GeoIP_addr_to_num(StringValuePtr(addr)));
|
324
338
|
}
|
325
339
|
|
326
|
-
// Fixes a bug with 64bit architectures where this delcaration doesn't exist
|
327
|
-
// in the GeoIP library causing segmentation faults.
|
328
|
-
char *_GeoIP_num_to_addr(GeoIP* gi, unsigned long ipnum);
|
329
340
|
|
330
341
|
VALUE rb_geoip_num_to_addr(VALUE self, VALUE num) {
|
331
342
|
VALUE num_type = TYPE(num);
|
@@ -334,7 +345,7 @@ VALUE rb_geoip_num_to_addr(VALUE self, VALUE num) {
|
|
334
345
|
case T_BIGNUM: break;
|
335
346
|
default: rb_raise(rb_eTypeError, "wrong argument type %s (expected Fixnum or Bignum)", rb_obj_classname(num));
|
336
347
|
}
|
337
|
-
return rb_str_new2((char*)
|
348
|
+
return rb_str_new2((char*)GeoIP_num_to_addr((unsigned long)NUM2ULONG(num)));
|
338
349
|
}
|
339
350
|
|
340
351
|
void Init_geoip()
|
metadata
CHANGED
@@ -1,27 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoip-c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15424151
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
|
8
|
+
- 8
|
9
|
+
- 0
|
10
|
+
- rc
|
11
|
+
- 1
|
12
|
+
version: 0.8.0.rc1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Ryah Dahl
|
14
16
|
- Matt Todd
|
17
|
+
- Andy Lindeman
|
15
18
|
autorequire:
|
16
19
|
bindir: bin
|
17
20
|
cert_chain: []
|
18
21
|
|
19
|
-
date: 2011-
|
20
|
-
default_executable:
|
22
|
+
date: 2011-09-28 00:00:00 Z
|
21
23
|
dependencies: []
|
22
24
|
|
23
25
|
description: Generic GeoIP lookup tool. Based on the geoip_city RubyGem by Ryah Dahl
|
24
|
-
email:
|
26
|
+
email:
|
27
|
+
- alindeman@gmail.com
|
28
|
+
- mtodd@highgroove.com
|
25
29
|
executables: []
|
26
30
|
|
27
31
|
extensions:
|
@@ -34,7 +38,6 @@ files:
|
|
34
38
|
- test.rb
|
35
39
|
- geoip.c
|
36
40
|
- README.md
|
37
|
-
has_rdoc: true
|
38
41
|
homepage: http://github.com/mtodd/geoip
|
39
42
|
licenses: []
|
40
43
|
|
@@ -55,16 +58,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
59
|
none: false
|
57
60
|
requirements:
|
58
|
-
- - "
|
61
|
+
- - ">"
|
59
62
|
- !ruby/object:Gem::Version
|
60
|
-
hash:
|
63
|
+
hash: 25
|
61
64
|
segments:
|
62
|
-
-
|
63
|
-
|
65
|
+
- 1
|
66
|
+
- 3
|
67
|
+
- 1
|
68
|
+
version: 1.3.1
|
64
69
|
requirements: []
|
65
70
|
|
66
71
|
rubyforge_project:
|
67
|
-
rubygems_version: 1.
|
72
|
+
rubygems_version: 1.8.10
|
68
73
|
signing_key:
|
69
74
|
specification_version: 3
|
70
75
|
summary: A Binding to the GeoIP C library
|