/** * @file ip_to_geo.h * @author Lew Price (lewis.e.price@outlook.com) * @brief A series of functions for checking the location of a given IP * @version 0.1 * @date 2026-06-03 * * @copyright Copyright (c) 2026 * */ #pragma once #include struct loc_data { std::string country; std::string subdivision; std::string city; std::string latitutde; std::string longitude; }; /** * @brief Loads configuration keys from a local environment file. * * This function parses the project's `.env` configuration mapping and injects * the parameters into the system environment space via `setenv`. * * @param env_path Relative path configuration target string. Defaults to ".env". * * @note Users must alter the `.env` file to specify their own local file path for the `DB_PATH` variable pointing to the MaxMind MMDB database. * * @warning If the path provided in `.env` is invalid or missing, the GeoIP engine will fail to initialize. * * @attention Ensure your local firewall allows `geoipupdate` syncs if hosting the database externally. */ void load_env_file(const std::string& env_path = ".env"); /** * @brief Takes in a pointer to an ip address string and looks up the geolocation data via Maxmind DB (local) * @note Users must alter the `.env` file to specify their own local file path for the `DB_PATH` variable pointing to the MaxMind MMDB database. * * @return loc_data */ loc_data iplookup(const std::string&);