See the MaxMind DB spec for more details on what node record values mean. These are the node's number (which is based on its position in the file) and the values of its left and right records. This callback is called with three arguments. The node callback is called for every node in the database's search tree. This method iterates over the entire search tree, calling the callbacks you provided for each data record and node in the tree.īoth callbacks are optional (although calling this with neither will do a lot of work for no good reason). $reader->iterate_search_tree( $data_callback, $node_callback ) Depending on the contents of the database, this can be a scalar or a reference to an array or hash. The method returns the data associated with the IP address. This method will die if the address is not a valid IP address. This can be either a dotted quad ( 1.2.3.4) or any valid IPv6 format ( abcd::1234, ::1.2.3.4, etc.). This method takes an IPv4 or IPv6 address as a string. Under normal usage, the reader simply opens the provided file to read from. For example, you can have the reader read from a filehandle opened to a scalar reference. ![]() You can also pass an additional parameter, "data_source", which must be a valid filehandle. The constructor will die if the file provided is not readable. It must be a string containing a path to a file. The "file" parameter is a required attribute for the constructor. If you need to check that an object is a valid reader, you should check that the object does the MaxMind::DB::Reader::Role::Reader role. Note that the class of the object returned will actually be either MaxMind::DB::Reader::PP or MaxMind::DB::Reader::XS. This module provides the following API: MaxMind::DB::Reader->new( file => $path ) You do not need to change your code to take advantage of it. If you install the XS implementation it will be automatically loaded. The XS implementation is approximately 100 times faster than the pure Perl implementation, so if speed is important to you, we highly recommend that you install it! There is a separate distribution on CPAN, MaxMind::DB::Reader::XS, that provides an XS implementation which links against libmaxminddb. The MaxMind-DB-Reader distribution ships with a single pure Perl implementation of the Reader API. In addition, if speed is critical, this API will always be faster than the GeoIP2 modules, since it returns results as a raw Perl data structure rather than as an object. ![]() This API will work with any MaxMind DB databases, regardless of whether it is a GeoIP2 database or not. That distribution provides a higher level OO interface to those databases. If you are looking for an interface to MaxMind's GeoIP2 or GeoLite2 downloadable databases, you should also check out the GeoIP2 distribution. ![]() This module provides a low-level interface to the MaxMind DB file format. My $record = $reader->record_for_address('1.2.3.4') DESCRIPTION Version 1.000014 SYNOPSIS my $reader = MaxMind::DB::Reader->new( file => 'path/to/database.mmdb' ) MaxMind::DB::Reader - Read MaxMind DB files and look up IP addresses VERSION
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |