From: Pekka Riikonen Date: Wed, 8 Oct 2003 07:33:27 +0000 (+0000) Subject: INVITE and BAN notifys are now sent from routers to servers on X-Git-Tag: silc.toolkit.0.9.10~8 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=3da305416d8b01f3d3797423299eb732515154ac;p=silc.git INVITE and BAN notifys are now sent from routers to servers on the channel (but not to clients). --- diff --git a/CHANGES b/CHANGES index 6491a928..fa51fec2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +Wed Oct 8 09:32:12 CEST 2003 Pekka Riikonen + + * 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 * Backup router protocol version 1.2 implemented. Testing still diff --git a/apps/silcd/command.c b/apps/silcd/command.c index e01731b0..42ea5336 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -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); diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index 3d06ca03..bd6a8282 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -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; diff --git a/apps/silcd/packet_send.c b/apps/silcd/packet_send.c index 71868184..b72ac0f3 100644 --- a/apps/silcd/packet_send.c +++ b/apps/silcd/packet_send.c @@ -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); diff --git a/apps/silcd/packet_send.h b/apps/silcd/packet_send.h index 730111ad..6c85c3a8 100644 --- a/apps/silcd/packet_send.h +++ b/apps/silcd/packet_send.h @@ -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, diff --git a/apps/silcd/server.c b/apps/silcd/server.c index 1f18368e..d8c49346 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -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); diff --git a/apps/silcd/server_util.c b/apps/silcd/server_util.c index 5815ca5a..5429e421 100644 --- a/apps/silcd/server_util.c +++ b/apps/silcd/server_util.c @@ -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,