From 25f9c71f690f9fd846a39e646fbd11f715ffbfa5 Mon Sep 17 00:00:00 2001 From: Jari Matilainen Date: Thu, 11 May 2017 14:02:23 +0200 Subject: [PATCH 1/5] Allow -port or irc.host.tld in /server add and /server modify --- src/fe-common/core/fe-server.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c index f4c1d3ee..89d6f739 100644 --- a/src/fe-common/core/fe-server.c +++ b/src/fe-common/core/fe-server.c @@ -117,7 +117,11 @@ 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"); + port = *portstr == '\0' ? + (value != NULL && *value != '\0' ? atoi(value) : DEFAULT_SERVER_ADD_PORT) + : atoi(portstr); chatnet = g_hash_table_lookup(optlist, "network"); @@ -137,11 +141,7 @@ static void cmd_server_add_modify(const char *data, gboolean add) return; } 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 (*password != '\0') g_free_and_null(rec->password); if (g_hash_table_lookup(optlist, "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")) rec->family = AF_INET6; else if (g_hash_table_lookup(optlist, "4")) From 4a6fbdbe7891859ffd7b51a87147ecb6158df141 Mon Sep 17 00:00:00 2001 From: Jari Matilainen Date: Sun, 14 May 2017 03:01:01 +0200 Subject: [PATCH 2/5] Spaces to tabs --- src/fe-common/core/fe-server.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c index 89d6f739..73c77e77 100644 --- a/src/fe-common/core/fe-server.c +++ b/src/fe-common/core/fe-server.c @@ -118,9 +118,9 @@ static void cmd_server_add_modify(const char *data, gboolean add) if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - value = g_hash_table_lookup(optlist, "port"); - port = *portstr == '\0' ? - (value != NULL && *value != '\0' ? atoi(value) : DEFAULT_SERVER_ADD_PORT) + 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"); From 0c26aeb9fc716416aa7dde2356cc59643f7cc793 Mon Sep 17 00:00:00 2001 From: Jari Matilainen Date: Mon, 15 May 2017 23:07:01 +0200 Subject: [PATCH 3/5] Make sure port is only set on /server modify if specified --- src/fe-common/core/fe-server.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c index 73c77e77..46d25ae9 100644 --- a/src/fe-common/core/fe-server.c +++ b/src/fe-common/core/fe-server.c @@ -120,7 +120,8 @@ static void cmd_server_add_modify(const char *data, gboolean add) value = g_hash_table_lookup(optlist, "port"); port = *portstr == '\0' ? - (value != NULL && *value != '\0' ? atoi(value) : DEFAULT_SERVER_ADD_PORT) + (value != NULL && *value != '\0' ? + atoi(value) : DEFAULT_SERVER_ADD_PORT) : atoi(portstr); chatnet = g_hash_table_lookup(optlist, "network"); @@ -141,7 +142,11 @@ static void cmd_server_add_modify(const char *data, gboolean add) return; } rec->address = g_strdup(addr); + rec->port = port; } else { + 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")) { g_free_and_null(rec->own_host); @@ -149,8 +154,6 @@ static void cmd_server_add_modify(const char *data, gboolean add) } } - rec->port = port; - if (g_hash_table_lookup(optlist, "6")) rec->family = AF_INET6; else if (g_hash_table_lookup(optlist, "4")) From e84adeca15084a82c04ff6c3b5c7b8941c297322 Mon Sep 17 00:00:00 2001 From: Jari Matilainen Date: Sun, 4 Jun 2017 17:41:38 +0200 Subject: [PATCH 4/5] change ternary operator to if/else statements, add default ssl port support --- src/common.h | 1 + src/fe-common/core/fe-server.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/common.h b/src/common.h index b6f9153e..ddbb1deb 100644 --- a/src/common.h +++ b/src/common.h @@ -9,6 +9,7 @@ #define IRSSI_ABI_VERSION 9 #define DEFAULT_SERVER_ADD_PORT 6667 +#define DEFAULT_SERVER_ADD_TLS_PORT 6697 #ifdef HAVE_CONFIG_H #include "irssi-config.h" diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c index 46d25ae9..6e373139 100644 --- a/src/fe-common/core/fe-server.c +++ b/src/fe-common/core/fe-server.c @@ -119,10 +119,15 @@ static void cmd_server_add_modify(const char *data, gboolean add) if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); value = g_hash_table_lookup(optlist, "port"); - port = *portstr == '\0' ? - (value != NULL && *value != '\0' ? - atoi(value) : DEFAULT_SERVER_ADD_PORT) - : atoi(portstr); + + if (*portstr != '\0') + port = atoi(portstr); + else if (value != NULL && *value != '\0') + port = atoi(value); + else if (g_hash_table_lookup(optlist, "tls")) + port = DEFAULT_SERVER_ADD_TLS_PORT; + else + port = DEFAULT_SERVER_ADD_PORT; chatnet = g_hash_table_lookup(optlist, "network"); From f28c64a3dc1e66f9d1e49650d5b2ab15795b9e53 Mon Sep 17 00:00:00 2001 From: Jari Matilainen Date: Sun, 4 Jun 2017 19:47:30 +0200 Subject: [PATCH 5/5] Make backward compatible with ssl flags --- src/fe-common/core/fe-server.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c index 6e373139..75f857c2 100644 --- a/src/fe-common/core/fe-server.c +++ b/src/fe-common/core/fe-server.c @@ -124,7 +124,8 @@ static void cmd_server_add_modify(const char *data, gboolean add) port = atoi(portstr); else if (value != NULL && *value != '\0') port = atoi(value); - else if (g_hash_table_lookup(optlist, "tls")) + 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;