1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Allow -port <num> or irc.host.tld <port num> in /server add and /server modify

This commit is contained in:
Jari Matilainen 2017-05-11 14:02:23 +02:00
parent c890ecafa0
commit 25f9c71f69

View File

@ -117,7 +117,11 @@ static void cmd_server_add_modify(const char *data, gboolean add)
return; return;
if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
port = *portstr == '\0' ? DEFAULT_SERVER_ADD_PORT : atoi(portstr);
value = g_hash_table_lookup(optlist, "port");
port = *portstr == '\0' ?
(value != NULL && *value != '\0' ? atoi(value) : DEFAULT_SERVER_ADD_PORT)
: atoi(portstr);
chatnet = g_hash_table_lookup(optlist, "network"); chatnet = g_hash_table_lookup(optlist, "network");
@ -137,11 +141,7 @@ static void cmd_server_add_modify(const char *data, gboolean add)
return; return;
} }
rec->address = g_strdup(addr); rec->address = g_strdup(addr);
rec->port = port;
} else { } else {
value = g_hash_table_lookup(optlist, "port");
if (value != NULL && *value != '\0') rec->port = atoi(value);
if (*password != '\0') g_free_and_null(rec->password); if (*password != '\0') g_free_and_null(rec->password);
if (g_hash_table_lookup(optlist, "host")) { if (g_hash_table_lookup(optlist, "host")) {
g_free_and_null(rec->own_host); g_free_and_null(rec->own_host);
@ -149,6 +149,8 @@ static void cmd_server_add_modify(const char *data, gboolean add)
} }
} }
rec->port = port;
if (g_hash_table_lookup(optlist, "6")) if (g_hash_table_lookup(optlist, "6"))
rec->family = AF_INET6; rec->family = AF_INET6;
else if (g_hash_table_lookup(optlist, "4")) else if (g_hash_table_lookup(optlist, "4"))