ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Member Functions | List of all members
geolocation_service Class Reference

Service for looking up geographic location from IP addresses. More...

#include <geolocation_service.hpp>

Collaboration diagram for geolocation_service:
Collaboration graph

Public Member Functions

 geolocation_service (database::context ctx)
 Construct a geolocation service with database context.
 
std::expected< geolocation_result, geolocation_errorlookup (const boost::asio::ip::address &ip) const
 Look up geolocation for an IP address.
 
std::expected< geolocation_result, geolocation_errorlookup (const std::string &ip_string) const
 Look up geolocation for an IP address string.
 

Detailed Description

Service for looking up geographic location from IP addresses.

Uses PostgreSQL ip2country table for lookups. The table must be populated with ip2country data from iptoasn.com using the geolocation_import.sql script.

Thread-safety: All public methods are thread-safe.

Constructor & Destructor Documentation

◆ geolocation_service()

Construct a geolocation service with database context.

Parameters
ctxDatabase context for PostgreSQL queries

Member Function Documentation

◆ lookup() [1/2]

std::expected< geolocation_result, geolocation_error > lookup ( const boost::asio::ip::address &  ip) const

Look up geolocation for an IP address.

Parameters
ipThe IP address to look up
Returns
Geolocation result or error
Here is the caller graph for this function:

◆ lookup() [2/2]

std::expected< geolocation_result, geolocation_error > lookup ( const std::string &  ip_string) const

Look up geolocation for an IP address string.

Parameters
ip_stringThe IP address string to look up
Returns
Geolocation result or error