Files
checkpoint/src/config/Config.hpp

56 lines
1.9 KiB
C++
Raw Normal View History

2025-04-12 20:06:56 +01:00
#pragma once
#include <string>
#include <memory>
#include <re2/re2.h>
#include "IPRange.hpp"
2025-04-12 20:06:56 +01:00
class CConfig {
public:
CConfig();
enum eConfigIPAction : uint8_t {
2025-04-15 14:54:26 +01:00
IP_ACTION_NONE = 0,
IP_ACTION_DENY,
IP_ACTION_ALLOW,
IP_ACTION_CHALLENGE
};
struct SIPRangeConfig {
std::string action = "";
std::vector<std::string> ip_ranges;
2025-04-15 14:54:26 +01:00
int difficulty = -1;
std::string exclude_regex = "";
std::string action_on_exclude = "";
};
struct SIPRangeConfigParsed {
eConfigIPAction action = IP_ACTION_DENY;
std::vector<CIPRange> ip_ranges;
int difficulty = -1;
std::unique_ptr<re2::RE2> exclude_regex;
2025-04-15 14:54:26 +01:00
eConfigIPAction action_on_exclude = IP_ACTION_NONE;
};
2025-04-12 20:06:56 +01:00
struct SConfig {
int port = 3001;
std::string forward_address = "127.0.0.1:3000";
std::string data_dir = "";
std::string html_dir = "";
unsigned long int max_request_size = 10000000; // 10MB
bool git_host = false;
unsigned long int proxy_timeout_sec = 120; // 2 minutes
bool trace_logging = false;
std::vector<SIPRangeConfig> ip_configs = {};
int default_challenge_difficulty = 4;
bool async_proxy = true;
2025-04-12 20:06:56 +01:00
} m_config;
struct {
std::vector<SIPRangeConfigParsed> ip_configs;
} m_parsedConfigDatas;
2025-04-12 20:06:56 +01:00
};
inline std::unique_ptr<CConfig> g_pConfig;