mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 12:56:37 +02:00
Add support for more than one proxy, with proxy selection for each IRC server (task #6859)
This commit is contained in:
@@ -2752,7 +2752,7 @@ weechat_lua_api_hook_connect_cb (void *data, int status, const char *ip_address)
|
||||
static int
|
||||
weechat_lua_api_hook_connect (lua_State *L)
|
||||
{
|
||||
const char *address, *local_hostname, *function;
|
||||
const char *proxy, *address, *local_hostname, *function;
|
||||
int n, port, sock, ipv6;
|
||||
char *result;
|
||||
|
||||
@@ -2764,7 +2764,8 @@ weechat_lua_api_hook_connect (lua_State *L)
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_connect");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
|
||||
proxy = NULL;
|
||||
address = NULL;
|
||||
port = 0;
|
||||
sock = 0;
|
||||
@@ -2773,13 +2774,14 @@ weechat_lua_api_hook_connect (lua_State *L)
|
||||
function = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 6)
|
||||
|
||||
if (n < 7)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
|
||||
proxy = lua_tostring (lua_current_interpreter, -7);
|
||||
address = lua_tostring (lua_current_interpreter, -6);
|
||||
port = lua_tonumber (lua_current_interpreter, -5);
|
||||
sock = lua_tonumber (lua_current_interpreter, -4);
|
||||
@@ -2789,6 +2791,7 @@ weechat_lua_api_hook_connect (lua_State *L)
|
||||
|
||||
result = script_ptr2str (script_api_hook_connect (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
proxy,
|
||||
address,
|
||||
port,
|
||||
sock,
|
||||
|
||||
@@ -2299,7 +2299,7 @@ weechat_perl_api_hook_connect_cb (void *data, int status,
|
||||
|
||||
static XS (XS_weechat_api_hook_connect)
|
||||
{
|
||||
char *address, *local_hostname, *result;
|
||||
char *proxy, *address, *local_hostname, *result;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -2311,25 +2311,27 @@ static XS (XS_weechat_api_hook_connect)
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 6)
|
||||
if (items < 7)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
address = SvPV (ST (0), PL_na);
|
||||
local_hostname = SvPV (ST (4), PL_na);
|
||||
proxy = SvPV (ST (0), PL_na);
|
||||
address = SvPV (ST (1), PL_na);
|
||||
local_hostname = SvPV (ST (5), PL_na);
|
||||
|
||||
result = script_ptr2str (script_api_hook_connect (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
proxy,
|
||||
address,
|
||||
SvIV (ST (1)), /* port */
|
||||
SvIV (ST (2)), /* sock */
|
||||
SvIV (ST (3)), /* ipv6 */
|
||||
SvIV (ST (2)), /* port */
|
||||
SvIV (ST (3)), /* sock */
|
||||
SvIV (ST (4)), /* ipv6 */
|
||||
NULL, /* gnutls session */
|
||||
local_hostname,
|
||||
&weechat_perl_api_hook_connect_cb,
|
||||
SvPV (ST (5), PL_na))); /* perl function */
|
||||
SvPV (ST (6), PL_na))); /* perl function */
|
||||
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
@@ -2453,7 +2453,7 @@ weechat_python_api_hook_connect_cb (void *data, int status,
|
||||
static PyObject *
|
||||
weechat_python_api_hook_connect (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *address, *local_hostname, *function, *result;
|
||||
char *proxy, *address, *local_hostname, *function, *result;
|
||||
int port, sock, ipv6;
|
||||
PyObject *object;
|
||||
|
||||
@@ -2465,7 +2465,8 @@ weechat_python_api_hook_connect (PyObject *self, PyObject *args)
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_connect");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
|
||||
proxy = NULL;
|
||||
address = NULL;
|
||||
port = 0;
|
||||
sock = 0;
|
||||
@@ -2473,8 +2474,8 @@ weechat_python_api_hook_connect (PyObject *self, PyObject *args)
|
||||
local_hostname = NULL;
|
||||
function = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "siiiss", &address, &port, &sock, &ipv6,
|
||||
&local_hostname, &function))
|
||||
if (!PyArg_ParseTuple (args, "ssiiiss", &proxy, &address, &port, &sock,
|
||||
&ipv6, &local_hostname, &function))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
@@ -2482,6 +2483,7 @@ weechat_python_api_hook_connect (PyObject *self, PyObject *args)
|
||||
|
||||
result = script_ptr2str (script_api_hook_connect (weechat_python_plugin,
|
||||
python_current_script,
|
||||
proxy,
|
||||
address,
|
||||
port,
|
||||
sock,
|
||||
|
||||
@@ -2816,11 +2816,11 @@ weechat_ruby_api_hook_connect_cb (void *data, int status,
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hook_connect (VALUE class, VALUE address, VALUE port,
|
||||
VALUE sock, VALUE ipv6, VALUE local_hostname,
|
||||
VALUE function)
|
||||
weechat_ruby_api_hook_connect (VALUE class, VALUE proxy, VALUE address,
|
||||
VALUE port, VALUE sock, VALUE ipv6,
|
||||
VALUE local_hostname, VALUE function)
|
||||
{
|
||||
char *c_address, *c_local_hostname, *c_function, *result;
|
||||
char *c_proxy, *c_address, *c_local_hostname, *c_function, *result;
|
||||
int c_port, c_sock, c_ipv6;
|
||||
VALUE return_value;
|
||||
|
||||
@@ -2832,7 +2832,8 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE address, VALUE port,
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_connect");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
|
||||
c_proxy = NULL;
|
||||
c_address = NULL;
|
||||
c_port = 0;
|
||||
c_sock = 0;
|
||||
@@ -2840,20 +2841,22 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE address, VALUE port,
|
||||
c_local_hostname = NULL;
|
||||
c_function = NULL;
|
||||
|
||||
if (NIL_P (address) || NIL_P (port) || NIL_P (sock) || NIL_P (ipv6)
|
||||
|| NIL_P (local_hostname) || NIL_P (function))
|
||||
if (NIL_P (proxy) || NIL_P (address) || NIL_P (port) || NIL_P (sock)
|
||||
|| NIL_P (ipv6) || NIL_P (local_hostname) || NIL_P (function))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
|
||||
Check_Type (proxy, T_STRING);
|
||||
Check_Type (address, T_STRING);
|
||||
Check_Type (port, T_FIXNUM);
|
||||
Check_Type (sock, T_FIXNUM);
|
||||
Check_Type (ipv6, T_FIXNUM);
|
||||
Check_Type (local_hostname, T_STRING);
|
||||
Check_Type (function, T_STRING);
|
||||
|
||||
|
||||
c_proxy = STR2CSTR (proxy);
|
||||
c_address = STR2CSTR (address);
|
||||
c_port = FIX2INT (port);
|
||||
c_sock = FIX2INT (sock);
|
||||
@@ -2863,6 +2866,7 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE address, VALUE port,
|
||||
|
||||
result = script_ptr2str (script_api_hook_connect (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
c_proxy,
|
||||
c_address,
|
||||
c_port,
|
||||
c_sock,
|
||||
@@ -5633,7 +5637,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "hook_command", &weechat_ruby_api_hook_command, 6);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_timer", &weechat_ruby_api_hook_timer, 4);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_fd", &weechat_ruby_api_hook_fd, 5);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_connect", &weechat_ruby_api_hook_connect, 6);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_connect", &weechat_ruby_api_hook_connect, 7);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_print", &weechat_ruby_api_hook_print, 5);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_signal", &weechat_ruby_api_hook_signal, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_signal_send", &weechat_ruby_api_hook_signal_send, 3);
|
||||
|
||||
@@ -744,8 +744,9 @@ script_api_hook_fd (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_hook *
|
||||
script_api_hook_connect (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *address, int port, int sock, int ipv6,
|
||||
void *gnutls_sess, const char *local_hostname,
|
||||
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),
|
||||
const char *function)
|
||||
{
|
||||
@@ -756,8 +757,8 @@ script_api_hook_connect (struct t_weechat_plugin *weechat_plugin,
|
||||
if (!new_script_callback)
|
||||
return NULL;
|
||||
|
||||
new_hook = weechat_hook_connect (address, port, sock, ipv6, gnutls_sess,
|
||||
local_hostname, callback,
|
||||
new_hook = weechat_hook_connect (proxy, address, port, sock, ipv6,
|
||||
gnutls_sess, local_hostname, callback,
|
||||
new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
|
||||
@@ -121,6 +121,7 @@ extern struct t_hook *script_api_hook_fd (struct t_weechat_plugin *weechat_plugi
|
||||
const char *function);
|
||||
extern struct t_hook *script_api_hook_connect (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *proxy,
|
||||
const char *address,
|
||||
int port,
|
||||
int sock,
|
||||
|
||||
@@ -2663,7 +2663,7 @@ weechat_tcl_api_hook_connect (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *address, *local_hostname, *result;
|
||||
char *proxy, *address, *local_hostname, *result;
|
||||
int i, port, sock, ipv6;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -2675,25 +2675,27 @@ weechat_tcl_api_hook_connect (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 6)
|
||||
if (objc < 7)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if ((Tcl_GetIntFromObj (interp, objv[2], &port) != TCL_OK)
|
||||
|| (Tcl_GetIntFromObj (interp, objv[3], &sock) != TCL_OK)
|
||||
|| (Tcl_GetIntFromObj (interp, objv[4], &ipv6) != TCL_OK))
|
||||
if ((Tcl_GetIntFromObj (interp, objv[3], &port) != TCL_OK)
|
||||
|| (Tcl_GetIntFromObj (interp, objv[4], &sock) != TCL_OK)
|
||||
|| (Tcl_GetIntFromObj (interp, objv[5], &ipv6) != TCL_OK))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_connect");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
address = Tcl_GetStringFromObj (objv[1], &i);
|
||||
local_hostname = Tcl_GetStringFromObj (objv[5], &i);
|
||||
proxy = Tcl_GetStringFromObj (objv[1], &i);
|
||||
address = Tcl_GetStringFromObj (objv[2], &i);
|
||||
local_hostname = Tcl_GetStringFromObj (objv[6], &i);
|
||||
|
||||
result = script_ptr2str (script_api_hook_connect (weechat_tcl_plugin,
|
||||
tcl_current_script,
|
||||
proxy,
|
||||
address,
|
||||
port,
|
||||
sock,
|
||||
@@ -2701,7 +2703,7 @@ weechat_tcl_api_hook_connect (ClientData clientData, Tcl_Interp *interp,
|
||||
NULL, /* gnutls session */
|
||||
local_hostname,
|
||||
&weechat_tcl_api_hook_connect_cb,
|
||||
Tcl_GetStringFromObj (objv[6], &i))); /* tcl function */
|
||||
Tcl_GetStringFromObj (objv[7], &i))); /* tcl function */
|
||||
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user