ores.geo

Table of Contents

1. Diagram

ores.geo component diagram

Figure 1: ores.geo

2. Summary

ores.geo answers one question: which country does this IP address belong to. It reads ores_geo_ip2country_tbl in PostgreSQL through the ores_geo_ip2country_lookup_fn function, and exposes a geolocation_service that returns an ISO 3166-1 alpha-2 country code. The data source is ip2country, so the answer is country-level only; city and coordinate data are not available. ores.http constructs the service and calls it from its login route, and no other component consumes it.

3. Inputs

  • An IP address, IPv4 or IPv6, as a boost::asio::ip::address or a string.
  • ip2country ranges in ores_geo_ip2country_tbl, written by the dq ip2country publish path. No recreate step runs that path, so a database built from scratch answers address_not_found until a publish has run.
  • A database::context for the PostgreSQL connection.

4. Outputs

  • geolocation_result, holding the ISO 3166-1 alpha-2 country code.
  • A geolocation_error when the lookup cannot answer: address_not_found when no range covers the address, invalid_address when a string is not an address, or lookup_failed when the query throws.

5. Entry points

  • include/ores.geo/service/geolocation_service.hpp — the lookup API.

6. Dependencies

  • ores.database — the connection pool and the raw multi-column query helper.
  • ores_geo_ip2country_lookup_fn over ores_geo_ip2country_tbl, defined under projects/ores.sql/create/geo/.

7. Build dependencies

What the shared profile cannot know, declared here rather than hand-edited into the generated build file. Each block is spliced into its generated file after the profile's baseline.

8. See also

9. Test dependencies

The suites link what the profile cannot know about.

target_link_libraries(${lib_target_name}
    PUBLIC
        ores.database.lib
        ores.telemetry.core.lib
    PRIVATE
        Boost::boost)
target_link_libraries(${tests_target_name}
    PRIVATE
        ${lib_target_name}
        ores.telemetry.core.lib
        ores.testing.lib
        Catch2::Catch2
        faker-cxx::faker-cxx
        ores.openssl_cleanup
        Threads::Threads)

Emacs 29.3 (Org mode 9.6.15)