geoip2_c 0.3.4 → 0.4.1
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 +4 -4
- data/.github/dependabot.yml +23 -0
- data/.github/workflows/ubuntu.yml +17 -8
- data/.github/workflows/windows.yml +18 -8
- data/.gitmodules +0 -3
- data/ext/geoip2/extconf.rb +9 -25
- data/ext/geoip2/geoip2.c +82 -32
- data/geoip2_c.gemspec +1 -0
- data/lib/geoip2/version.rb +1 -1
- metadata +18 -182
- data/ext/geoip2/libmaxminddb/.gitignore +0 -38
- data/ext/geoip2/libmaxminddb/.gitmodules +0 -9
- data/ext/geoip2/libmaxminddb/.perltidyrc +0 -11
- data/ext/geoip2/libmaxminddb/.travis.yml +0 -70
- data/ext/geoip2/libmaxminddb/.uncrustify.cfg +0 -78
- data/ext/geoip2/libmaxminddb/AUTHORS +0 -0
- data/ext/geoip2/libmaxminddb/Changes.md +0 -277
- data/ext/geoip2/libmaxminddb/LICENSE +0 -202
- data/ext/geoip2/libmaxminddb/Makefile.am +0 -41
- data/ext/geoip2/libmaxminddb/NOTICE +0 -13
- data/ext/geoip2/libmaxminddb/README.dev.md +0 -69
- data/ext/geoip2/libmaxminddb/README.md +0 -122
- data/ext/geoip2/libmaxminddb/appveyor.yml +0 -33
- data/ext/geoip2/libmaxminddb/bin/Makefile.am +0 -10
- data/ext/geoip2/libmaxminddb/bin/mmdblookup.c +0 -715
- data/ext/geoip2/libmaxminddb/bootstrap +0 -21
- data/ext/geoip2/libmaxminddb/common.mk +0 -7
- data/ext/geoip2/libmaxminddb/configure.ac +0 -132
- data/ext/geoip2/libmaxminddb/dev-bin/make-man-pages.pl +0 -76
- data/ext/geoip2/libmaxminddb/dev-bin/ppa-release.sh +0 -53
- data/ext/geoip2/libmaxminddb/dev-bin/regen-prototypes.pl +0 -136
- data/ext/geoip2/libmaxminddb/dev-bin/regen-win32-test-projs.pl +0 -54
- data/ext/geoip2/libmaxminddb/dev-bin/release.sh +0 -113
- data/ext/geoip2/libmaxminddb/dev-bin/uncrustify-all.sh +0 -21
- data/ext/geoip2/libmaxminddb/dev-bin/valgrind-all.pl +0 -53
- data/ext/geoip2/libmaxminddb/doc/libmaxminddb.md +0 -889
- data/ext/geoip2/libmaxminddb/doc/mmdblookup.md +0 -103
- data/ext/geoip2/libmaxminddb/include/maxminddb.h +0 -241
- data/ext/geoip2/libmaxminddb/include/maxminddb_config.h.in +0 -14
- data/ext/geoip2/libmaxminddb/projects/VS12/README.md +0 -59
- data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb-release.props +0 -32
- data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb-x64.props +0 -14
- data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.props +0 -32
- data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.sln +0 -150
- data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.vcxproj +0 -143
- data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.vcxproj.filters +0 -32
- data/ext/geoip2/libmaxminddb/projects/VS12/maxminddb_config.h +0 -14
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/bad_pointers.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/basic_lookup.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/data_entry_list.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/data_types.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/dump.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/get_value.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/get_value_pointer_bug.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/ipv4_start_cache.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/ipv6_lookup_in_ipv4.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/libtap.vcxproj +0 -85
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/maxminddb_test_helper.vcxproj +0 -107
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/metadata.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/metadata_pointers.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/no_map_get_value.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/read_node.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/shared.vcxproj +0 -104
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/threads.vcxproj +0 -103
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/version.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/test.vcxproj.template +0 -105
- data/ext/geoip2/libmaxminddb/src/Makefile.am +0 -25
- data/ext/geoip2/libmaxminddb/src/data-pool.c +0 -180
- data/ext/geoip2/libmaxminddb/src/data-pool.h +0 -52
- data/ext/geoip2/libmaxminddb/src/libmaxminddb.pc.in +0 -11
- data/ext/geoip2/libmaxminddb/src/maxminddb-compat-util.h +0 -167
- data/ext/geoip2/libmaxminddb/src/maxminddb.c +0 -2181
- data/ext/geoip2/libmaxminddb/t/Makefile.am +0 -27
- data/ext/geoip2/libmaxminddb/t/bad_databases_t.c +0 -67
- data/ext/geoip2/libmaxminddb/t/bad_pointers_t.c +0 -53
- data/ext/geoip2/libmaxminddb/t/basic_lookup_t.c +0 -207
- data/ext/geoip2/libmaxminddb/t/compile_c++_t.pl +0 -107
- data/ext/geoip2/libmaxminddb/t/data-pool-t.c +0 -374
- data/ext/geoip2/libmaxminddb/t/data_entry_list_t.c +0 -353
- data/ext/geoip2/libmaxminddb/t/data_types_t.c +0 -439
- data/ext/geoip2/libmaxminddb/t/dump_t.c +0 -103
- data/ext/geoip2/libmaxminddb/t/external_symbols_t.pl +0 -106
- data/ext/geoip2/libmaxminddb/t/get_value_pointer_bug_t.c +0 -66
- data/ext/geoip2/libmaxminddb/t/get_value_t.c +0 -249
- data/ext/geoip2/libmaxminddb/t/ipv4_start_cache_t.c +0 -36
- data/ext/geoip2/libmaxminddb/t/ipv6_lookup_in_ipv4_t.c +0 -48
- data/ext/geoip2/libmaxminddb/t/libtap/.gitignore +0 -13
- data/ext/geoip2/libmaxminddb/t/libtap/.travis.yml +0 -13
- data/ext/geoip2/libmaxminddb/t/libtap/COPYING +0 -165
- data/ext/geoip2/libmaxminddb/t/libtap/INSTALL +0 -41
- data/ext/geoip2/libmaxminddb/t/libtap/Makefile +0 -72
- data/ext/geoip2/libmaxminddb/t/libtap/Makefile.win +0 -37
- data/ext/geoip2/libmaxminddb/t/libtap/README.md +0 -268
- data/ext/geoip2/libmaxminddb/t/libtap/t/cmp_mem.c +0 -20
- data/ext/geoip2/libmaxminddb/t/libtap/t/cmp_mem.expected +0 -28
- data/ext/geoip2/libmaxminddb/t/libtap/t/cmpok.c +0 -16
- data/ext/geoip2/libmaxminddb/t/libtap/t/cmpok.expected +0 -37
- data/ext/geoip2/libmaxminddb/t/libtap/t/diag.c +0 -10
- data/ext/geoip2/libmaxminddb/t/libtap/t/diag.expected +0 -2
- data/ext/geoip2/libmaxminddb/t/libtap/t/diesok.c +0 -14
- data/ext/geoip2/libmaxminddb/t/libtap/t/diesok.expected +0 -6
- data/ext/geoip2/libmaxminddb/t/libtap/t/is.c +0 -24
- data/ext/geoip2/libmaxminddb/t/libtap/t/is.expected +0 -58
- data/ext/geoip2/libmaxminddb/t/libtap/t/like.c +0 -10
- data/ext/geoip2/libmaxminddb/t/libtap/t/like.expected +0 -4
- data/ext/geoip2/libmaxminddb/t/libtap/t/simple.c +0 -31
- data/ext/geoip2/libmaxminddb/t/libtap/t/simple.expected +0 -32
- data/ext/geoip2/libmaxminddb/t/libtap/t/skip.c +0 -23
- data/ext/geoip2/libmaxminddb/t/libtap/t/skip.expected +0 -9
- data/ext/geoip2/libmaxminddb/t/libtap/t/synopsis.c +0 -13
- data/ext/geoip2/libmaxminddb/t/libtap/t/synopsis.expected +0 -9
- data/ext/geoip2/libmaxminddb/t/libtap/t/test.c +0 -28
- data/ext/geoip2/libmaxminddb/t/libtap/t/todo.c +0 -17
- data/ext/geoip2/libmaxminddb/t/libtap/t/todo.expected +0 -11
- data/ext/geoip2/libmaxminddb/t/libtap/tap.c +0 -354
- data/ext/geoip2/libmaxminddb/t/libtap/tap.h +0 -115
- data/ext/geoip2/libmaxminddb/t/maxmind-db/.gitattributes +0 -1
- data/ext/geoip2/libmaxminddb/t/maxmind-db/.gitconfig +0 -2
- data/ext/geoip2/libmaxminddb/t/maxmind-db/.gitignore +0 -2
- data/ext/geoip2/libmaxminddb/t/maxmind-db/.perltidyallrc +0 -11
- data/ext/geoip2/libmaxminddb/t/maxmind-db/.tidyallrc +0 -7
- data/ext/geoip2/libmaxminddb/t/maxmind-db/LICENSE +0 -4
- data/ext/geoip2/libmaxminddb/t/maxmind-db/MaxMind-DB-spec.md +0 -558
- data/ext/geoip2/libmaxminddb/t/maxmind-db/README.md +0 -4
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/README.md +0 -7
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/libmaxminddb/libmaxminddb-offset-integer-overflow.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/cyclic-data-structure.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/invalid-bytes-length.mmdb +0 -1
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/invalid-data-record-offset.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/invalid-map-key-length.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/invalid-string-length.mmdb +0 -1
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/metadata-is-an-uint128.mmdb +0 -1
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/unexpected-bytes.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/perltidyrc +0 -12
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Anonymous-IP-Test.json +0 -32
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-City-Test.json +0 -12616
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Connection-Type-Test.json +0 -102
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Country-Test.json +0 -10975
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-DensityIncome-Test.json +0 -14
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Domain-Test.json +0 -452
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Enterprise-Test.json +0 -666
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-ISP-Test.json +0 -12585
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Precision-Enterprise-Test.json +0 -1035
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoLite2-ASN-Test.json +0 -37
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/README +0 -13
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Anonymous-IP-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-City-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Connection-Type-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Country-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-DensityIncome-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Domain-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Enterprise-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-ISP-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Precision-Enterprise-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoLite2-ASN-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-string-value-entries.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-broken-pointers-24.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-decoder.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv4-24.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv4-28.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv4-32.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv6-24.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv6-28.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv6-32.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-metadata-pointers.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-mixed-24.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-mixed-28.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-mixed-32.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-nested.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/README.md +0 -26
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/maps-with-pointers.raw +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/write-test-data.pl +0 -614
- data/ext/geoip2/libmaxminddb/t/maxmind-db/tidyall.ini +0 -5
- data/ext/geoip2/libmaxminddb/t/maxminddb_test_helper.c +0 -255
- data/ext/geoip2/libmaxminddb/t/maxminddb_test_helper.h +0 -69
- data/ext/geoip2/libmaxminddb/t/metadata_pointers_t.c +0 -32
- data/ext/geoip2/libmaxminddb/t/metadata_t.c +0 -226
- data/ext/geoip2/libmaxminddb/t/mmdblookup_t.pl +0 -158
- data/ext/geoip2/libmaxminddb/t/no_map_get_value_t.c +0 -32
- data/ext/geoip2/libmaxminddb/t/read_node_t.c +0 -157
- data/ext/geoip2/libmaxminddb/t/threads_t.c +0 -196
- data/ext/geoip2/libmaxminddb/t/version_t.c +0 -10
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env perl
|
|
2
|
-
|
|
3
|
-
use strict;
|
|
4
|
-
use warnings;
|
|
5
|
-
|
|
6
|
-
use FindBin qw( $Bin );
|
|
7
|
-
|
|
8
|
-
eval <<'EOF';
|
|
9
|
-
use Test::More 0.88;
|
|
10
|
-
use IPC::Run3 qw( run3 );
|
|
11
|
-
EOF
|
|
12
|
-
|
|
13
|
-
if ($@) {
|
|
14
|
-
print
|
|
15
|
-
"1..0 # skip all tests skipped - these tests need the Test::More 0.88, IPC::Run3 and Test::Output modules:\n";
|
|
16
|
-
print "$@";
|
|
17
|
-
exit 0;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
my $mmdblookup = "$Bin/../bin/mmdblookup";
|
|
21
|
-
my $test_data_dir = "$Bin/maxmind-db/test-data";
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
ok( -x $mmdblookup, 'mmdblookup script is executable' );
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
for my $arg (qw( -h -? --help )) {
|
|
28
|
-
_test_stdout(
|
|
29
|
-
[$arg],
|
|
30
|
-
qr{mmdblookup --file.+This application accepts the following options:}s,
|
|
31
|
-
0,
|
|
32
|
-
"help output from $arg"
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
_test_both(
|
|
37
|
-
[],
|
|
38
|
-
qr{mmdblookup --file.+This application accepts the following options:}s,
|
|
39
|
-
qr{ERROR: You must provide a filename with --file},
|
|
40
|
-
1,
|
|
41
|
-
"help output with no CLI options"
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
_test_stderr(
|
|
45
|
-
[qw( --file foo )],
|
|
46
|
-
qr{ERROR: You must provide an IP address with --ip},
|
|
47
|
-
1,
|
|
48
|
-
'error when no --ip is given'
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
_test_stdout(
|
|
52
|
-
[qw( --version )],
|
|
53
|
-
qr/mmdblookup version \d+\.\d+\.\d+/,
|
|
54
|
-
0,
|
|
55
|
-
'output for --version'
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
_test_stdout(
|
|
59
|
-
['--file', "$test_data_dir/GeoIP2-City-Test.mmdb", '--ip', '2.125.160.216'],
|
|
60
|
-
qr/"en"\s*:\s*"Boxford"/,
|
|
61
|
-
0,
|
|
62
|
-
'output for 2.125.160.216'
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
_test_stdout(
|
|
66
|
-
['--file', "$test_data_dir/GeoIP2-City-Test.mmdb", '--ip', '2.125.160.216', '--verbose'],
|
|
67
|
-
qr/Database metadata.+"en"\s*:\s*"Boxford"/s,
|
|
68
|
-
0,
|
|
69
|
-
'verbose output for 2.125.160.216'
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
_test_stdout(
|
|
73
|
-
['--file', "$test_data_dir/GeoIP2-City-Test.mmdb", '--ip', '2.125.160.216', qw( location latitude )],
|
|
74
|
-
qr/^\s*51\.750000 <double>\s*$/s,
|
|
75
|
-
0,
|
|
76
|
-
'output for 2.125.160.216 with lookup path'
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
_test_stderr(
|
|
80
|
-
[ qw( --file this/path/better/not/exist.mmdb --ip 1.2.3.4 ) ],
|
|
81
|
-
qr{Can't open this/path/better/not/exist.mmdb}s,
|
|
82
|
-
2,
|
|
83
|
-
'error for file that does not exist'
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
_test_stderr(
|
|
87
|
-
['--file', "$test_data_dir/GeoIP2-City-Test.mmdb", '--ip', 'not-an-ip-address' ],
|
|
88
|
-
qr{Error from call to getaddrinfo for not-an-ip-address}s,
|
|
89
|
-
3,
|
|
90
|
-
'error for bad IP address'
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
_test_stderr(
|
|
94
|
-
['--file', "$test_data_dir/GeoIP2-City-Test.mmdb", '--ip', '10.2.3.4' ],
|
|
95
|
-
qr{\QCould not find an entry for this IP address (10.2.3.4)}s,
|
|
96
|
-
6,
|
|
97
|
-
'error for bad PI address'
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
done_testing();
|
|
101
|
-
|
|
102
|
-
sub _test_stdout {
|
|
103
|
-
my $args = shift;
|
|
104
|
-
my $expect_stdout = shift;
|
|
105
|
-
my $expect_status = shift;
|
|
106
|
-
my $desc = shift;
|
|
107
|
-
|
|
108
|
-
_test_both( $args, $expect_stdout, q{}, $expect_status, $desc );
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
sub _test_stderr {
|
|
112
|
-
my $args = shift;
|
|
113
|
-
my $expect_stderr = shift;
|
|
114
|
-
my $expect_status = shift;
|
|
115
|
-
my $desc = shift;
|
|
116
|
-
|
|
117
|
-
_test_both( $args, undef, $expect_stderr, $expect_status, $desc );
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
sub _test_both {
|
|
121
|
-
my $args = shift;
|
|
122
|
-
my $expect_stdout = shift;
|
|
123
|
-
my $expect_stderr = shift;
|
|
124
|
-
my $expect_status = shift;
|
|
125
|
-
my $desc = shift;
|
|
126
|
-
|
|
127
|
-
my $stdout;
|
|
128
|
-
my $stderr;
|
|
129
|
-
run3(
|
|
130
|
-
[ $mmdblookup, @{$args} ],
|
|
131
|
-
\undef,
|
|
132
|
-
\$stdout,
|
|
133
|
-
\$stderr,
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
my $exit_status = $? >> 8;
|
|
137
|
-
|
|
138
|
-
# We don't need to retest that the help output shows up for all errors
|
|
139
|
-
if ( defined $expect_stdout ) {
|
|
140
|
-
like(
|
|
141
|
-
$stdout,
|
|
142
|
-
$expect_stdout,
|
|
143
|
-
"stdout for mmdblookup @{$args}"
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if ( ref $expect_stderr ) {
|
|
148
|
-
like( $stderr, $expect_stderr, "stderr for mmdblookup @{$args}" );
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
is( $stderr, $expect_stderr, "stderr for mmdblookup @{$args}" );
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
is(
|
|
155
|
-
$exit_status, $expect_status,
|
|
156
|
-
"exit status was $expect_status for mmdblookup @{$args}"
|
|
157
|
-
);
|
|
158
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#include "maxminddb_test_helper.h"
|
|
2
|
-
|
|
3
|
-
void run_tests(int mode, const char *mode_desc)
|
|
4
|
-
{
|
|
5
|
-
const char *filename = "MaxMind-DB-string-value-entries.mmdb";
|
|
6
|
-
const char *path = test_database_path(filename);
|
|
7
|
-
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
|
|
8
|
-
free((void *)path);
|
|
9
|
-
|
|
10
|
-
const char *ip = "1.1.1.1";
|
|
11
|
-
MMDB_lookup_result_s result =
|
|
12
|
-
lookup_string_ok(mmdb, ip, filename, mode_desc);
|
|
13
|
-
|
|
14
|
-
MMDB_entry_data_s entry_data;
|
|
15
|
-
int status = MMDB_get_value(&result.entry, &entry_data, NULL);
|
|
16
|
-
|
|
17
|
-
cmp_ok(status, "==", MMDB_SUCCESS,
|
|
18
|
-
"status for MMDB_get_value() is MMDB_SUCCESS");
|
|
19
|
-
ok(entry_data.has_data, "found a value when varargs list is just NULL");
|
|
20
|
-
cmp_ok(entry_data.type, "==", MMDB_DATA_TYPE_UTF8_STRING,
|
|
21
|
-
"returned entry type is utf8_string");
|
|
22
|
-
|
|
23
|
-
MMDB_close(mmdb);
|
|
24
|
-
free(mmdb);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
int main(void)
|
|
28
|
-
{
|
|
29
|
-
plan(NO_PLAN);
|
|
30
|
-
for_all_modes(&run_tests);
|
|
31
|
-
done_testing();
|
|
32
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
#include "maxminddb_test_helper.h"
|
|
2
|
-
|
|
3
|
-
void test_entry_data(MMDB_s *mmdb, MMDB_entry_s *entry, uint32_t node_number,
|
|
4
|
-
char * node_record)
|
|
5
|
-
{
|
|
6
|
-
MMDB_entry_data_s entry_data;
|
|
7
|
-
int status =
|
|
8
|
-
MMDB_get_value(entry, &entry_data, "ip",
|
|
9
|
-
NULL);
|
|
10
|
-
cmp_ok(status, "==", MMDB_SUCCESS,
|
|
11
|
-
"successful data lookup for node");
|
|
12
|
-
cmp_ok(
|
|
13
|
-
entry_data.type, "==", MMDB_DATA_TYPE_UTF8_STRING,
|
|
14
|
-
"returned entry type is UTF8_STRING for %s record of node %i",
|
|
15
|
-
node_record, node_number);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
void run_read_node_tests(MMDB_s *mmdb, const uint32_t tests[][5],
|
|
19
|
-
int test_count,
|
|
20
|
-
uint8_t record_size)
|
|
21
|
-
{
|
|
22
|
-
for (int i = 0; i < test_count; i++) {
|
|
23
|
-
uint32_t node_number = tests[i][0];
|
|
24
|
-
MMDB_search_node_s node;
|
|
25
|
-
int status = MMDB_read_node(mmdb, node_number, &node);
|
|
26
|
-
if (MMDB_SUCCESS == status) {
|
|
27
|
-
cmp_ok(node.left_record, "==", tests[i][1],
|
|
28
|
-
"left record for node %i is %i - %i bit DB",
|
|
29
|
-
node_number, tests[i][1], record_size);
|
|
30
|
-
cmp_ok(node.left_record_type, "==", tests[i][2],
|
|
31
|
-
"left record type for node %i is %i", node_number,
|
|
32
|
-
tests[i][2]);
|
|
33
|
-
if (node.left_record_type == MMDB_RECORD_TYPE_DATA) {
|
|
34
|
-
test_entry_data(mmdb, &node.left_record_entry, node_number,
|
|
35
|
-
"left");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
cmp_ok(node.right_record, "==", tests[i][3],
|
|
39
|
-
"right record for node %i is %i - %i bit DB",
|
|
40
|
-
node_number, tests[i][3], record_size);
|
|
41
|
-
cmp_ok(node.right_record_type, "==", tests[i][4],
|
|
42
|
-
"right record type for node %i is %i", node_number,
|
|
43
|
-
tests[i][4]);
|
|
44
|
-
|
|
45
|
-
if (node.right_record_type == MMDB_RECORD_TYPE_DATA) {
|
|
46
|
-
test_entry_data(mmdb, &node.right_record_entry, node_number,
|
|
47
|
-
"right");
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
diag("call to MMDB_read_node for node %i failed - %i bit DB",
|
|
51
|
-
node_number,
|
|
52
|
-
record_size);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
void run_24_bit_record_tests(int mode, const char *mode_desc)
|
|
58
|
-
{
|
|
59
|
-
const char *filename = "MaxMind-DB-test-mixed-24.mmdb";
|
|
60
|
-
const char *path = test_database_path(filename);
|
|
61
|
-
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
|
|
62
|
-
free((void *)path);
|
|
63
|
-
|
|
64
|
-
const uint32_t tests[7][5] = {
|
|
65
|
-
{ 0, 1, MMDB_RECORD_TYPE_SEARCH_NODE, 242,
|
|
66
|
-
MMDB_RECORD_TYPE_EMPTY },
|
|
67
|
-
{ 80, 81, MMDB_RECORD_TYPE_SEARCH_NODE, 197,
|
|
68
|
-
MMDB_RECORD_TYPE_SEARCH_NODE, },
|
|
69
|
-
{ 96, 97, MMDB_RECORD_TYPE_SEARCH_NODE, 242,
|
|
70
|
-
MMDB_RECORD_TYPE_EMPTY, },
|
|
71
|
-
{ 103, 242, MMDB_RECORD_TYPE_EMPTY, 104,
|
|
72
|
-
MMDB_RECORD_TYPE_SEARCH_NODE, },
|
|
73
|
-
{ 127, 242, MMDB_RECORD_TYPE_EMPTY, 315,
|
|
74
|
-
MMDB_RECORD_TYPE_DATA, },
|
|
75
|
-
{ 132, 329, MMDB_RECORD_TYPE_DATA, 242,
|
|
76
|
-
MMDB_RECORD_TYPE_EMPTY, },
|
|
77
|
-
{ 241, 96, MMDB_RECORD_TYPE_SEARCH_NODE, 242,
|
|
78
|
-
MMDB_RECORD_TYPE_EMPTY, }
|
|
79
|
-
};
|
|
80
|
-
run_read_node_tests(mmdb, tests, 7, 24);
|
|
81
|
-
|
|
82
|
-
MMDB_close(mmdb);
|
|
83
|
-
free(mmdb);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
void run_28_bit_record_tests(int mode, const char *mode_desc)
|
|
87
|
-
{
|
|
88
|
-
const char *filename = "MaxMind-DB-test-mixed-28.mmdb";
|
|
89
|
-
const char *path = test_database_path(filename);
|
|
90
|
-
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
|
|
91
|
-
free((void *)path);
|
|
92
|
-
|
|
93
|
-
const uint32_t tests[7][5] = {
|
|
94
|
-
{ 0, 1, MMDB_RECORD_TYPE_SEARCH_NODE, 242,
|
|
95
|
-
MMDB_RECORD_TYPE_EMPTY },
|
|
96
|
-
{ 80, 81, MMDB_RECORD_TYPE_SEARCH_NODE, 197,
|
|
97
|
-
MMDB_RECORD_TYPE_SEARCH_NODE, },
|
|
98
|
-
{ 96, 97, MMDB_RECORD_TYPE_SEARCH_NODE, 242,
|
|
99
|
-
MMDB_RECORD_TYPE_EMPTY, },
|
|
100
|
-
{ 103, 242, MMDB_RECORD_TYPE_EMPTY, 104,
|
|
101
|
-
MMDB_RECORD_TYPE_SEARCH_NODE, },
|
|
102
|
-
{ 127, 242, MMDB_RECORD_TYPE_EMPTY, 315,
|
|
103
|
-
MMDB_RECORD_TYPE_DATA, },
|
|
104
|
-
{ 132, 329, MMDB_RECORD_TYPE_DATA, 242,
|
|
105
|
-
MMDB_RECORD_TYPE_EMPTY, },
|
|
106
|
-
{ 241, 96, MMDB_RECORD_TYPE_SEARCH_NODE, 242,
|
|
107
|
-
MMDB_RECORD_TYPE_EMPTY, }
|
|
108
|
-
};
|
|
109
|
-
run_read_node_tests(mmdb, tests, 7, 28);
|
|
110
|
-
|
|
111
|
-
MMDB_close(mmdb);
|
|
112
|
-
free(mmdb);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
void run_32_bit_record_tests(int mode, const char *mode_desc)
|
|
116
|
-
{
|
|
117
|
-
const char *filename = "MaxMind-DB-test-mixed-32.mmdb";
|
|
118
|
-
const char *path = test_database_path(filename);
|
|
119
|
-
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
|
|
120
|
-
free((void *)path);
|
|
121
|
-
|
|
122
|
-
const uint32_t tests[7][5] = {
|
|
123
|
-
{ 0, 1, MMDB_RECORD_TYPE_SEARCH_NODE, 242,
|
|
124
|
-
MMDB_RECORD_TYPE_EMPTY },
|
|
125
|
-
{ 80, 81, MMDB_RECORD_TYPE_SEARCH_NODE, 197,
|
|
126
|
-
MMDB_RECORD_TYPE_SEARCH_NODE, },
|
|
127
|
-
{ 96, 97, MMDB_RECORD_TYPE_SEARCH_NODE, 242,
|
|
128
|
-
MMDB_RECORD_TYPE_EMPTY, },
|
|
129
|
-
{ 103, 242, MMDB_RECORD_TYPE_EMPTY, 104,
|
|
130
|
-
MMDB_RECORD_TYPE_SEARCH_NODE, },
|
|
131
|
-
{ 127, 242, MMDB_RECORD_TYPE_EMPTY, 315,
|
|
132
|
-
MMDB_RECORD_TYPE_DATA, },
|
|
133
|
-
{ 132, 329, MMDB_RECORD_TYPE_DATA, 242,
|
|
134
|
-
MMDB_RECORD_TYPE_EMPTY, },
|
|
135
|
-
{ 241, 96, MMDB_RECORD_TYPE_SEARCH_NODE, 242,
|
|
136
|
-
MMDB_RECORD_TYPE_EMPTY, }
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
run_read_node_tests(mmdb, tests, 7, 32);
|
|
140
|
-
|
|
141
|
-
MMDB_close(mmdb);
|
|
142
|
-
free(mmdb);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
void run_tests(int mode, const char *mode_desc)
|
|
146
|
-
{
|
|
147
|
-
run_24_bit_record_tests(mode, mode_desc);
|
|
148
|
-
run_28_bit_record_tests(mode, mode_desc);
|
|
149
|
-
run_32_bit_record_tests(mode, mode_desc);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
int main(void)
|
|
153
|
-
{
|
|
154
|
-
plan(NO_PLAN);
|
|
155
|
-
for_all_modes(&run_tests);
|
|
156
|
-
done_testing();
|
|
157
|
-
}
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
#include "maxminddb_test_helper.h"
|
|
2
|
-
#include <pthread.h>
|
|
3
|
-
|
|
4
|
-
typedef struct thread_arg {
|
|
5
|
-
int thread_id;
|
|
6
|
-
MMDB_s *mmdb;
|
|
7
|
-
const char *ip_to_lookup;
|
|
8
|
-
} thread_arg_s;
|
|
9
|
-
|
|
10
|
-
typedef struct test_result {
|
|
11
|
-
const char *ip_looked_up;
|
|
12
|
-
int lookup_string_gai_error;
|
|
13
|
-
int lookup_string_mmdb_error;
|
|
14
|
-
int found_entry;
|
|
15
|
-
int get_value_status;
|
|
16
|
-
int data_type_ok;
|
|
17
|
-
char *data_value;
|
|
18
|
-
} test_result_s;
|
|
19
|
-
|
|
20
|
-
void test_one_ip(MMDB_s *mmdb, const char *ip, test_result_s *test_result)
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
test_result->ip_looked_up = ip;
|
|
24
|
-
|
|
25
|
-
int gai_error = 0;
|
|
26
|
-
int mmdb_error = 0;
|
|
27
|
-
MMDB_lookup_result_s result =
|
|
28
|
-
MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error);
|
|
29
|
-
|
|
30
|
-
test_result->lookup_string_gai_error = gai_error;
|
|
31
|
-
if (gai_error) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
test_result->lookup_string_mmdb_error = mmdb_error;
|
|
36
|
-
if (mmdb_error) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
test_result->found_entry = result.found_entry;
|
|
41
|
-
if (!result.found_entry) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
MMDB_entry_data_s data;
|
|
46
|
-
int status = MMDB_get_value(&result.entry, &data, "ip", NULL);
|
|
47
|
-
|
|
48
|
-
test_result->get_value_status = status;
|
|
49
|
-
if (status) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
test_result->data_type_ok = data.type == MMDB_DATA_TYPE_UTF8_STRING;
|
|
54
|
-
if (!test_result->data_type_ok) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
test_result->data_value = strndup(data.utf8_string, data.data_size);
|
|
59
|
-
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
void *run_one_thread(void *arg)
|
|
64
|
-
{
|
|
65
|
-
thread_arg_s *thread_arg = (thread_arg_s *)arg;
|
|
66
|
-
|
|
67
|
-
MMDB_s *mmdb = thread_arg->mmdb;
|
|
68
|
-
const char *ip = thread_arg->ip_to_lookup;
|
|
69
|
-
|
|
70
|
-
test_result_s *result = malloc(sizeof(test_result_s));
|
|
71
|
-
test_one_ip(mmdb, ip, result);
|
|
72
|
-
|
|
73
|
-
pthread_exit((void *)result);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
void process_result(test_result_s *result, const char *expect,
|
|
77
|
-
const char *mode_desc)
|
|
78
|
-
{
|
|
79
|
-
int is_ok;
|
|
80
|
-
is_ok =
|
|
81
|
-
ok(!result->lookup_string_gai_error, "no getaddrinfo error for %s - %s",
|
|
82
|
-
result->ip_looked_up, mode_desc);
|
|
83
|
-
if (!is_ok) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
is_ok = ok(!result->lookup_string_mmdb_error, "no mmdb error for %s - %s",
|
|
88
|
-
result->ip_looked_up, mode_desc);
|
|
89
|
-
if (!is_ok) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
is_ok = ok(result->found_entry, "got a result for %s in the database - %s",
|
|
94
|
-
result->ip_looked_up, mode_desc);
|
|
95
|
-
if (!is_ok) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
is_ok =
|
|
100
|
-
ok(!result->get_value_status,
|
|
101
|
-
"no error from MMDB_get_value for %s - %s",
|
|
102
|
-
result->ip_looked_up,
|
|
103
|
-
mode_desc);
|
|
104
|
-
if (!is_ok) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
is_ok = ok(result->data_type_ok,
|
|
109
|
-
"MMDB_get_value found a utf8_string at 'ip' key for %s - %s",
|
|
110
|
-
result->ip_looked_up, mode_desc);
|
|
111
|
-
if (!is_ok) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
is(result->data_value, expect,
|
|
116
|
-
"found expected result for 'ip' key for %s - %s",
|
|
117
|
-
result->ip_looked_up, mode_desc);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
void run_ipX_tests(MMDB_s *mmdb, const char *pairs[][2], int pairs_rows,
|
|
121
|
-
int mode, const char *mode_desc)
|
|
122
|
-
{
|
|
123
|
-
pthread_t threads[pairs_rows];
|
|
124
|
-
struct thread_arg thread_args[pairs_rows];
|
|
125
|
-
|
|
126
|
-
for (int i = 0; i < pairs_rows; i += 1) {
|
|
127
|
-
thread_args[i].thread_id = i;
|
|
128
|
-
thread_args[i].mmdb = mmdb;
|
|
129
|
-
thread_args[i].ip_to_lookup = pairs[i][0];
|
|
130
|
-
|
|
131
|
-
int error = pthread_create(&threads[i], NULL, run_one_thread,
|
|
132
|
-
&thread_args[i]);
|
|
133
|
-
if (error) {
|
|
134
|
-
BAIL_OUT("pthread_create failed");
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
for (int i = 0; i < pairs_rows; i += 1) {
|
|
139
|
-
void *thread_return;
|
|
140
|
-
int error = pthread_join(threads[i], &thread_return);
|
|
141
|
-
if (error) {
|
|
142
|
-
BAIL_OUT("pthread_join failed");
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
test_result_s *test_result = (test_result_s *)thread_return;
|
|
146
|
-
if (NULL != test_result) {
|
|
147
|
-
process_result(test_result, pairs[i][1], mode_desc);
|
|
148
|
-
if (test_result->data_type_ok) {
|
|
149
|
-
free(test_result->data_value);
|
|
150
|
-
}
|
|
151
|
-
free(test_result);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
void run_tests(int mode, const char *mode_desc)
|
|
157
|
-
{
|
|
158
|
-
const char *filename = "MaxMind-DB-test-mixed-32.mmdb";
|
|
159
|
-
const char *path = test_database_path(filename);
|
|
160
|
-
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
|
|
161
|
-
free((void *)path);
|
|
162
|
-
|
|
163
|
-
const char *pairs[18][2] = {
|
|
164
|
-
{ "1.1.1.1", "::1.1.1.1" },
|
|
165
|
-
{ "1.1.1.2", "::1.1.1.2" },
|
|
166
|
-
{ "1.1.1.3", "::1.1.1.2" },
|
|
167
|
-
{ "1.1.1.7", "::1.1.1.4" },
|
|
168
|
-
{ "1.1.1.9", "::1.1.1.8" },
|
|
169
|
-
{ "1.1.1.15", "::1.1.1.8" },
|
|
170
|
-
{ "1.1.1.17", "::1.1.1.16" },
|
|
171
|
-
{ "1.1.1.31", "::1.1.1.16" },
|
|
172
|
-
{ "1.1.1.32", "::1.1.1.32" },
|
|
173
|
-
{ "::1:ffff:ffff", "::1:ffff:ffff" },
|
|
174
|
-
{ "::2:0:0", "::2:0:0" },
|
|
175
|
-
{ "::2:0:1a", "::2:0:0" },
|
|
176
|
-
{ "::2:0:40", "::2:0:40" },
|
|
177
|
-
{ "::2:0:4f", "::2:0:40" },
|
|
178
|
-
{ "::2:0:50", "::2:0:50" },
|
|
179
|
-
{ "::2:0:52", "::2:0:50" },
|
|
180
|
-
{ "::2:0:58", "::2:0:58" },
|
|
181
|
-
{ "::2:0:59", "::2:0:58" },
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
run_ipX_tests(mmdb, pairs, 18, mode, mode_desc);
|
|
185
|
-
|
|
186
|
-
MMDB_close(mmdb);
|
|
187
|
-
free(mmdb);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
int main(void)
|
|
191
|
-
{
|
|
192
|
-
plan(NO_PLAN);
|
|
193
|
-
for_all_modes(&run_tests);
|
|
194
|
-
done_testing();
|
|
195
|
-
pthread_exit(NULL);
|
|
196
|
-
}
|