17 std::string default_http_auth_key =
"123456789abcdefgh";
20 std::string
connDRIV,
connTRANS,
connUNAME,
connHOST,
connPORT,
connPATH,
connEXTP,
connURI,
http_address,
http_doc_root,
http_auth_key,
httpURI,
28 void init(std::string_view config_file_loc) {
29 config_file = config_file_loc;
30 INIReader reader(config_file);
36 if (reader.ParseError() < 0) {
40 logger.
info(
"HTTP Wrapper : http://0.0.0.0:8081/");
42 logger.
info(
"Config loaded from ", config_file);
44 http_address = reader.Get(
"http_server",
"address",
"0.0.0.0");
45 http_port = reader.GetInteger(
"http_server",
"port", 8081);
46 http_doc_root = reader.Get(
"http_server",
"doc_root",
".");
47 http_threads = reader.GetInteger(
"http_server",
"threads", 1);
49 http_auth_key = reader.Get(
"http_server",
"auth-key", default_http_auth_key);
51 logger.
warning(
"Using default HTTP Auth Key: ", default_http_auth_key);
53 connDRIV = reader.Get(
"libvirtd",
"driver",
"qemu");
54 connTRANS = reader.Get(
"libvirtd",
"transport",
"");
55 connUNAME = reader.Get(
"libvirtd",
"username",
"");
56 connHOST = reader.Get(
"libvirtd",
"hostname",
"");
57 connPORT = reader.Get(
"libvirtd",
"port",
"");
58 connPATH = reader.Get(
"libvirtd",
"path",
"system");
59 connEXTP = reader.Get(
"libvirtd",
"extras",
"");
67 connURI.append(connDRIV);
68 if (!connTRANS.empty())
69 connURI +=
'+' + connTRANS;
71 if (!connUNAME.empty())
72 connURI += connUNAME +
'@';
74 if (!connPORT.empty())
75 connURI +=
':' + connPORT;
77 if (!connEXTP.empty())
78 connURI +=
'?' + connEXTP;
84 httpURI.append(
"http://");
85 httpURI += http_address +
":" + std::to_string(
http_port);
IniConfig(std::string_view config_file_loc)
Definition: config.hpp:26
long http_threads
Definition: config.hpp:22
std::string httpURI
Definition: config.hpp:20
bool http_auth_key_required
Definition: config.hpp:23
void setColored(bool b)
Definition: logger.hpp:50
const std::string & getConnURI() const noexcept
Definition: config.hpp:88
std::string connPORT
Definition: config.hpp:20
void setDebug(bool b)
Definition: logger.hpp:49
std::string config_file
Definition: config.hpp:20
void setQuiet(bool b)
Definition: logger.hpp:48
std::string connEXTP
Definition: config.hpp:20
void buildHttpURI()
Definition: config.hpp:81
Logger logger
Definition: logger.hpp:58
Definition: config.hpp:15
std::string http_doc_root
Definition: config.hpp:20
std::string connPATH
Definition: config.hpp:20
std::string connHOST
Definition: config.hpp:20
void init(std::string_view config_file_loc)
Definition: config.hpp:28
bool isHTTPAuthRequired() const noexcept
Definition: config.hpp:92
void buildConnURI()
Definition: config.hpp:64
std::string http_address
Definition: config.hpp:20
void info(Ts...msg)
Definition: logger.hpp:34
std::string connURI
Definition: config.hpp:20
std::string connTRANS
Definition: config.hpp:20
const std::string & getHttpURI() const noexcept
Definition: config.hpp:90
void warning(Ts...msg)
Definition: logger.hpp:16
std::string connDRIV
Definition: config.hpp:20
std::string connUNAME
Definition: config.hpp:20
std::string http_auth_key
Definition: config.hpp:20
long http_port
Definition: config.hpp:22