summaryrefslogtreecommitdiffhomepage
path: root/config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'config.cpp')
-rw-r--r--config.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/config.cpp b/config.cpp
index d28a3c1..17376d0 100644
--- a/config.cpp
+++ b/config.cpp
@@ -20,8 +20,11 @@ void Config::readConfigfile(std::string filename)
// mandatory
m_user = tree.get<std::string>("webserver.user");
+
m_group = tree.get<std::string>("webserver.group");
+ m_threads = tree.get<int>("webserver.threads");
+
// optional entries
auto elements = tree.get_child_optional("webserver");
if (elements) {
@@ -71,11 +74,15 @@ void Config::readConfigfile(std::string filename)
socket_struct.port = x.second.data();
} else if (x.first == "protocol"s) {
if (x.second.data() == "http"s)
- socket_struct.protocol = HTTP;
+ socket_struct.protocol = SocketProtocol::HTTP;
else if (x.second.data() == "https"s)
- socket_struct.protocol = HTTPS;
+ socket_struct.protocol = SocketProtocol::HTTPS;
else
throw std::runtime_error("Unknown protocol: "s + x.second.data());
+ } else if (x.first == "certpath"s) {
+ socket_struct.cert_path = x.second.data();
+ } else if (x.first == "keypath"s) {
+ socket_struct.key_path = x.second.data();
} else
throw std::runtime_error("Unknown element: "s + x.first);
}
@@ -102,6 +109,11 @@ std::string Config::Group() const
return m_group;
}
+int Config::Threads() const
+{
+ return m_threads;
+}
+
const std::vector<std::string>& Config::PluginDirectories() const
{
return m_plugin_directories;
@@ -122,6 +134,8 @@ void Config::dump() const
std::cout << "=== Configuration ===========================" << std::endl;
std::cout << "User: " << m_user << std::endl;
std::cout << "Group: " << m_user << std::endl;
+
+ std::cout << "Threads: " << m_threads << std::endl;
std::cout << "Plugin Directories:";
for (const auto& dir: m_plugin_directories)
@@ -131,17 +145,21 @@ void Config::dump() const
for (const auto& site: m_sites) {
std::cout << "Site: " << site.name << ": " << site.host << std::endl;
if (site.paths.size() == 0)
- std::cout << " Warning: No paths configured." << std::endl;
+ std::cout << " Warning: No paths configured." << std::endl;
for (const auto& path: site.paths) {
- std::cout << " Path: " << path.requested << " -> " << ((path.type == Files) ? "files" : "plugin") << std::endl;
+ std::cout << " Path: " << path.requested << " -> " << ((path.type == Files) ? "files" : "plugin") << std::endl;
for (const auto& param: path.params) {
- std::cout << " " << param.first << ": " << param.second << std::endl;
+ std::cout << " " << param.first << ": " << param.second << std::endl;
}
}
}
for (const auto& socket: m_sockets) {
- std::cout << "Socket: " << socket.address << ":" << socket.port << " (" << (socket.protocol == HTTP ? "HTTP" : "HTTPS") << ")" << std::endl;
+ std::cout << "Socket: " << socket.address << ":" << socket.port << " (" << (socket.protocol == SocketProtocol::HTTP ? "HTTP" : "HTTPS") << ")" << std::endl;
+ if (socket.protocol == SocketProtocol::HTTPS) {
+ std::cout << " Key: " << socket.key_path.generic_string() << std::endl;
+ std::cout << " Cert: " << socket.cert_path.generic_string() << std::endl;
+ }
}
std::cout << "=============================================" << std::endl;
}