Resolves an IP address to geographic and network information using local MaxMind GeoIP2 databases (city-level location and ASN/network owner), without any external network call. Registered in the root context and reached from JS via the Formatter's getGeoIPService() property, and used internally to enrich web hit and email tracking records with a visitor's location. Falls back to returning null, rather than throwing, when a database was not loaded or a lookup fails, so callers do not need to special-case an uninitialised service for most methods.


Methods

getCityResponse(String ipAddress)

Returns: CityResponse

Looks up the city-level location for the given IP address, given as text, in the local city database.

ParameterDescription
ipAddressthe IP address to resolve, as a literal address or host name

getCityResponse(InetAddress ipAddress)

Returns: CityResponse

Looks up the city-level location for the given IP address in the local city database. Loopback (127.0.0.1) and private 10.x addresses are treated as not locatable and always resolve to null, as does any address once the underlying lookup fails, in which case the failure is logged rather than propagated.

ParameterDescription
ipAddressthe IP address to resolve

getGeoIPResponseAsJson(String ipAddress)

Returns: String

Looks up the city-level location for the given IP address and returns it as the raw JSON produced by the MaxMind response object. When the address is a comma-separated chain, as produced by a proxy header such as X-Forwarded-For, only the first non-blank entry is resolved.

ParameterDescription
ipAddressthe IP address to resolve, optionally a comma-separated chain of addresses

getGeoIPResponseAsJson(InetAddress ipAddress)

Returns: String

Looks up the city-level location for the given IP address and returns it as the raw JSON produced by the MaxMind response object.

ParameterDescription
ipAddressthe IP address to resolve

getAsnResponse(String ipAddress)

Returns: AsnResponse

Looks up the network (ASN) owner for the given IP address in the local ASN database, after normalising it with KademiUtils.getRemoteIP.

ParameterDescription
ipAddressthe IP address to resolve

getAsnResponse(InetAddress ipAddress)

Returns: AsnResponse

Looks up the network (ASN) owner for the given IP address in the local ASN database.

ParameterDescription
ipAddressthe IP address to resolve

getAsnResponseAsJson(String ipAddress)

Returns: String

Looks up the network (ASN) owner for the given IP address and returns it as the raw JSON produced by the MaxMind response object. Any resolution or lookup failure is caught internally, logged, and reported as null.

ParameterDescription
ipAddressthe IP address to resolve
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.