Files
LumberJack_TUI/ip_to_geo/ip_to_geo.hpp

46 lines
1.4 KiB
C++

/**
* @file ip_to_geo.hpp
* @author Lewis Price (lewis.e.price@outlook.com)
* @brief A series of functions for checking the location of a given IP
* @version 1.0.0
* @date 2026-06-09
*
* @copyright Copyright (c) 2026
*
*/
#pragma once
#include <string>
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&);