From: Pekka Riikonen Date: Wed, 27 Nov 2002 16:38:06 +0000 (+0000) Subject: Added support for removing client from invite list in KILLED/KILL. X-Git-Tag: silc.server.0.9.6~2 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=bbcf6d6759de9df452d8df3be8b906ddeb1317a5 Added support for removing client from invite list in KILLED/KILL. Fixed bugs in invite list handling in INVITE comman. --- diff --git a/CHANGES b/CHANGES index 46f022ef..80f173ab 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,13 @@ Wed Nov 27 16:01:11 CET 2002 Pekka Riikonen no arguments) or when list was modified. Affected file silcd/command.c. + * Remove client from invite list in KILLED notify and in + KILL command. Affected file silcd/command.c and + silcd/server.[ch]. + + * Fixed bugs in invite list handling in INVITE command. + Affected files silcd/command.c and silcd/server_util.c. + Mon Nov 25 18:21:43 EET 2002 Pekka Riikonen * The silc_argument_get_[first/next] now return the argument diff --git a/apps/silcd/command.c b/apps/silcd/command.c index b372dc80..4b1a1c62 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -1431,6 +1431,8 @@ SILC_SERVER_CMD_FUNC(kill) /* Do normal signoff for the destination client */ sock = remote_client->connection; + silc_server_remove_from_channels(server, NULL, remote_client, + TRUE, (char *)"Killed", TRUE, TRUE); silc_server_free_client_data(server, NULL, remote_client, TRUE, comment ? comment : (unsigned char *)"Killed"); diff --git a/apps/silcd/command_reply.c b/apps/silcd/command_reply.c index d02b62ff..2711d02f 100644 --- a/apps/silcd/command_reply.c +++ b/apps/silcd/command_reply.c @@ -148,7 +148,7 @@ silc_server_command_process_error(SilcServerCommandReplyContext cmd, client_id, FALSE, NULL); if (client) { silc_server_remove_from_channels(server, NULL, client, TRUE, - NULL, TRUE); + NULL, TRUE, FALSE); silc_idlist_del_data(client); silc_idlist_del_client(server->global_list, client); } diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index 5bd89cce..01aa8258 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -362,7 +362,8 @@ void silc_server_notify(SilcServer server, silc_schedule_task_del_by_context(server->schedule, client); /* Remove the client from all channels. */ - silc_server_remove_from_channels(server, NULL, client, TRUE, tmp, FALSE); + silc_server_remove_from_channels(server, NULL, client, TRUE, + tmp, FALSE, FALSE); /* Check if anyone is watching this nickname */ if (server->server_type == SILC_ROUTER) @@ -1280,7 +1281,7 @@ void silc_server_notify(SilcServer server, /* Remove the client from all channels. */ silc_server_remove_from_channels(server, NULL, client, - TRUE, NULL, FALSE); + TRUE, NULL, FALSE, FALSE); /* Check if anyone is watching this nickname */ if (server->server_type == SILC_ROUTER) @@ -1519,7 +1520,7 @@ void silc_server_notify(SilcServer server, /* Remove the client from all channels */ silc_server_remove_from_channels(server, NULL, client, FALSE, NULL, - FALSE); + FALSE, TRUE); /* Check if anyone is watching this nickname */ silc_server_check_watcher_list(server, client, NULL, @@ -1698,7 +1699,7 @@ void silc_server_notify(SilcServer server, client_id, FALSE, NULL); if (client) { silc_server_remove_from_channels(server, NULL, client, TRUE, - NULL, TRUE); + NULL, TRUE, FALSE); silc_idlist_del_data(client); silc_idlist_del_client(server->global_list, client); } @@ -3658,7 +3659,8 @@ void silc_server_resume_client(SilcServer server, server->stat.clients--; if (server->stat.cell_clients) server->stat.cell_clients--; - silc_server_remove_from_channels(server, NULL, client, FALSE, NULL, FALSE); + silc_server_remove_from_channels(server, NULL, client, FALSE, + NULL, FALSE, FALSE); silc_server_del_from_watcher_list(server, client); if (!silc_idlist_del_client(server->local_list, client)) silc_idlist_del_client(server->global_list, client); diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 250ae76c..2a9b149a 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -3083,10 +3083,10 @@ void silc_server_free_client_data(SilcServer server, /* Remove client from all channels */ if (notify) silc_server_remove_from_channels(server, NULL, client, - TRUE, (char *)signoff, TRUE); + TRUE, (char *)signoff, TRUE, FALSE); else silc_server_remove_from_channels(server, NULL, client, - FALSE, NULL, FALSE); + FALSE, NULL, FALSE, FALSE); /* Remove this client from watcher list if it is */ silc_server_del_from_watcher_list(server, client); @@ -3349,7 +3349,8 @@ void silc_server_remove_from_channels(SilcServer server, SilcClientEntry client, bool notify, const char *signoff_message, - bool keygen) + bool keygen, + bool killed) { SilcChannelEntry channel; SilcChannelClientEntry chl; @@ -3433,6 +3434,21 @@ void silc_server_remove_from_channels(SilcServer server, signoff_message, signoff_message ? strlen(signoff_message) : 0); + if (killed && clidp) { + /* Remove the client from channel's invite list */ + if (channel->invite_list && + silc_hash_table_count(channel->invite_list)) { + SilcBuffer ab; + SilcArgumentPayload iargs; + ab = silc_argument_payload_encode_one(NULL, clidp->data, + clidp->len, 3); + iargs = silc_argument_payload_parse(ab->data, ab->len, 1); + silc_server_inviteban_process(server, channel->invite_list, 1, iargs); + silc_buffer_free(ab); + silc_argument_payload_free(iargs); + } + } + /* Don't create keys if we are shutting down */ if (server->server_shutdown) continue; diff --git a/apps/silcd/server.h b/apps/silcd/server.h index f7520b79..d7b2d3da 100644 --- a/apps/silcd/server.h +++ b/apps/silcd/server.h @@ -156,7 +156,7 @@ void silc_server_remove_from_channels(SilcServer server, SilcClientEntry client, bool notify, const char *signoff_message, - bool keygen); + bool keygen, bool killed); bool silc_server_remove_from_one_channel(SilcServer server, SilcSocketConnection sock, SilcChannelEntry channel, diff --git a/apps/silcd/server_util.c b/apps/silcd/server_util.c index 3a549ae7..de2d5d02 100644 --- a/apps/silcd/server_util.c +++ b/apps/silcd/server_util.c @@ -43,7 +43,8 @@ silc_server_remove_clients_channels(SilcServer server, return; SILC_LOG_DEBUG(("Remove client %s from all channels", - client->nickname ? client->nickname : "")); + client->nickname ? client->nickname : + (unsigned char *)"")); if (silc_hash_table_find(clients, client, NULL, NULL)) silc_hash_table_del(clients, client); @@ -1514,7 +1515,7 @@ void silc_server_kill_client(SilcServer server, /* Remove the client from all channels. This generates new keys to the channels as well. */ silc_server_remove_from_channels(server, NULL, remote_client, FALSE, - NULL, TRUE); + NULL, TRUE, FALSE); /* Remove the client entry, If it is locally connected then we will also disconnect the client here */ @@ -1724,7 +1725,7 @@ bool silc_server_inviteban_match(SilcServer server, SilcHashTable list, unsigned char *tmp = NULL; SilcUInt32 len = 0, t; SilcHashTableList htl; - SilcBuffer entry; + SilcBuffer entry, idp = NULL; bool ret = FALSE; if (type < 1 || type > 3 || !check) @@ -1741,10 +1742,11 @@ bool silc_server_inviteban_match(SilcServer server, SilcHashTable list, return FALSE; } if (type == 3) { - tmp = silc_id_id2str(check, SILC_ID_CLIENT); - if (!tmp) + idp = silc_id_payload_encode(check, SILC_ID_CLIENT); + if (!idp) return FALSE; - len = silc_id_get_len(check, SILC_ID_CLIENT); + tmp = idp->data; + len = idp->len; } /* Compare the list */ @@ -1764,7 +1766,9 @@ bool silc_server_inviteban_match(SilcServer server, SilcHashTable list, } silc_hash_table_list_reset(&htl); - silc_free(tmp); + if (!idp) + silc_free(tmp); + silc_buffer_free(idp); return ret; } @@ -1907,8 +1911,8 @@ void silc_server_inviteban_process(SilcServer server, SilcHashTable list, /* Delete from the invite list */ silc_hash_table_list(list, &htl); while (silc_hash_table_get(&htl, (void **)&type, (void **)&tmp2)) { - if (type == 2 && !memcmp(tmp2->data, tmp, len)) { - silc_hash_table_del_by_context(list, (void *)2, tmp2); + if (type == 3 && !memcmp(tmp2->data, tmp, len)) { + silc_hash_table_del_by_context(list, (void *)3, tmp2); silc_buffer_free(tmp2); break; }