Geo  IP
1 Introduction
2 Usage
3 Reference
geoip?
make-geoip
geoip-metadata
geoip-lookup
8.12

GeoIP🔗ℹ

Bogdan Popa <bogdan@defn.io>

 (require geoip) package: geoip-lib

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🔗ℹ

procedure

(geoip? x)  boolean?

  x : any/c
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.

procedure

(geoip-lookup geoip ip)  (or/c false/c hash?)

  geoip : geoip?
  ip : string?
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.