diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-config.c | 56 | ||||
-rw-r--r-- | src/core/wee-config.h | 2 | ||||
-rw-r--r-- | src/core/wee-hook.h | 1 | ||||
-rw-r--r-- | src/core/wee-network.c | 11 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 67 | ||||
-rw-r--r-- | src/plugins/jabber/jabber-server.c | 67 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 8 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 7 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 7 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 7 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.c | 4 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.h | 1 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 7 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 1 |
14 files changed, 221 insertions, 25 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 7d6b727bd..b5fd829e4 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -159,6 +159,10 @@ struct t_config_option *config_history_max_lines; struct t_config_option *config_history_max_commands; struct t_config_option *config_history_display_default; +/* config, network section */ + +struct t_config_option *config_network_gnutls_dh_prime_bits; + /* config, plugin section */ struct t_config_option *config_plugin_autoload; @@ -978,12 +982,12 @@ config_weechat_key_write_cb (void *data, struct t_config_file *config_file, } /* - * config_weechat_init: init WeeChat config structure - * return: 1 if ok, 0 if error + * config_weechat_init_options: init WeeChat config structure (all core options) + * return: 1 if ok, 0 if error */ int -config_weechat_init () +config_weechat_init_options () { struct t_config_section *ptr_section; @@ -1680,6 +1684,24 @@ config_weechat_init () } weechat_config_section_proxy = ptr_section; + + /* network */ + ptr_section = config_file_new_section (weechat_config_file, "network", + 0, 0, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL); + if (!ptr_section) + { + config_file_free (weechat_config_file); + return 0; + } + + config_network_gnutls_dh_prime_bits = config_file_new_option ( + weechat_config_file, ptr_section, + "gnutls_dh_prime_bitsmax_lines", "integer", + N_("minimum size in bits for handshake using Diffie Hellman key " + "exchange"), + NULL, 0, INT_MAX, "512", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); /* plugin */ ptr_section = config_file_new_section (weechat_config_file, "plugin", @@ -1786,6 +1808,27 @@ config_weechat_init () } /* + * config_weechat_init: init WeeChat config structure + * return: 1 if ok, 0 if error + */ + +int +config_weechat_init () +{ + int rc; + + rc = config_weechat_init_options (); + + if (!rc) + { + gui_chat_printf (NULL, + _("FATAL: error initializing configuration options")); + } + + return rc; +} + +/* * config_weechat_read: read WeeChat configuration file * return one of these values: * WEECHAT_CONFIG_READ_OK @@ -1806,6 +1849,13 @@ config_weechat_read () gui_bar_use_temp_bars (); gui_bar_create_default (); } + + if (rc != WEECHAT_CONFIG_READ_OK) + { + gui_chat_printf (NULL, + _("%sError reading configuration"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); + } return rc; } diff --git a/src/core/wee-config.h b/src/core/wee-config.h index 17314d806..bcefc2143 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -159,6 +159,8 @@ extern struct t_config_option *config_history_max_lines; extern struct t_config_option *config_history_max_commands; extern struct t_config_option *config_history_display_default; +extern struct t_config_option *config_network_gnutls_dh_prime_bits; + extern struct t_config_option *config_plugin_autoload; extern struct t_config_option *config_plugin_debug; extern struct t_config_option *config_plugin_extension; diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h index 68f6d8800..fb6aa0010 100644 --- a/src/core/wee-hook.h +++ b/src/core/wee-hook.h @@ -167,6 +167,7 @@ struct t_hook_process /* hook connect */ typedef int (t_hook_callback_connect)(void *data, int status, + const char *error, const char *ip_address); struct t_hook_connect diff --git a/src/core/wee-network.c b/src/core/wee-network.c index d3468ab49..15d7bbb8c 100644 --- a/src/core/wee-network.c +++ b/src/core/wee-network.c @@ -804,6 +804,8 @@ network_connect_child_read_cb (void *arg_hook_connect, int fd) { gnutls_transport_set_ptr (*HOOK_CONNECT(hook_connect, gnutls_sess), (gnutls_transport_ptr) ((unsigned long) HOOK_CONNECT(hook_connect, sock))); + gnutls_dh_set_prime_bits (*HOOK_CONNECT(hook_connect, gnutls_sess), + CONFIG_INTEGER(config_network_gnutls_dh_prime_bits)); while (1) { rc = gnutls_handshake (*HOOK_CONNECT(hook_connect, gnutls_sess)); @@ -817,6 +819,7 @@ network_connect_child_read_cb (void *arg_hook_connect, int fd) (void) (HOOK_CONNECT(hook_connect, callback)) (hook_connect->callback_data, WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR, + gnutls_strerror (rc), ip_address); unhook (hook_connect); if (ip_address) @@ -827,7 +830,7 @@ network_connect_child_read_cb (void *arg_hook_connect, int fd) #endif } (void) (HOOK_CONNECT(hook_connect, callback)) - (hook_connect->callback_data, buffer[0] - '0', ip_address); + (hook_connect->callback_data, buffer[0] - '0', NULL, ip_address); unhook (hook_connect); } @@ -858,7 +861,7 @@ network_connect_with_fork (struct t_hook *hook_connect) (void) (HOOK_CONNECT(hook_connect, callback)) (hook_connect->callback_data, '0' + WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR, - NULL); + NULL, NULL); unhook (hook_connect); return; } @@ -881,7 +884,7 @@ network_connect_with_fork (struct t_hook *hook_connect) (void) (HOOK_CONNECT(hook_connect, callback)) (hook_connect->callback_data, '0' + WEECHAT_HOOK_CONNECT_MEMORY_ERROR, - NULL); + NULL, NULL); unhook (hook_connect); return; } @@ -903,7 +906,7 @@ network_connect_with_fork (struct t_hook *hook_connect) (void) (HOOK_CONNECT(hook_connect, callback)) (hook_connect->callback_data, '0' + WEECHAT_HOOK_CONNECT_MEMORY_ERROR, - NULL); + NULL, NULL); unhook (hook_connect); return; /* child process */ diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index ff8692347..6f6918c4d 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -1847,7 +1847,8 @@ irc_server_switch_address (struct t_irc_server *server) */ int -irc_server_connect_cb (void *arg_server, int status, const char *ip_address) +irc_server_connect_cb (void *arg_server, int status, const char *error, + const char *ip_address) { struct t_irc_server *server; const char *proxy; @@ -1885,6 +1886,14 @@ irc_server_connect_cb (void *arg_server, int status, const char *ip_address) irc_buffer_get_server_prefix (server, "error"), IRC_PLUGIN_NAME, server->addresses_array[server->index_current_address]); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + irc_buffer_get_server_prefix (server, "error"), + IRC_PLUGIN_NAME, + error); + } irc_server_close_connection (server); irc_server_switch_address (server); break; @@ -1895,6 +1904,14 @@ irc_server_connect_cb (void *arg_server, int status, const char *ip_address) _("%s%s: IP address not found"), irc_buffer_get_server_prefix (server, "error"), IRC_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + irc_buffer_get_server_prefix (server, "error"), + IRC_PLUGIN_NAME, + error); + } irc_server_close_connection (server); irc_server_switch_address (server); break; @@ -1905,6 +1922,14 @@ irc_server_connect_cb (void *arg_server, int status, const char *ip_address) _("%s%s: connection refused"), irc_buffer_get_server_prefix (server, "error"), IRC_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + irc_buffer_get_server_prefix (server, "error"), + IRC_PLUGIN_NAME, + error); + } irc_server_close_connection (server); irc_server_switch_address (server); break; @@ -1917,6 +1942,14 @@ irc_server_connect_cb (void *arg_server, int status, const char *ip_address) "proxy)"), irc_buffer_get_server_prefix (server, "error"), IRC_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + irc_buffer_get_server_prefix (server, "error"), + IRC_PLUGIN_NAME, + error); + } irc_server_close_connection (server); irc_server_switch_address (server); break; @@ -1925,6 +1958,14 @@ irc_server_connect_cb (void *arg_server, int status, const char *ip_address) _("%s%s: unable to set local hostname/IP"), irc_buffer_get_server_prefix (server, "error"), IRC_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + irc_buffer_get_server_prefix (server, "error"), + IRC_PLUGIN_NAME, + error); + } irc_server_close_connection (server); irc_server_reconnect_schedule (server); break; @@ -1933,6 +1974,14 @@ irc_server_connect_cb (void *arg_server, int status, const char *ip_address) _("%s%s: TLS init error"), irc_buffer_get_server_prefix (server, "error"), IRC_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + irc_buffer_get_server_prefix (server, "error"), + IRC_PLUGIN_NAME, + error); + } irc_server_close_connection (server); irc_server_reconnect_schedule (server); break; @@ -1941,6 +1990,14 @@ irc_server_connect_cb (void *arg_server, int status, const char *ip_address) _("%s%s: TLS handshake failed"), irc_buffer_get_server_prefix (server, "error"), IRC_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + irc_buffer_get_server_prefix (server, "error"), + IRC_PLUGIN_NAME, + error); + } irc_server_close_connection (server); irc_server_switch_address (server); break; @@ -1949,6 +2006,14 @@ irc_server_connect_cb (void *arg_server, int status, const char *ip_address) _("%s%s: not enough memory"), irc_buffer_get_server_prefix (server, "error"), IRC_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + irc_buffer_get_server_prefix (server, "error"), + IRC_PLUGIN_NAME, + error); + } irc_server_close_connection (server); irc_server_reconnect_schedule (server); break; diff --git a/src/plugins/jabber/jabber-server.c b/src/plugins/jabber/jabber-server.c index 7c09f2500..bb2053e0c 100644 --- a/src/plugins/jabber/jabber-server.c +++ b/src/plugins/jabber/jabber-server.c @@ -539,7 +539,8 @@ jabber_server_login (struct t_jabber_server *server) */ int -jabber_server_connect_cb (void *arg_server, int status, const char *ip_address) +jabber_server_connect_cb (void *arg_server, int status, const char *error, + const char *ip_address) { struct t_jabber_server *server; const char *proxy; @@ -577,6 +578,14 @@ jabber_server_connect_cb (void *arg_server, int status, const char *ip_address) jabber_buffer_get_server_prefix (server, "error"), JABBER_PLUGIN_NAME, server->address); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + jabber_buffer_get_server_prefix (server, "error"), + JABBER_PLUGIN_NAME, + error); + } jabber_server_close_connection (server); jabber_server_reconnect_schedule (server); break; @@ -587,6 +596,14 @@ jabber_server_connect_cb (void *arg_server, int status, const char *ip_address) _("%s%s: IP address not found"), jabber_buffer_get_server_prefix (server, "error"), JABBER_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + jabber_buffer_get_server_prefix (server, "error"), + JABBER_PLUGIN_NAME, + error); + } jabber_server_close_connection (server); jabber_server_reconnect_schedule (server); break; @@ -597,6 +614,14 @@ jabber_server_connect_cb (void *arg_server, int status, const char *ip_address) _("%s%s: connection refused"), jabber_buffer_get_server_prefix (server, "error"), JABBER_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + jabber_buffer_get_server_prefix (server, "error"), + JABBER_PLUGIN_NAME, + error); + } jabber_server_close_connection (server); jabber_server_reconnect_schedule (server); break; @@ -609,6 +634,14 @@ jabber_server_connect_cb (void *arg_server, int status, const char *ip_address) "proxy)"), jabber_buffer_get_server_prefix (server, "error"), JABBER_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + jabber_buffer_get_server_prefix (server, "error"), + JABBER_PLUGIN_NAME, + error); + } jabber_server_close_connection (server); jabber_server_reconnect_schedule (server); break; @@ -617,6 +650,14 @@ jabber_server_connect_cb (void *arg_server, int status, const char *ip_address) _("%s%s: unable to set local hostname/IP"), jabber_buffer_get_server_prefix (server, "error"), JABBER_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + jabber_buffer_get_server_prefix (server, "error"), + JABBER_PLUGIN_NAME, + error); + } jabber_server_close_connection (server); jabber_server_reconnect_schedule (server); break; @@ -625,6 +666,14 @@ jabber_server_connect_cb (void *arg_server, int status, const char *ip_address) _("%s%s: GnuTLS init error"), jabber_buffer_get_server_prefix (server, "error"), JABBER_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + jabber_buffer_get_server_prefix (server, "error"), + JABBER_PLUGIN_NAME, + error); + } jabber_server_close_connection (server); jabber_server_reconnect_schedule (server); break; @@ -633,6 +682,14 @@ jabber_server_connect_cb (void *arg_server, int status, const char *ip_address) _("%s%s: GnuTLS handshake failed"), jabber_buffer_get_server_prefix (server, "error"), JABBER_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + jabber_buffer_get_server_prefix (server, "error"), + JABBER_PLUGIN_NAME, + error); + } jabber_server_close_connection (server); jabber_server_reconnect_schedule (server); break; @@ -641,6 +698,14 @@ jabber_server_connect_cb (void *arg_server, int status, const char *ip_address) _("%s%s: not enough memory"), jabber_buffer_get_server_prefix (server, "error"), JABBER_PLUGIN_NAME); + if (error && error[0]) + { + weechat_printf (server->buffer, + _("%s%s: error: %s"), + jabber_buffer_get_server_prefix (server, "error"), + JABBER_PLUGIN_NAME, + error); + } jabber_server_close_connection (server); jabber_server_reconnect_schedule (server); break; diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index 9271d9ce4..7808cdc74 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -3424,10 +3424,11 @@ weechat_lua_api_hook_process (lua_State *L) */ int -weechat_lua_api_hook_connect_cb (void *data, int status, const char *ip_address) +weechat_lua_api_hook_connect_cb (void *data, int status, + const char *error, const char *ip_address) { struct t_script_callback *script_callback; - char *lua_argv[3], str_status[32], empty_arg[1] = { '\0' }; + char *lua_argv[4], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3438,7 +3439,8 @@ weechat_lua_api_hook_connect_cb (void *data, int status, const char *ip_address) lua_argv[0] = str_status; lua_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; - lua_argv[2] = NULL; + lua_argv[2] = (error) ? (char *)error : empty_arg; + lua_argv[3] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 2a3ef2815..dfeb36686 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -2862,10 +2862,10 @@ static XS (XS_weechat_api_hook_process) int weechat_perl_api_hook_connect_cb (void *data, int status, - const char *ip_address) + const char *error, const char *ip_address) { struct t_script_callback *script_callback; - char *perl_argv[3], str_status[32], empty_arg[1] = { '\0' }; + char *perl_argv[4], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -2876,7 +2876,8 @@ weechat_perl_api_hook_connect_cb (void *data, int status, perl_argv[0] = str_status; perl_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; - perl_argv[2] = NULL; + perl_argv[2] = (error) ? (char *)error : empty_arg; + perl_argv[3] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index 4f0d3a8d5..e42cbbbb4 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -3054,10 +3054,10 @@ weechat_python_api_hook_process (PyObject *self, PyObject *args) int weechat_python_api_hook_connect_cb (void *data, int status, - const char *ip_address) + const char *error, const char *ip_address) { struct t_script_callback *script_callback; - char *python_argv[3], str_status[32], empty_arg[1] = { '\0' }; + char *python_argv[4], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3068,7 +3068,8 @@ weechat_python_api_hook_connect_cb (void *data, int status, python_argv[0] = str_status; python_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; - python_argv[2] = NULL; + python_argv[2] = (error) ? (char *)error : empty_arg; + python_argv[3] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index bf150363a..dd6b5fe6a 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -3494,10 +3494,10 @@ weechat_ruby_api_hook_process (VALUE class, VALUE command, VALUE timeout, int weechat_ruby_api_hook_connect_cb (void *data, int status, - const char *ip_address) + const char *error, const char *ip_address) { struct t_script_callback *script_callback; - char *ruby_argv[3], str_status[32], empty_arg[1] = { '\0' }; + char *ruby_argv[4], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3508,7 +3508,8 @@ weechat_ruby_api_hook_connect_cb (void *data, int status, ruby_argv[0] = str_status; ruby_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; - ruby_argv[2] = NULL; + ruby_argv[2] = (error) ? (char *)error : empty_arg; + ruby_argv[3] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c index 8784fba3e..99266a04f 100644 --- a/src/plugins/scripts/script-api.c +++ b/src/plugins/scripts/script-api.c @@ -917,7 +917,9 @@ script_api_hook_connect (struct t_weechat_plugin *weechat_plugin, const char *proxy, const char *address, int port, int sock, int ipv6, void *gnutls_sess, const char *local_hostname, - int (*callback)(void *data, int status, const char *ip_address), + int (*callback)(void *data, int status, + const char *error, + const char *ip_address), const char *function) { struct t_script_callback *new_script_callback; diff --git a/src/plugins/scripts/script-api.h b/src/plugins/scripts/script-api.h index 1bb20f0e5..6f6959a62 100644 --- a/src/plugins/scripts/script-api.h +++ b/src/plugins/scripts/script-api.h @@ -159,6 +159,7 @@ extern struct t_hook *script_api_hook_connect (struct t_weechat_plugin *weechat_ const char *local_hostname, int (*callback)(void *data, int status, + const char *error, const char *ip_address), const char *function); extern struct t_hook *script_api_hook_print (struct t_weechat_plugin *weechat_plugin, diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index 790122dad..99fb5282a 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -3274,10 +3274,10 @@ weechat_tcl_api_hook_process (ClientData clientData, Tcl_Interp *interp, int weechat_tcl_api_hook_connect_cb (void *data, int status, - const char *ip_address) + const char *error, const char *ip_address) { struct t_script_callback *script_callback; - char *tcl_argv[3], str_status[32], empty_arg[1] = { '\0' }; + char *tcl_argv[4], str_status[32], empty_arg[1] = { '\0' }; int *rc, ret; script_callback = (struct t_script_callback *)data; @@ -3288,7 +3288,8 @@ weechat_tcl_api_hook_connect_cb (void *data, int status, tcl_argv[0] = str_status; tcl_argv[1] = (ip_address) ? (char *)ip_address : empty_arg; - tcl_argv[2] = NULL; + tcl_argv[2] = (error) ? (char *)error : empty_arg; + tcl_argv[3] = NULL; rc = (int *) weechat_tcl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 880fd45bb..92885cd45 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -393,6 +393,7 @@ struct t_weechat_plugin const char *local_hostname, int (*callback)(void *data, int status, + const char *error, const char *ip_address), void *callback_data); struct t_hook *(*hook_print) (struct t_weechat_plugin *plugin, |