SILC_LOG_INFO(("Connected to router %s", sock->hostname));
+ /* Check that we do not have this ID already */
+ id_entry = silc_idlist_find_server_by_id(server->local_list,
+ ctx->dest_id, TRUE, NULL);
+ if (id_entry) {
+ silc_idcache_del_by_context(server->local_list->servers, id_entry);
+ } else {
+ id_entry = silc_idlist_find_server_by_id(server->global_list,
+ ctx->dest_id, TRUE, NULL);
+ if (id_entry)
+ silc_idcache_del_by_context(server->global_list->servers, id_entry);
+ }
+
+ SILC_LOG_DEBUG(("New server id(%s)",
+ silc_id_render(ctx->dest_id, SILC_ID_SERVER)));
+
/* Add the connected router to local server list */
id_entry = silc_idlist_add_server(server->local_list, strdup(sock->hostname),
SILC_ROUTER, ctx->dest_id, NULL, sock);
ctx->conn_type == SILC_SOCKET_TYPE_SERVER ?
SILC_SERVER : SILC_ROUTER, NULL,
ctx->conn_type == SILC_SOCKET_TYPE_SERVER ?
- server->id_entry : NULL, sock);
+ server->id_entry :
+ (conn->backup_router ? server->id_entry :
+ NULL), sock);
if (!new_server) {
SILC_LOG_ERROR(("Could not add new server to cache"));
silc_free(sock->user_data);
}
}
-#if 0
- /* If the incoming connection is normal server and marked as backup
- server then it will use us as backup router. We'll disable the
- connection until it is allowed to be used. */
- if (ctx->conn_type == SILC_SOCKET_TYPE_SERVER && conn->backup_router)
- SILC_SET_DISABLED(sock);
-#endif
-
/* Check whether this connection is to be our primary router connection
if we do not already have the primary route. */
if (server->standalone && ctx->conn_type == SILC_SOCKET_TYPE_ROUTER) {
if (backup_router) {
/* Announce all of our stuff that was created about 5 minutes ago.
The backup router knows all the other stuff already. */
- if (server->server_type == SILC_ROUTER)
- silc_server_announce_servers(server, FALSE, 0,
- server->router->connection);
-
- /* Announce our clients and channels to the router */
- silc_server_announce_clients(server, 0,
- server->router->connection);
- silc_server_announce_channels(server, 0,
- server->router->connection);
-#if 0
if (server->server_type == SILC_ROUTER)
silc_server_announce_servers(server, FALSE, time(0) - 300,
server->router->connection);
server->router->connection);
silc_server_announce_channels(server, time(0) - 300,
server->router->connection);
-#endif
}
break;
}