File: country_v6.pl

package info (click to toggle)
libgeo-ip-perl 1.51-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,000 kB
  • sloc: perl: 6,844; makefile: 3
file content (23 lines) | stat: -rwxr-xr-x 443 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl

use strict;
use warnings;

use Geo::IP;

my $gi
    = Geo::IP->open( "/usr/local/share/GeoIP/GeoIPv6.dat", GEOIP_STANDARD );

die "Please install the CAPI for IPv6 support\n" unless $gi->api eq 'CAPI';

while (<DATA>) {
    chomp;
    my ($cc) = $gi->country_code_by_addr_v6($_) || '';
    print join( "\t", $_, $cc ) . "\n";
}

__DATA__
::24.24.24.24
2001:4860:0:1001::68
2002:1818:1818::
2001:638:500:101:2e0:81ff:fe24:37c6