updates.
authorPekka Riikonen <priikone@silcnet.org>
Fri, 30 Mar 2001 10:39:27 +0000 (10:39 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 30 Mar 2001 10:39:27 +0000 (10:39 +0000)
CHANGES
TODO
apps/silcd/command.c

diff --git a/CHANGES b/CHANGES
index 59a535f5fa29f85ba8b8479fce0d8a1976db8617..cc2ce9707c1a7bd453741000b1a250932eea7e11 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,12 @@
+Fri Mar 30 13:35:27 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Fixed the WHOIS and IDENTIFY send reply function to really
+         check whether to send list or just one entry.  Affected file
+         silcd/command.c.
+
+       * Cleaned up the LEAVE command's channel key distribution.  The
+         affected file silcd/command.c.
+
 Thu Mar 29 19:10:28 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Fixed a fatal bug when client does /join 1 2 3 4 5 6 the server
@@ -7,13 +16,6 @@ Thu Mar 29 19:10:28 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
        * Added SILC_MESSAGE_FLAG_REQUEST message flag as generic request
          flag.  It can be used to send message requests.
 
-       * Fixed the WHOIS and IDENTIFY send reply function to really
-         check whether to send list or just one entry.  Affected file
-         silcd/command.c.
-
-       * Cleaned up the LEAVE command's channel key distribution.  The
-         affected file silcd/command.c.
-
 Thu Mar 29 12:26:25 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Implemented the RESTART command in the client.
diff --git a/TODO b/TODO
index cc211d0259d10aeb664fb18f10f6245b129ed6fe..efd655d9aca2256faa3162fed4136aaf7e9d3beb 100644 (file)
--- a/TODO
+++ b/TODO
@@ -70,15 +70,6 @@ TODO In SILC Server
          When implementing this check that all commands handle the
          situation correctly when it is called as pending command
          (it should most likely check that cmd->pending == TRUE/FALSE).
-       o WHOIS and IDENTIFY command reply sending is buggy because
-         it may put status to be SILC_STATUS_LIST_START even though
-         there is only one valid entry (thus should be SILC_STATUS_OK).
-         This happens because it does not check the data.registered == FALSE
-         clients before setting the status.  Good fix for this would be
-         to make sure that the clients table does not include any
-         unregistered clients in the first place.
-       o Cleanup LEAVE command's channel key sending, it can be done
-         simpler by one function: silc_server_send_channel_key.
 
  o TODO in notify types (packet_receive.c):
 
@@ -141,11 +132,6 @@ TODO In SILC Libraries
    that needs to be commited (from Schneier's Yarrow-160 paper).  They 
    should make the RNG even better.
 
- o Scheduler needs to be analyzed on high load as it might be unfair
-   towards select() because it may run timeout tasks before select() and
-   after select().  If it is found to be unfair the timeout task running
-   before select() should probably be removed.
-
 
 TODO in the protocol before SILC 0.x
 ====================================
index ec42a1f6312853a748796a4955a53da0becb7294..ccc3cbb6a9ab8b243f2b8911b7f3c57ef4042a16 100644 (file)
@@ -528,11 +528,12 @@ silc_server_command_whois_check(SilcServerCommandContext cmd,
 static void
 silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
                                     SilcClientEntry *clients,
-                                    unsigned int clients_count)
+                                    unsigned int clients_count,
+                                    int count)
 {
   SilcServer server = cmd->server;
   char *tmp;
-  int i, count = 0, len;
+  int i, k, len;
   SilcBuffer packet, idp, channels;
   SilcClientEntry entry;
   SilcCommandStatus status;
@@ -541,11 +542,16 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
   unsigned char idle[4], mode[4];
   SilcSocketConnection hsock;
 
+  len = 0;
+  for (i = 0; i < clients_count; i++)
+    if (clients[i]->data.registered)
+      len++;
+
   status = SILC_STATUS_OK;
-  if (clients_count > 1)
+  if (len > 1)
     status = SILC_STATUS_LIST_START;
 
-  for (i = 0; i < clients_count; i++) {
+  for (i = 0, k = 0; i < clients_count; i++) {
     entry = clients[i];
 
     if (entry->data.registered == FALSE) {
@@ -559,15 +565,18 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
       continue;
     }
 
-    if (count && i - 1 == count)
-      break;
-
-    if (i >= 1)
+    if (k >= 1)
       status = SILC_STATUS_LIST_ITEM;
 
-    if (clients_count > 1 && i == clients_count - 1)
+    if (clients_count > 1 && k == clients_count - 1)
       status = SILC_STATUS_LIST_END;
 
+    if (count && k - 1 == count)
+      status = SILC_STATUS_LIST_END;
+
+    if (count && k - 1 > count)
+      break;
+
     /* Sanity check, however these should never fail. However, as
        this sanity check has been added here they have failed. */
     if (!entry->nickname || !entry->username || !entry->userinfo)
@@ -636,6 +645,8 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
     silc_buffer_free(idp);
     if (channels)
       silc_buffer_free(channels);
+
+    k++;
   }
 }
 
@@ -766,7 +777,8 @@ silc_server_command_whois_from_client(SilcServerCommandContext cmd)
   }
 
   /* Send the command reply to the client */
-  silc_server_command_whois_send_reply(cmd, clients, clients_count);
+  silc_server_command_whois_send_reply(cmd, clients, clients_count,
+                                      count);
 
  out:
   if (client_id_count) {
@@ -876,7 +888,8 @@ silc_server_command_whois_from_server(SilcServerCommandContext cmd)
   }
 
   /* Send the command reply to the client */
-  silc_server_command_whois_send_reply(cmd, clients, clients_count);
+  silc_server_command_whois_send_reply(cmd, clients, clients_count,
+                                      count);
 
  out:
   if (client_id_count) {
@@ -1333,11 +1346,12 @@ silc_server_command_identify_check(SilcServerCommandContext cmd,
 static void
 silc_server_command_identify_send_reply(SilcServerCommandContext cmd,
                                        SilcClientEntry *clients,
-                                       unsigned int clients_count)
+                                       unsigned int clients_count,
+                                       int count)
 {
   SilcServer server = cmd->server;
   char *tmp;
-  int i, count = 0, len;
+  int i, k, len;
   SilcBuffer packet, idp;
   SilcClientEntry entry;
   SilcCommandStatus status;
@@ -1345,11 +1359,16 @@ silc_server_command_identify_send_reply(SilcServerCommandContext cmd,
   char nh[256], uh[256];
   SilcSocketConnection hsock;
 
+  len = 0;
+  for (i = 0; i < clients_count; i++)
+    if (clients[i]->data.registered)
+      len++;
+
   status = SILC_STATUS_OK;
-  if (clients_count > 1)
+  if (len > 1)
     status = SILC_STATUS_LIST_START;
 
-  for (i = 0; i < clients_count; i++) {
+  for (i = 0, k = 0; i < clients_count; i++) {
     entry = clients[i];
 
     if (entry->data.registered == FALSE) {
@@ -1363,15 +1382,18 @@ silc_server_command_identify_send_reply(SilcServerCommandContext cmd,
       continue;
     }
 
-    if (count && i - 1 == count)
-      break;
-
-    if (i >= 1)
+    if (k >= 1)
       status = SILC_STATUS_LIST_ITEM;
 
-    if (clients_count > 1 && i == clients_count - 1)
+    if (clients_count > 1 && k == clients_count - 1)
       status = SILC_STATUS_LIST_END;
 
+    if (count && k - 1 == count)
+      status = SILC_STATUS_LIST_END;
+
+    if (count && k - 1 > count)
+      break;
+
     /* Send IDENTIFY reply */
     idp = silc_id_payload_encode(entry->id, SILC_ID_CLIENT);
     tmp = silc_argument_get_first_arg(cmd->args, NULL);
@@ -1414,6 +1436,8 @@ silc_server_command_identify_send_reply(SilcServerCommandContext cmd,
     
     silc_buffer_free(packet);
     silc_buffer_free(idp);
+
+    k++;
   }
 }
 
@@ -1541,7 +1565,8 @@ silc_server_command_identify_from_client(SilcServerCommandContext cmd)
   }
 
   /* Send the command reply to the client */
-  silc_server_command_identify_send_reply(cmd, clients, clients_count);
+  silc_server_command_identify_send_reply(cmd, clients, clients_count,
+                                         count);
 
  out:
   if (client_id_count) {
@@ -1648,7 +1673,7 @@ silc_server_command_identify_from_server(SilcServerCommandContext cmd)
   }
 
   /* Send the command reply */
-  silc_server_command_identify_send_reply(cmd, clients, clients_count);
+  silc_server_command_identify_send_reply(cmd, clients, clients_count, count);
 
  out:
   if (client_id_count) {
@@ -4187,6 +4212,9 @@ SILC_SERVER_CMD_FUNC(connect)
 
 SILC_SERVER_CMD_FUNC(restart)
 {
+  SilcServerCommandContext cmd = (SilcServerCommandContext)context;
+
+  silc_server_command_free(cmd);
 }
 
 /* Server side command of CLOSE. Closes connection to a specified server. */
@@ -4292,8 +4320,7 @@ SILC_SERVER_CMD_FUNC(leave)
   SilcClientEntry id_entry = (SilcClientEntry)cmd->sock->user_data;
   SilcChannelID *id;
   SilcChannelEntry channel;
-  SilcBuffer packet;
-  unsigned int i, len;
+  unsigned int len;
   unsigned char *tmp;
 
   SILC_SERVER_COMMAND_CHECK_ARGC(SILC_COMMAND_LEAVE, cmd, 1, 2);
@@ -4338,47 +4365,23 @@ SILC_SERVER_CMD_FUNC(leave)
                                  TRUE : FALSE, channel, id_entry->id,
                                  SILC_ID_CLIENT_LEN);
 
-  /* Remove client from channel */
-  i = silc_server_remove_from_one_channel(server, sock, channel, id_entry,
-                                         TRUE);
   silc_server_command_send_status_reply(cmd, SILC_COMMAND_LEAVE,
                                        SILC_STATUS_OK);
 
-  /* If the channel does not exist anymore we won't send anything */
-  if (!i)
+  /* Remove client from channel */
+  if (!silc_server_remove_from_one_channel(server, sock, channel, id_entry,
+                                          TRUE))
+    /* If the channel does not exist anymore we won't send anything */
     goto out;
 
   if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
     /* Re-generate channel key */
     silc_server_create_channel_key(server, channel, 0);
 
-    /* Encode channel key payload to be distributed on the channel */
-    packet = 
-      silc_channel_key_payload_encode(len, tmp,
-                                     strlen(channel->channel_key->
-                                            cipher->name),
-                                     channel->channel_key->cipher->name,
-                                     channel->key_len / 8, channel->key);
-
-    /* If we are normal server then we will send it to our router.  If we
-       are router we will send it to all local servers that has clients on
-       the channel */
-    if (server->server_type == SILC_SERVER) {
-      if (!server->standalone)
-       silc_server_packet_send(server, 
-                               cmd->server->router->connection,
-                               SILC_PACKET_CHANNEL_KEY, 0, packet->data,
-                               packet->len, FALSE);
-    } else {
-      
-    }
-
-    /* Send to locally connected clients on the channel */
-    silc_server_packet_send_local_channel(server, channel, 
-                                         SILC_PACKET_CHANNEL_KEY, 0,
-                                         packet->data, packet->len, FALSE);
-
-    silc_buffer_free(packet);
+    /* Send the channel key */
+    silc_server_send_channel_key(server, NULL, channel, 
+                                server->server_type == SILC_ROUTER ? 
+                                FALSE : !server->standalone);
   }
 
   silc_free(id);