Getting the MOTD from other servers works now.
authorPatrik Weiskircher <pat@silcnet.org>
Sat, 6 Dec 2003 20:38:39 +0000 (20:38 +0000)
committerPatrik Weiskircher <pat@silcnet.org>
Sat, 6 Dec 2003 20:38:39 +0000 (20:38 +0000)
CHANGES
TODO
apps/silcd/command.c
apps/silcd/command_reply.c

diff --git a/CHANGES b/CHANGES
index c9eb041c667241ed1bb08f1c1411c90ddcab1e92..09064ba6e5f520df6a982ab2ad13bdb79b52da77 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+Sat Dec 06 21:35:14 CET 2003  Patrik Weiskircher <pat@icore.at>
+
+       * 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 <jochen@penguin-breeder.org>
 
        * Initialize the variable idletag, since it is tested in 
diff --git a/TODO b/TODO
index a09432a3a47967d7eb2c0f3586db1df06d0609a4..9a228f196dc085c5bfdea34ef4b28f9a4be397bd 100644 (file)
--- 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?
 
index 2b24e7403091523f0a4725f4dbc3b5a08981fba5..d3f89b9a85fecd0aa30be6787fb805dd0bcb650e 100644 (file)
@@ -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);
index 530f593bcc8400f31f272862339ed58bce2d9dba..cfcd8b4b6a5513693e63c9776c9acbb9f90a8f3c 100644 (file)
@@ -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 */