From 1fcaed7a34cce8e55bb071d503bb583f715e7d37 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 4 Apr 2020 19:24:16 +0200 Subject: Serve configured sockets --- config.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'config.cpp') diff --git a/config.cpp b/config.cpp index 17376d0..c478265 100644 --- a/config.cpp +++ b/config.cpp @@ -40,7 +40,7 @@ void Config::readConfigfile(std::string filename) if (x.first == "name"s) { site_struct.name = x.second.data(); } else if (x.first == "host"s) { - site_struct.host = x.second.data(); + site_struct.hosts.insert(x.second.data()); } else if (x.first == "path"s) { Path path; auto attrs = x.second.get_child(""); @@ -91,6 +91,15 @@ void Config::readConfigfile(std::string filename) } } } + + // expand socket sites + for (auto& socket: m_sockets) { + if (socket.serve_sites.empty()) { + for (const auto& site: m_sites) { + socket.serve_sites.push_back(site.name); + } + } + } } Config::Config(const std::string& filename) @@ -143,7 +152,10 @@ void Config::dump() const std::cout << std::endl; for (const auto& site: m_sites) { - std::cout << "Site: " << site.name << ": " << site.host << std::endl; + std::cout << "Site: " << site.name << ":"; + for (const auto& host: site.hosts) + std::cout << " " << host; + std::cout << std::endl; if (site.paths.size() == 0) std::cout << " Warning: No paths configured." << std::endl; for (const auto& path: site.paths) { @@ -160,6 +172,11 @@ void Config::dump() const std::cout << " Key: " << socket.key_path.generic_string() << std::endl; std::cout << " Cert: " << socket.cert_path.generic_string() << std::endl; } + std::cout << " Serving:"; + for (const auto& site: socket.serve_sites) { + std::cout << " " << site; + } + std::cout << std::endl; } std::cout << "=============================================" << std::endl; } -- cgit v1.2.3