8.16
GeoIP
1 Introduction
This library provides utilities for working with MaxMindâs geolocation databases. It lets you look up information about where an IP address is located.
2 Usage
To use this library, youâre going to need to download one of MaxMindâs V2 databases. The library has been tested against their free "GeoLite2" databases, but should work with their enterprise DBs as well.
Once youâve downloaded one of the databases, you can read it using make-geoip. Thatâll return a structure that you can use to perform lookups using geoip-lookup. For example:
(define geoip (make-geoip "/path/to/some-database.mmdb")) (geoip-lookup geoip "127.0.0.1") (geoip-lookup geoip "188.24.7.80")
3 Reference
Returns #t when x is a geolocation database.
procedure
(make-geoip path) â geoip?
path : path-string?
Reads a MaxMind geolocation database into memory. Raises an error
if the database is not a version 2 database or if it is otherwise
invalid.
procedure
(geoip-metadata geoip) â (hash/c string? any/c)
geoip : geoip?
Returns the metadata for the given geoip database.
Added in version 0.2 of package geoip-lib.
Looks up an ip in the geoip database and returns a
hash of information about the address on success or #f when
the address cannot be found.