diff --git a/docs/help/in/server.in b/docs/help/in/server.in
index 7c6f03b3..174c7eb2 100644
--- a/docs/help/in/server.in
+++ b/docs/help/in/server.in
@@ -30,7 +30,7 @@ where the server is connected (ie. /window new hide;
/SERVER without any arguments displays the list of connected
servers.
-/SERVER REMOVE
[]
+/SERVER REMOVE [] []
/SERVER LIST
diff --git a/src/core/servers-setup.c b/src/core/servers-setup.c
index 1eb69491..83b90db3 100644
--- a/src/core/servers-setup.c
+++ b/src/core/servers-setup.c
@@ -352,15 +352,6 @@ SERVER_SETUP_REC *server_setup_find(const char *address, int port,
return server;
}
-/* Find matching server from setup. Ports must match or NULL is returned. */
-SERVER_SETUP_REC *server_setup_find_port(const char *address, int port)
-{
- SERVER_SETUP_REC *rec;
-
- rec = server_setup_find(address, port, NULL);
- return rec == NULL || rec->port != port ? NULL : rec;
-}
-
static SERVER_SETUP_REC *server_setup_read(CONFIG_NODE *node)
{
SERVER_SETUP_REC *rec;
@@ -375,14 +366,13 @@ static SERVER_SETUP_REC *server_setup_read(CONFIG_NODE *node)
return NULL;
port = config_node_get_int(node, "port", 0);
- if (server_setup_find_port(server, port) != NULL) {
- /* already exists - don't let it get there twice or
- server reconnects will screw up! */
+ chatnet = config_node_get_str(node, "chatnet", NULL);
+
+ if (server_setup_find(server, port, chatnet) != NULL) {
return NULL;
}
rec = NULL;
- chatnet = config_node_get_str(node, "chatnet", NULL);
chatnetrec = chatnet == NULL ? NULL : chatnet_find(chatnet);
if (chatnetrec == NULL && chatnet != NULL) {
diff --git a/src/core/servers-setup.h b/src/core/servers-setup.h
index d0101bcb..f7601a68 100644
--- a/src/core/servers-setup.h
+++ b/src/core/servers-setup.h
@@ -35,8 +35,6 @@ server_create_conn(int chat_type, const char *dest, int port,
but fallback to any server with the same address. */
SERVER_SETUP_REC *server_setup_find(const char *address, int port,
const char *chatnet);
-/* Find matching server from setup. Ports must match or NULL is returned. */
-SERVER_SETUP_REC *server_setup_find_port(const char *address, int port);
void server_setup_add(SERVER_SETUP_REC *rec);
void server_setup_remove(SERVER_SETUP_REC *rec);
diff --git a/src/fe-common/core/fe-common-core.c b/src/fe-common/core/fe-common-core.c
index 2b88b946..dce6890e 100644
--- a/src/fe-common/core/fe-common-core.c
+++ b/src/fe-common/core/fe-common-core.c
@@ -346,10 +346,13 @@ static void autoconnect_servers(void)
if (rec->autoconnect &&
(rec->chatnet == NULL ||
gslist_find_icase_string(chatnets, rec->chatnet) == NULL)) {
- if (rec->chatnet != NULL)
+ if (rec->chatnet != NULL) {
chatnets = g_slist_append(chatnets, rec->chatnet);
+ str = g_strdup_printf("-network %s %s %d", rec->chatnet, rec->address, rec->port);
+ } else {
+ str = g_strdup_printf("%s %d", rec->address, rec->port);
+ }
- str = g_strdup_printf("%s %d", rec->address, rec->port);
signal_emit("command connect", 1, str);
g_free(str);
}
diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c
index e5cce827..e4b32bdb 100644
--- a/src/fe-common/core/fe-server.c
+++ b/src/fe-common/core/fe-server.c
@@ -108,7 +108,7 @@ static void cmd_server_add(const char *data)
{
GHashTable *optlist;
SERVER_SETUP_REC *rec;
- char *addr, *portstr, *password, *value;
+ char *addr, *portstr, *password, *value, *chatnet;
void *free_arg;
int port;
@@ -119,7 +119,10 @@ static void cmd_server_add(const char *data)
if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
port = *portstr == '\0' ? DEFAULT_SERVER_ADD_PORT : atoi(portstr);
- rec = server_setup_find_port(addr, port);
+ chatnet = g_hash_table_lookup(optlist, "network");
+
+ rec = server_setup_find(addr, port, chatnet);
+
if (rec == NULL) {
rec = create_server_setup(optlist);
if (rec == NULL) {
@@ -194,21 +197,30 @@ static void cmd_server_add(const char *data)
cmd_params_free(free_arg);
}
-/* SYNTAX: SERVER REMOVE [] */
+/* SYNTAX: SERVER REMOVE [] [] */
static void cmd_server_remove(const char *data)
{
SERVER_SETUP_REC *rec;
- char *addr, *port;
+ char *addr, *port, *chatnet;
void *free_arg;
- if (!cmd_get_params(data, &free_arg, 2, &addr, &port))
+ if (!cmd_get_params(data, &free_arg, 3, &addr, &port, &chatnet))
return;
if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
- if (*port == '\0')
- rec = server_setup_find(addr, -1, NULL);
+ if (*port == '\0') {
+ if (*chatnet == '\0')
+ rec = server_setup_find(addr, -1, NULL);
+ else
+ rec = server_setup_find(addr, -1, chatnet);
+ }
else
- rec = server_setup_find_port(addr, atoi(port));
+ {
+ if (*chatnet == '\0')
+ rec = server_setup_find(addr, atoi(port), NULL);
+ else
+ rec = server_setup_find(addr, atoi(port), chatnet);
+ }
if (rec == NULL)
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_SETUPSERVER_NOT_FOUND, addr, port);