2025-04-12 20:06:56 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
2025-04-15 14:49:29 +01:00
|
|
|
#include <re2/re2.h>
|
|
|
|
|
|
2025-04-15 01:34:57 +01:00
|
|
|
#include "IPRange.hpp"
|
|
|
|
|
|
2025-04-12 20:06:56 +01:00
|
|
|
class CConfig {
|
|
|
|
|
public:
|
|
|
|
|
CConfig();
|
|
|
|
|
|
2025-04-15 01:34:57 +01:00
|
|
|
enum eConfigIPAction : uint8_t {
|
2025-04-15 14:54:26 +01:00
|
|
|
IP_ACTION_NONE = 0,
|
|
|
|
|
IP_ACTION_DENY,
|
2025-04-15 01:34:57 +01:00
|
|
|
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 = "";
|
2025-04-15 01:34:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SIPRangeConfigParsed {
|
2025-04-15 14:49:29 +01:00
|
|
|
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-15 01:34:57 +01:00
|
|
|
};
|
|
|
|
|
|
2025-04-12 20:06:56 +01:00
|
|
|
struct SConfig {
|
2025-04-15 23:32:56 +01:00
|
|
|
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 = {};
|
2025-04-15 01:34:57 +01:00
|
|
|
int default_challenge_difficulty = 4;
|
2025-04-15 23:32:56 +01:00
|
|
|
bool async_proxy = true;
|
2025-04-12 20:06:56 +01:00
|
|
|
} m_config;
|
2025-04-15 01:34:57 +01:00
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
std::vector<SIPRangeConfigParsed> ip_configs;
|
|
|
|
|
} m_parsedConfigDatas;
|
2025-04-12 20:06:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inline std::unique_ptr<CConfig> g_pConfig;
|