+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.
{
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;
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));
}
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,
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;
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)
/* 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);
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;
/* 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);
/* 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);
{
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);
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;
/* 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 */
client->nickname = nick;
client->username = strdup(username);
client->userinfo = strdup(realname);
+ client->mode = mode;
if (cache) {
cache->data = nick;
[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]
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
:::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]
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
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);
}
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,
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,
silc_free(client_entry->username);
if (client_entry->realname)
silc_free(client_entry->realname);
+ client_entry->mode = mode;
SILC_LOG_DEBUG(("Updating client entry"));
/* 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
/* 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);