INVITE and BAN notifys are now sent from routers to servers on
authorPekka Riikonen <priikone@silcnet.org>
Wed, 8 Oct 2003 07:33:27 +0000 (07:33 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 8 Oct 2003 07:33:27 +0000 (07:33 +0000)
the channel (but not to clients).

CHANGES
apps/silcd/command.c
apps/silcd/packet_receive.c
apps/silcd/packet_send.c
apps/silcd/packet_send.h
apps/silcd/server.c
apps/silcd/server_util.c

diff --git a/CHANGES b/CHANGES
index 6491a92844bf31785630bb2d00b3a9f97d553ffd..fa51fec26527dd0e2abda8b2eaf9ccd56e7c292e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,10 @@
+Wed Oct  8 09:32:12 CEST 2003  Pekka Riikonen <priikone@silcnet.org>
+
+       * INVITE and BAN notifys are now delivered from routers to
+         servers (but not clients) on the channel.  Updated specs and
+         code.  Affected files silcd/packet_[send|receive].[ch], 
+         command.c, server.c and server_util.c.
+
 Sun Oct  5 20:22:08 EEST 2003  Pekka Riikonen <priikone@silcnet.org>
 
        * Backup router protocol version 1.2 implemented.  Testing still
index e01731b006d4297bdae72af88309085887e0c465..42ea5336a39cec789f26528a570829919a8346df 100644 (file)
@@ -981,7 +981,7 @@ SILC_SERVER_CMD_FUNC(topic)
 
       /* Send notify about topic change to all clients on the channel */
       idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
-      silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+      silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
                                         SILC_NOTIFY_TYPE_TOPIC_SET, 2,
                                         idp->data, idp->len,
                                         channel->topic,
@@ -1229,9 +1229,29 @@ SILC_SERVER_CMD_FUNC(invite)
     silc_hash_table_list_reset(&htl);
   }
 
-  /* Send notify to the primary router */
+  /* The notify is sent to local servers (not clients), and to network. */
   if (atype && tmp && len2) {
     silc_buffer_set(&alist, tmp, len2);
+
+    /* Send to local servers if we are router */
+    if (server->server_type == SILC_ROUTER) {
+      SilcBuffer idp, idp2;
+      idp = silc_id_payload_encode(channel_id, SILC_ID_CHANNEL);
+      idp2 = silc_id_payload_encode(sender->id, SILC_ID_CLIENT);
+      silc_server_send_notify_to_channel(server, NULL, channel, FALSE, FALSE,
+                                         SILC_NOTIFY_TYPE_INVITE, 5,
+                                        idp->data, idp->len,
+                                        channel->channel_name,
+                                        strlen(channel->channel_name),
+                                        idp2->data, idp2->len,
+                                        atype, 1,
+                                        tmp ? alist.data : NULL,
+                                        tmp ? alist.len : 0);
+      silc_buffer_free(idp);
+      silc_buffer_free(idp2);
+    }
+
+    /* Send to network */
     silc_server_send_notify_invite(server, SILC_PRIMARY_ROUTE(server),
                                   SILC_BROADCAST(server), channel,
                                   sender->id, atype,
@@ -2138,7 +2158,7 @@ static void silc_server_command_join_channel(SilcServer server,
      we are router then this will send it to local clients and local
      servers. */
   SILC_LOG_DEBUG(("Send JOIN notify to channel"));
-  silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+  silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
                                     SILC_NOTIFY_TYPE_JOIN, 2,
                                     clidp->data, clidp->len,
                                     chidp->data, chidp->len);
@@ -2165,7 +2185,7 @@ static void silc_server_command_join_channel(SilcServer server,
     if (founder) {
       SILC_PUT32_MSB(chl->mode, mode);
       SILC_LOG_DEBUG(("Send CUMODE_CHANGE notify to channel"));
-      silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+      silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
                                         SILC_NOTIFY_TYPE_CUMODE_CHANGE, 4,
                                         clidp->data, clidp->len,
                                         mode, 4, clidp->data, clidp->len,
@@ -3091,7 +3111,7 @@ SILC_SERVER_CMD_FUNC(cmode)
 
   /* Send CMODE_CHANGE notify. */
   cidp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
-  silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+  silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
                                     SILC_NOTIFY_TYPE_CMODE_CHANGE, 7,
                                     cidp->data, cidp->len,
                                     tmp_mask, 4,
@@ -3466,7 +3486,7 @@ SILC_SERVER_CMD_FUNC(cumode)
 
   /* Send notify to channel, notify only if mode was actually changed. */
   if (notify) {
-    silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+    silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
                                       SILC_NOTIFY_TYPE_CUMODE_CHANGE, 4,
                                       idp->data, idp->len,
                                       tmp_mask, 4,
@@ -3630,7 +3650,7 @@ SILC_SERVER_CMD_FUNC(kick)
 
   /* Send KICKED notify to local clients on the channel */
   idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
-  silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+  silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
                                     SILC_NOTIFY_TYPE_KICKED, 3,
                                     target_idp, target_idp_len,
                                     comment, comment ? strlen(comment) : 0,
@@ -4301,9 +4321,21 @@ SILC_SERVER_CMD_FUNC(ban)
     silc_hash_table_list_reset(&htl);
   }
 
-  /* Send the BAN notify type to our primary router. */
+  /* Send BAN notify type to local servers (but not clients) and to
+     network. */
   if (atype && tmp && len2) {
     silc_buffer_set(&blist, tmp, len2);
+
+    /* Send to local servers if we are router */
+    if (server->server_type == SILC_ROUTER)
+      silc_server_send_notify_to_channel(server, NULL, channel, FALSE, FALSE,
+                                         SILC_NOTIFY_TYPE_BAN, 3,
+                                        id, id_len,
+                                        atype, 1,
+                                        tmp ? blist.data : NULL,
+                                        tmp ? blist.len : 0);
+
+    /* Send to network. */
     silc_server_send_notify_ban(server, SILC_PRIMARY_ROUTE(server),
                                SILC_BROADCAST(server), channel, atype,
                                &blist);
index 3d06ca0305ef69bdcba9ae3903643ab6ae33f0a5..bd6a8282b29b5220d36fe85b971d605c6bafb12e 100644 (file)
@@ -209,7 +209,7 @@ void silc_server_notify(SilcServer server,
 
     /* Send to channel */
     silc_server_packet_send_to_channel(server, sock, channel, packet->type,
-                                      FALSE, packet->buffer->data,
+                                      FALSE, TRUE, packet->buffer->data,
                                       packet->buffer->len, FALSE);
 
     if (server->server_type != SILC_ROUTER &&
@@ -314,7 +314,7 @@ void silc_server_notify(SilcServer server,
 
     /* Send the leave notify to channel */
     silc_server_packet_send_to_channel(server, sock, channel, packet->type,
-                                      FALSE, packet->buffer->data,
+                                      FALSE, TRUE, packet->buffer->data,
                                       packet->buffer->len, FALSE);
 
     /* Remove the user from channel */
@@ -458,7 +458,7 @@ void silc_server_notify(SilcServer server,
 
     /* Send the same notify to the channel */
     silc_server_packet_send_to_channel(server, NULL, channel, packet->type,
-                                      FALSE, packet->buffer->data,
+                                      FALSE, TRUE, packet->buffer->data,
                                       packet->buffer->len, FALSE);
     break;
 
@@ -639,7 +639,7 @@ void silc_server_notify(SilcServer server,
          break;
        sidp = silc_id_payload_encode(server->router->id, SILC_ID_SERVER);
        SILC_PUT32_MSB(channel->mode, mask);
-       silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+       silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
                                           SILC_NOTIFY_TYPE_CMODE_CHANGE, 7,
                                           sidp->data, sidp->len,
                                           mask, 4,
@@ -810,7 +810,7 @@ void silc_server_notify(SilcServer server,
 
     /* Send the same notify to the channel */
     silc_server_packet_send_to_channel(server, NULL, channel, packet->type,
-                                      FALSE, packet->buffer->data,
+                                      FALSE, TRUE, packet->buffer->data,
                                       packet->buffer->len, FALSE);
 
     /* Change mode */
@@ -1061,7 +1061,7 @@ void silc_server_notify(SilcServer server,
       if (!notify_sent)
        silc_server_packet_send_to_channel(server, NULL, channel,
                                           packet->type,
-                                          FALSE, packet->buffer->data,
+                                          FALSE, TRUE, packet->buffer->data,
                                           packet->buffer->len, FALSE);
 
       silc_free(channel_id);
@@ -1119,13 +1119,15 @@ void silc_server_notify(SilcServer server,
     silc_free(client_id);
 
     /* Get user's channel entry and check that inviting is allowed. */
-    if (!silc_server_client_on_channel(client, channel, &chl))
-      goto out;
-    if (channel->mode & SILC_CHANNEL_MODE_INVITE &&
-       !(chl->mode & SILC_CHANNEL_UMODE_CHANOP) &&
-       !(chl->mode & SILC_CHANNEL_UMODE_CHANFO)) {
-      SILC_LOG_DEBUG(("Inviting is not allowed"));
-      goto out;
+    if (server->server_type == SILC_ROUTER) {
+      if (!silc_server_client_on_channel(client, channel, &chl))
+        goto out;
+      if (channel->mode & SILC_CHANNEL_MODE_INVITE &&
+         !(chl->mode & SILC_CHANNEL_UMODE_CHANOP) &&
+         !(chl->mode & SILC_CHANNEL_UMODE_CHANFO)) {
+        SILC_LOG_DEBUG(("Inviting is not allowed"));
+        goto out;
+      }
     }
 
     /* Get the invite action */
@@ -1156,6 +1158,15 @@ void silc_server_notify(SilcServer server,
       silc_server_inviteban_process(server, channel->invite_list, action,
                                    iargs);
       silc_argument_payload_free(iargs);
+
+      /* If we are router we must send this notify to our local servers on
+         the channel.  Normal server does nothing.  The notify is not
+         sent to clients. */
+      if (server->server_type == SILC_ROUTER)
+       silc_server_packet_send_to_channel(server, sock, channel,
+                                          packet->type, FALSE, FALSE,
+                                          packet->buffer->data,
+                                          packet->buffer->len, FALSE);
     }
 
     break;
@@ -1194,7 +1205,7 @@ void silc_server_notify(SilcServer server,
 
     /* Send the notify to the channel */
     silc_server_packet_send_to_channel(server, sock, channel, packet->type,
-                                      FALSE, packet->buffer->data,
+                                      FALSE, TRUE, packet->buffer->data,
                                       packet->buffer->len, FALSE);
 
     /* Get the new Channel ID */
@@ -1490,7 +1501,7 @@ void silc_server_notify(SilcServer server,
 
     /* Send to channel */
     silc_server_packet_send_to_channel(server, sock, channel, packet->type,
-                                      FALSE, packet->buffer->data,
+                                      FALSE, TRUE, packet->buffer->data,
                                       packet->buffer->len, FALSE);
 
     /* Remove the client from channel's invite list */
@@ -1744,6 +1755,15 @@ void silc_server_notify(SilcServer server,
       silc_server_inviteban_process(server, channel->ban_list, action,
                                    iargs);
       silc_argument_payload_free(iargs);
+
+      /* If we are router we must send this notify to our local servers on
+         the channel.  Normal server does nothing.  The notify is not
+         sent to clients. */
+      if (server->server_type == SILC_ROUTER)
+       silc_server_packet_send_to_channel(server, sock, channel,
+                                          packet->type, FALSE, FALSE,
+                                          packet->buffer->data,
+                                          packet->buffer->len, FALSE);
     }
     break;
 
index 71868184b9c61e27e0c0d1d41426b56e9cac121b..b72ac0f3012379add36543e2f4e3b8ad19baafb8 100644 (file)
@@ -591,6 +591,7 @@ void silc_server_packet_send_to_channel(SilcServer server,
                                        SilcChannelEntry channel,
                                        SilcPacketType type,
                                        bool route,
+                                       bool send_to_clients,
                                        unsigned char *data,
                                        SilcUInt32 data_len,
                                        bool force_send)
@@ -704,7 +705,7 @@ void silc_server_packet_send_to_channel(SilcServer server,
       continue;
     }
 
-    if (client->router)
+    if (client->router || !send_to_clients)
       continue;
 
     /* Send to locally connected client */
@@ -1586,6 +1587,7 @@ void silc_server_send_notify_to_channel(SilcServer server,
                                        SilcSocketConnection sender,
                                        SilcChannelEntry channel,
                                        bool route_notify,
+                                       bool send_to_clients,
                                        SilcNotifyType type,
                                        SilcUInt32 argc, ...)
 {
@@ -1597,6 +1599,7 @@ void silc_server_send_notify_to_channel(SilcServer server,
   packet = silc_notify_payload_encode(type, argc, ap);
   silc_server_packet_send_to_channel(server, sender, channel,
                                     SILC_PACKET_NOTIFY, route_notify,
+                                    send_to_clients,
                                     packet->data, packet->len, FALSE);
   silc_buffer_free(packet);
   va_end(ap);
@@ -1853,7 +1856,7 @@ void silc_server_send_channel_key(SilcServer server,
                                            channel->key_len / 8, channel->key);
   silc_server_packet_send_to_channel(server, sender, channel,
                                     SILC_PACKET_CHANNEL_KEY,
-                                     route, packet->data, packet->len,
+                                     route, TRUE, packet->data, packet->len,
                                     FALSE);
   silc_buffer_free(packet);
   silc_free(chid);
index 730111adeb2f2a341258d968c713fcf9b43bedf2..6c85c3a8c6c8a52d7bba8deced511e7a201bfd01 100644 (file)
@@ -72,6 +72,7 @@ void silc_server_packet_send_to_channel(SilcServer server,
                                        SilcChannelEntry channel,
                                        SilcPacketType type,
                                        bool route,
+                                       bool send_to_clients,
                                        unsigned char *data,
                                        SilcUInt32 data_len,
                                        bool force_send);
@@ -211,6 +212,7 @@ void silc_server_send_notify_to_channel(SilcServer server,
                                        SilcSocketConnection sender,
                                        SilcChannelEntry channel,
                                        bool route_notify,
+                                       bool send_to_clients,
                                        SilcNotifyType type,
                                        SilcUInt32 argc, ...);
 void silc_server_send_notify_on_channels(SilcServer server,
index 1f18368ec07d0e8a2170c502877a788a381e69b7..d8c49346678f5c70a5c146cb79314c9e95b93610 100644 (file)
@@ -3499,7 +3499,7 @@ void silc_server_remove_from_channels(SilcServer server,
        !silc_server_channel_has_local(channel)) {
       /* Notify about leaving client if this channel has global users. */
       if (notify && channel->global_users)
-       silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+       silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
                                           SILC_NOTIFY_TYPE_SIGNOFF,
                                           signoff_message ? 2 : 1,
                                           clidp->data, clidp->len,
@@ -3513,7 +3513,7 @@ void silc_server_remove_from_channels(SilcServer server,
 
     /* Send notify to channel about client leaving SILC and channel too */
     if (notify)
-      silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+      silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
                                         SILC_NOTIFY_TYPE_SIGNOFF,
                                         signoff_message ? 2 : 1,
                                         clidp->data, clidp->len,
@@ -3621,7 +3621,7 @@ bool silc_server_remove_from_one_channel(SilcServer server,
       !silc_server_channel_has_local(channel)) {
     /* Notify about leaving client if this channel has global users. */
     if (notify && channel->global_users)
-      silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+      silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
                                         SILC_NOTIFY_TYPE_LEAVE, 1,
                                         clidp->data, clidp->len);
 
@@ -3633,7 +3633,7 @@ bool silc_server_remove_from_one_channel(SilcServer server,
 
   /* Send notify to channel about client leaving the channel */
   if (notify)
-    silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+    silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
                                       SILC_NOTIFY_TYPE_LEAVE, 1,
                                       clidp->data, clidp->len);
 
index 5815ca5ae14ae0551dccda8a9a86f1472cf270e1..5429e4218d6e1ae62798cc2b9c214ac72834aa06 100644 (file)
@@ -1719,7 +1719,7 @@ bool silc_server_force_cumode_change(SilcServer server,
   idp1 = silc_id_payload_encode(server->id, SILC_ID_SERVER);
   idp2 = silc_id_payload_encode(chl->client->id, SILC_ID_CLIENT);
   SILC_PUT32_MSB(forced_mode, cumode);
-  silc_server_send_notify_to_channel(server, sock, channel, FALSE,
+  silc_server_send_notify_to_channel(server, sock, channel, FALSE, TRUE,
                                     SILC_NOTIFY_TYPE_CUMODE_CHANGE,
                                     3, idp1->data, idp1->len,
                                     cumode, sizeof(cumode),
@@ -2127,7 +2127,7 @@ SilcStatus silc_server_set_channel_pk_list(SilcServer server,
     /* Send notify that removes the old list */
     sidp = silc_id_payload_encode(server->id, SILC_ID_SERVER);
     SILC_PUT32_MSB((channel->mode & (~SILC_CHANNEL_MODE_CHANNEL_AUTH)), mask);
-    silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+    silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
                                       SILC_NOTIFY_TYPE_CMODE_CHANGE, 7,
                                       sidp->data, sidp->len,
                                       mask, 4,