Fixed the server to check correctly number of connections per
authorPekka Riikonen <priikone@silcnet.org>
Sun, 10 Mar 2002 18:12:28 +0000 (18:12 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sun, 10 Mar 2002 18:12:28 +0000 (18:12 +0000)
host by checking also the type of the connection.

CHANGES
TODO
apps/silcd/server.c
apps/silcd/server_util.c
apps/silcd/server_util.h

diff --git a/CHANGES b/CHANGES
index 6bd7de1e99ea14b4826606d348e8a92ac5637e8d..bc2264a7f4c4457dd75c30579cee0108322077f9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+Sun Mar 10 20:07:49 EET 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * 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 <priikone@silcnet.org>
 
        * Fixed the USERS command reply to save the user's mode on the
diff --git a/TODO b/TODO
index 6b95e0b9f2b6d23228866714e011e3cbd7ad7550..322e71f0792fc5dee65317a83331b397127010e0 100644 (file)
--- 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.
index 85cd3c0066ab64953937b8d05ecc527b69f43518..b9a09d99d4e4dcb830caee5c2e335dd6e5a1aebf 100644 (file)
@@ -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, 
index 7e83c5fc1947e8662d67a7441daf4d18f6a5d14f..4425e64dc5cdd96f4552b26c5af7692261205fad 100644 (file)
@@ -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++;
   }
 
index b7e040451df8ed31cc705a83aaf50f1013f3d9e3..83cd26bd8e055650d8e7480c9da7dea538fbda89 100644 (file)
@@ -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 */