updates.
[silc.git] / apps / silcd / server.c
index 05323399eda32a43a8612d13898fbf6f42f15bef..101235e43e54834fcc8d5c81eb022e3764d78307 100644 (file)
@@ -872,6 +872,21 @@ SILC_TASK_CALLBACK(silc_server_connect_to_router_final)
 
   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);
@@ -1319,7 +1334,9 @@ SILC_TASK_CALLBACK(silc_server_accept_new_connection_final)
                               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);
@@ -1351,14 +1368,6 @@ SILC_TASK_CALLBACK(silc_server_accept_new_connection_final)
        }
       }
 
-#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) {
@@ -2381,16 +2390,6 @@ void silc_server_free_sock_user_data(SilcServer server,
       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);
@@ -2400,7 +2399,6 @@ void silc_server_free_sock_user_data(SilcServer server,
                                     server->router->connection);
        silc_server_announce_channels(server, time(0) - 300,
                                      server->router->connection);
-#endif
       }
       break;
     }