Add method to change MHD_OPTION_PER_IP_CONNECTION_LIMIT

Adds new method setIpConnectionLimit() to server.
Default is 0 (infinite)
This commit is contained in:
Nikhil Tanwar committed 2022-02-05 18:31:42 +05:30
1 parent ce24b1fa5f
commit 261adf0ef9
4 files changed
+11 -3

No files matched your search

+4 -1
View File
@@ -120,7 +120,8 @@ InternalServer::InternalServer(Library* library,
bool withTaskbar,
bool withLibraryButton,
bool blockExternalLinks,
std::string indexTemplateString) :
std::string indexTemplateString,
int ipConnectionLimit) :
m_addr(addr),
m_port(port),
m_root(normalizeRootUrl(root)),
@@ -130,6 +131,7 @@ InternalServer::InternalServer(Library* library,
m_withLibraryButton(withLibraryButton),
m_blockExternalLinks(blockExternalLinks),
m_indexTemplateString(indexTemplateString.empty() ? RESOURCE::templates::index_html : indexTemplateString),
m_ipConnectionLimit(ipConnectionLimit),
mp_daemon(nullptr),
mp_library(library),
mp_nameMapper(nameMapper ? nameMapper : &defaultNameMapper)
@@ -168,6 +170,7 @@ bool InternalServer::start() {
this,
MHD_OPTION_SOCK_ADDR, &sockAddr,
MHD_OPTION_THREAD_POOL_SIZE, m_nbThreads,
MHD_OPTION_PER_IP_CONNECTION_LIMIT, m_ipConnectionLimit,
MHD_OPTION_END);
if (mp_daemon == nullptr) {
std::cerr << "Unable to instantiate the HTTP daemon. The port " << m_port