Skip to content
MaxMind GeoIP support for Perl6
Perl6
Find file
Latest commit 3547ba0 Jan 2, 2016 @bbkr Merge pull request #9 from zoffixznet/fix-meta
Fix meta
Failed to load latest commit information.
lib fixed more appropriate int types Dec 30, 2015
logotype refactoring for IPv4 / IPv6 support Dec 29, 2015
t refactoring for IPv4 / IPv6 support Dec 29, 2015
.travis.yml manually install latest geoip database in debian, Travis uses too old… Dec 30, 2015
META.info
README.md documentation tidy Dec 30, 2015

README.md

MaxMind GeoIP legacy free/pro interface

Build Status

Currently City databases are supported.

Country, Region, Organization or ISP support may follow.

SYNOPSIS

    use GeoIP::City;

    my $gc = GeoIP::City.new;

    say $gc.locate( '8.8.8.8' );                # IPv4
    say $gc.locate( '2001:4860:4860::8888' );   # IPv6

METHODS

new( directory => '/home/me/geoip' )

Initialize databases.

Optional directory param overwrites default databases location, which may be useful for customized geoipupdate configuration and/or non-root users.

info

Check available database versions.

    {
        'GEOIP_CITY_EDITION_REV1' => 'GEO-533LITE 20151103 Build 1...',
        'GEOIP_CITY_EDITION_REV1_V6' => 'GEO-536LITE 20151103 Build 1...'
    }

locate ( $ip )

Find geo location for given IPv4 or IPv6 address.

Amount of fields in response may vary, below is the most complete one:

    {
        'area_code' => 650,
        'city' => 'Mountain View',
        'continent_code' => 'NA',
        'country' => 'United States',
        'country_code' => 'US',
        'dma_code' => 807,
        'latitude' => 37.384499,
        'longitude' => -122.088097,
        'postal_code' => '94040',
        'region' => 'California',
        'region_code' => 'CA',
        'time_zone' => 'America/Los_Angeles'
    }

If geo location for IP was not found then Nil is returned.

If database for given IP version is not available then GeoIP::City::X::DatabaseMissing exception is thrown.

REQUIREMENTS

MaxMind GeoIP C library and City legacy databases are required.

Ubuntu Linux

In terminal enter:

    sudo apt-get install libgeoip1 geoip-database-contrib
    sudo ln -s /usr/share/GeoIP/GeoLiteCityv6.dat /usr/share/GeoIP/GeoIPCityv6.dat

Mac OS X

Install Xcode from AppStore, then install HomeBrew.

In terminal enter:

    brew install geoip geoipupdate
    geoipupdate
    ln -s /usr/local/var/GeoIP/GeoLiteCityv6.dat /usr/local/var/GeoIP/GeoIPCityv6.dat

geoipupdate

To obtain databases through geoipupdate use following names as ProductIds:

  • 533 - Free IPv4 database. File GeoLiteCity.dat must be linked as GeoIPCity.dat.
  • 133 - Paid IPv4 database. In this case you also need valid license filled.
  • GeoLite-Legacy-IPv6-City - Free IPv6 database. File GeoLiteCityv6.dat must be linked as GeoIPCityv6.dat. (there is no paid version of IPv6 database)

Warning: Make sure your geoipupdate uses the same directory that libGeoIP expects. Or pass it explicitly to new( ).

Warning: Do not use old REV0 databases (for example paid ProductIds = 132).

LICENSE

Released under Artistic License 2.0.

CONTACT

You can find me (and awesome people who helped me to develop this module) on irc.freenode.net #perl6 channel as bbkr.

Something went wrong with that request. Please try again.