hive_geoip2 0.1.2 → 0.1.4
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.
- checksums.yaml +5 -5
- data/ext/hive_geoip2/hive_geoip2.c +48 -10
- data/hive_geoip2.gemspec +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 209e8f8c9e603be8bde6f15e6c09ae9e2665c63fb427c0b3af48920e1a6b2179
|
4
|
+
data.tar.gz: 903ca36a7999f737f31407badf8a70abcd2284a371850ad636c5e0acbc964fec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66dee7bd11266d7481e3d01127c3232aa31336ac0a2aa020bd81308c471511d5e549f059fc8b7c90991fc881b553b518cc6b08fef43c3aab35eee6af903183a9
|
7
|
+
data.tar.gz: 1465bc69a609a0f3ba147e37a4241a53c5e1f9f880aa87b5f7f0a93466838cde8202c730f2fc2379089badd993cc1c5a9c64ef5ee88b73bc5ff8a127c03a663d
|
@@ -8,7 +8,7 @@
|
|
8
8
|
VALUE rb_mHive;
|
9
9
|
VALUE rb_cGeoIP2;
|
10
10
|
|
11
|
-
static
|
11
|
+
static VALUE guard_parse_data_list(VALUE arg);
|
12
12
|
static MMDB_entry_data_list_s * parse_data_list(
|
13
13
|
MMDB_entry_data_list_s *data_list, VALUE *ret_obj
|
14
14
|
);
|
@@ -19,6 +19,8 @@ static VALUE mmdb_lookup(MMDB_s *mmdb, char *ip_addr, bool cleanup);
|
|
19
19
|
|
20
20
|
static VALUE rb_hive_geo_lookup(VALUE self, VALUE ip_arg);
|
21
21
|
static VALUE rb_hive_geo_lookup2(VALUE self, VALUE ip_arg, VALUE db_arg);
|
22
|
+
static VALUE rb_hive_geo_lookup_with_prefix_length(VALUE self, VALUE ip_arg);
|
23
|
+
static VALUE rb_hive_geo_lookup_with_prefix_length2(VALUE self, VALUE ip_arg, VALUE db_arg);
|
22
24
|
static VALUE rb_hive_geo_is_closed(VALUE self);
|
23
25
|
static VALUE rb_hive_geo_close(VALUE self);
|
24
26
|
static void rb_hive_geo_free(MMDB_s *mmdb);
|
@@ -30,10 +32,12 @@ struct args_parse_data_list {
|
|
30
32
|
VALUE *ret_obj;
|
31
33
|
};
|
32
34
|
|
33
|
-
static
|
35
|
+
static VALUE guard_parse_data_list(VALUE arg) {
|
34
36
|
struct args_parse_data_list *args = (struct args_parse_data_list *)arg;
|
35
37
|
|
36
38
|
parse_data_list(args->data_list, args->ret_obj);
|
39
|
+
|
40
|
+
return RUBY_Qnil;
|
37
41
|
}
|
38
42
|
|
39
43
|
static MMDB_entry_data_list_s *
|
@@ -318,11 +322,22 @@ static VALUE mmdb_lookup(MMDB_s *mmdb, char *ip_addr, bool cleanup) {
|
|
318
322
|
if (exception) {
|
319
323
|
rb_jump_tag(exception);
|
320
324
|
}
|
321
|
-
|
322
|
-
|
325
|
+
|
326
|
+
// Return [data, prefix_length] tuple
|
327
|
+
VALUE result_array = rb_ary_new2(2);
|
328
|
+
rb_ary_push(result_array, ret_obj);
|
329
|
+
rb_ary_push(result_array, INT2NUM(result.netmask));
|
330
|
+
return result_array;
|
323
331
|
}
|
324
332
|
else {
|
325
|
-
|
333
|
+
if (cleanup) {
|
334
|
+
mmdb_close(mmdb);
|
335
|
+
}
|
336
|
+
// Return [nil, 0] for not found
|
337
|
+
VALUE result_array = rb_ary_new2(2);
|
338
|
+
rb_ary_push(result_array, Qnil);
|
339
|
+
rb_ary_push(result_array, INT2NUM(0));
|
340
|
+
return result_array;
|
326
341
|
}
|
327
342
|
}
|
328
343
|
|
@@ -338,8 +353,8 @@ static VALUE rb_hive_geo_lookup(VALUE self, VALUE ip_arg) {
|
|
338
353
|
if (mmdb_is_closed(mmdb)) {
|
339
354
|
rb_raise(rb_eIOError, "GeoIP2 - closed database");
|
340
355
|
}
|
341
|
-
|
342
|
-
return
|
356
|
+
VALUE result_tuple = mmdb_lookup(mmdb, ip_addr, false);
|
357
|
+
return rb_ary_entry(result_tuple, 0); // Extract just the data part
|
343
358
|
}
|
344
359
|
|
345
360
|
static VALUE rb_hive_geo_lookup2(VALUE self, VALUE ip_arg, VALUE db_arg) {
|
@@ -352,8 +367,29 @@ static VALUE rb_hive_geo_lookup2(VALUE self, VALUE ip_arg, VALUE db_arg) {
|
|
352
367
|
MMDB_s mmdb;
|
353
368
|
|
354
369
|
mmdb_try_open(db_path, &mmdb);
|
355
|
-
|
356
|
-
return
|
370
|
+
VALUE result_tuple = mmdb_lookup(&mmdb, ip_addr, true);
|
371
|
+
return rb_ary_entry(result_tuple, 0); // Extract just the data part
|
372
|
+
}
|
373
|
+
|
374
|
+
static VALUE rb_hive_geo_lookup_with_prefix_length(VALUE self, VALUE ip_arg) {
|
375
|
+
Check_Type(ip_arg, T_STRING);
|
376
|
+
char *ip_addr = StringValuePtr(ip_arg);
|
377
|
+
MMDB_s *mmdb;
|
378
|
+
Data_Get_Struct(self, MMDB_s, mmdb);
|
379
|
+
if (mmdb_is_closed(mmdb)) {
|
380
|
+
rb_raise(rb_eIOError, "GeoIP2 - closed database");
|
381
|
+
}
|
382
|
+
return mmdb_lookup(mmdb, ip_addr, false); // Return full tuple with prefix length
|
383
|
+
}
|
384
|
+
|
385
|
+
static VALUE rb_hive_geo_lookup_with_prefix_length2(VALUE self, VALUE ip_arg, VALUE db_arg) {
|
386
|
+
Check_Type(ip_arg, T_STRING);
|
387
|
+
Check_Type(db_arg, T_STRING);
|
388
|
+
char *ip_addr = StringValuePtr(ip_arg);
|
389
|
+
char *db_path = StringValuePtr(db_arg);
|
390
|
+
MMDB_s mmdb;
|
391
|
+
mmdb_try_open(db_path, &mmdb);
|
392
|
+
return mmdb_lookup(&mmdb, ip_addr, true); // Return full tuple with prefix length
|
357
393
|
}
|
358
394
|
|
359
395
|
static VALUE rb_hive_geo_is_closed(VALUE self) {
|
@@ -411,9 +447,11 @@ void Init_hive_geoip2() {
|
|
411
447
|
rb_define_alloc_func(rb_cGeoIP2, rb_hive_geo_alloc);
|
412
448
|
|
413
449
|
rb_define_singleton_method(rb_cGeoIP2, "lookup", rb_hive_geo_lookup2, 2);
|
414
|
-
|
450
|
+
rb_define_singleton_method(rb_cGeoIP2, "lookup_with_prefix_length", rb_hive_geo_lookup_with_prefix_length2, 2);
|
451
|
+
|
415
452
|
rb_define_method(rb_cGeoIP2, "initialize", rb_hive_geo_init, 1);
|
416
453
|
rb_define_method(rb_cGeoIP2, "close", rb_hive_geo_close, 0);
|
417
454
|
rb_define_method(rb_cGeoIP2, "closed?", rb_hive_geo_is_closed, 0);
|
418
455
|
rb_define_method(rb_cGeoIP2, "lookup", rb_hive_geo_lookup, 1);
|
456
|
+
rb_define_method(rb_cGeoIP2, "lookup_with_prefix_length", rb_hive_geo_lookup_with_prefix_length, 1);
|
419
457
|
}
|
data/hive_geoip2.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hive_geoip2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxime Youdine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -17,10 +17,10 @@ extensions:
|
|
17
17
|
- ext/hive_geoip2/extconf.rb
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- hive_geoip2.gemspec
|
21
|
-
- lib/hive_geoip2/hive_geoip2.rb
|
22
20
|
- ext/hive_geoip2/extconf.rb
|
23
21
|
- ext/hive_geoip2/hive_geoip2.c
|
22
|
+
- hive_geoip2.gemspec
|
23
|
+
- lib/hive_geoip2/hive_geoip2.rb
|
24
24
|
homepage: https://github.com/desuwa/hive_geoip2
|
25
25
|
licenses:
|
26
26
|
- MIT
|
@@ -31,17 +31,16 @@ require_paths:
|
|
31
31
|
- lib
|
32
32
|
required_ruby_version: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
|
-
- -
|
34
|
+
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: 1.9.2
|
37
37
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
|
-
|
44
|
-
rubygems_version: 2.0.14
|
43
|
+
rubygems_version: 3.0.1
|
45
44
|
signing_key:
|
46
45
|
specification_version: 4
|
47
46
|
summary: libmaxminddb GeoIP2 Ruby bindings
|