Do not allow several server connections.
[silc.git] / apps / silc / local_command.c
index 110a8eb81092fa17fecc154d30a86f755a89aa3c..56e36da4a9f6bdc2071b1071c9d4184cd3579ab1 100644 (file)
@@ -20,6 +20,9 @@
 /*
  * $Id$
  * $Log$
+ * Revision 1.3  2001/02/14 15:31:33  priikone
+ *     Do not allow several server connections.
+ *
  * Revision 1.2  2001/01/30 21:40:21  priikone
  *     updates.
  *
@@ -204,6 +207,17 @@ SILC_CLIENT_LCMD_FUNC(server)
     port = 706;
   }
 
+  if (conn && conn->remote_host) {
+    if (!strcmp(hostname, conn->remote_host) && port == conn->remote_port) {
+      silc_say(client, conn, "You are already connected to that server");
+      goto out;
+    }
+
+    /* Close connection */
+    cmd->client->ops->disconnect(cmd->client, cmd->conn);
+    silc_client_close_connection(cmd->client, cmd->conn->sock);
+  }
+
   /* Connect asynchronously to not to block user interface */
   silc_client_connect_to_server(cmd->client, port, hostname, NULL);