commit 292efe4aab89dd1ed260350e6f6bab04d8469e36
parent e5c2647ba4dc0b1a7a11457f7e19a296fb633ba6
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date: Fri, 30 May 2025 09:52:19 +0200
Daemon struct: added conns.cfg.per_ip_limit
Diffstat:
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/mhd2/daemon_start.c b/src/mhd2/daemon_start.c
@@ -149,6 +149,8 @@ daemon_set_basic_settings (struct MHD_Daemon *restrict d,
else if (max_timeout_ms_value < d->conns.cfg.timeout_ms)
d->conns.cfg.timeout_ms = max_timeout_ms_value;
+ d->conns.cfg.per_ip_limit = s->per_ip_limit;
+
return MHD_SC_OK;
}
@@ -2642,6 +2644,8 @@ set_connections_total_limits (struct MHD_Daemon *restrict d,
mhd_assert (resulting_limit >= num_worker_daemons);
d->conns.cfg.count_limit = resulting_limit;
+ if (d->conns.cfg.per_ip_limit <= d->conns.cfg.count_limit)
+ d->conns.cfg.per_ip_limit = 0; /* Already enforced by global limit */
return MHD_SC_OK;
}
diff --git a/src/mhd2/mhd_daemon.h b/src/mhd2/mhd_daemon.h
@@ -884,6 +884,11 @@ struct mhd_DaemonConnectionsSettings
unsigned int count_limit;
/**
+ * The maximum number of connections per any IP handled by the daemon
+ */
+ unsigned int per_ip_limit;
+
+ /**
* Connection's default timeout value (in milliseconds)
*/
uint_fast64_t timeout_ms;