To build this extension, you will need a current version of the GeoIP C API library installed.
Note that it is not necessary to explicitly use the following two procedures for accessing the GeoIP Standard Country database, as all the lookup procedures will use that database by default if no
DB argument is given.
Opens a GeoIP database with the specified
FLAGS, and returns it as a
geoip:database object. With no arguments given, will attempt to open the default
GeoIP.dat that ships with the GeoIP library. To enable caching, pass one of the following constants in
|GEOIP-STANDARD||Read database from file system. This is the default and uses the least memory.|
|GEOIP-MEMORY-CACHE||Load database into memory. Faster performance but uses more memory.|
|GEOIP-CHECK-CACHE||Check for updated database. If the database has been updated, reload the file handle and/or memory cache.|
Just cache the most frequently accessed index portion of the database, resulting in faster lookups than with
Opens a GeoIP database of the specified
TYPE from the standard installation location (usually
FLAGS are the same as for
TYPE can be one of the following constants:
Determines whether a GeoIP database of the class
TYPE has been installed.
Returns a constant indicating the type of the specified GeoIP database. When called without an argument, returns the type of the default database.
Returns a string containing information about the specified GeoIP database, including the type and release date. When called without an argument, returns information on the default database.
Looks up a 2-letter ISO 3166-1 country code based on the specified IP address.
Looks up a 2-letter ISO 3166-1 country code based on the specified hostname.
Looks up a 3-letter ISO 3166-1 country code based on the specified IP address.
Looks up a 3-letter ISO 3166-1 country code based on the specified hostname.
Looks up a country name based on the specified IP address.
Looks up a country name based on the specified hostname.
(use geoip) (geoip:database-available? GEOIP-COUNTRY-EDITION) ; => #t (geoip:database-available? GEOIP-ISP-EDITION) ; => #f (geoip:database-edition) ; => #\x1 (i.e. GEOIP-COUNTRY-EDITION) (geoip:database-info) ; => "GEO-106FREE 20050901 Build 1 Copyright (c) 2005 MaxMind LLC All Rights Reserved" (geoip:country-code-by-name "www.call-with-current-continuation.org") ; => "DE" (geoip:country-code-by-addr "22.214.171.124") ; => "DE" (geoip:country-code3-by-name "www.google.com") ; => "USA" (geoip:country-name-by-name "www.bbc.co.uk") ; => "United Kingdom"
Copyright (c) 2006 Arto Bendiken. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. This product includes GeoLite data created by MaxMind.