updates.
authorPekka Riikonen <priikone@silcnet.org>
Fri, 25 Jan 2002 18:04:45 +0000 (18:04 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 25 Jan 2002 18:04:45 +0000 (18:04 +0000)
CHANGES
TODO
apps/irssi/docs/help/in/sconnect.in
apps/silcd/command.c
apps/silcd/packet_receive.c
apps/silcd/server.c
apps/silcd/server.h
apps/silcd/server_internal.h
apps/silcd/server_util.c

diff --git a/CHANGES b/CHANGES
index 0d6761e42cb96e5d1102170f1ce9fc7328c51771..f843b00b73de48b3d797aad4ab2b1a7090e72db0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,16 @@
+Fri Jan 25 19:12:36 EET 2002  Pekka Riikonen <priikone@silcnet.org>
+
+       * Added server & router operator statistics updating.  Affected
+         file silcd/packet_receive.c and silcd/command.c.
+
+       * Fixed the SERVER_SIGNOFF notify handling on normal server
+         not to save the history information for clients.  Same was
+         fixed earlier in remove_clients_by_server function, but not
+         here.  Affected file silcd/packet_receive.c.
+
+       * Raised the default connection-retry count from 4 to 7 in
+         server.  Affected file silcd/server.h.
+
 Tue Jan 22 18:19:36 EET 2002  Pekka Riikonen <priikone@silcnet.org>
 
        * Removed assert()'s from the lib/silcclient/client_keyagr.c.
diff --git a/TODO b/TODO
index b8f2c9ec9c6ab91c835fc6416953966e10df9119..2a2da686b2d6f715cecb91b76c2e4926be50fb6f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -81,6 +81,8 @@ TODO/bugs In SILC Server
        o IP address fields in configuration file should accept mask
          format as well, IP/MASK, and not just plain IP.
 
+ o Lots of statistics updating is missing around the server.
+
  o If client's public key is saved in the server (and doing public key
    authentication) then the hostname and the username information could
    be taken from the public key.  Should be a configuration option!
index 0d2137ba422fb0b99d82ca5dc802dc13cad83c32..f77c5d3d978752c89a1acd3affe52d2354edf6da 100644 (file)
@@ -2,7 +2,10 @@
 @SYNTAX:sconnect@
 
 Operator command. Makes an server to connect to another
-server or router.
+server or router.  The <server> is the hostname or IP 
+addres of the server.
+
+Example: /SCONNECT silc.silcnet.org 706
 
 See also: OPER, SILCOPER, CLOSE, SHUTDOWN
 
index 11e930370cf9a98f9a45daf6eb015055670fa035..d413a946ebaa43bdd6f9efc132a38831c385af25 100644 (file)
@@ -2657,6 +2657,7 @@ SILC_SERVER_CMD_FUNC(kill)
   SilcClientID *client_id;
   unsigned char *tmp, *comment;
   uint32 tmp_len, tmp_len2;
+  bool local;
 
   SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_KILL, cmd, 1, 2);
 
@@ -2694,9 +2695,11 @@ SILC_SERVER_CMD_FUNC(kill)
   /* Get the client entry */
   remote_client = silc_idlist_find_client_by_id(server->local_list, 
                                                client_id, TRUE, NULL);
+  local = TRUE;
   if (!remote_client) {
     remote_client = silc_idlist_find_client_by_id(server->global_list, 
                                                  client_id, TRUE, NULL);
+    local = FALSE;
     if (!remote_client) {
       silc_server_command_send_status_reply(cmd, SILC_COMMAND_KILL,
                                            SILC_STATUS_ERR_NO_SUCH_CLIENT_ID);
@@ -2750,9 +2753,17 @@ SILC_SERVER_CMD_FUNC(kill)
     silc_server_free_client_data(server, sock, remote_client, FALSE, NULL);
     silc_server_close_connection(server, sock);
   } else {
+    /* Update statistics */
+    if (remote_client->connection)
+      server->stat.my_clients--;
+    if (server->server_type == SILC_ROUTER)
+      server->stat.cell_clients--;
+    SILC_OPER_STATS_UPDATE(remote_client, server, SILC_UMODE_SERVER_OPERATOR);
+    SILC_OPER_STATS_UPDATE(remote_client, router, SILC_UMODE_ROUTER_OPERATOR);
+
     /* Remove remote client */
-    if (!silc_idlist_del_client(server->global_list, remote_client))
-      silc_idlist_del_client(server->local_list, remote_client);
+    silc_idlist_del_client(local ? server->local_list :
+                          server->global_list, remote_client);
   }
 
  out:
@@ -3640,9 +3651,14 @@ SILC_SERVER_CMD_FUNC(umode)
       goto out;
     }
   } else {
-    if (client->mode & SILC_UMODE_SERVER_OPERATOR)
-      /* Remove the server operator rights */
+    /* Remove the server operator rights */
+    if (client->mode & SILC_UMODE_SERVER_OPERATOR) {
       client->mode &= ~SILC_UMODE_SERVER_OPERATOR;
+      if (client->connection)
+       server->stat.my_server_ops--;
+      if (server->server_type == SILC_ROUTER)
+       server->stat.server_ops--;
+    }
   }
 
   if (mask & SILC_UMODE_ROUTER_OPERATOR) {
@@ -3653,9 +3669,14 @@ SILC_SERVER_CMD_FUNC(umode)
       goto out;
     }
   } else {
-    if (client->mode & SILC_UMODE_ROUTER_OPERATOR)
-      /* Remove the router operator rights */
+    /* Remove the router operator rights */
+    if (client->mode & SILC_UMODE_ROUTER_OPERATOR) {
       client->mode &= ~SILC_UMODE_ROUTER_OPERATOR;
+      if (client->connection)
+       server->stat.my_router_ops--;
+      if (server->server_type == SILC_ROUTER)
+       server->stat.router_ops--;
+    }
   }
 
   if (mask & SILC_UMODE_GONE) {
@@ -4590,6 +4611,12 @@ SILC_SERVER_CMD_FUNC(oper)
   /* Client is now server operator */
   client->mode |= SILC_UMODE_SERVER_OPERATOR;
 
+  /* Update statistics */
+  if (client->connection)
+    server->stat.my_server_ops++;
+  if (server->server_type == SILC_ROUTER)
+    server->stat.server_ops++;
+
   /* Send UMODE change to primary router */
   if (!server->standalone)
     silc_server_send_notify_umode(server, server->router->connection, TRUE,
@@ -4668,6 +4695,12 @@ SILC_SERVER_CMD_FUNC(silcoper)
   /* Client is now router operator */
   client->mode |= SILC_UMODE_ROUTER_OPERATOR;
 
+  /* Update statistics */
+  if (client->connection)
+    server->stat.my_router_ops++;
+  if (server->server_type == SILC_ROUTER)
+    server->stat.router_ops++;
+
   /* Send UMODE change to primary router */
   if (!server->standalone)
     silc_server_send_notify_umode(server, server->router->connection, TRUE,
index a4bedaef9f402599f9fbf6ffcc273c4ad851d012..85b1a1b20444afc59ec5584ba53d8aa24a87b245 100644 (file)
@@ -324,14 +324,18 @@ void silc_server_notify(SilcServer server,
     if (tmp_len > 128)
       tmp = NULL;
 
+    /* Update statistics */
+    server->stat.clients--;
+    if (server->server_type == SILC_ROUTER)
+      server->stat.cell_clients--;
+    SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
+    SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
+
     /* Remove the client from all channels. */
     silc_server_remove_from_channels(server, NULL, client, TRUE, tmp, FALSE);
 
     client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
     cache->expire = SILC_ID_CACHE_EXPIRE_DEF;
-    server->stat.clients--;
-    if (server->server_type == SILC_ROUTER)
-      server->stat.cell_clients--;
     break;
 
   case SILC_NOTIFY_TYPE_TOPIC_SET:
@@ -849,6 +853,7 @@ void silc_server_notify(SilcServer server,
        if (server->server_type != SILC_ROUTER &&
            silc_argument_get_arg_num(args) > 1) {
          int i;
+         bool local;
 
          for (i = 1; i < silc_argument_get_arg_num(args); i++) {
            /* Get Client ID */
@@ -862,9 +867,11 @@ void silc_server_notify(SilcServer server,
            /* Get client entry */
            client = silc_idlist_find_client_by_id(server->global_list, 
                                                   client_id, TRUE, &cache);
+           local = TRUE;
            if (!client) {
              client = silc_idlist_find_client_by_id(server->local_list, 
                                                     client_id, TRUE, &cache);
+             local = FALSE;
              if (!client) {
                silc_free(client_id);
                continue;
@@ -872,15 +879,20 @@ void silc_server_notify(SilcServer server,
            }
            silc_free(client_id);
 
-           /* Remove the client from all channels. */
-           silc_server_remove_from_channels(server, NULL, client, 
-                                            TRUE, NULL, FALSE);
-           
-           client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
-           cache->expire = SILC_ID_CACHE_EXPIRE_DEF;
+           /* Update statistics */
            server->stat.clients--;
            if (server->server_type == SILC_ROUTER)
              server->stat.cell_clients--;
+           SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
+           SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
+
+           /* Remove the client from all channels. */
+           silc_server_remove_from_channels(server, NULL, client, 
+                                            TRUE, NULL, FALSE);
+
+           /* Remove the client */
+           silc_idlist_del_client(local ? server->local_list :
+                                  server->global_list, client);
          }
        }
 
@@ -1025,7 +1037,7 @@ void silc_server_notify(SilcServer server,
      */
 
     SILC_LOG_DEBUG(("UMODE_CHANGE notify"));
-      
+
     /* Get client ID */
     tmp = silc_argument_get_arg_type(args, 1, &tmp_len);
     if (!tmp)
@@ -1051,9 +1063,33 @@ void silc_server_notify(SilcServer server,
     tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
     if (!tmp)
       goto out;
+    SILC_GET32_MSB(mode, tmp);
+
+#define SILC_UMODE_STATS_UPDATE(oper, mod)     \
+do {                                           \
+    if (client->mode & (mod)) {                        \
+      if (!(mode & (mod))) {                   \
+       if (client->connection)                 \
+         server->stat.my_ ## oper ## _ops--;   \
+        if (server->server_type == SILC_ROUTER)        \
+         server->stat. oper ## _ops--;         \
+      }                                                \
+    } else {                                   \
+      if (mode & (mod)) {                      \
+       if (client->connection)                 \
+         server->stat.my_ ## oper ## _ops++;   \
+        if (server->server_type == SILC_ROUTER)        \
+         server->stat. oper ## _ops++;         \
+      }                                                \
+    }                                          \
+} while(0)
+
+    /* Update statistics */
+    SILC_UMODE_STATS_UPDATE(server, SILC_UMODE_SERVER_OPERATOR);
+    SILC_UMODE_STATS_UPDATE(router, SILC_UMODE_ROUTER_OPERATOR);
 
     /* Save the mode */
-    SILC_GET32_MSB(client->mode, tmp);
+    client->mode = mode;
 
     break;
 
@@ -1121,7 +1157,6 @@ void silc_server_notify(SilcServer server,
        }
       }
     }
-
     break;
 
     /* Ignore rest of the notify types for now */
@@ -1673,10 +1708,14 @@ SilcClientEntry silc_server_new_client(SilcServer server,
                             server->stat.my_servers,
                             server->stat.my_routers));
     SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
-                           ("%d server operators and %d router operators "
-                            "online",
-                            server->stat.my_server_ops,
-                            server->stat.my_router_ops));
+                           ("There are %d server operators and %d router "
+                            "operators online",
+                            server->stat.server_ops,
+                            server->stat.router_ops));
+    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+                           ("I have %d operators online",
+                            server->stat.my_router_ops +
+                            server->stat.my_server_ops));
   } else {
     SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
                            ("I have %d clients and %d channels formed",
index 64c837a158d1d23d3d655931e7f259e26ecd8bfc..509453855b6313d4bf727fdf2d0bc6c20248e6b1 100644 (file)
@@ -2351,6 +2351,14 @@ void silc_server_free_client_data(SilcServer server,
     silc_server_remove_from_channels(server, NULL, client, 
                                     FALSE, NULL, FALSE);
     
+  /* Update statistics */
+  server->stat.my_clients--;
+  server->stat.clients--;
+  if (server->server_type == SILC_ROUTER)
+    server->stat.cell_clients--;
+  SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
+  SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
+
   /* We will not delete the client entry right away. We will take it
      into history (for WHOWAS command) for 5 minutes */
   i->server = server;
@@ -2362,12 +2370,7 @@ void silc_server_free_client_data(SilcServer server,
   client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
   client->router = NULL;
   client->connection = NULL;
-
-  /* Free the client entry and everything in it */
-  server->stat.my_clients--;
-  server->stat.clients--;
-  if (server->server_type == SILC_ROUTER)
-    server->stat.cell_clients--;
+  client->mode = 0;
 }
 
 /* Frees user_data pointer from socket connection object. This also sends
index 6590f602987c2fc207a111d4cc5ab9e444dde983..012d1edfb56fb2e400a45c5fc957a35ece73f033 100644 (file)
@@ -42,10 +42,10 @@ typedef struct SilcServerBackupStruct *SilcServerBackup;
 #define SILC_BACKUP_ROUTER 2
 
 /* Connection retry timeout. We implement exponential backoff algorithm
-   in connection retry. The interval of timeuot grows when retry count
+   in connection retry. The interval of timeout grows when retry count
    grows. */
-#define SILC_SERVER_RETRY_COUNT        4        /* Max retry count */
-#define SILC_SERVER_RETRY_MULTIPLIER   7 / 4    /* Interval growth */
+#define SILC_SERVER_RETRY_COUNT        7        /* Max retry count */
+#define SILC_SERVER_RETRY_MULTIPLIER   2        /* Interval growth */
 #define SILC_SERVER_RETRY_RANDOMIZER   2        /* timeout += rnd % 2 */
 #define SILC_SERVER_RETRY_INTERVAL_MIN 10       /* Min retry timeout */
 #define SILC_SERVER_RETRY_INTERVAL_MAX 600      /* Max generated timeout */
index 8001cf382e1c7c1cabcc2ff1cbf32f5be3f528e7..e50340b839c88f4fea73433686170124d8999ec2 100644 (file)
@@ -173,6 +173,16 @@ do {                                                                             \
   silc_schedule_set_listen_fd((s), (fd), (SILC_TASK_READ | SILC_TASK_WRITE)); \
 } while(0)
 
+#define SILC_OPER_STATS_UPDATE(c, type, mod)   \
+do {                                           \
+  if ((c)->mode & (mod)) {                     \
+    if ((c)->connection)                       \
+      server->stat.my_ ## type ## _ops--;      \
+    if (server->server_type == SILC_ROUTER)    \
+      server->stat. type ## _ops--;            \
+  }                                            \
+} while(0)
+
 /* Prototypes */
 SILC_TASK_CALLBACK_GLOBAL(silc_server_rekey_final);
 
index c41c8bcfe54f16adf2d894d5f279d2eec677ced0..88e6afa610357b01bccd8b9687d849d55a1d8a51 100644 (file)
@@ -210,6 +210,13 @@ bool silc_server_remove_clients_by_server(SilcServer server,
          silc_buffer_free(idp);
        }
 
+       /* Update statistics */
+       server->stat.clients--;
+       if (server->server_type == SILC_ROUTER)
+         server->stat.cell_clients--;
+       SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
+       SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
+
        /* Remove the client entry */
        silc_server_remove_clients_channels(server, NULL, client, channels);
        if (!server_signoff) {
@@ -218,9 +225,6 @@ bool silc_server_remove_clients_by_server(SilcServer server,
        } else {
          silc_idlist_del_client(server->local_list, client);
        }
-       server->stat.clients--;
-       if (server->server_type == SILC_ROUTER)
-         server->stat.cell_clients--;
 
        if (!silc_idcache_list_next(list, &id_cache))
          break;
@@ -270,6 +274,13 @@ bool silc_server_remove_clients_by_server(SilcServer server,
          silc_buffer_free(idp);
        }
 
+       /* Update statistics */
+       server->stat.clients--;
+       if (server->server_type == SILC_ROUTER)
+         server->stat.cell_clients--;
+       SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
+       SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
+
        /* Remove the client entry */
        silc_server_remove_clients_channels(server, NULL, client, channels);
        if (!server_signoff) {
@@ -278,9 +289,6 @@ bool silc_server_remove_clients_by_server(SilcServer server,
        } else {
          silc_idlist_del_client(server->global_list, client);
        }
-       server->stat.clients--;
-       if (server->server_type == SILC_ROUTER)
-         server->stat.cell_clients--;
 
        if (!silc_idcache_list_next(list, &id_cache))
          break;