summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-12-04 17:36:09 +0100
committerSebastien Helleu <flashcode@flashtux.org>2009-12-04 17:36:09 +0100
commit7e5acaf50f25dd097e8225b0df6c4731c8730a63 (patch)
treeb625584236ec23fcd11c4f37a845f41243d64859 /src/plugins
parentda6b882ed82b9e902df5649c326ecfa7ddae4d84 (diff)
downloadweechat-7e5acaf50f25dd097e8225b0df6c4731c8730a63.zip
Give GnuTLS return code to callback if handshake has failed, display extra info in irc plugin if Diffie-Hellman prime sent by the server is not acceptable (not long enough)
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/irc-server.c15
-rw-r--r--src/plugins/scripts/lua/weechat-lua-api.c13
-rw-r--r--src/plugins/scripts/perl/weechat-perl-api.c13
-rw-r--r--src/plugins/scripts/python/weechat-python-api.c13
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby-api.c13
-rw-r--r--src/plugins/scripts/script-api.c1
-rw-r--r--src/plugins/scripts/script-api.h1
-rw-r--r--src/plugins/scripts/tcl/weechat-tcl-api.c13
-rw-r--r--src/plugins/weechat-plugin.h3
9 files changed, 57 insertions, 28 deletions
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 9bcba9a27..a76abf4a5 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -1909,8 +1909,8 @@ irc_server_switch_address (struct t_irc_server *server)
*/
int
-irc_server_connect_cb (void *arg_server, int status, const char *error,
- const char *ip_address)
+irc_server_connect_cb (void *arg_server, int status, int gnutls_rc,
+ const char *error, const char *ip_address)
{
struct t_irc_server *server;
const char *proxy;
@@ -2045,6 +2045,17 @@ irc_server_connect_cb (void *arg_server, int status, const char *error,
weechat_prefix ("error"), IRC_PLUGIN_NAME,
error);
}
+ if (gnutls_rc == GNUTLS_E_DH_PRIME_UNACCEPTABLE)
+ {
+ weechat_printf (server->buffer,
+ _("%s%s: you should play with option "
+ "irc.server.%s.ssl_dhkey_size (current "
+ "value is %d)"),
+ weechat_prefix ("error"), IRC_PLUGIN_NAME,
+ server->name,
+ IRC_SERVER_OPTION_INTEGER (server,
+ IRC_SERVER_OPTION_SSL_DHKEY_SIZE));
+ }
irc_server_close_connection (server);
irc_server_switch_address (server);
break;
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c
index 85968d721..f97eeb968 100644
--- a/src/plugins/scripts/lua/weechat-lua-api.c
+++ b/src/plugins/scripts/lua/weechat-lua-api.c
@@ -3523,11 +3523,12 @@ weechat_lua_api_hook_process (lua_State *L)
*/
int
-weechat_lua_api_hook_connect_cb (void *data, int status,
+weechat_lua_api_hook_connect_cb (void *data, int status, int gnutls_rc,
const char *error, const char *ip_address)
{
struct t_script_callback *script_callback;
- char *lua_argv[5], str_status[32], empty_arg[1] = { '\0' };
+ char *lua_argv[6], str_status[32], str_gnutls_rc[32];
+ char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -3535,12 +3536,14 @@ weechat_lua_api_hook_connect_cb (void *data, int status,
if (script_callback && script_callback->function && script_callback->function[0])
{
snprintf (str_status, sizeof (str_status), "%d", status);
+ snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
lua_argv[1] = str_status;
- lua_argv[2] = (ip_address) ? (char *)ip_address : empty_arg;
- lua_argv[3] = (error) ? (char *)error : empty_arg;
- lua_argv[4] = NULL;
+ lua_argv[2] = str_gnutls_rc;
+ lua_argv[3] = (ip_address) ? (char *)ip_address : empty_arg;
+ lua_argv[4] = (error) ? (char *)error : empty_arg;
+ lua_argv[5] = 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 4b12fff25..1538e7177 100644
--- a/src/plugins/scripts/perl/weechat-perl-api.c
+++ b/src/plugins/scripts/perl/weechat-perl-api.c
@@ -2968,11 +2968,12 @@ XS (XS_weechat_api_hook_process)
*/
int
-weechat_perl_api_hook_connect_cb (void *data, int status,
+weechat_perl_api_hook_connect_cb (void *data, int status, int gnutls_rc,
const char *error, const char *ip_address)
{
struct t_script_callback *script_callback;
- char *perl_argv[5], str_status[32], empty_arg[1] = { '\0' };
+ char *perl_argv[6], str_status[32], str_gnutls_rc[32];
+ char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -2980,12 +2981,14 @@ weechat_perl_api_hook_connect_cb (void *data, int status,
if (script_callback && script_callback->function && script_callback->function[0])
{
snprintf (str_status, sizeof (str_status), "%d", status);
+ snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
perl_argv[1] = str_status;
- perl_argv[2] = (ip_address) ? (char *)ip_address : empty_arg;
- perl_argv[3] = (error) ? (char *)error : empty_arg;
- perl_argv[4] = NULL;
+ perl_argv[2] = str_gnutls_rc;
+ perl_argv[3] = (ip_address) ? (char *)ip_address : empty_arg;
+ perl_argv[4] = (error) ? (char *)error : empty_arg;
+ perl_argv[5] = 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 a839093a0..c13e9cb18 100644
--- a/src/plugins/scripts/python/weechat-python-api.c
+++ b/src/plugins/scripts/python/weechat-python-api.c
@@ -3135,11 +3135,12 @@ weechat_python_api_hook_process (PyObject *self, PyObject *args)
*/
int
-weechat_python_api_hook_connect_cb (void *data, int status,
+weechat_python_api_hook_connect_cb (void *data, int status, int gnutls_rc,
const char *error, const char *ip_address)
{
struct t_script_callback *script_callback;
- char *python_argv[5], str_status[32], empty_arg[1] = { '\0' };
+ char *python_argv[6], str_status[32], str_gnutls_rc[32];
+ char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -3147,12 +3148,14 @@ weechat_python_api_hook_connect_cb (void *data, int status,
if (script_callback && script_callback->function && script_callback->function[0])
{
snprintf (str_status, sizeof (str_status), "%d", status);
+ snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
python_argv[1] = str_status;
- python_argv[2] = (ip_address) ? (char *)ip_address : empty_arg;
- python_argv[3] = (error) ? (char *)error : empty_arg;
- python_argv[4] = NULL;
+ python_argv[2] = str_gnutls_rc;
+ python_argv[3] = (ip_address) ? (char *)ip_address : empty_arg;
+ python_argv[4] = (error) ? (char *)error : empty_arg;
+ python_argv[5] = 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 31d4490cc..930489cc8 100644
--- a/src/plugins/scripts/ruby/weechat-ruby-api.c
+++ b/src/plugins/scripts/ruby/weechat-ruby-api.c
@@ -3620,11 +3620,12 @@ weechat_ruby_api_hook_process (VALUE class, VALUE command, VALUE timeout,
*/
int
-weechat_ruby_api_hook_connect_cb (void *data, int status,
+weechat_ruby_api_hook_connect_cb (void *data, int status, int gnutls_rc,
const char *error, const char *ip_address)
{
struct t_script_callback *script_callback;
- char *ruby_argv[5], str_status[32], empty_arg[1] = { '\0' };
+ char *ruby_argv[6], str_status[32], str_gnutls_rc[32];
+ char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -3632,12 +3633,14 @@ weechat_ruby_api_hook_connect_cb (void *data, int status,
if (script_callback && script_callback->function && script_callback->function[0])
{
snprintf (str_status, sizeof (str_status), "%d", status);
+ snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
ruby_argv[1] = str_status;
- ruby_argv[2] = (ip_address) ? (char *)ip_address : empty_arg;
- ruby_argv[3] = (error) ? (char *)error : empty_arg;
- ruby_argv[4] = NULL;
+ ruby_argv[2] = str_gnutls_rc;
+ ruby_argv[3] = (ip_address) ? (char *)ip_address : empty_arg;
+ ruby_argv[4] = (error) ? (char *)error : empty_arg;
+ ruby_argv[5] = 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 2eaabeefc..96d602add 100644
--- a/src/plugins/scripts/script-api.c
+++ b/src/plugins/scripts/script-api.c
@@ -929,6 +929,7 @@ script_api_hook_connect (struct t_weechat_plugin *weechat_plugin,
void *gnutls_cb, int gnutls_dhkey_size,
const char *local_hostname,
int (*callback)(void *data, int status,
+ int gnutls_rc,
const char *error,
const char *ip_address),
const char *function,
diff --git a/src/plugins/scripts/script-api.h b/src/plugins/scripts/script-api.h
index 434660f7f..8dce7becd 100644
--- a/src/plugins/scripts/script-api.h
+++ b/src/plugins/scripts/script-api.h
@@ -174,6 +174,7 @@ extern struct t_hook *script_api_hook_connect (struct t_weechat_plugin *weechat_
const char *local_hostname,
int (*callback)(void *data,
int status,
+ int gnutls_rc,
const char *error,
const char *ip_address),
const char *function,
diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c
index 04a654475..63701f3e1 100644
--- a/src/plugins/scripts/tcl/weechat-tcl-api.c
+++ b/src/plugins/scripts/tcl/weechat-tcl-api.c
@@ -3375,11 +3375,12 @@ weechat_tcl_api_hook_process (ClientData clientData, Tcl_Interp *interp,
*/
int
-weechat_tcl_api_hook_connect_cb (void *data, int status,
+weechat_tcl_api_hook_connect_cb (void *data, int status, int gnutls_rc,
const char *error, const char *ip_address)
{
struct t_script_callback *script_callback;
- char *tcl_argv[5], str_status[32], empty_arg[1] = { '\0' };
+ char *tcl_argv[6], str_status[32], str_gnutls_rc[32];
+ char empty_arg[1] = { '\0' };
int *rc, ret;
script_callback = (struct t_script_callback *)data;
@@ -3387,12 +3388,14 @@ weechat_tcl_api_hook_connect_cb (void *data, int status,
if (script_callback && script_callback->function && script_callback->function[0])
{
snprintf (str_status, sizeof (str_status), "%d", status);
+ snprintf (str_gnutls_rc, sizeof (str_gnutls_rc), "%d", gnutls_rc);
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
tcl_argv[1] = str_status;
- tcl_argv[2] = (ip_address) ? (char *)ip_address : empty_arg;
- tcl_argv[3] = (error) ? (char *)error : empty_arg;
- tcl_argv[4] = NULL;
+ tcl_argv[2] = str_gnutls_rc;
+ tcl_argv[3] = (ip_address) ? (char *)ip_address : empty_arg;
+ tcl_argv[4] = (error) ? (char *)error : empty_arg;
+ tcl_argv[5] = 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 9a3e79c0a..b4b4a7a4d 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -34,7 +34,7 @@ struct t_weelist;
struct timeval;
/* API version (used to check that plugin has same API and can be loaded) */
-#define WEECHAT_PLUGIN_API_VERSION "20091107-01"
+#define WEECHAT_PLUGIN_API_VERSION "20091204-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -401,6 +401,7 @@ struct t_weechat_plugin
const char *local_hostname,
int (*callback)(void *data,
int status,
+ int gnutls_rc,
const char *error,
const char *ip_address),
void *callback_data);