NAME
IP::Country::DB_File - IPv4 and IPv6 to country translation using DB_File
VERSION
version 2.99_01
SYNOPSIS
use IP::Country::DB_File;
my $ipcc = IP::Country::DB_File->new();
my $cc = $ipcc->inet_atocc('1.2.3.4');
my $cc = $ipcc->inet_atocc('host.example.com');
my $cc = $ipcc->inet6_atocc('1a00:300::');
my $cc = $ipcc->inet6_atocc('ipv6.example.com');
DESCRIPTION
IP::Country::DB_File is a light-weight module for fast IP address to country translation based on DB_File. The country code database is stored in a Berkeley DB file. You have to build the database using IP::Country::DB_File::Builder before you can lookup country codes.
This module tries to be API compatible with the other IP::Country modules. The installation of IP::Country is not required.
There are many other modules for locating IP addresses. Neil Bowers posted an excellent review. Some features that make this module unique:
IPv6 support.
Pure Perl.
Reasonably fast and accurate.
Builds the database directly from the statistics files of the regional internet registries. No third-party tie-in.
CONSTRUCTOR
new
my $ipcc = IP::Country::DB_File->new([ $db_file ]);
Creates a new object and opens the database file $db_file. $db_file defaults to ipcc.db. The database file can be built with IP::Country::DB_File::Builder or the build_ipcc.pl
command.
OBJECT METHODS
inet_atocc
my $cc = $ipcc->inet_atocc($host);
Looks up the country code of host $host. $host can either be an IPv4 address in dotted quad notation or a hostname.
If successful, returns the country code. In most cases this is an ISO-3166-1 alpha-2 country code, but there are also codes like 'EU' for Europe. See the documentation of IP::Country for more details.
Returns '**' for private IP addresses.
Returns undef if there's no country code listed for the IP address, the DNS lookup fails, or the host string is invalid.
inet_ntocc
my $cc = $ipcc->inet_ntocc($packed_address);
Like inet_atocc but works with a packed IPv4 address.
inet6_atocc
my $cc = $ipcc->inet6_atocc($host);
Like inet_atocc but works with IPv6 addresses or hosts.
inet6_ntocc
my $cc = $ipcc->inet6_ntocc($packed_address);
Like inet_ntocc but works with a packed IPv6 address.
db_time
my $time = $ipcc->db_time();
Returns the mtime of the DB file.
SEE ALSO
IP::Country, IP::Country::DB_File::Builder
AUTHOR
Nick Wellnhofer <wellnhofer@aevum.de>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Nick Wellnhofer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.