This plugin allows you to lookup an IP address with MaxMind's GeoIP2 database. Depending on the database type used the plugin will return different values. The plugin depends on the libmaxminddb library (libmaxminddb-dev) and the appropiate GeoLite2 databases obtained from MaxMind.
Upon error the function will return an associative array with a error
(string) property.
If a country database is used the plugin will return the country name country
(string) and country ISO code iso_code
(string) as an associative array. An empty array will be returned if no data is available for the queried IP.
If an ASN database is used the plugin will return the organization name organization
(string) and asn number
(number) as an associative array. An empty array will be returned if no data is available for the queried IP.
Follow the instructions in our manual to add our package repository and then run the below command.
apt-get install halon-extras-maxmind-geoip
yum install halon-extras-maxmind-geoip
smtpd.yaml
plugins:
- id: geoip
config:
path: /path/to/GeoLite2-Country.mmdb
A function called geoip
is now available in HSL and can be used in any context.
An example how you can use it in the connect hook.
import { geoip } from "extras://geoip";
$remoteip = $arguments["remoteip"];
echo "GeoIP: ".geoip($remoteip);