From: Pekka Riikonen Date: Mon, 26 Mar 2001 16:05:28 +0000 (+0000) Subject: updates. X-Git-Tag: SILC.0.1~95 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=8efe996e0555acb74cd3d181d9bdd773a30613a4 updates. --- diff --git a/CHANGES b/CHANGES index c047d18c..bb857d32 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,14 @@ Mon Mar 26 14:39:48 EEST 2001 Pekka Riikonen Also, do not remove the client entry when giving the KILL command but when the KILLED notify is received. + * Removed silc_idlist_find_client_by_nickname from the server. + Not needed anymore. Affected files silcd/idlist.[ch]. + + * Implemented the CHANNEL_CHANGE notify type handling to the + server. Affected file silcd/server.c. + + * Updated TODO. + Mon Mar 26 12:11:14 EEST 2001 Pekka Riikonen * Added silc_server_send_notify_invite to send the INVITE diff --git a/TODO b/TODO index 14ccfa83..15a3fc3e 100644 --- a/TODO +++ b/TODO @@ -102,8 +102,6 @@ TODO In SILC Server o TODO in commands (command.c and command_reply.c): - o WHOIS argument is probably ignored - o IDENTIFY argument is probably ignored o RESTART is not implemented o CMODE should be rewritten as it uses a lot duplicated code. Some of the modes may still not be implemented or is implemented @@ -117,9 +115,23 @@ TODO In SILC Server o TODO in notify types (packet_receive.c): - o CHANNEL_CHANGE notify type is not implemented o SERVER_SIGNOFF notify type is not implemented + o TODO in authentication protocol (protocol.c): + + o Public key authentication is missing in initiator side. It must + be implemented by creating the authentication data. + + o TODO in general server (server.c) + + o SILC_PACKET_CONNECTION_AUTH_REQUEST packet type is not + implemented. + + o silc_server_connect_to_router_second checks the authentication + method to be used in the connection. However, if it does not + find it it must resolve it from the responder by sending the + SILC_PACKET_CONNECTION_AUTH_REQUEST packet. + o Packet processing can be made faster. All packet function in the packet_receive.c has same prototypes. Instead of calling those from huge switch() make a table of callback functions that can be called @@ -146,6 +158,9 @@ TODO In SILC Server o Connection classes should be actually implemented in serverconfig.c. They can be defined but they are totally ignored currently. + o Connection redirect, if server is full, is not implemented. I also + don't know how to do it currently. Maybe it shouldn't be done at all. + TODO In SILC Libraries ====================== diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 43cc4d21..4dd4aeb3 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -1342,6 +1342,8 @@ silc_server_command_identify_send_reply(SilcServerCommandContext cmd, SilcClientEntry entry; SilcCommandStatus status; unsigned short ident = silc_command_get_ident(cmd->payload); + char nh[256], uh[256]; + SilcSocketConnection hsock; status = SILC_STATUS_OK; if (clients_count > 1) @@ -1374,50 +1376,44 @@ silc_server_command_identify_send_reply(SilcServerCommandContext cmd, idp = silc_id_payload_encode(entry->id, SILC_ID_CLIENT); tmp = silc_argument_get_first_arg(cmd->args, NULL); - /* XXX */ - { - char nh[256], uh[256]; - 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)); - if (!entry->username) { - packet = silc_command_reply_payload_encode_va(SILC_COMMAND_IDENTIFY, - status, ident, 2, - 2, idp->data, idp->len, - 3, nh, strlen(nh)); - } else { - 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(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); + } - packet = silc_command_reply_payload_encode_va(SILC_COMMAND_IDENTIFY, - status, ident, 3, - 2, idp->data, idp->len, - 3, nh, strlen(nh), - 4, uh, strlen(uh)); + if (!entry->username) { + packet = silc_command_reply_payload_encode_va(SILC_COMMAND_IDENTIFY, + status, ident, 2, + 2, idp->data, idp->len, + 3, nh, strlen(nh)); + } else { + 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); } - silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY, - 0, packet->data, packet->len, FALSE); - - silc_buffer_free(packet); - silc_buffer_free(idp); + packet = silc_command_reply_payload_encode_va(SILC_COMMAND_IDENTIFY, + status, ident, 3, + 2, idp->data, idp->len, + 3, nh, strlen(nh), + 4, uh, strlen(uh)); } + + silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY, + 0, packet->data, packet->len, FALSE); + + silc_buffer_free(packet); + silc_buffer_free(idp); } } diff --git a/apps/silcd/command_reply.c b/apps/silcd/command_reply.c index 37c2838d..4b865ad8 100644 --- a/apps/silcd/command_reply.c +++ b/apps/silcd/command_reply.c @@ -122,9 +122,7 @@ void silc_server_command_reply_free(SilcServerCommandReplyContext cmd) } } -/* Caches the received WHOIS information. If we are normal server currently - we cache global information only for short period of time. */ -/* XXX cache expirying not implemented yet! */ +/* Caches the received WHOIS information. */ static char silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd) diff --git a/apps/silcd/idlist.c b/apps/silcd/idlist.c index f756df13..888f5bc2 100644 --- a/apps/silcd/idlist.c +++ b/apps/silcd/idlist.c @@ -422,52 +422,6 @@ silc_idlist_get_clients_by_hash(SilcIDList id_list, char *nickname, return clients; } -/* Finds client entry by nickname. */ - -SilcClientEntry -silc_idlist_find_client_by_nickname(SilcIDList id_list, char *nickname, - char *server, SilcIDCacheEntry *ret_entry) -{ - SilcIDCacheList list = NULL; - SilcIDCacheEntry id_cache = NULL; - SilcClientEntry client = NULL; - - SILC_LOG_DEBUG(("Client by nickname")); - - if (server) { - if (!silc_idcache_find_by_data(id_list->clients, nickname, &list)) - return NULL; - -#if 0 - while (silc_idcache_list_next(list, &id_cache)) { - client = (SilcClientEntry)id_cache->context; - - if (!strcmp(server, XXX, strlen(server))) - break; - - client = NULL; - } -#endif - - silc_idcache_list_free(list); - - if (!client) - return NULL; - } else { - if (!silc_idcache_find_by_data_one(id_list->clients, nickname, &id_cache)) - return NULL; - - client = (SilcClientEntry)id_cache->context; - - if (ret_entry) - *ret_entry = id_cache; - } - - SILC_LOG_DEBUG(("Found")); - - return client; -} - /* Finds client by nickname hash. */ SilcClientEntry diff --git a/apps/silcd/idlist.h b/apps/silcd/idlist.h index 1198e58a..63756484 100644 --- a/apps/silcd/idlist.h +++ b/apps/silcd/idlist.h @@ -502,10 +502,6 @@ silc_idlist_get_clients_by_hash(SilcIDList id_list, char *nickname, SilcHash md5hash, unsigned int *clients_count); SilcClientEntry -silc_idlist_find_client_by_nickname(SilcIDList id_list, char *nickname, - char *server, - SilcIDCacheEntry *ret_entry); -SilcClientEntry silc_idlist_find_client_by_hash(SilcIDList id_list, char *nickname, SilcHash md5hash, SilcIDCacheEntry *ret_entry); SilcClientEntry diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index 937cc2e7..ecfab1cf 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -37,7 +37,7 @@ void silc_server_notify(SilcServer server, SilcNotifyPayload payload; SilcNotifyType type; SilcArgumentPayload args; - SilcChannelID *channel_id; + SilcChannelID *channel_id, *channel_id2; SilcClientID *client_id, *client_id2; SilcChannelEntry channel; SilcClientEntry client; @@ -570,7 +570,55 @@ void silc_server_notify(SilcServer server, break; case SILC_NOTIFY_TYPE_CHANNEL_CHANGE: - SILC_LOG_DEBUG(("CHANNEL CHANGE notify (not-impl XXX)")); + /* + * Distribute to the local clients on the channel and change the + * channel ID. + */ + + SILC_LOG_DEBUG(("CHANNEL CHANGE")); + + /* Get the old Channel ID */ + tmp = silc_argument_get_arg_type(args, 1, &tmp_len); + if (!tmp) + goto out; + channel_id = silc_id_payload_parse_id(tmp, tmp_len); + if (!channel_id) + goto out; + + /* Get the channel entry */ + channel = silc_idlist_find_channel_by_id(server->global_list, + channel_id, NULL); + if (!channel) { + channel = silc_idlist_find_channel_by_id(server->local_list, + channel_id, NULL); + if (!channel) { + silc_free(channel_id); + goto out; + } + } + + /* Send the notify to the channel */ + silc_server_packet_send_to_channel(server, sock, channel, packet->type, + FALSE, packet->buffer->data, + packet->buffer->len, FALSE); + + /* Get the new Channel ID */ + tmp = silc_argument_get_arg_type(args, 2, &tmp_len); + if (!tmp) + goto out; + channel_id2 = silc_id_payload_parse_id(tmp, tmp_len); + if (!channel_id2) + goto out; + + /* Replace the Channel ID */ + if (!silc_idlist_replace_channel_id(server->global_list, channel_id, + channel_id2)) + silc_idlist_replace_channel_id(server->local_list, channel_id, + channel_id2); + + silc_free(channel_id); + silc_free(channel_id2); + break; case SILC_NOTIFY_TYPE_SERVER_SIGNOFF: @@ -1449,20 +1497,6 @@ static void silc_server_new_id_real(SilcServer server, if (sock->type == SILC_SOCKET_TYPE_SERVER) server->stat.cell_clients++; server->stat.clients++; - -#if 0 - /* XXX Adding two ID's with same IP number replaces the old entry thus - gives wrong route. Thus, now disabled until figured out a better way - to do this or when removed the whole thing. This could be removed - because entry->router->connection gives always the most optimal route - for the ID anyway (unless new routes (faster perhaps) are established - after receiving this ID, this we don't know however). */ - /* Add route cache for this ID */ - silc_server_route_add(silc_server_route_hash( - ((SilcClientID *)id)->ip.s_addr, - server->id->port), ((SilcClientID *)id)->ip.s_addr, - router); -#endif } break; @@ -1479,15 +1513,6 @@ static void silc_server_new_id_real(SilcServer server, if (sock->type == SILC_SOCKET_TYPE_SERVER) server->stat.cell_servers++; server->stat.servers++; - -#if 0 - /* Add route cache for this ID */ - silc_server_route_add(silc_server_route_hash( - ((SilcServerID *)id)->ip.s_addr, - ((SilcServerID *)id)->port), - ((SilcServerID *)id)->ip.s_addr, - router); -#endif break; case SILC_ID_CHANNEL: diff --git a/apps/silcd/protocol.c b/apps/silcd/protocol.c index 8275145d..e5c6b8de 100644 --- a/apps/silcd/protocol.c +++ b/apps/silcd/protocol.c @@ -102,17 +102,6 @@ int silc_server_protocol_ke_set_keys(SilcSKE ske, idata->receive_key->set_iv(idata->receive_key, keymat->receive_iv); } - /* Allocate PKCS to be used */ -#if 0 - /* XXX Do we ever need to allocate PKCS for the connection?? - If yes, we need to change KE protocol to get the initiators - public key. */ - silc_pkcs_alloc(pkcs->pkcs->name, &idata->pkcs); - idata->public_key = silc_pkcs_public_key_alloc(XXX); - silc_pkcs_set_public_key(idata->pkcs, ske->ke2_payload->pk_data, - ske->ke2_payload->pk_len); -#endif - /* Save the hash */ if (!silc_hash_alloc(hash->hash->name, &idata->hash)) { silc_cipher_free(idata->send_key); @@ -441,8 +430,6 @@ SILC_TASK_CALLBACK(silc_server_protocol_key_exchange) * Connection Authentication protocol functions */ -/* XXX move these to somehwere else */ - int silc_server_password_authentication(SilcServer server, char *auth1, char *auth2) { @@ -650,7 +637,7 @@ SILC_TASK_CALLBACK(silc_server_protocol_connection_auth) auth_data, payload_len, ctx->ske); - + if (ret) { memset(auth_data, 0, payload_len); silc_free(auth_data); @@ -873,10 +860,6 @@ SILC_TASK_CALLBACK(silc_server_protocol_connection_auth) auth_data_len = ctx->auth_data_len; break; } - - /* No authentication data exits. Ask interactively from user. */ - /* XXX */ - break; case SILC_AUTH_PUBLIC_KEY: diff --git a/apps/silcd/route.c b/apps/silcd/route.c index 09d99262..3563b498 100644 --- a/apps/silcd/route.c +++ b/apps/silcd/route.c @@ -22,6 +22,12 @@ * routes. If route entry doesn't exist for a specific destination, server * uses primary route (default route). */ +/* XXX Adding two ID's with same IP number replaces the old entry thus + gives wrong route. Thus, now disabled until figured out a better way + to do this or when removed the whole thing. This could be removed + because entry->router->connection gives always the most optimal route + for the ID anyway (unless new routes (faster perhaps) are established + after receiving this ID, this we don't know however). */ /* $Id$ */ #include "serverincludes.h" diff --git a/apps/silcd/serverconfig.c b/apps/silcd/serverconfig.c index d1c0ad37..5acb4c58 100644 --- a/apps/silcd/serverconfig.c +++ b/apps/silcd/serverconfig.c @@ -1029,9 +1029,6 @@ int silc_server_config_parse_lines(SilcServerConfig config, } pc = pc->next; - /* XXXX */ - // silc_free(pc->prev); - // pc->prev = NULL; } if (check == FALSE) @@ -1090,7 +1087,8 @@ int silc_server_config_check_sections(unsigned int checkmask) return FALSE; } - if (!(checkmask & (1L << SILC_CONFIG_SERVER_SECTION_TYPE_CLIENT_CONNECTION))) { + if (!(checkmask & + (1L << SILC_CONFIG_SERVER_SECTION_TYPE_CLIENT_CONNECTION))) { return FALSE; } diff --git a/doc/draft-riikonen-silc-pp-01.nroff b/doc/draft-riikonen-silc-pp-01.nroff index 0567d6d7..8ab11cf1 100644 --- a/doc/draft-riikonen-silc-pp-01.nroff +++ b/doc/draft-riikonen-silc-pp-01.nroff @@ -1264,9 +1264,10 @@ ID's sent in arguments are sent inside ID Payload. 10 SILC_NOTIFY_TYPE_CHANNEL_CHANGE Sent when channel's ID has changed for a reason or another. This - is sent by normal server to the client. Client must change the - old Channel ID to the new one. This type must be sent only to the - clients who is joined on the channel. + is sent by normal server to the client. This can also be sent by + router to other server to force the Channel ID change. The Channel + ID must be changed to use the new one. When sent to clients, this + type must be sent only to the clients who is joined on the channel. Max Arguments: 2 Arguments: (1) (2)