diff --git a/src/networking.c b/src/networking.c index 80ef917738..d1c93447ae 100644 --- a/src/networking.c +++ b/src/networking.c @@ -1408,9 +1408,10 @@ void acceptCommonHandler(connection *conn, struct ClientFlags flags, char *ip) { return; } - if (port == server.admin_port && connIsLocal(conn) != 1) { - serverLog(LL_WARNING, "Denied connection. On admin-port, connections are" - " only accepted from the loopback interface."); + if (port == server.admin_port && (connIsLocal(conn) != 1 || + (listLength(server.clients) + getClusterConnectionsCount() >= server.maxclients + MAX_ADMIN_CLIENTS))) { + serverLog(LL_WARNING, "Denied connection. Max number of clients reached on admin-port or connection is not" + " from the loopback interface."); server.stat_rejected_conn++; connClose(conn); return; diff --git a/src/server.h b/src/server.h index 4cbea99f24..a138bb0955 100644 --- a/src/server.h +++ b/src/server.h @@ -116,6 +116,7 @@ struct hdr_histogram; #define CONFIG_MIN_HZ 1 #define CONFIG_MAX_HZ 500 #define MAX_CLIENTS_PER_CLOCK_TICK 200 /* HZ is adapted based on that. */ +#define MAX_ADMIN_CLIENTS 20 #define CRON_DBS_PER_CALL 16 #define CRON_DICTS_PER_DB 16 #define NET_MAX_WRITES_PER_EVENT (1024 * 64)