From 4ecd5017b929bac32862af26ec72a912903b1f97 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sun, 10 Mar 2002 18:12:28 +0000 Subject: [PATCH] Fixed the server to check correctly number of connections per host by checking also the type of the connection. --- CHANGES | 8 ++++++++ TODO | 8 ++++++++ apps/silcd/server.c | 7 ++++--- apps/silcd/server_util.c | 6 ++++-- apps/silcd/server_util.h | 3 ++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 6bd7de1e..bc2264a7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,11 @@ +Sun Mar 10 20:07:49 EET 2002 Pekka Riikonen + + * Fixed the server to check correctly the amount of connections + from single host, by checking also the type of the connection. + Fixed also the comparison of number of connections and number + of allowed connections. Affected files are silcd/server.c, + server_util.[ch]. + Fri Mar 8 17:16:41 EET 2002 Pekka Riikonen * Fixed the USERS command reply to save the user's mode on the diff --git a/TODO b/TODO index 6b95e0b9..322e71f0 100644 --- a/TODO +++ b/TODO @@ -212,3 +212,11 @@ describe new stuff to be added to protocol versions 1.x. 10. Check command reply error status types in various commands, specifically NO_FOPRIV is missing from many commands. To be included in protocol version 1.1. + + 11. Change the wording in Private Message Key Payload definition to + describe the problems of trusting the payload, and to indicate that + the receiver may not accept the key in the payload, and to describe + other means of distributing a key. + + 12. The router to router connection diagram in spec-xx is showing the + primary routers direction to wrong direction. Swap it. diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 85cd3c00..b9a09d99 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -1311,7 +1311,8 @@ SILC_TASK_CALLBACK(silc_server_accept_new_connection_final) entry->data.last_receive = time(NULL); - num_sockets = silc_server_num_sockets_by_ip(server, sock->ip); + num_sockets = silc_server_num_sockets_by_ip(server, sock->ip, + ctx->conn_type); switch (ctx->conn_type) { case SILC_SOCKET_TYPE_CLIENT: @@ -1336,7 +1337,7 @@ SILC_TASK_CALLBACK(silc_server_accept_new_connection_final) max_per_host = conn->param->connections_max_per_host; } - if (num_sockets > max_per_host) { + if (num_sockets >= max_per_host) { SILC_LOG_INFO(("Too many connections from %s (%s), closing connection", sock->hostname, sock->ip)); silc_server_disconnect_remote(server, sock, @@ -1439,7 +1440,7 @@ SILC_TASK_CALLBACK(silc_server_accept_new_connection_final) backup_router = sconn->backup_router; } - if (num_sockets > max_per_host) { + if (num_sockets >= max_per_host) { SILC_LOG_INFO(("Too many connections from %s (%s), closing connection", sock->hostname, sock->ip)); silc_server_disconnect_remote(server, sock, diff --git a/apps/silcd/server_util.c b/apps/silcd/server_util.c index 7e83c5fc..4425e64d 100644 --- a/apps/silcd/server_util.c +++ b/apps/silcd/server_util.c @@ -793,12 +793,14 @@ char *silc_server_name_modify_bad(const char *name, SilcUInt32 name_len) /* Find number of sockets by IP address indicated by `ip'. Returns 0 if socket connections with the IP address does not exist. */ -SilcUInt32 silc_server_num_sockets_by_ip(SilcServer server, const char *ip) +SilcUInt32 silc_server_num_sockets_by_ip(SilcServer server, const char *ip, + SilcSocketType type) { int i, count; for (i = 0, count = 0; i < server->config->param.connections_max; i++) { - if (server->sockets[i] && !strcmp(server->sockets[i]->ip, ip)) + if (server->sockets[i] && !strcmp(server->sockets[i]->ip, ip) && + server->sockets[i]->type == type) count++; } diff --git a/apps/silcd/server_util.h b/apps/silcd/server_util.h index b7e04045..83cd26bd 100644 --- a/apps/silcd/server_util.h +++ b/apps/silcd/server_util.h @@ -83,6 +83,7 @@ char *silc_server_name_modify_bad(const char *name, SilcUInt32 name_len); /* Find number of sockets by IP address indicated by `ip'. Returns 0 if socket connections with the IP address does not exist. */ -SilcUInt32 silc_server_num_sockets_by_ip(SilcServer server, const char *ip); +SilcUInt32 silc_server_num_sockets_by_ip(SilcServer server, const char *ip, + SilcSocketType type); #endif /* SERVER_UTIL_H */ -- 2.24.0