mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
irc: convert server option ipv6 from boolean to enum (disable, auto, force) (issue #2164)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
- **breaking:** alias: display an error with `/alias add` or `/alias addcompletion` when the alias already exists, add options `addreplace` and `addreplacecompletion` in command `/alias` ([#2095](https://github.com/weechat/weechat/issues/2095))
|
||||
- **breaking:** irc: rename parameter `-re` to `-raw` in command `/list` ([#2124](https://github.com/weechat/weechat/issues/2124))
|
||||
- **breaking:** api: add constants for IPv6 and allow force of IPv6 in function hook_connect ([#2164](https://github.com/weechat/weechat/issues/2164))
|
||||
- **breaking:** irc: convert server option `ipv6` from boolean to enum (disable, auto, force) ([#2164](https://github.com/weechat/weechat/issues/2164))
|
||||
- core: add option `addreplace` in commands `/bar` and `/proxy` ([#2095](https://github.com/weechat/weechat/issues/2095))
|
||||
- irc: add option `addreplace` in commands `/ignore`, `/notify` and `/server` ([#2095](https://github.com/weechat/weechat/issues/2095))
|
||||
- relay: add option `addreplace` in commands `/relay` and `/remote` ([#2095](https://github.com/weechat/weechat/issues/2095))
|
||||
|
||||
@@ -5337,14 +5337,12 @@ irc_command_display_server (struct t_irc_server *server, int with_detail)
|
||||
weechat_config_string (server->options[IRC_SERVER_OPTION_PROXY]));
|
||||
/* ipv6 */
|
||||
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_IPV6]))
|
||||
weechat_printf (NULL, " ipv6 . . . . . . . . : (%s)",
|
||||
(IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_IPV6)) ?
|
||||
_("on") : _("off"));
|
||||
weechat_printf (NULL, " ipv6 . . . . . . . . : ('%s')",
|
||||
irc_server_ipv6_string[IRC_SERVER_OPTION_ENUM(server, IRC_SERVER_OPTION_IPV6)]);
|
||||
else
|
||||
weechat_printf (NULL, " ipv6 . . . . . . . . : %s%s",
|
||||
weechat_printf (NULL, " ipv6 . . . . . . . . : %s'%s'",
|
||||
IRC_COLOR_CHAT_VALUE,
|
||||
(weechat_config_boolean (server->options[IRC_SERVER_OPTION_IPV6])) ?
|
||||
_("on") : _("off"));
|
||||
irc_server_ipv6_string[weechat_config_enum (server->options[IRC_SERVER_OPTION_IPV6])]);
|
||||
/* tls */
|
||||
if (weechat_config_option_is_null (server->options[IRC_SERVER_OPTION_TLS]))
|
||||
weechat_printf (NULL, " tls. . . . . . . . . : (%s)",
|
||||
@@ -7289,7 +7287,7 @@ irc_command_init ()
|
||||
AI(" /connect libera"),
|
||||
AI(" /connect irc.oftc.net"),
|
||||
AI(" /connect irc.oftc.net/6667 -notls"),
|
||||
AI(" /connect irc6.oftc.net/9999 -ipv6"),
|
||||
AI(" /connect irc6.oftc.net/9999 -ipv6=force"),
|
||||
AI(" /connect my.server.org -password=test"),
|
||||
AI(" /connect irc://nick@irc.oftc.net/#channel"),
|
||||
AI(" /connect -switch")),
|
||||
|
||||
@@ -1886,10 +1886,9 @@ irc_config_server_new_option (struct t_config_file *config_file,
|
||||
case IRC_SERVER_OPTION_IPV6:
|
||||
new_option = weechat_config_new_option (
|
||||
config_file, section,
|
||||
option_name, "boolean",
|
||||
N_("use IPv6 protocol for server communication (try IPv6 then "
|
||||
"fallback to IPv4); if disabled, only IPv4 is used"),
|
||||
NULL, 0, 0,
|
||||
option_name, "enum",
|
||||
N_("use IPv6 protocol for server communication"),
|
||||
"disable|auto|force", 0, 0,
|
||||
default_value, value,
|
||||
null_value_allowed,
|
||||
callback_check_value,
|
||||
@@ -2889,7 +2888,7 @@ irc_config_update_cb (const void *pointer, void *data,
|
||||
int version_read,
|
||||
struct t_hashtable *data_read)
|
||||
{
|
||||
const char *ptr_section, *ptr_option, *ptr_value;
|
||||
const char *ptr_config, *ptr_section, *ptr_option, *ptr_value;
|
||||
const char *option_autojoin_delay = "autojoin_delay";
|
||||
char *new_option, *pos_option, *new_value;
|
||||
int changes, length;
|
||||
@@ -3048,6 +3047,70 @@ irc_config_update_cb (const void *pointer, void *data,
|
||||
}
|
||||
}
|
||||
|
||||
if (version_read < 5)
|
||||
{
|
||||
/*
|
||||
* changes in v5 (WeeChat 4.4.0):
|
||||
* - server option "ipv6" is converted from boolean to enum:
|
||||
* - "on" -> "auto"
|
||||
* - "off" -> "disable"
|
||||
* (new possible value "force" is not set by this function)
|
||||
*/
|
||||
ptr_config = weechat_hashtable_get (data_read, "config");
|
||||
ptr_section = weechat_hashtable_get (data_read, "section");
|
||||
ptr_option = weechat_hashtable_get (data_read, "option");
|
||||
ptr_value = weechat_hashtable_get (data_read, "value");
|
||||
if (ptr_section
|
||||
&& ptr_option
|
||||
&& (strcmp (ptr_section, "server_default") == 0)
|
||||
&& (strcmp (ptr_option, "ipv6") == 0)
|
||||
&& ptr_value)
|
||||
{
|
||||
new_value = (strcmp (ptr_value, "off") == 0) ?
|
||||
strdup ("disable") : strdup ("auto");
|
||||
if (new_value)
|
||||
{
|
||||
weechat_printf (
|
||||
NULL,
|
||||
_("Value of option \"%s.%s.%s\" has been converted: \"%s\" => \"%s\""),
|
||||
ptr_config,
|
||||
ptr_section,
|
||||
ptr_option,
|
||||
ptr_value,
|
||||
new_value);
|
||||
weechat_hashtable_set (data_read, "value", new_value);
|
||||
changes++;
|
||||
free (new_value);
|
||||
}
|
||||
}
|
||||
else if (ptr_section
|
||||
&& ptr_option
|
||||
&& (strcmp (ptr_section, "server") == 0)
|
||||
&& ptr_value)
|
||||
{
|
||||
pos_option = strrchr (ptr_option, '.');
|
||||
if (pos_option && (strcmp (pos_option + 1, "ipv6") == 0))
|
||||
{
|
||||
new_value = (strcmp (ptr_value, "off") == 0) ?
|
||||
strdup ("disable") : strdup ("auto");
|
||||
if (new_value)
|
||||
{
|
||||
weechat_printf (
|
||||
NULL,
|
||||
_("Value of option \"%s.%s.%s\" has been converted: \"%s\" => \"%s\""),
|
||||
ptr_config,
|
||||
ptr_section,
|
||||
ptr_option,
|
||||
ptr_value,
|
||||
new_value);
|
||||
weechat_hashtable_set (data_read, "value", new_value);
|
||||
changes++;
|
||||
free (new_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (changes) ? data_read : NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#define IRC_CONFIG_NAME "irc"
|
||||
#define IRC_CONFIG_PRIO_NAME (TO_STR(IRC_PLUGIN_PRIORITY) "|" IRC_CONFIG_NAME)
|
||||
|
||||
#define IRC_CONFIG_VERSION 4
|
||||
#define IRC_CONFIG_VERSION 5
|
||||
|
||||
enum t_irc_config_look_server_buffer
|
||||
{
|
||||
|
||||
@@ -76,13 +76,16 @@ struct t_irc_server *last_irc_server = NULL;
|
||||
struct t_irc_message *irc_recv_msgq = NULL;
|
||||
struct t_irc_message *irc_msgq_last_msg = NULL;
|
||||
|
||||
char *irc_server_ipv6_string[IRC_SERVER_NUM_IPV6] =
|
||||
{ "disable", "auto", "force" };
|
||||
|
||||
char *irc_server_sasl_fail_string[IRC_SERVER_NUM_SASL_FAIL] =
|
||||
{ "continue", "reconnect", "disconnect" };
|
||||
|
||||
char *irc_server_options[IRC_SERVER_NUM_OPTIONS][2] =
|
||||
{ { "addresses", "" },
|
||||
{ "proxy", "" },
|
||||
{ "ipv6", "on" },
|
||||
{ "ipv6", "auto" },
|
||||
{ "tls", "on" },
|
||||
{ "tls_cert", "" },
|
||||
{ "tls_password", "" },
|
||||
@@ -2076,7 +2079,7 @@ irc_server_alloc_with_url (const char *irc_url)
|
||||
}
|
||||
}
|
||||
weechat_config_option_set (ptr_server->options[IRC_SERVER_OPTION_IPV6],
|
||||
(ipv6) ? "on" : "off",
|
||||
(ipv6) ? "auto" : "disable",
|
||||
1);
|
||||
weechat_config_option_set (ptr_server->options[IRC_SERVER_OPTION_TLS],
|
||||
(tls) ? "on" : "off",
|
||||
@@ -5629,7 +5632,7 @@ irc_server_connect (struct t_irc_server *server)
|
||||
proxy,
|
||||
server->current_address,
|
||||
server->current_port,
|
||||
proxy_type ? weechat_config_integer (proxy_ipv6) : IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_IPV6),
|
||||
proxy_type ? weechat_config_integer (proxy_ipv6) : IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_IPV6),
|
||||
server->current_retry,
|
||||
(server->tls_connected) ? &server->gnutls_sess : NULL,
|
||||
(server->tls_connected) ? &irc_server_gnutls_callback : NULL,
|
||||
@@ -6708,7 +6711,7 @@ irc_server_add_to_infolist (struct t_infolist *infolist,
|
||||
IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_PROXY)))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "ipv6",
|
||||
IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_IPV6)))
|
||||
IRC_SERVER_OPTION_INTEGER(server, IRC_SERVER_OPTION_IPV6)))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "tls",
|
||||
IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_TLS)))
|
||||
@@ -7051,13 +7054,11 @@ irc_server_print_log ()
|
||||
weechat_config_string (ptr_server->options[IRC_SERVER_OPTION_PROXY]));
|
||||
/* ipv6 */
|
||||
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_IPV6]))
|
||||
weechat_log_printf (" ipv6. . . . . . . . . . . : null (%s)",
|
||||
(IRC_SERVER_OPTION_BOOLEAN(ptr_server, IRC_SERVER_OPTION_IPV6)) ?
|
||||
"on" : "off");
|
||||
weechat_log_printf (" ipv6. . . . . . . . . . . : null ('%s')",
|
||||
irc_server_ipv6_string[IRC_SERVER_OPTION_ENUM(ptr_server, IRC_SERVER_OPTION_IPV6)]);
|
||||
else
|
||||
weechat_log_printf (" ipv6. . . . . . . . . . . : %s",
|
||||
(weechat_config_boolean (ptr_server->options[IRC_SERVER_OPTION_IPV6])) ?
|
||||
"on" : "off");
|
||||
weechat_log_printf (" ipv6. . . . . . . . . . . : '%s'",
|
||||
irc_server_ipv6_string[weechat_config_enum (ptr_server->options[IRC_SERVER_OPTION_IPV6])]);
|
||||
/* tls */
|
||||
if (weechat_config_option_is_null (ptr_server->options[IRC_SERVER_OPTION_TLS]))
|
||||
weechat_log_printf (" tls . . . . . . . . . . . : null (%s)",
|
||||
|
||||
@@ -31,6 +31,15 @@
|
||||
#define NI_MAXHOST 256
|
||||
#endif /* NI_MAXHOST */
|
||||
|
||||
enum t_irc_server_ipv6
|
||||
{
|
||||
IRC_SERVER_IPV6_DISABLE = 0,
|
||||
IRC_SERVER_IPV6_AUTO,
|
||||
IRC_SERVER_IPV6_FORCE,
|
||||
/* number of IPv6 options */
|
||||
IRC_SERVER_NUM_IPV6,
|
||||
};
|
||||
|
||||
enum t_irc_server_sasl_fail
|
||||
{
|
||||
IRC_SERVER_SASL_FAIL_CONTINUE = 0,
|
||||
@@ -324,6 +333,7 @@ extern struct t_irc_server *irc_servers;
|
||||
extern const int gnutls_cert_type_prio[];
|
||||
extern const int gnutls_prot_prio[];
|
||||
extern struct t_irc_message *irc_recv_msgq, *irc_msgq_last_msg;
|
||||
extern char *irc_server_ipv6_string[];
|
||||
extern char *irc_server_sasl_fail_string[];
|
||||
extern char *irc_server_options[][2];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user