goto out;
}
- /* Set the topic for channel */
- silc_free(channel->topic);
- channel->topic = strdup(tmp);
-
- /* Send TOPIC_SET notify type to the network */
- silc_server_send_notify_topic_set(server, SILC_PRIMARY_ROUTE(server),
- SILC_BROADCAST(server), channel,
- client->id, SILC_ID_CLIENT,
- channel->topic);
-
- idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
-
- /* Send notify about topic change to all clients on the channel */
- silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
- SILC_NOTIFY_TYPE_TOPIC_SET, 2,
- idp->data, idp->len,
- channel->topic, strlen(channel->topic));
- silc_buffer_free(idp);
+ if (!channel->topic || strcmp(channel->topic, tmp)) {
+ /* Set the topic for channel */
+ silc_free(channel->topic);
+ channel->topic = strdup(tmp);
+
+ /* Send TOPIC_SET notify type to the network */
+ silc_server_send_notify_topic_set(server, SILC_PRIMARY_ROUTE(server),
+ SILC_BROADCAST(server), channel,
+ client->id, SILC_ID_CLIENT,
+ channel->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_NOTIFY_TYPE_TOPIC_SET, 2,
+ idp->data, idp->len,
+ channel->topic,
+ strlen(channel->topic));
+ silc_buffer_free(idp);
+ }
}
/* Send the topic to client as reply packet */
/* Check that client has rights to change any requested channel modes */
if (set_mask && !silc_server_check_cmode_rights(server, channel, chl,
mode_mask)) {
+ SILC_LOG_DEBUG(("Client does not have rights to change mode"));
silc_server_command_send_status_reply(
cmd, SILC_COMMAND_CMODE,
(!(chl->mode & SILC_CHANNEL_UMODE_CHANOP) ?
if (!channel_id)
goto out;
- if (!server->standalone)
- silc_server_packet_send_dest(server, SILC_PRIMARY_ROUTE(server),
- packet->type, packet->flags |
- SILC_PACKET_FLAG_BROADCAST,
- channel_id, SILC_ID_CHANNEL,
- packet->buffer->data,
- packet->buffer->len, FALSE);
+ silc_server_packet_send_dest(server, SILC_PRIMARY_ROUTE(server),
+ packet->type, packet->flags |
+ SILC_PACKET_FLAG_BROADCAST,
+ channel_id, SILC_ID_CHANNEL,
+ packet->buffer->data,
+ packet->buffer->len, FALSE);
silc_server_backup_send_dest(server, (SilcServerEntry)sock->user_data,
packet->type, packet->flags,
channel_id, SILC_ID_CHANNEL,
FALSE, TRUE);
} else {
/* Packet is destined to client or server */
- if (!server->standalone)
- silc_server_packet_send(server, SILC_PRIMARY_ROUTE(server),
- packet->type,
- packet->flags | SILC_PACKET_FLAG_BROADCAST,
- packet->buffer->data, packet->buffer->len,
- FALSE);
+ silc_server_packet_send(server, SILC_PRIMARY_ROUTE(server),
+ packet->type,
+ packet->flags | SILC_PACKET_FLAG_BROADCAST,
+ packet->buffer->data, packet->buffer->len,
+ FALSE);
silc_server_backup_send(server, (SilcServerEntry)sock->user_data,
packet->type, packet->flags,
packet->buffer->data, packet->buffer->len,
channel = silc_idlist_find_channel_by_id(server->local_list,
channel_id, NULL);
if (!channel) {
+ SILC_LOG_DEBUG(("Notify for unknown channel"));
silc_free(channel_id);
goto out;
}
channel = silc_idlist_find_channel_by_id(server->local_list,
channel_id, NULL);
if (!channel) {
+ SILC_LOG_DEBUG(("Notify for unknown channel"));
silc_free(channel_id);
goto out;
}
channel = silc_idlist_find_channel_by_id(server->local_list,
channel_id, NULL);
if (!channel) {
+ SILC_LOG_DEBUG(("Notify for unknown channel"));
silc_free(channel_id);
goto out;
}
}
- if (channel->topic && !strcmp(channel->topic, tmp))
+ if (channel->topic && !strcmp(channel->topic, tmp)) {
+ SILC_LOG_DEBUG(("Topic is already set and same"));
goto out;
+ }
if (client) {
/* Get user's channel entry and check that topic set is allowed. */
/*
* Distribute the notify to local clients on the channel
*/
-
+
SILC_LOG_DEBUG(("CMODE CHANGE notify"));
-
+
/* Get client ID */
tmp = silc_argument_get_arg_type(args, 1, &tmp_len);
if (!tmp)
channel = silc_idlist_find_channel_by_id(server->local_list,
channel_id, NULL);
if (!channel) {
+ SILC_LOG_DEBUG(("Notify for unknown channel"));
silc_free(channel_id);
goto out;
}
goto out;
if (!silc_server_check_cmode_rights(server, channel, chl, mode)) {
SILC_LOG_DEBUG(("CMODE change is not allowed"));
+ silc_server_send_notify_cmode(server, sock, FALSE, channel,
+ channel->mode, server->id,
+ SILC_ID_SERVER, channel->cipher,
+ channel->hmac_name,
+ channel->passphrase,
+ channel->founder_key);
goto out;
}
} else {
+ /* Assure that server is not removing founder mode from us */
if (server->server_type == SILC_ROUTER &&
+ sock != SILC_PRIMARY_ROUTE(server) &&
channel->mode & SILC_CHANNEL_MODE_FOUNDER_AUTH &&
!(mode & SILC_CHANNEL_MODE_FOUNDER_AUTH)) {
SILC_LOG_DEBUG(("Enforcing sender to change channel mode"));
silc_server_send_notify_cmode(server, sock, FALSE, channel,
channel->mode, server->id,
- SILC_ID_SERVER,
- channel->cipher,
+ SILC_ID_SERVER, channel->cipher,
channel->hmac_name,
channel->passphrase,
channel->founder_key);
goto out;
}
+
+ /* If server is adding founder mode, check whether there is founder
+ on channel already and is not from this server */
+ if (server->server_type == SILC_ROUTER &&
+ sock != SILC_PRIMARY_ROUTE(server) &&
+ mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) {
+ silc_hash_table_list(channel->user_list, &htl);
+ while (silc_hash_table_get(&htl, NULL, (void *)&chl))
+ if (chl->mode & SILC_CHANNEL_UMODE_CHANFO &&
+ chl->client->router != sock->user_data) {
+ SILC_LOG_DEBUG(("Enforcing sender to change channel mode"));
+ silc_server_send_notify_cmode(server, sock, FALSE, channel,
+ channel->mode, server->id,
+ SILC_ID_SERVER, channel->cipher,
+ channel->hmac_name,
+ channel->passphrase,
+ channel->founder_key);
+ silc_hash_table_list_reset(&htl);
+ goto out;
+ }
+ silc_hash_table_list_reset(&htl);
+ }
}
/* If the channel had private keys set and the mode was removed then
*/
SilcChannelClientEntry chl2 = NULL;
bool notify_sent = FALSE;
-
+
SILC_LOG_DEBUG(("CUMODE CHANGE notify"));
-
+
/* Get client ID */
tmp = silc_argument_get_arg_type(args, 1, &tmp_len);
if (!tmp)
channel = silc_idlist_find_channel_by_id(server->local_list,
channel_id, NULL);
if (!channel) {
+ SILC_LOG_DEBUG(("Notify for unknown channel"));
silc_free(channel_id);
goto out;
}
if (!silc_server_client_on_channel(client2, channel, &chl))
goto out;
+ if (server->server_type == SILC_SERVER && chl->mode == mode) {
+ SILC_LOG_DEBUG(("Mode is changed already"));
+ break;
+ }
+
if (mode & SILC_CHANNEL_UMODE_CHANFO &&
!(chl->mode & SILC_CHANNEL_UMODE_CHANFO) &&
server->server_type == SILC_ROUTER &&
- sock->user_data != server->router) {
+ sock != SILC_PRIMARY_ROUTE(server)) {
SilcPublicKey founder_key = NULL;
/* If channel doesn't have founder auth mode then it's impossible
silc_pkcs_public_key_free(founder_key);
}
- if (chl->mode == mode) {
+ if (server->server_type != SILC_SERVER && chl->mode == mode) {
SILC_LOG_DEBUG(("Mode is changed already"));
break;
}
channel = silc_idlist_find_channel_by_id(server->local_list,
channel_id, NULL);
if (!channel) {
+ SILC_LOG_DEBUG(("Notify for unknown channel"));
silc_free(channel_id);
goto out;
}
channel = silc_idlist_find_channel_by_id(server->global_list,
channel_id, NULL);
if (!channel) {
+ SILC_LOG_DEBUG(("Notify for unknown channel"));
silc_free(channel_id);
goto out;
}
channel = silc_idlist_find_channel_by_id(server->local_list,
channel_id, NULL);
if (!channel) {
+ SILC_LOG_DEBUG(("Notify for unknown channel"));
silc_free(channel_id);
goto out;
}
channel = silc_idlist_find_channel_by_id(server->local_list,
channel_id, NULL);
if (!channel) {
+ SILC_LOG_DEBUG(("Notify for unknown channel"));
silc_free(channel_id);
goto out;
}
SilcServerEntry server_entry;
SilcChannelEntry channel;
- SILC_LOG_DEBUG(("Processing New Channel"));
-
if (sock->type == SILC_SOCKET_TYPE_CLIENT ||
packet->src_id_type != SILC_ID_SERVER ||
server->server_type == SILC_SERVER)
/* If the channel does not exist, then create it. This creates a new
key to the channel as well that we will send to the server. */
if (!channel) {
+ SILC_LOG_DEBUG(("Channel is new to us"));
+
/* The protocol says that the Channel ID's IP address must be based
on the router's IP address. Check whether the ID is based in our
IP and if it is not then create a new ID and enforce the server
return;
}
channel->disabled = TRUE;
+ channel->mode = silc_channel_get_mode(payload);
/* Send the new channel key to the server */
id = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
We also create a new key for the channel. */
SilcBuffer modes = NULL, users = NULL, users_modes = NULL;
+ SILC_LOG_DEBUG(("Channel already exists"));
+
if (!SILC_ID_CHANNEL_COMPARE(channel_id, channel->id)) {
/* They don't match, send CHANNEL_CHANGE notify to the server to
force the ID change. */
return;
}
-#if 0 /* Lets expect that server send CMODE_CHANGE notify anyway to
- (attempt) force mode change, and may very well get it. */
+#if 0 /* We will announce our CMODE anyway for this channel, so no need
+ to check it (implicit enforce). */
/* If the mode is different from what we have then enforce the
mode change. */