summaryrefslogtreecommitdiffhomepage
path: root/config.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-02-10 19:34:47 +0100
committerRoland Reichwein <mail@reichwein.it>2023-02-10 19:34:47 +0100
commit00f02b19ad8ce2f8f0195d3610e06566bf68cd0c (patch)
treebf35dbcd980505ba9bc3404edb0921966b51cecf /config.cpp
parentcba42916126a1baed33a6f122a5301982993d344 (diff)
Added connection limit
Diffstat (limited to 'config.cpp')
-rw-r--r--config.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/config.cpp b/config.cpp
index d59156f..afb5cd2 100644
--- a/config.cpp
+++ b/config.cpp
@@ -14,6 +14,7 @@ namespace {
const uint64_t default_maxage{0}; // timeout in seconds; 0 = no timeout
const std::string default_listen {"::1:9000"};
const int default_threads{1};
+ const int default_max_connections{1000};
}
Config::Config(const std::string& config_filename):
@@ -21,7 +22,8 @@ Config::Config(const std::string& config_filename):
m_maxage{default_maxage},
m_listenAddress{"::1"},
m_listenPort{9000},
- m_threads{default_threads}
+ m_threads{default_threads},
+ m_max_connections{default_max_connections}
{
try {
@@ -42,6 +44,8 @@ Config::Config(const std::string& config_filename):
throw std::runtime_error("Bad listen port: "s + std::to_string(m_listenPort));
m_threads = tree.get<int>("config.threads", default_threads);
+
+ m_max_connections = tree.get<int>("config.maxconnections", default_max_connections);
} catch (const std::exception& ex) {
std::cerr << "Error reading config file " << config_filename << ". Using defaults." << std::endl;
}
@@ -71,3 +75,9 @@ int Config::getThreads() const
{
return m_threads;
}
+
+int Config::getMaxConnections() const
+{
+ return m_max_connections;
+}
+