mentat.services.geoip module

Implementation of internal geoip2 database library.

Prerequisites

This library is dependent on geoip2 (available through PyPI) and requires GeoLite2 Free downloadable databases:

Note

This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com/.

Warning

Work in progress and alpha code.

class mentat.services.geoip.GeoipService(asndb=None, citydb=None, countrydb=None)[source]

Bases: object

Implementation of internal geoip2 database service.

lookup(ipaddr)[source]

Lookup given IP address in all databases.

lookup_asn(ipaddr)[source]

Lookup given IP address in ASN database.

lookup_city(ipaddr)[source]

Lookup given IP address in city database.

lookup_country(ipaddr)[source]

Lookup given IP address in Country database.

setup()[source]

Setup internal geolocation database readers.

status()[source]

Display status of internal geolocation readers.

class mentat.services.geoip.GeoipServiceManager(core_config, updates=None)[source]

Bases: object

Class representing a custom GeoipServiceManager capable of understanding and parsing Mentat system core configurations and enabling easy way of unified bootstrapping of mentat.services.geoip.GeoipService service.

service()[source]

Return handle to geoip service according to internal configurations.

Returns

Reference to geoip service object.

Return type

mentat.services.geoip.GeoipService

mentat.services.geoip.init(core_config, updates=None)[source]

(Re-)Initialize GeoipServiceManager instance at module level and store the refence within module.

mentat.services.geoip.manager()[source]

Obtain reference to GeoipServiceManager instance stored at module level.

mentat.services.geoip.service()[source]

Obtain reference to GeoipService instance from module level manager.