1) First draft of the TUI functionality
2) Added env_reader functions (env.hpp and env.cpp) 3) Program looks for a .env on startup and creates one based on user input if not found. 4) Refactored log_parsing and ip_to_geo to use the global env variables for parsing and ip lookup from the local .mmdb database 5) CMakeLists.txt is now cross platform functional 6) Added various cross platform checks for creating .env variables
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <ostream>
|
||||
@@ -9,7 +10,9 @@
|
||||
#include "../ip_to_geo/ip_to_geo.hpp"
|
||||
|
||||
p_logs::p_logs(std::string log_path) {
|
||||
|
||||
if(log_path.empty()){
|
||||
log_path = std::getenv("LOG_PATH");
|
||||
}
|
||||
std::ifstream file(log_path);
|
||||
if (!file.is_open()) {
|
||||
std::cerr << "Error loading " << log_path << std::endl;
|
||||
@@ -59,6 +62,10 @@ p_logs::p_logs(std::string log_path) {
|
||||
file.close();
|
||||
}
|
||||
|
||||
std::vector<Entry> p_logs::get_all_logs(){
|
||||
return logs;
|
||||
}
|
||||
|
||||
std::string p_logs::entryx_ip(int x){
|
||||
return logs[x].ip;
|
||||
}
|
||||
@@ -96,7 +103,7 @@ void p_logs::print_logs() {
|
||||
std::ios_base::sync_with_stdio(false);
|
||||
for (const auto& log : logs) {
|
||||
std::cout << "IP: " << log.ip.c_str() << "\n"
|
||||
<< "Location:" << "\n"
|
||||
<< "Location Data:" << "\n"
|
||||
<< "\tCountry: " << log.location.country << "\n"
|
||||
<< "\tSubdivision: " << log.location.subdivision << "\n"
|
||||
<< "\tCity: " << log.location.city << "\n"
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
* @param string
|
||||
*/
|
||||
p_logs(std::string);
|
||||
|
||||
std::vector<Entry> get_all_logs();
|
||||
|
||||
/**
|
||||
* @brief Getter function for a specific Entry's IP
|
||||
|
||||
Reference in New Issue
Block a user