#include #include #include #include #include #include "ip_to_geo.hpp" #include "../third_party/include/GeoLite2PP.hpp" loc_data iplookup(const std::string& ip) { const char* env_db_path = std::getenv("DB_PATH"); std::string db_path = (env_db_path != nullptr) ? env_db_path : "data/GeoLite2-City.mmdb"; loc_data location; try { GeoLite2PP::DB db(db_path); std::map geo_data = db.get_all_fields(ip, "en"); location.country = geo_data["country"]; location.subdivision = geo_data["subdivision"]; location.city = geo_data["city"]; location.latitutde = geo_data["latitude"]; location.longitude = geo_data["longitude"]; } catch (const std::exception& e) { //std::cerr << "Database failed to load: " << e.what() << std::endl; } return location; };