diff options
author | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2017-06-23 17:59:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-23 17:59:02 +0200 |
commit | 9d32636ebe99d13a752cb8dad23a2c36881b0578 (patch) | |
tree | 35e17136ef6b189b7b24b01bc93e0301d9d0b90d /src/fe-common | |
parent | c56919768e1072985aab1377714ea5038417cd4d (diff) | |
parent | f28c64a3dc1e66f9d1e49650d5b2ab15795b9e53 (diff) | |
download | irssi-9d32636ebe99d13a752cb8dad23a2c36881b0578.zip |
Merge pull request #703 from vague666/server_modify_port
Allow -port <num> or irc.host.tld <num> in /server add
Diffstat (limited to 'src/fe-common')
-rw-r--r-- | src/fe-common/core/fe-server.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c index e8e9f33f..810afe83 100644 --- a/src/fe-common/core/fe-server.c +++ b/src/fe-common/core/fe-server.c @@ -117,7 +117,18 @@ static void cmd_server_add_modify(const char *data, gboolean add) return; 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"); + + if (*portstr != '\0') + port = atoi(portstr); + else if (value != NULL && *value != '\0') + port = atoi(value); + else if (g_hash_table_lookup(optlist, "tls") || + g_hash_table_lookup(optlist, "ssl")) + port = DEFAULT_SERVER_ADD_TLS_PORT; + else + port = DEFAULT_SERVER_ADD_PORT; chatnet = g_hash_table_lookup(optlist, "network"); @@ -139,8 +150,8 @@ static void cmd_server_add_modify(const char *data, gboolean add) rec->address = g_strdup(addr); rec->port = port; } else { - value = g_hash_table_lookup(optlist, "port"); - if (value != NULL && *value != '\0') rec->port = atoi(value); + if (*portstr != '\0' || g_hash_table_lookup(optlist, "port")) + rec->port = port; if (*password != '\0') g_free_and_null(rec->password); if (g_hash_table_lookup(optlist, "host")) { |