Skip to content
API Documentation
BastionGuard™
bsc::config::anonymous_namespace{Config.cpp} Namespace Reference

Functions

std::string expand_path (std::string path)
nlohmann::json to_json (const Config &cfg)

Function Documentation

◆ expand_path()

std::string bsc::config::anonymous_namespace{Config.cpp}::expand_path ( std::string path)

Definition at line 14 of file Config.cpp.

14 {
15 if (path.empty()) return path;
16 if (path[0] == '~') {
17 if (const char* home = std::getenv("HOME")) path.replace(0, 1, home);
18 }
19 return path;
20}

References expand_path().

Referenced by expand_path().

◆ to_json()

nlohmann::json bsc::config::anonymous_namespace{Config.cpp}::to_json ( const Config & cfg)

Definition at line 22 of file Config.cpp.

22 {
23 return nlohmann::json{
24 {"LogLevel", cfg.log_level},
25 {"Firewall", cfg.firewall},
26 {"DefaultAction", cfg.default_action},
27 {"DefaultDuration", cfg.default_duration},
28 {"ProcMonitorMethod", cfg.proc_monitor_method},
29 {"EBPFObjPath", cfg.ebpf_obj_path},
30 {"InterceptUnknown", cfg.intercept_unknown},
31 {"LogUTC", cfg.log_utc},
32 {"LogMicro", cfg.log_micro},
33 {"Server", {{"Address", cfg.server.address}, {"LogFile", cfg.server.log_file}, {"Authentication", {{"Type", cfg.server.authentication.type}}}}},
34 {"Rules", {{"Path", cfg.rules.path}, {"EnableChecksums", cfg.rules.enable_checksums}}},
35 {"FwOptions", {{"ConfigPath", cfg.fw_options.config_path}, {"MonitorInterval", cfg.fw_options.monitor_interval}, {"QueueNum", cfg.fw_options.queue_num}, {"QueueBypass", cfg.fw_options.queue_bypass}}},
36 {"Stats", {{"MaxEvents", cfg.stats.max_events}, {"MaxStats", cfg.stats.max_stats}, {"Workers", cfg.stats.workers}}},
37 {"Internal", {{"GCPercent", cfg.internal.gc_percent}, {"FlushConnsOnStart", cfg.internal.flush_conns_on_start}}},
38 {"Tasks", {{"ConfigPath", cfg.tasks.config_path}}}
39 };
40}
StatsOptions stats
Definition Config.hpp:60
RulesOptions rules
Definition Config.hpp:58
std::string default_duration
Definition Config.hpp:53
std::string proc_monitor_method
Definition Config.hpp:54
std::string firewall
Definition Config.hpp:51
InternalOptions internal
Definition Config.hpp:59
std::int32_t log_level
Definition Config.hpp:50
std::string ebpf_obj_path
Definition Config.hpp:55
FwOptions fw_options
Definition Config.hpp:56
TasksOptions tasks
Definition Config.hpp:61
ServerConfig server
Definition Config.hpp:57
std::string default_action
Definition Config.hpp:52

References bsc::config::Config::ServerConfig::address, bsc::config::Config::ServerConfig::authentication, bsc::config::Config::FwOptions::config_path, bsc::config::Config::TasksOptions::config_path, bsc::config::Config::default_action, bsc::config::Config::default_duration, bsc::config::Config::ebpf_obj_path, bsc::config::Config::RulesOptions::enable_checksums, bsc::config::Config::firewall, bsc::config::Config::InternalOptions::flush_conns_on_start, bsc::config::Config::fw_options, bsc::config::Config::InternalOptions::gc_percent, bsc::config::Config::intercept_unknown, bsc::config::Config::internal, bsc::config::Config::ServerConfig::log_file, bsc::config::Config::log_level, bsc::config::Config::log_micro, bsc::config::Config::log_utc, bsc::config::Config::StatsOptions::max_events, bsc::config::Config::StatsOptions::max_stats, bsc::config::Config::FwOptions::monitor_interval, bsc::config::Config::RulesOptions::path, bsc::config::Config::proc_monitor_method, bsc::config::Config::FwOptions::queue_bypass, bsc::config::Config::FwOptions::queue_num, bsc::config::Config::rules, bsc::config::Config::server, bsc::config::Config::stats, bsc::config::Config::tasks, to_json(), bsc::config::Config::ServerAuth::type, and bsc::config::Config::StatsOptions::workers.

Referenced by to_json().