Additionally, I added a .env file and started using cmake build styles rather than g++ for more efficient compiling and testing. Changes to be committed: new file: .env new file: CMakeLists.txt new file: build/CMakeCache.txt new file: build/CMakeFiles/4.3.2/CMakeCXXCompiler.cmake new file: build/CMakeFiles/4.3.2/CMakeDetermineCompilerABI_CXX.bin new file: build/CMakeFiles/4.3.2/CMakeSystem.cmake new file: build/CMakeFiles/4.3.2/CompilerIdCXX/CMakeCXXCompilerId.cpp new file: build/CMakeFiles/4.3.2/CompilerIdCXX/a.out new file: build/CMakeFiles/CMakeConfigureLog.yaml new file: build/CMakeFiles/CMakeDirectoryInformation.cmake new file: build/CMakeFiles/InstallScripts.json new file: build/CMakeFiles/Makefile.cmake new file: build/CMakeFiles/Makefile2 new file: build/CMakeFiles/TargetDirectories.txt new file: build/CMakeFiles/cmake.check_cache new file: build/CMakeFiles/parselog_cli.dir/DependInfo.cmake new file: build/CMakeFiles/parselog_cli.dir/build.make new file: build/CMakeFiles/parselog_cli.dir/cmake_clean.cmake new file: build/CMakeFiles/parselog_cli.dir/compiler_depend.internal new file: build/CMakeFiles/parselog_cli.dir/compiler_depend.make new file: build/CMakeFiles/parselog_cli.dir/compiler_depend.ts new file: build/CMakeFiles/parselog_cli.dir/depend.make new file: build/CMakeFiles/parselog_cli.dir/flags.make new file: build/CMakeFiles/parselog_cli.dir/ip_to_geo/ip_to_geo.cpp.o new file: build/CMakeFiles/parselog_cli.dir/ip_to_geo/ip_to_geo.cpp.o.d new file: build/CMakeFiles/parselog_cli.dir/link.d new file: build/CMakeFiles/parselog_cli.dir/link.txt new file: build/CMakeFiles/parselog_cli.dir/log_parsing/log_parsing.cpp.o new file: build/CMakeFiles/parselog_cli.dir/log_parsing/log_parsing.cpp.o.d new file: build/CMakeFiles/parselog_cli.dir/main.cpp.o new file: build/CMakeFiles/parselog_cli.dir/main.cpp.o.d new file: build/CMakeFiles/parselog_cli.dir/progress.make new file: build/CMakeFiles/parselog_cli.dir/third_party/src/GeoLite2PP.cpp.o new file: build/CMakeFiles/parselog_cli.dir/third_party/src/GeoLite2PP.cpp.o.d new file: build/CMakeFiles/parselog_cli.dir/third_party/src/GeoLite2PP_error_category.cpp.o new file: build/CMakeFiles/parselog_cli.dir/third_party/src/GeoLite2PP_error_category.cpp.o.d new file: build/CMakeFiles/progress.marks new file: build/Makefile new file: build/cmake_install.cmake new file: build/compile_commands.json new file: build/parselog_cli new file: compile_commands.json new file: data/GeoLite2-City.mmdb modified: ip_to_geo/ip_to_geo.cpp modified: ip_to_geo/ip_to_geo.hpp modified: main.cpp deleted: parselog_cli.exe deleted: test renamed: ip_to_geo/GeoLite2PP.hpp -> third_party/include/GeoLite2PP.hpp new file: third_party/include/GeoLite2PP_error_category.hpp new file: third_party/include/GeoLite2PP_version.hpp new file: third_party/include/maxminddb.h new file: third_party/include/maxminddb_config.h new file: third_party/lib/libmaxminddb.a new file: third_party/src/GeoLite2PP.cpp new file: third_party/src/GeoLite2PP_error_category.cpp
38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
/**
|
|
* @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 <string>
|
|
|
|
/**
|
|
* @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 std::string
|
|
*/
|
|
std::string iplookup(const std::string&); |