updates.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 19 Mar 2001 20:25:14 +0000 (20:25 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 19 Mar 2001 20:25:14 +0000 (20:25 +0000)
CHANGES
apps/silc/client_ops.c
apps/silcd/command.c
apps/silcd/command_reply.c
apps/silcd/testi2.conf
doc/draft-riikonen-silc-spec-01.nroff
lib/silcclient/command_reply.c

diff --git a/CHANGES b/CHANGES
index 9ee79cc3e38ef4b6b5e3538de1e8c159d2fbc558..35c817a551d05ba9ce1b349c2f09c37e1411d556 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+Mon Mar 19 21:39:15 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+       * Added one new argument <user mode> to the WHOIS command reply
+         to return the mode of the user in SILC.  Updated the protocol
+         specs.
+
+         Implemented it to the server and client.
+
 Mon Mar 19 18:43:06 EET 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Fixed the mode printing on the user interface on joining.
index a37129d74d09255205f65aa48e53ab6ba5a90ddb..e7c3b7f655beb289a9c5710ae85903e3e238d374 100644 (file)
@@ -410,7 +410,7 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
       {
        char buf[1024], *nickname, *username, *realname;
        int len;
-       unsigned int idle;
+       unsigned int idle, mode;
 
        if (status == SILC_STATUS_ERR_NO_SUCH_NICK) {
          char *tmp;
@@ -433,6 +433,7 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
        username = va_arg(vp, char *);
        realname = va_arg(vp, char *);
        (void)va_arg(vp, void *);
+       mode = va_arg(vp, unsigned int);
        idle = va_arg(vp, unsigned int);
 
        memset(buf, 0, sizeof(buf));
@@ -454,6 +455,14 @@ void silc_command_reply(SilcClient client, SilcClientConnection conn,
        }
 
        client->ops->say(client, conn, "%s", buf);
+
+       if (mode)
+         client->ops->say(client, conn, "%s is %s", nickname,
+                          (mode & SILC_UMODE_SERVER_OPERATOR) ?
+                          "Server Operator" :
+                          (mode & SILC_UMODE_ROUTER_OPERATOR) ?
+                          "SILC Operator" : "[Unknown mode]");
+
        if (idle && nickname)
          client->ops->say(client, conn, "%s has been idle %d %s",
                           nickname,
index 215d0cbdb9456cac4c9ae19f4dc94e2006e89eae..1a8e7d628e4222655de1061730730076639d7662 100644 (file)
@@ -487,7 +487,7 @@ silc_server_command_whois_check(SilcServerCommandContext cmd,
   for (i = 0; i < clients_count; i++) {
     entry = clients[i];
 
-    if (!entry->nickname || !entry->username) {
+    if (!entry->nickname || !entry->username || !entry->userinfo) {
       SilcBuffer tmpbuf;
       unsigned short old_ident;
 
@@ -533,6 +533,9 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
   SilcClientEntry entry;
   SilcCommandStatus status;
   unsigned short ident = silc_command_get_ident(cmd->payload);
+  char nh[128], uh[128];
+  unsigned char idle[4], mode[4];
+  SilcSocketConnection hsock;
 
   status = SILC_STATUS_OK;
   if (clients_count > 1)
@@ -561,50 +564,49 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
 
     /* Sanity check, however these should never fail. However, as
        this sanity check has been added here they have failed. */
-    if (!entry->nickname || !entry->username)
+    if (!entry->nickname || !entry->username || !entry->userinfo)
       continue;
       
     /* Send WHOIS reply */
     idp = silc_id_payload_encode(entry->id, SILC_ID_CLIENT);
     tmp = silc_argument_get_first_arg(cmd->args, NULL);
     
-    {
-      char nh[256], uh[256];
-      unsigned char idle[4];
-      SilcSocketConnection hsock;
-
-      memset(uh, 0, sizeof(uh));
-      memset(nh, 0, sizeof(nh));
-
-      strncat(nh, entry->nickname, strlen(entry->nickname));
-      if (!strchr(entry->nickname, '@')) {
-       strncat(nh, "@", 1);
-       len = entry->router ? strlen(entry->router->server_name) :
-         strlen(server->server_name);
-       strncat(nh, entry->router ? entry->router->server_name :
-               server->server_name, len);
-      }
+    memset(uh, 0, sizeof(uh));
+    memset(nh, 0, sizeof(nh));
+    memset(idle, 0, sizeof(idle));
+    
+    strncat(nh, entry->nickname, strlen(entry->nickname));
+    if (!strchr(entry->nickname, '@')) {
+      strncat(nh, "@", 1);
+      len = entry->router ? strlen(entry->router->server_name) :
+       strlen(server->server_name);
+      strncat(nh, entry->router ? entry->router->server_name :
+             server->server_name, len);
+    }
       
-      strncat(uh, entry->username, strlen(entry->username));
-      if (!strchr(entry->username, '@')) {
-       strncat(uh, "@", 1);
-       hsock = (SilcSocketConnection)entry->connection;
-       len = strlen(hsock->hostname);
-       strncat(uh, hsock->hostname, len);
-      }
+    strncat(uh, entry->username, strlen(entry->username));
+    if (!strchr(entry->username, '@')) {
+      strncat(uh, "@", 1);
+      hsock = (SilcSocketConnection)entry->connection;
+      len = strlen(hsock->hostname);
+      strncat(uh, hsock->hostname, len);
+    }
       
+    if (entry->connection) {
       SILC_PUT32_MSB((time(NULL) - entry->data.last_receive), idle);
-      
-      packet = 
-       silc_command_reply_payload_encode_va(SILC_COMMAND_WHOIS,
-                                            status, ident, 5, 
-                                            2, idp->data, idp->len,
-                                            3, nh, strlen(nh),
-                                            4, uh, strlen(uh),
-                                            5, entry->userinfo, 
-                                            strlen(entry->userinfo),
-                                            7, idle, 4);
     }
+
+    SILC_PUT32_MSB(entry->mode, mode);
+
+    packet = silc_command_reply_payload_encode_va(SILC_COMMAND_WHOIS,
+                                                 status, ident, 6, 
+                                                 2, idp->data, idp->len,
+                                                 3, nh, strlen(nh),
+                                                 4, uh, strlen(uh),
+                                                 5, entry->userinfo, 
+                                                 strlen(entry->userinfo),
+                                                 7, mode, 4,
+                                                 8, idle, 4);
     
     silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY,
                            0, packet->data, packet->len, FALSE);
@@ -629,8 +631,8 @@ silc_server_command_whois_from_client(SilcServerCommandContext cmd)
      to our router if we are normal server, so let's do it now unless we
      are standalone. We will not send any replies to the client until we
      have received reply from the router. */
-  if (server->server_type == SILC_SERVER && 
-      !cmd->pending && !server->standalone) {
+  if (server->server_type == SILC_SERVER && !cmd->pending && 
+      !server->standalone) {
     SilcBuffer tmpbuf;
     unsigned short old_ident;
 
@@ -3668,8 +3670,9 @@ SILC_SERVER_CMD_FUNC(connect)
 
   /* Get port */
   tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
-  if (tmp)
+  if (tmp) {
     SILC_GET32_MSB(port, tmp);
+  }
 
   /* Create the connection. It is done with timeout and is async. */
   silc_server_create_connection(server, host, port);
@@ -3722,8 +3725,9 @@ SILC_SERVER_CMD_FUNC(close)
 
   /* Get port */
   tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
-  if (tmp)
+  if (tmp) {
     SILC_GET32_MSB(port, tmp);
+  }
 
   server_entry = silc_idlist_find_server_by_conn(server->local_list,
                                                 name, port, NULL);
index 360b85d2ae378320d40925ba0b461c443d92f205..1ff8818f2839d1ffbd6c85f006ee76ba302d70f8 100644 (file)
@@ -128,13 +128,14 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
 {
   SilcServer server = cmd->server;
   int len, id_len;
-  unsigned char *id_data;
+  unsigned char *tmp, *id_data;
   char *nickname, *username, *realname;
   SilcClientID *client_id;
   SilcClientEntry client;
   SilcIDCacheEntry cache = NULL;
   char global = FALSE;
   char *nick;
+  unsigned int mode = 0;
 
   id_data = silc_argument_get_arg_type(cmd->args, 2, &id_len);
   nickname = silc_argument_get_arg_type(cmd->args, 3, &len);
@@ -148,6 +149,12 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
     return FALSE;
   }
 
+  tmp = silc_argument_get_arg_type(cmd->args, 7, &len);
+  if (tmp) {
+    SILC_GET32_MSB(mode, tmp);
+  }
+
+
   client_id = silc_id_payload_parse_id(id_data, id_len);
   if (!client_id)
     return FALSE;
@@ -180,10 +187,14 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
     /* We don't have that client anywhere, add it. The client is added
        to global list since server didn't have it in the lists so it must be 
        global. */
-    silc_idlist_add_client(server->global_list, nick,
-                          strdup(username), 
-                          strdup(realname), client_id, 
-                          cmd->sock->user_data, NULL);
+    client = silc_idlist_add_client(server->global_list, nick,
+                                   strdup(username), 
+                                   strdup(realname), client_id, 
+                                   cmd->sock->user_data, NULL);
+    if (!client)
+      return FALSE;
+
+    client->mode = mode;
   } else {
     /* We have the client already, update the data */
 
@@ -208,6 +219,7 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
     client->nickname = nick;
     client->username = strdup(username);
     client->userinfo = strdup(realname);
+    client->mode = mode;
 
     if (cache) {
       cache->data = nick;
index e584862bc54b776543fdc5caa78fdd7c1dd172dc..d0c7bbf22cc8343d38f39ca6be0e691ae675c096 100644 (file)
@@ -1,17 +1,23 @@
 [Cipher]
-rc6:../lib/silcsim/modules/rc6.sim.so:16:16
-twofish:../lib/silcsim/modules/twofish.sim.so:16:16
-mars:../lib/silcsim/modules/mars.sim.so:16:16
+aes-256-cbc:../lib/silcsim/modules/aes.sim.so:32:16
+aes-192-cbc:../lib/silcsim/modules/aes.sim.so:24:16
+aes-128-cbc:../lib/silcsim/modules/aes.sim.so:16:16
+twofish-256-cbc:../lib/silcsim/modules/twofish.sim.so:32:16
+twofish-192-cbc:../lib/silcsim/modules/twofish.sim.so:24:16
+twofish-128-cbc:../lib/silcsim/modules/twofish.sim.so:16:16
+mars-256-cbc:../lib/silcsim/modules/mars.sim.so:32:16
+mars-192-cbc:../lib/silcsim/modules/mars.sim.so:24:16
+mars-128-cbc:../lib/silcsim/modules/mars.sim.so:16:16
 none:../lib/silcsim/modules/none.sim.so:0:0
 
-[Hash] 
+[Hash]
 md5::64:16
 sha1::64:20
 
 [hmac]
 hmac-sha1-96:sha1:12
 hmac-md5-96:md5:12
-hmac-sha1:sha1:20
+hmac-sha1:sha1:20   
 hmac-md5:md5:16
 
 #[PKCS]
@@ -25,10 +31,10 @@ nobody:nobody
 Mun huone:Mun servo:Pekka Riikonen:priikone@poseidon.pspt.fi
 
 [ServerInfo]
-lassi.kuo.fi.ssh.com:10.2.1.7:Kuopio, Finland:1334
+lassi.kuo.fi.ssh.com:212.146.42.253:Kuopio, Finland:1334
 
 [ListenPort]
-10.2.1.7:10.2.1.7:1334
+212.146.42.253:212.146.42.253:1334
 
 [Logging]
 infologfile:silcd2.log:10000
@@ -47,13 +53,13 @@ errorlogfile:silcd2.log:10000
 :::1336:1
 
 [AdminConnection]
-*:silc:silc:passwd:testi
+*:priikone:*:passwd:testi
 
 [ServerConnection]
-10.2.1.7:passwd:priikone:1333:1:1
+212.146.42.253:passwd:priikone:1336:1:1
 
 [RouterConnection]
-10.2.1.7:passwd:priikone:1334:1:1:0
+212.146.42.253:passwd:priikone:1335:1:1:0
 
 [DenyConnection]
 [RedirectClient]
index 3129a44390fda84f56baf2b2845be64222940694..509a8e93fa2af8997cfdf5dcd471aab78ce2b6a9 100644 (file)
@@ -1981,11 +1981,12 @@ List of all defined commands in SILC follows.
 
         Reply messages to the command:
 
-        Max Arguments:  7
+        Max Arguments:  8
             Arguments:  (1) <Status Payload>       (2) <Client ID> 
                         (3) <nickname>[@<server>]  (4) <username@host> 
                         (5) <real name>            (6) [<channel list>] 
-                        (7) [<idle time>]
+                        (7) [<user mode>]          (8) [<idle time>]
+
 
         This command may reply with several command reply messages to
         form a list of results.  In this case the status payload will
index d0f898a9283e873565c7ce9157c33944d9c65c27..559b5cf9022519941acd6aa2103c355cd9313555 100644 (file)
@@ -208,7 +208,7 @@ silc_client_command_reply_whois_save(SilcClientCommandReplyContext cmd,
   unsigned char *id_data, *tmp;
   char *nickname = NULL, *username = NULL;
   char *realname = NULL;
-  unsigned int idle = 0;
+  unsigned int idle = 0, mode = 0;
   
   argc = silc_argument_get_arg_num(cmd->args);
 
@@ -233,8 +233,14 @@ silc_client_command_reply_whois_save(SilcClientCommandReplyContext cmd,
   }
 
   tmp = silc_argument_get_arg_type(cmd->args, 7, &len);
-  if (tmp)
+  if (tmp) {
+    SILC_GET32_MSB(mode, tmp);
+  }
+
+  tmp = silc_argument_get_arg_type(cmd->args, 8, &len);
+  if (tmp) {
     SILC_GET32_MSB(idle, tmp);
+  }
 
   /* Check if we have this client cached already. */
   if (!silc_idcache_find_by_id_one(conn->client_cache, (void *)client_id,
@@ -248,6 +254,7 @@ silc_client_command_reply_whois_save(SilcClientCommandReplyContext cmd,
     client_entry->username = strdup(username);
     if (realname)
       client_entry->realname = strdup(realname);
+    client_entry->mode = mode;
     
     /* Add client to cache */
     silc_idcache_add(conn->client_cache, client_entry->nickname,
@@ -263,6 +270,7 @@ silc_client_command_reply_whois_save(SilcClientCommandReplyContext cmd,
       silc_free(client_entry->username);
     if (client_entry->realname)
       silc_free(client_entry->realname);
+    client_entry->mode = mode;
 
     SILC_LOG_DEBUG(("Updating client entry"));
 
@@ -281,7 +289,7 @@ silc_client_command_reply_whois_save(SilcClientCommandReplyContext cmd,
   /* Notify application */
   if (!cmd->callback)
     COMMAND_REPLY((ARGS, client_entry, nickname, username, realname, 
-                  NULL, idle));
+                  NULL, mode, idle));
 }
 
 /* Received reply for WHOIS command. This maybe called several times
@@ -869,10 +877,11 @@ SILC_CLIENT_CMD_REPLY_FUNC(join)
 
   /* Get channel mode */
   tmp = silc_argument_get_arg_type(cmd->args, 5, NULL);
-  if (tmp)
+  if (tmp) {
     SILC_GET32_MSB(mode, tmp);
-  else
+  } else {
     mode = 0;
+  }
 
   /* Get channel key */
   tmp = silc_argument_get_arg_type(cmd->args, 7, &len);