Skip to content

Commit

Permalink
Add condition for number of clients allowed on the admin-port
Browse files Browse the repository at this point in the history
Signed-off-by: hwware <[email protected]>
  • Loading branch information
hwware committed Oct 11, 2024
1 parent bccac8c commit fe9bd71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fe9bd71

Please sign in to comment.