From 159bc12c89b6652ab3bca022b8c244e95b8297e4 Mon Sep 17 00:00:00 2001 From: Patrik Weiskircher Date: Sat, 6 Dec 2003 20:38:39 +0000 Subject: [PATCH] Getting the MOTD from other servers works now. --- CHANGES | 5 +++++ TODO | 2 -- apps/silcd/command.c | 13 ++++++++----- apps/silcd/command_reply.c | 22 ++++++++++++++++++++-- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index c9eb041c..09064ba6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +Sat Dec 06 21:35:14 CET 2003 Patrik Weiskircher + + * Getting the MOTD from other servers works now. Affected + files are silcd/command.c and silcd/command_reply.c + Thu Dec 04 11:33:46 CET 2003 Jochen Eisinger * Initialize the variable idletag, since it is tested in diff --git a/TODO b/TODO index a09432a3..9a228f19 100644 --- a/TODO +++ b/TODO @@ -10,8 +10,6 @@ TODO for SILC Server 1.0 o Check that founder key is distributed ok during backup resuming. - o Check that getting MOTD from other servers works. - o invite (with @server!*@host) not working from normal server/backup router? diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 2b24e740..d3f89b9a 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -2559,14 +2559,14 @@ SILC_SERVER_CMD_FUNC(motd) packet = silc_command_reply_payload_encode_va(SILC_COMMAND_MOTD, SILC_STATUS_OK, 0, ident, 2, - 2, idp, idp->len, + 2, idp->data, idp->len, 3, motd, motd_len); } else { /* No motd */ packet = silc_command_reply_payload_encode_va(SILC_COMMAND_MOTD, SILC_STATUS_OK, 0, ident, 1, - 2, idp, idp->len); + 2, idp->data, idp->len); } silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY, 0, @@ -2609,7 +2609,10 @@ SILC_SERVER_CMD_FUNC(motd) goto out; } - if (!entry && !cmd->pending && !server->standalone) { + /* Send to primary router only if we don't know the server + * the client requested or if the server is not locally connected */ + if ((!entry || !(entry->data.status & SILC_IDLIST_STATUS_LOCAL)) + && !cmd->pending && !server->standalone) { /* Send to the primary router */ SilcBuffer tmpbuf; SilcUInt16 old_ident; @@ -2641,10 +2644,10 @@ SILC_SERVER_CMD_FUNC(motd) goto out; } - idp = silc_id_payload_encode(server->id_entry->id, SILC_ID_SERVER); + idp = silc_id_payload_encode(entry->id, SILC_ID_SERVER); packet = silc_command_reply_payload_encode_va(SILC_COMMAND_MOTD, SILC_STATUS_OK, 0, ident, 2, - 2, idp, idp->len, + 2, idp->data, idp->len, 3, entry->motd, entry->motd ? strlen(entry->motd) : 0); diff --git a/apps/silcd/command_reply.c b/apps/silcd/command_reply.c index 530f593b..cfcd8b4b 100644 --- a/apps/silcd/command_reply.c +++ b/apps/silcd/command_reply.c @@ -885,8 +885,26 @@ SILC_SERVER_CMD_REPLY_FUNC(motd) if (!entry) { entry = silc_idlist_find_server_by_id(server->global_list, server_id, TRUE, NULL); - if (!entry) - goto out; + if (!entry) { + /* entry isn't known so we IDENTIFY it. otherwise the + * silc_server_command_motd won't know about it and tell + * the client that there is no such server */ + SilcBuffer buffer; + buffer = silc_command_payload_encode_va(SILC_COMMAND_IDENTIFY, + ++server->cmd_ident, 5, + 1, NULL, 0, 2, NULL, 0, + 3, NULL, 0, 4, NULL, 0, + 5, tmp, tmp_len); + silc_server_packet_send(server, SILC_PRIMARY_ROUTE(server), + SILC_PACKET_COMMAND, 0, buffer->data, + buffer->len, TRUE); + silc_server_command_pending(server, SILC_COMMAND_IDENTIFY, + server->cmd_ident, + silc_server_command_reply_motd, + cmd); + silc_buffer_free(buffer); + return; + } } /* Get the motd */ -- 2.43.0