.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Geo::IP::PurePerl 3" .TH Geo::IP::PurePerl 3 "2010-03-30" "perl v5.20.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Geo::IP::PurePerl \- Look up country by IP Address .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Geo::IP::PurePerl; \& \& my $gi = Geo::IP::PurePerl\->new(GEOIP_STANDARD); \& \& # look up IP address \*(Aq24.24.24.24\*(Aq \& my $country = $gi\->country_code_by_addr(\*(Aq24.24.24.24\*(Aq); \& $country = $gi\->country_code_by_name(\*(Aqyahoo.com\*(Aq); \& # $country is equal to "US" .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module uses a file based database. This database simply contains \&\s-1IP\s0 blocks as keys, and countries as values. This database is more complete and accurate than reverse \s-1DNS\s0 lookups. .PP This module can be used to automatically select the geographically closest mirror, to analyze your web server logs to determine the countries of your visiters, for credit card fraud detection, and for software export controls. .SH "IP ADDRESS TO COUNTRY DATABASES" .IX Header "IP ADDRESS TO COUNTRY DATABASES" The database is available for free, updated monthly: .PP .Vb 1 \& http://www.maxmind.com/download/geoip/database/ .Ve .PP This free database is similar to the database contained in IP::Country, as well as many paid databases. It uses \s-1ARIN, RIPE, APNIC,\s0 and \s-1LACNIC\s0 whois to obtain the \s-1IP\-\s0>Country mappings. .PP If you require greater accuracy, MaxMind offers a paid database on a paid subscription basis from http://www.maxmind.com/app/country .SH "CLASS METHODS" .IX Header "CLASS METHODS" .ie n .IP "$gi = Geo::IP\->new( [$flags] );" 4 .el .IP "\f(CW$gi\fR = Geo::IP\->new( [$flags] );" 4 .IX Item "$gi = Geo::IP->new( [$flags] );" Constructs a new Geo::IP object with the default database located inside your system's \&\fIdatadir\fR, typically \fI/usr/local/share/GeoIP/GeoIP.dat\fR. .Sp Flags can be set to either \s-1GEOIP_STANDARD,\s0 or for faster performance (at a cost of using more memory), \s-1GEOIP_MEMORY_CACHE.\s0 The default flag is \s-1GEOIP_STANDARD \s0(uses less memory, but runs slower). .ie n .IP "$gi = Geo::IP\->new( $database_filename );" 4 .el .IP "\f(CW$gi\fR = Geo::IP\->new( \f(CW$database_filename\fR );" 4 .IX Item "$gi = Geo::IP->new( $database_filename );" Calling the \f(CW\*(C`new\*(C'\fR constructor in this fashion was was deprecated after version 0.26 in order to make the \s-1XS\s0 and pure perl interfaces more similar. Use the \&\f(CW\*(C`open\*(C'\fR constructor (below) if you need to specify a path. Eventually, this means of calling \f(CW\*(C`new\*(C'\fR will no longer be supported. .Sp Flags can be set to either \s-1GEOIP_STANDARD,\s0 or for faster performance (at a cost of using more memory), \s-1GEOIP_MEMORY_CACHE.\s0 .ie n .IP "$gi = Geo::IP\->open( $database_filename, [$flags] );" 4 .el .IP "\f(CW$gi\fR = Geo::IP\->open( \f(CW$database_filename\fR, [$flags] );" 4 .IX Item "$gi = Geo::IP->open( $database_filename, [$flags] );" Constructs a new Geo::IP object with the database located at \f(CW$database_filename\fR. The default flag is \s-1GEOIP_STANDARD \s0(uses less memory, but runs slower). .SH "OBJECT METHODS" .IX Header "OBJECT METHODS" .ie n .IP "$code = $gi\->country_code_by_addr( $ipaddr );" 4 .el .IP "\f(CW$code\fR = \f(CW$gi\fR\->country_code_by_addr( \f(CW$ipaddr\fR );" 4 .IX Item "$code = $gi->country_code_by_addr( $ipaddr );" Returns the \s-1ISO 3166\s0 country code for an \s-1IP\s0 address. .ie n .IP "$code = $gi\->country_code_by_name( $ipname );" 4 .el .IP "\f(CW$code\fR = \f(CW$gi\fR\->country_code_by_name( \f(CW$ipname\fR );" 4 .IX Item "$code = $gi->country_code_by_name( $ipname );" Returns the \s-1ISO 3166\s0 country code for a hostname. .ie n .IP "$code = $gi\->country_code3_by_addr( $ipaddr );" 4 .el .IP "\f(CW$code\fR = \f(CW$gi\fR\->country_code3_by_addr( \f(CW$ipaddr\fR );" 4 .IX Item "$code = $gi->country_code3_by_addr( $ipaddr );" Returns the 3 letter country code for an \s-1IP\s0 address. .ie n .IP "$code = $gi\->country_code3_by_name( $ipname );" 4 .el .IP "\f(CW$code\fR = \f(CW$gi\fR\->country_code3_by_name( \f(CW$ipname\fR );" 4 .IX Item "$code = $gi->country_code3_by_name( $ipname );" Returns the 3 letter country code for a hostname. .ie n .IP "$name = $gi\->country_name_by_addr( $ipaddr );" 4 .el .IP "\f(CW$name\fR = \f(CW$gi\fR\->country_name_by_addr( \f(CW$ipaddr\fR );" 4 .IX Item "$name = $gi->country_name_by_addr( $ipaddr );" Returns the full country name for an \s-1IP\s0 address. .ie n .IP "$name = $gi\->country_name_by_name( $ipname );" 4 .el .IP "\f(CW$name\fR = \f(CW$gi\fR\->country_name_by_name( \f(CW$ipname\fR );" 4 .IX Item "$name = $gi->country_name_by_name( $ipname );" Returns the full country name for a hostname. .ie n .IP "$info = $gi\->database_info;" 4 .el .IP "\f(CW$info\fR = \f(CW$gi\fR\->database_info;" 4 .IX Item "$info = $gi->database_info;" Returns database string, includes version, date, build number and copyright notice. .ie n .IP "$old_charset = $gi\->set_charset( $charset );" 4 .el .IP "\f(CW$old_charset\fR = \f(CW$gi\fR\->set_charset( \f(CW$charset\fR );" 4 .IX Item "$old_charset = $gi->set_charset( $charset );" Set the charset for the city name \- defaults to \s-1GEOIP_CHARSET_ISO_8859_1. \s0 To set \s-1UTF8,\s0 pass \s-1GEOIP_CHARSET_UTF8\s0 to set_charset. .ie n .IP "$charset = $gi\->charset;" 4 .el .IP "\f(CW$charset\fR = \f(CW$gi\fR\->charset;" 4 .IX Item "$charset = $gi->charset;" Gets the currently used charset. .ie n .IP "$netmask = $gi\->last_netmask;" 4 .el .IP "\f(CW$netmask\fR = \f(CW$gi\fR\->last_netmask;" 4 .IX Item "$netmask = $gi->last_netmask;" Gets netmask of network block from last lookup. .ie n .IP "$gi\->netmask(12);" 4 .el .IP "\f(CW$gi\fR\->netmask(12);" 4 .IX Item "$gi->netmask(12);" Sets netmask for the last lookup .ie n .IP "my ( $from, $to ) = $gi\->range_by_ip('24.24.24.24');" 4 .el .IP "my ( \f(CW$from\fR, \f(CW$to\fR ) = \f(CW$gi\fR\->range_by_ip('24.24.24.24');" 4 .IX Item "my ( $from, $to ) = $gi->range_by_ip('24.24.24.24');" Returns the start and end of the current network block. The method tries to join several continous netblocks. .ie n .IP "@data = $gi\->get_city_record( $addr );" 4 .el .IP "\f(CW@data\fR = \f(CW$gi\fR\->get_city_record( \f(CW$addr\fR );" 4 .IX Item "@data = $gi->get_city_record( $addr );" .Vb 1 \& Returns a array filled with information about the city. \& \& my ($country_code,$country_code3,$country_name,$region,$city,$postal_code,$latitude,$longitude,$metro_code,$area_code ) = $gi\->get_city_record($addr); .Ve .ie n .IP "$href = get_city_record_as_hash( $addr );" 4 .el .IP "\f(CW$href\fR = get_city_record_as_hash( \f(CW$addr\fR );" 4 .IX Item "$href = get_city_record_as_hash( $addr );" .Vb 1 \& Returns a hashref filled with information about the city. \& \& my $href = $gi\->get_city_record_as_hash($addr); .Ve .Sp The hash include the following keys: country_code, country_code3, country_name, region, city, postal_code, latitude, longitude, metro_code, area_code .ie n .IP "$gi\->isp_by_addr($addr)" 4 .el .IP "\f(CW$gi\fR\->isp_by_addr($addr)" 4 .IX Item "$gi->isp_by_addr($addr)" .Vb 1 \& Returns the isp name for an ipaddress .Ve .ie n .IP "$gi\->isp_by_name($name)" 4 .el .IP "\f(CW$gi\fR\->isp_by_name($name)" 4 .IX Item "$gi->isp_by_name($name)" .Vb 1 \& Returns the isp name for a hostname .Ve .ie n .IP "$gi\->org_by_addr($addr)" 4 .el .IP "\f(CW$gi\fR\->org_by_addr($addr)" 4 .IX Item "$gi->org_by_addr($addr)" .Vb 1 \& Returns the organisation name for an ipaddress .Ve .ie n .IP "$gi\->org_by_name($name)" 4 .el .IP "\f(CW$gi\fR\->org_by_name($name)" 4 .IX Item "$gi->org_by_name($name)" .Vb 1 \& Returns the organisation name for a hostname .Ve .SH "MAILING LISTS AND CVS" .IX Header "MAILING LISTS AND CVS" Are available from SourceForge, see http://sourceforge.net/projects/geoip/ .SH "VERSION" .IX Header "VERSION" 1.25 .SH "SEE ALSO" .IX Header "SEE ALSO" Geo::IP \- this now has the PurePerl code merged it, so it supports both \s-1XS\s0 and Pure Perl implementations. The \s-1XS\s0 implementation is a wrapper around the GeoIP C \s-1API,\s0 which is much faster than the Pure Perl \s-1API.\s0 .SH "AUTHOR" .IX Header "AUTHOR" Copyright (c) 2010 MaxMind Inc .PP All rights reserved. This package is free software; it is licensed under the \s-1GPL.\s0