updates.
[silc.git] / apps / silcd / command.c
index 8e835507c2ab0efc65c58a0b384ebf70e4729d75..48033266a4e0eb5f7ced7b97007340b52f18e0f3 100644 (file)
@@ -537,7 +537,7 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
   SilcClientEntry entry;
   SilcCommandStatus status;
   uint16 ident = silc_command_get_ident(cmd->payload);
-  char nh[128], uh[128];
+  char nh[256], uh[256];
   unsigned char idle[4], mode[4];
   SilcSocketConnection hsock;
 
@@ -2221,6 +2221,11 @@ SILC_SERVER_CMD_FUNC(invite)
     
     /* Get route to the client */
     dest_sock = silc_server_get_client_route(server, NULL, 0, dest_id, &idata);
+    if (!dest_sock) {
+      silc_server_command_send_status_reply(cmd, SILC_COMMAND_INVITE,
+                                           SILC_STATUS_ERR_NO_SUCH_CLIENT_ID);
+      goto out;
+    }
 
     memset(invite, 0, sizeof(invite));
     strncat(invite, dest->nickname, strlen(dest->nickname));
@@ -2307,13 +2312,20 @@ SILC_SERVER_CMD_FUNC(invite)
 
   /* Send command reply */
   tmp = silc_argument_get_arg_type(cmd->args, 1, &len);
-  packet = silc_command_reply_payload_encode_va(SILC_COMMAND_INVITE,
-                                               SILC_STATUS_OK, ident, 2,
-                                               2, tmp, len,
-                                               3, channel->invite_list,
-                                               channel->invite_list ?
-                                               strlen(channel->invite_list) :
-                                               0);
+
+  if (add || del)
+    packet = 
+      silc_command_reply_payload_encode_va(SILC_COMMAND_INVITE,
+                                          SILC_STATUS_OK, ident, 2,
+                                          2, tmp, len,
+                                          3, channel->invite_list,
+                                          channel->invite_list ?
+                                          strlen(channel->invite_list) : 0);
+  else
+    packet = 
+      silc_command_reply_payload_encode_va(SILC_COMMAND_INVITE,
+                                          SILC_STATUS_OK, ident, 1,
+                                          2, tmp, len);
   silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY, 0, 
                          packet->data, packet->len, FALSE);
   silc_buffer_free(packet);
@@ -2446,6 +2458,12 @@ SILC_SERVER_CMD_FUNC(kill)
     }
   }
 
+  if (remote_client->data.registered == FALSE) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_KILL,
+                                         SILC_STATUS_ERR_NO_SUCH_CLIENT_ID);
+    goto out;
+  }
+
   /* Get comment */
   comment = silc_argument_get_arg_type(cmd->args, 2, &tmp_len2);
   if (tmp_len2 > 128)
@@ -2642,13 +2660,20 @@ SILC_SERVER_CMD_FUNC(info)
   server_name = entry->server_name;
 
   /* Send the reply */
-  packet = silc_command_reply_payload_encode_va(SILC_COMMAND_INFO,
-                                               SILC_STATUS_OK, ident, 3,
-                                               2, idp->data, idp->len,
-                                               3, server_name, 
-                                               strlen(server_name),
-                                               4, server_info, 
-                                               strlen(server_info));
+  if (server_info)
+    packet = silc_command_reply_payload_encode_va(SILC_COMMAND_INFO,
+                                                 SILC_STATUS_OK, ident, 3,
+                                                 2, idp->data, idp->len,
+                                                 3, server_name, 
+                                                 strlen(server_name),
+                                                 4, server_info, 
+                                                 strlen(server_info));
+  else
+    packet = silc_command_reply_payload_encode_va(SILC_COMMAND_INFO,
+                                                 SILC_STATUS_OK, ident, 2,
+                                                 2, idp->data, idp->len,
+                                                 3, server_name, 
+                                                 strlen(server_name));
   silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY, 0, 
                          packet->data, packet->len, FALSE);
     
@@ -4757,6 +4782,8 @@ SILC_SERVER_CMD_FUNC(getkey)
   SilcBuffer pk;
   SilcIdType id_type;
 
+  SILC_LOG_DEBUG(("Start"));
+
   tmp = silc_argument_get_arg_type(cmd->args, 1, &tmp_len);
   if (!tmp) {
     silc_server_command_send_status_reply(cmd, SILC_COMMAND_GETKEY,
@@ -4778,9 +4805,15 @@ SILC_SERVER_CMD_FUNC(getkey)
        would be locally connected client so send the command further. */
     client = silc_idlist_find_client_by_id(server->local_list, 
                                           client_id, NULL);
+    if (!client)
+      client = silc_idlist_find_client_by_id(server->global_list, 
+                                            client_id, NULL);
     
     if ((!client && !cmd->pending && !server->standalone) ||
-       (client && !client->connection)) {
+       (client && !client->connection && !cmd->pending && 
+        !server->standalone) ||
+       (client && !client->data.public_key && !cmd->pending &&
+        !server->standalone)) {
       SilcBuffer tmpbuf;
       uint16 old_ident;
       SilcSocketConnection dest_sock;
@@ -4836,9 +4869,15 @@ SILC_SERVER_CMD_FUNC(getkey)
        would be locally connected server so send the command further. */
     server_entry = silc_idlist_find_server_by_id(server->local_list, 
                                                 server_id, NULL);
+    if (!server_entry)
+      server_entry = silc_idlist_find_server_by_id(server->global_list, 
+                                                  server_id, NULL);
     
     if ((!server_entry && !cmd->pending && !server->standalone) ||
-       (server_entry && !server_entry->connection)) {
+       (server_entry && !server_entry->connection && !cmd->pending &&
+        !server->standalone) ||
+       (server_entry && !server_entry->data.public_key && !cmd->pending &&
+        !server->standalone)) {
       SilcBuffer tmpbuf;
       uint16 old_ident;