From 8019bab077be31e4f87311f066271206bafd7b68 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Mon, 18 Jun 2001 17:04:40 +0000 Subject: [PATCH] updates. --- CHANGES | 16 +++++ TODO | 8 --- .../irssi/src/fe-common/silc/module-formats.c | 4 ++ .../irssi/src/fe-common/silc/module-formats.h | 4 ++ apps/irssi/src/silc/core/client_ops.c | 27 +++++++- apps/irssi/src/silc/core/silc-channels.c | 62 +++++++++++++++---- apps/silcd/command.c | 21 ++++--- apps/silcd/packet_receive.c | 3 + apps/silcd/server.c | 3 +- doc/draft-riikonen-silc-commands-01.nroff | 3 +- lib/silcclient/client_prvmsg.c | 11 ++-- lib/silcclient/command.c | 46 +++++++++++--- lib/silcclient/command_reply.c | 4 +- 13 files changed, 165 insertions(+), 47 deletions(-) diff --git a/CHANGES b/CHANGES index baf0e550..5613f683 100644 --- a/CHANGES +++ b/CHANGES @@ -33,6 +33,22 @@ Mon Jun 18 18:49:07 EEST 2001 Pekka Riikonen but check whether the channel by that name already exists. Affected file irssi/silc/core/silc-channels.c. + * Do not send the SERVER_SIGNOFF to router if the disconnected + entity was the router. Affected file silcd/server.c. + + * Added the handling of the SERVER_SIGNOFF notify to the Irssi + SILC client as it was missing from there. + + Added the handling of the KICK notify to the Irssi SILC client + as it was missing. Added "you have been kicked" message to + Irssi SILC client's message modules formats. + + Added the handing of the KILL notify to the Irssi SILC client + as it was missing. Added the kill message module formats + as well. + + The affected file is irssi/src/silc/core/silc-channels.c. + Sun Jun 17 15:26:05 EEST 2001 Pekka Riikonen * Fixed the GETKEY command in the server to check also the diff --git a/TODO b/TODO index 94fae2a4..c3a93359 100644 --- a/TODO +++ b/TODO @@ -59,14 +59,6 @@ TODO/bugs In SILC Client Library TODO/bugs In SILC Server ======================== - o Normal server seemed not to distribute the SERVER_SIGNOFF properly - when its router disconnected. - - o Router seemed not to force the channel mode change if the normal - server announced different modes than what the router had. For example - if router crashed and then reconnected the server had different - modes on the channel. - o When server quits and all clients of that server are removed from all channels the channel keys are re-generated for all clients. This is a bug and should be done only once per channel after all clients of diff --git a/apps/irssi/src/fe-common/silc/module-formats.c b/apps/irssi/src/fe-common/silc/module-formats.c index 58d1462b..7e5c7df3 100644 --- a/apps/irssi/src/fe-common/silc/module-formats.c +++ b/apps/irssi/src/fe-common/silc/module-formats.c @@ -43,6 +43,10 @@ FORMAT_REC fecommon_silc_formats[] = { { "ban_list", "channel {channel $0} ban list: $1", 2, { 0, 0 } }, { "no_ban_list", "channel {channel $0} ban list not set", 1, { 0 } }, { "inviting", "Inviting {nick $0} to channel {channel $1}", 2, { 0, 0 } }, + { "kicked_you", "You have been kicked off channel {channel $0} ($1}", 2, { 0, 0 } }, + { "kicked", "{nick $0} has been kicked off channel {channel $1} ($2)", 3, { 0, 0, 0 } }, + { "killed_you", "You have been killed from the SILC Network", 0 }, + { "killed", "{nick $0} has been killed from the SILC Network ($1)", 2, { 0, 0 } }, /* WHOIS, WHOWAS and USERS (alias WHO) messages */ { NULL, "Who Queries", 0 }, diff --git a/apps/irssi/src/fe-common/silc/module-formats.h b/apps/irssi/src/fe-common/silc/module-formats.h index eb36f155..c4e0930b 100644 --- a/apps/irssi/src/fe-common/silc/module-formats.h +++ b/apps/irssi/src/fe-common/silc/module-formats.h @@ -40,6 +40,10 @@ enum { SILCTXT_CHANNEL_BAN_LIST, SILCTXT_CHANNEL_NO_BAN_LIST, SILCTXT_CHANNEL_INVITING, + SILCTXT_CHANNEL_KICKED_YOU, + SILCTXT_CHANNEL_KICKED, + SILCTXT_CHANNEL_KILLED_YOU, + SILCTXT_CHANNEL_KILLED, SILCTXT_FILL_2, diff --git a/apps/irssi/src/silc/core/client_ops.c b/apps/irssi/src/silc/core/client_ops.c index f3ae6de0..f80deb80 100644 --- a/apps/irssi/src/silc/core/client_ops.c +++ b/apps/irssi/src/silc/core/client_ops.c @@ -223,6 +223,23 @@ void silc_command(SilcClient client, SilcClientConnection conn, SilcClientCommandContext cmd_context, int success, SilcCommand command) { + SILC_SERVER_REC *server = conn->context; + + if (!success) + return; + + switch(command) { + case SILC_COMMAND_INVITE: + printformat_module("fe-common/silc", server, NULL, + MSGLEVEL_CRAP, SILCTXT_CHANNEL_INVITING, + cmd_context->argv[2], + (cmd_context->argv[1][0] == '*' ? + (char *)conn->current_channel->channel_name : + (char *)cmd_context->argv[1])); + break; + default: + break; + } } /* Client info resolving callback when JOIN command reply is received. @@ -431,18 +448,24 @@ silc_command_reply(SilcClient client, SilcClientConnection conn, { SilcChannelEntry channel; char *invite_list; + SilcArgumentPayload args; + int argc = 0; if (!success) return; channel = va_arg(vp, SilcChannelEntry); invite_list = va_arg(vp, char *); - + + args = silc_command_get_args(cmd_payload); + if (args) + argc = silc_argument_get_arg_num(args); + if (invite_list) printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP, SILCTXT_CHANNEL_INVITE_LIST, channel->channel_name, invite_list); - else + else if (argc == 3) printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP, SILCTXT_CHANNEL_NO_INVITE_LIST, channel->channel_name); diff --git a/apps/irssi/src/silc/core/silc-channels.c b/apps/irssi/src/silc/core/silc-channels.c index 2762014a..04d56233 100644 --- a/apps/irssi/src/silc/core/silc-channels.c +++ b/apps/irssi/src/silc/core/silc-channels.c @@ -386,7 +386,7 @@ static void event_motd(SILC_SERVER_REC *server, va_list va) static void event_channel_change(SILC_SERVER_REC *server, va_list va) { - + /* Nothing interesting to do */ } /* @@ -395,7 +395,18 @@ static void event_channel_change(SILC_SERVER_REC *server, va_list va) static void event_server_signoff(SILC_SERVER_REC *server, va_list va) { - + SilcClientEntry *clients; + uint32 clients_count; + int i; + + (void)va_arg(va, void *); + clients = va_arg(va, SilcClientEntry *); + clients_count = va_arg(va, uint32); + + for (i = 0; i < clients_count; i++) + signal_emit("message quit", 4, server, clients[i]->nickname, + clients[i]->username ? clients[i]->username : "", + "server signoff"); } /* @@ -404,7 +415,25 @@ static void event_server_signoff(SILC_SERVER_REC *server, va_list va) static void event_kick(SILC_SERVER_REC *server, va_list va) { + SilcClientConnection conn = server->conn; + SilcClientEntry client_entry; + SilcChannelEntry channel_entry; + char *tmp; + client_entry = va_arg(va, SilcClientEntry); + tmp = va_arg(va, char *); + channel_entry = va_arg(va, SilcChannelEntry); + + if (client_entry == conn->local_entry) { + printformat_module("fe-common/silc", server, channel_entry->channel_name, + MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_KICKED_YOU, + channel_entry->channel_name, tmp ? tmp : ""); + } else { + printformat_module("fe-common/silc", server, channel_entry->channel_name, + MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_KICKED, + client_entry->nickname, + channel_entry->channel_name, tmp ? tmp : ""); + } } /* @@ -413,16 +442,25 @@ static void event_kick(SILC_SERVER_REC *server, va_list va) static void event_kill(SILC_SERVER_REC *server, va_list va) { + SilcClientConnection conn = server->conn; + SilcClientEntry client_entry; + SilcChannelEntry channel_entry; + char *tmp; -} - -/* - * "event ban". Someone was banned or ban list was modified. - */ - -static void event_ban(SILC_SERVER_REC *server, va_list va) -{ - + client_entry = va_arg(va, SilcClientEntry); + tmp = va_arg(va, char *); + channel_entry = va_arg(va, SilcChannelEntry); + + if (client_entry == conn->local_entry) { + printformat_module("fe-common/silc", server, channel_entry->channel_name, + MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_KILLED_YOU, + channel_entry->channel_name, tmp ? tmp : ""); + } else { + printformat_module("fe-common/silc", server, channel_entry->channel_name, + MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_KILLED, + client_entry->nickname, + channel_entry->channel_name, tmp ? tmp : ""); + } } /* PART (LEAVE) command. */ @@ -1117,7 +1155,6 @@ void silc_channels_init(void) signal_add("silc event server_signoff", (SIGNAL_FUNC) event_server_signoff); signal_add("silc event kick", (SIGNAL_FUNC) event_kick); signal_add("silc event kill", (SIGNAL_FUNC) event_kill); - signal_add("silc event ban", (SIGNAL_FUNC) event_ban); command_bind("part", MODULE_NAME, (SIGNAL_FUNC) command_part); command_bind("me", MODULE_NAME, (SIGNAL_FUNC) command_me); @@ -1150,7 +1187,6 @@ void silc_channels_deinit(void) (SIGNAL_FUNC) event_server_signoff); signal_remove("silc event kick", (SIGNAL_FUNC) event_kick); signal_remove("silc event kill", (SIGNAL_FUNC) event_kill); - signal_remove("silc event ban", (SIGNAL_FUNC) event_ban); command_unbind("part", (SIGNAL_FUNC) command_part); command_unbind("me", (SIGNAL_FUNC) command_me); diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 83a22f11..2d0f493e 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -2654,13 +2654,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); diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index dc38962f..d4899345 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -1881,6 +1881,9 @@ void silc_server_new_channel(SilcServer server, return; } + /* Get the mode and set it to the channel */ + channel->mode = silc_channel_get_mode(payload); + /* Send the new channel key to the server */ chk = silc_channel_key_payload_encode(id_len, id, strlen(channel->channel_key-> diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 9914f962..d20df076 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -2406,7 +2406,8 @@ int silc_server_remove_clients_by_server(SilcServer server, SilcBuffer args; /* Send SERVER_SIGNOFF notify to our primary router */ - if (!server->standalone && server->router) { + if (!server->standalone && server->router && + server->router != entry) { args = silc_argument_payload_encode(1, argv, argv_lens, argv_types); silc_server_send_notify_args(server, diff --git a/doc/draft-riikonen-silc-commands-01.nroff b/doc/draft-riikonen-silc-commands-01.nroff index 47a5afcc..bf1aa600 100644 --- a/doc/draft-riikonen-silc-commands-01.nroff +++ b/doc/draft-riikonen-silc-commands-01.nroff @@ -586,7 +586,8 @@ List of all defined commands in SILC follows. (3) [] This command replies with the invite list of the channel if it - exists. + exists. The may be omitted if the list was not + altered. Status messages: diff --git a/lib/silcclient/client_prvmsg.c b/lib/silcclient/client_prvmsg.c index 98ccd699..c5a41b11 100644 --- a/lib/silcclient/client_prvmsg.c +++ b/lib/silcclient/client_prvmsg.c @@ -142,6 +142,7 @@ void silc_client_private_message(SilcClient client, SilcIDCacheEntry id_cache; SilcClientID *remote_id = NULL; SilcClientEntry remote_client; + SilcMessageFlags flags; if (packet->src_id_type != SILC_ID_CLIENT) goto out; @@ -173,22 +174,24 @@ void silc_client_private_message(SilcClient client, return; } + flags = silc_private_message_get_flags(payload); + /* Pass the private message to application */ - client->ops->private_message(client, conn, remote_client, - silc_private_message_get_flags(payload), + client->ops->private_message(client, conn, remote_client, flags, silc_private_message_get_message(payload, NULL)); /* See if we are away (gone). If we are away we will reply to the sender with the set away message. */ - if (conn->away && conn->away->away) { + if (conn->away && conn->away->away && !(flags & SILC_MESSAGE_FLAG_NOREPLY)) { /* If it's me, ignore */ if (SILC_ID_CLIENT_COMPARE(remote_id, conn->local_id)) goto out; /* Send the away message */ silc_client_send_private_message(client, conn, remote_client, - SILC_MESSAGE_FLAG_AUTOREPLY, + SILC_MESSAGE_FLAG_AUTOREPLY | + SILC_MESSAGE_FLAG_NOREPLY, conn->away->away, strlen(conn->away->away), TRUE); } diff --git a/lib/silcclient/command.c b/lib/silcclient/command.c index ac2324cb..6b90b369 100644 --- a/lib/silcclient/command.c +++ b/lib/silcclient/command.c @@ -367,6 +367,12 @@ SILC_CLIENT_CMD_FUNC(nick) goto out; } + if (cmd->argc < 2) { + cmd->client->ops->say(cmd->client, conn, "Usage: /NICK "); + COMMAND_ERROR; + goto out; + } + if (!strcmp(conn->nickname, cmd->argv[1])) goto out; @@ -613,10 +619,6 @@ SILC_CLIENT_CMD_FUNC(invite) cmd->pending = 1; return; } - - cmd->client->ops->say(cmd->client, conn, - "Inviting %s to channel %s", cmd->argv[2], - channel->channel_name); } else { invite = cmd->argv[2]; invite++; @@ -1209,6 +1211,12 @@ SILC_CLIENT_CMD_FUNC(cmode) int ll; mode |= SILC_CHANNEL_MODE_ULIMIT; type = 3; + if (cmd->argc < 4) { + cmd->client->ops->say(cmd->client, conn, + "Usage: /CMODE +|- [{ }]"); + COMMAND_ERROR; + goto out; + } ll = atoi(cmd->argv[3]); SILC_PUT32_MSB(ll, tmp); arg = tmp; @@ -1221,6 +1229,12 @@ SILC_CLIENT_CMD_FUNC(cmode) if (add) { mode |= SILC_CHANNEL_MODE_PASSPHRASE; type = 4; + if (cmd->argc < 4) { + cmd->client->ops->say(cmd->client, conn, + "Usage: /CMODE +|- [{ }]"); + COMMAND_ERROR; + goto out; + } arg = cmd->argv[3]; arg_len = cmd->argv_lens[3]; } else { @@ -1231,6 +1245,12 @@ SILC_CLIENT_CMD_FUNC(cmode) if (add) { mode |= SILC_CHANNEL_MODE_CIPHER; type = 5; + if (cmd->argc < 4) { + cmd->client->ops->say(cmd->client, conn, + "Usage: /CMODE +|- [{ }]"); + COMMAND_ERROR; + goto out; + } arg = cmd->argv[3]; arg_len = cmd->argv_lens[3]; } else { @@ -1241,6 +1261,12 @@ SILC_CLIENT_CMD_FUNC(cmode) if (add) { mode |= SILC_CHANNEL_MODE_HMAC; type = 6; + if (cmd->argc < 4) { + cmd->client->ops->say(cmd->client, conn, + "Usage: /CMODE +|- [{ }]"); + COMMAND_ERROR; + goto out; + } arg = cmd->argv[3]; arg_len = cmd->argv_lens[3]; } else { @@ -1252,6 +1278,13 @@ SILC_CLIENT_CMD_FUNC(cmode) mode |= SILC_CHANNEL_MODE_FOUNDER_AUTH; type = 7; + if (cmd->argc < 4) { + cmd->client->ops->say(cmd->client, conn, + "Usage: /CMODE +|- [{ }]"); + COMMAND_ERROR; + goto out; + } + if (!strcasecmp(cmd->argv[3], "-pubkey")) { auth = silc_auth_public_key_auth_generate(cmd->client->public_key, cmd->client->private_key, @@ -1276,11 +1309,6 @@ SILC_CLIENT_CMD_FUNC(cmode) } } - if (type && cmd->argc < 3) { - COMMAND_ERROR; - goto out; - } - chidp = silc_id_payload_encode(channel->id, SILC_ID_CHANNEL); SILC_PUT32_MSB(mode, modebuf); diff --git a/lib/silcclient/command_reply.c b/lib/silcclient/command_reply.c index caaabee5..8f2dff66 100644 --- a/lib/silcclient/command_reply.c +++ b/lib/silcclient/command_reply.c @@ -82,8 +82,8 @@ const SilcCommandStatusMessage silc_command_status_messages[] = { { STAT(NO_SERVER_ID), "No Server ID given" }, { STAT(BAD_CLIENT_ID), "Bad Client ID" }, { STAT(BAD_CHANNEL_ID), "Bad Channel ID" }, - { STAT(NO_SUCH_CLIENT_ID), "No such Client ID" }, - { STAT(NO_SUCH_CHANNEL_ID),"No such Channel ID" }, + { STAT(NO_SUCH_CLIENT_ID), "There was no such client" }, + { STAT(NO_SUCH_CHANNEL_ID),"There was no such channel" }, { STAT(NICKNAME_IN_USE), "Nickname already exists" }, { STAT(NOT_ON_CHANNEL), "You are not on that channel" }, { STAT(USER_NOT_ON_CHANNEL),"They are not on the channel" }, -- 2.43.0