break;
/* Do not add client to channel if it is there already */
- if (silc_server_client_on_channel(client, channel))
+ if (silc_server_client_on_channel(client, channel)) {
+ SILC_LOG_DEBUG(("Client already on channel"));
break;
+ }
/* Send to channel */
silc_server_packet_send_to_channel(server, sock, channel, packet->type,
SilcPacketContext *packet)
{
SilcBuffer buffer = packet->buffer;
- SilcServerEntry new_server;
+ SilcServerEntry new_server, server_entry;
SilcServerID *server_id;
SilcIDListData idata;
unsigned char *server_name, *id_string;
}
silc_free(id_string);
+ /* Check that we do not have this ID already */
+ server_entry = silc_idlist_find_server_by_id(server->local_list,
+ server_id, TRUE, NULL);
+ if (server_entry) {
+ silc_idcache_del_by_context(server->local_list->servers, server_entry);
+ } else {
+ server_entry = silc_idlist_find_server_by_id(server->global_list,
+ server_id, TRUE, NULL);
+ if (server_entry)
+ silc_idcache_del_by_context(server->global_list->servers, server_entry);
+ }
+
/* Update server entry */
idata->status |= SILC_IDLIST_STATUS_REGISTERED;
new_server->server_name = server_name;
new_server->id = server_id;
+
+ SILC_LOG_DEBUG(("New server id(%s)",
+ silc_id_render(server_id, SILC_ID_SERVER)));
/* Add again the entry to the ID cache. */
silc_idcache_add(server->local_list->servers, server_name, server_id,
SilcBuffer packet = silc_buffer_alloc(2);
silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
silc_buffer_format(packet,
- SILC_STR_UI_CHAR(20),
+ SILC_STR_UI_CHAR(SILC_SERVER_BACKUP_REPLACED),
SILC_STR_UI_CHAR(0),
SILC_STR_END);
silc_server_packet_send(server, sock,
packet->data, packet->len, TRUE);
silc_buffer_free(packet);
- /* Mark the server disabled. The data sent earlier will go but nothing
+ /* Mark the router disabled. The data sent earlier will go but nothing
after this does not go to this connection. */
idata->status |= SILC_IDLIST_STATUS_DISABLED;
}
unsigned char *id;
uint32 id_len;
uint32 mode;
+ SilcServerEntry server_entry;
SilcChannelEntry channel;
SILC_LOG_DEBUG(("Processing New Channel"));
id = silc_channel_get_id(payload, &id_len);
+ server_entry = (SilcServerEntry)sock->user_data;
+
if (sock->type == SILC_SOCKET_TYPE_ROUTER) {
/* Add the channel to global list as it is coming from router. It
cannot be our own channel as it is coming from router. */
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
to switch the ID. */
- if (!SILC_ID_COMPARE(channel_id, server->id, server->id->ip.data_len)) {
+ if (server_entry->server_type != SILC_BACKUP_ROUTER &&
+ !SILC_ID_COMPARE(channel_id, server->id, server->id->ip.data_len)) {
SilcChannelID *tmp;
SILC_LOG_DEBUG(("Forcing the server to change Channel ID"));