From fcb758c33d49c63fedff73fd184da7102c332c05 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Thu, 20 Sep 2001 17:50:13 +0000 Subject: [PATCH] udpates. --- CHANGES | 12 ++++++++++++ TODO | 9 +++++++-- apps/silcd/command_reply.c | 7 +++++++ apps/silcd/idlist.c | 36 ++++++++++++---------------------- lib/silcclient/command.c | 8 ++++++-- lib/silcclient/command_reply.c | 5 +++++ lib/silcclient/idlist.h | 2 +- 7 files changed, 50 insertions(+), 29 deletions(-) diff --git a/CHANGES b/CHANGES index 8f3b05b4..7f1b8575 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,15 @@ +Thu Sep 20 18:04:12 EEST 2001 Pekka Riikonen + + * When processing JOIN command reply in server check that if + the channel exists in our global list we'll move it the local + list. Affected file silcd/command_reply.c. + + * Fixed the check whether client is joined on the channel already + in JOIN command. Affected file lib/silcclient/command.c. + + * Fixed the JOIN command reply to check whether the channel + already exists. Affected file lib/silcclient/command_reply.c. + Wed Sep 19 22:58:32 EEST 2001 Pekka Riikonen * Added silc_ske_status_string to map the SKE error numbers diff --git a/TODO b/TODO index 6ff015e3..e7ee0e7b 100644 --- a/TODO +++ b/TODO @@ -46,6 +46,9 @@ TODO/bugs In SILC Server o Add perhaps /var/run/silcd.pid for PID information for the server. + o The backup router support described in the protocol specification + should be done at some point. + o Add a timeout to handling incmoing JOIN commands. It should be enforced that JOIN command is executed only once in a second or two seconds. Now it is possible to accept n incoming JOIN commands @@ -53,8 +56,10 @@ TODO/bugs In SILC Server each JOIN command will create and distribute the new channel key to everybody on the channel. - o The backup router support described in the protocol specification - should be done at some point. + o Add support for sending the LIST command to primary router on normal + server to receive all the created channels. Currently the command + returns only the channels the server knows about. The protocol spec + does not prohibit of sending the LIST to the router. o Incomplete IPv6 support: diff --git a/apps/silcd/command_reply.c b/apps/silcd/command_reply.c index c4add0a4..5ac3cb09 100644 --- a/apps/silcd/command_reply.c +++ b/apps/silcd/command_reply.c @@ -798,6 +798,13 @@ SILC_SERVER_CMD_REPLY_FUNC(join) (created == 0 ? "existing" : "created"), channel_name, silc_id_render(id, SILC_ID_CHANNEL))); + /* If the channel is found from global list we must move it to the + local list. */ + entry = silc_idlist_find_channel_by_name(server->global_list, + channel_name, &cache); + if (entry) + silc_idlist_del_channel(server->global_list, entry); + /* Add the channel to our local list. */ entry = silc_idlist_add_channel(server->local_list, strdup(channel_name), SILC_CHANNEL_MODE_NONE, id, diff --git a/apps/silcd/idlist.c b/apps/silcd/idlist.c index 5788e656..894bdc6e 100644 --- a/apps/silcd/idlist.c +++ b/apps/silcd/idlist.c @@ -281,10 +281,8 @@ int silc_idlist_del_server(SilcIDList id_list, SilcServerEntry entry) return FALSE; /* Free data */ - if (entry->server_name) - silc_free(entry->server_name); - if (entry->id) - silc_free(entry->id); + silc_free(entry->server_name); + silc_free(entry->id); memset(entry, 'F', sizeof(*entry)); silc_free(entry); @@ -352,14 +350,10 @@ int silc_idlist_del_client(SilcIDList id_list, SilcClientEntry entry) return FALSE; /* Free data */ - if (entry->nickname) - silc_free(entry->nickname); - if (entry->username) - silc_free(entry->username); - if (entry->userinfo) - silc_free(entry->userinfo); - if (entry->id) - silc_free(entry->id); + silc_free(entry->nickname); + silc_free(entry->username); + silc_free(entry->userinfo); + silc_free(entry->id); memset(entry, 'F', sizeof(*entry)); silc_free(entry); @@ -622,24 +616,18 @@ int silc_idlist_del_channel(SilcIDList id_list, SilcChannelEntry entry) return FALSE; /* Free data */ - if (entry->channel_name) - silc_free(entry->channel_name); - if (entry->id) - silc_free(entry->id); - if (entry->topic) - silc_free(entry->topic); + silc_free(entry->channel_name); + silc_free(entry->id); + silc_free(entry->topic); if (entry->channel_key) silc_cipher_free(entry->channel_key); if (entry->key) { memset(entry->key, 0, entry->key_len / 8); silc_free(entry->key); } - if (entry->cipher) - silc_free(entry->cipher); - if (entry->hmac_name) - silc_free(entry->hmac_name); - if (entry->rekey) - silc_free(entry->rekey); + silc_free(entry->cipher); + silc_free(entry->hmac_name); + silc_free(entry->rekey); /* Free all client entrys from the users list. The silc_hash_table_free will free all the entries so they are not freed at the foreach diff --git a/lib/silcclient/command.c b/lib/silcclient/command.c index b2314936..efb1765f 100644 --- a/lib/silcclient/command.c +++ b/lib/silcclient/command.c @@ -966,8 +966,11 @@ SILC_CLIENT_CMD_FUNC(join) /* See if we have joined to the requested channel already */ if (silc_idcache_find_by_name_one(conn->channel_cache, cmd->argv[1], - &id_cache)) - goto out; + &id_cache)) { + SilcChannelEntry channel = (SilcChannelEntry)id_cache->context; + if (channel->on_channel) + goto out; + } idp = silc_id_payload_encode(conn->local_id, SILC_ID_CLIENT); @@ -2012,6 +2015,7 @@ SILC_CLIENT_CMD_FUNC(leave) } channel = (SilcChannelEntry)id_cache->context; + channel->on_channel = FALSE; /* Send LEAVE command to the server */ idp = silc_id_payload_encode(id_cache->id, SILC_ID_CHANNEL); diff --git a/lib/silcclient/command_reply.c b/lib/silcclient/command_reply.c index 228dce57..575ba348 100644 --- a/lib/silcclient/command_reply.c +++ b/lib/silcclient/command_reply.c @@ -963,6 +963,11 @@ SILC_CLIENT_CMD_REPLY_FUNC(join) /* Get topic */ topic = silc_argument_get_arg_type(cmd->args, 10, NULL); + /* If we have the channel entry, remove it and create a new one */ + channel = silc_client_get_channel(cmd->client, conn, channel_name); + if (channel) + silc_client_del_channel(cmd->client, conn, channel); + /* Save received Channel ID. This actually creates the channel */ channel = silc_client_new_channel_id(cmd->client, cmd->sock, channel_name, mode, idp); diff --git a/lib/silcclient/idlist.h b/lib/silcclient/idlist.h index 0dc48f8f..08b9cc6f 100644 --- a/lib/silcclient/idlist.h +++ b/lib/silcclient/idlist.h @@ -66,7 +66,7 @@ typedef struct SilcChannelEntryStruct { char *channel_name; SilcChannelID *id; uint32 mode; - int on_channel; + bool on_channel; /* Joined clients */ SilcList clients; -- 2.24.0