mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
Allow servers with the same server and port to be part of multiple networks. This should make life much easier for znc users. Thanks to Tykling, Bazerka and znx.
git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@5125 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
1a4c665686
commit
e37be456cd
@ -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 <address> [<port>]
|
||||
/SERVER REMOVE <address> [<port>] [<network>]
|
||||
|
||||
/SERVER LIST
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 <address> [<port>] */
|
||||
/* SYNTAX: SERVER REMOVE <address> [<port>] [<network>] */
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user