summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--docs/perl.txt13
-rw-r--r--docs/signals.txt2
-rw-r--r--src/irc/proxy/Makefile.am3
-rw-r--r--src/irc/proxy/listen.c14
-rw-r--r--src/irc/proxy/module.h23
-rw-r--r--src/irc/proxy/proxy.h33
-rw-r--r--src/perl/Makefile.am1
-rwxr-xr-xsrc/perl/get-signals.pl1
-rw-r--r--src/perl/irc/Client.xs5
-rw-r--r--src/perl/irc/Irc.xs15
-rw-r--r--src/perl/irc/module.h4
-rw-r--r--src/perl/irc/typemap1
13 files changed, 94 insertions, 23 deletions
diff --git a/NEWS b/NEWS
index d05499c8..a0d6b61d 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,8 @@ v0.8.13
in /sb status more accurate (higher).
+ fix data getting dropped when a lot is sent at a time (e.g. when
attaching to irssi-proxy, bug #528).
+ + introduce the type Irssi::Irc::Client and signals to communicate with
+ proxy clients to allow for scripting parts of the irssi-proxy.
- fix leak with $L expando.
- fix possible crash with /script reset.
- ignore exceptions take precedence over ignores in all cases.
diff --git a/docs/perl.txt b/docs/perl.txt
index 2887478f..3236d28f 100644
--- a/docs/perl.txt
+++ b/docs/perl.txt
@@ -1143,3 +1143,16 @@ Server::notifylist_ison_server(nick)
Notifylist::ircnets_match(ircnet)
Returns 1 if notify is checked in `ircnet'.
+
+ *** Proxy clients
+
+Client->{}
+ nick - nick of the client
+ host - host of the client
+ proxy_address - address of the proxy server
+ server - Irc::Server for which we proxy to this client
+ pass_sent - whether the client already send a PASS command
+ user_sent - whether the client already send a USER command
+ connected - whether the client is connected and ready
+ want_ctcp - whether the client wants to receive CTCPs
+ ircnet - network tag of the network we proxy
diff --git a/docs/signals.txt b/docs/signals.txt
index 866b8d03..56460722 100644
--- a/docs/signals.txt
+++ b/docs/signals.txt
@@ -217,6 +217,8 @@ proxy/listen.c:
"proxy client connected", CLIENT_REC
"proxy client disconnected", CLIENT_REC
+ "proxy client command", CLIENT_REC, char *args, char *data
+ "proxy client dump", CLIENT_REC, char *data
FE common
---------
diff --git a/src/irc/proxy/Makefile.am b/src/irc/proxy/Makefile.am
index bf80bc2d..8a5b5046 100644
--- a/src/irc/proxy/Makefile.am
+++ b/src/irc/proxy/Makefile.am
@@ -21,7 +21,8 @@ libirc_proxy_la_SOURCES = \
listen.c
noinst_HEADERS = \
- module.h
+ module.h \
+ proxy.h
clean-generic:
rm -f libirc_proxy.a
diff --git a/src/irc/proxy/listen.c b/src/irc/proxy/listen.c
index 5e7497c1..5f473a34 100644
--- a/src/irc/proxy/listen.c
+++ b/src/irc/proxy/listen.c
@@ -186,6 +186,8 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args,
client->want_ctcp = 0;
proxy_outdata(client, ":%s NOTICE %s :Proxy is now handling itself CTCPs sent to %s\n",
client->proxy_address, client->nick, client->listen->ircnet);
+ } else {
+ signal_emit("proxy client command", 3, client, args, data);
}
return;
}
@@ -663,6 +665,14 @@ static void read_settings(void)
}
}
+static void sig_dump(CLIENT_REC *client, const char *data)
+{
+ g_return_if_fail(client != NULL);
+ g_return_if_fail(data != NULL);
+
+ proxy_outdata(client, data);
+}
+
void proxy_listen_init(void)
{
next_line = g_string_new(NULL);
@@ -680,6 +690,8 @@ void proxy_listen_init(void)
signal_add("message own_private", (SIGNAL_FUNC) sig_message_own_private);
signal_add("message irc own_action", (SIGNAL_FUNC) sig_message_own_action);
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
+
+ signal_add("proxy client dump", (SIGNAL_FUNC) sig_dump);
}
void proxy_listen_deinit(void)
@@ -697,4 +709,6 @@ void proxy_listen_deinit(void)
signal_remove("message own_private", (SIGNAL_FUNC) sig_message_own_private);
signal_remove("message irc own_action", (SIGNAL_FUNC) sig_message_own_action);
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
+
+ signal_remove("proxy client dump", (SIGNAL_FUNC) sig_dump);
}
diff --git a/src/irc/proxy/module.h b/src/irc/proxy/module.h
index e2580e1b..ff95227f 100644
--- a/src/irc/proxy/module.h
+++ b/src/irc/proxy/module.h
@@ -6,28 +6,7 @@
#include "irc.h"
#include "irc-servers.h"
-typedef struct {
- int port;
- char *ircnet;
-
- int tag;
- GIOChannel *handle;
-
- GSList *clients;
-} LISTEN_REC;
-
-typedef struct {
- char *nick, *host;
- NET_SENDBUF_REC *handle;
- int recv_tag;
- char *proxy_address;
- LISTEN_REC *listen;
- IRC_SERVER_REC *server;
- unsigned int pass_sent:1;
- unsigned int user_sent:1;
- unsigned int connected:1;
- unsigned int want_ctcp:1;
-} CLIENT_REC;
+#include "proxy.h"
extern GSList *proxy_listens;
extern GSList *proxy_clients;
diff --git a/src/irc/proxy/proxy.h b/src/irc/proxy/proxy.h
new file mode 100644
index 00000000..4ddc9da9
--- /dev/null
+++ b/src/irc/proxy/proxy.h
@@ -0,0 +1,33 @@
+#ifndef PROXY_H
+#define PROXY_H
+
+#include "common.h"
+
+#include "network.h"
+#include "irc.h"
+#include "irc-servers.h"
+
+typedef struct {
+ int port;
+ char *ircnet;
+
+ int tag;
+ GIOChannel *handle;
+
+ GSList *clients;
+} LISTEN_REC;
+
+typedef struct {
+ char *nick, *host;
+ NET_SENDBUF_REC *handle;
+ int recv_tag;
+ char *proxy_address;
+ LISTEN_REC *listen;
+ IRC_SERVER_REC *server;
+ unsigned int pass_sent:1;
+ unsigned int user_sent:1;
+ unsigned int connected:1;
+ unsigned int want_ctcp:1;
+} CLIENT_REC;
+
+#endif
diff --git a/src/perl/Makefile.am b/src/perl/Makefile.am
index 72521c3f..0bf65f79 100644
--- a/src/perl/Makefile.am
+++ b/src/perl/Makefile.am
@@ -100,6 +100,7 @@ irc_sources = \
irc/Modes.xs \
irc/Netsplit.xs \
irc/Notifylist.xs \
+ irc/Client.xs \
irc/Makefile.PL.in \
irc/typemap \
irc/module.h
diff --git a/src/perl/get-signals.pl b/src/perl/get-signals.pl
index c61c81cc..8f600fa9 100755
--- a/src/perl/get-signals.pl
+++ b/src/perl/get-signals.pl
@@ -42,6 +42,7 @@ while (<STDIN>) {
s/DCC_REC[^,]*/siobject/g;
s/AUTOIGNORE_REC[^,]*/Irssi::Irc::Autoignore/g;
s/NOTIFYLIST_REC[^,]*/Irssi::Irc::Notifylist/g;
+ s/CLIENT_REC[^,]*/Irssi::Irc::Client/g;
# fe-common
s/THEME_REC[^,]*/Irssi::UI::Theme/g;
diff --git a/src/perl/irc/Client.xs b/src/perl/irc/Client.xs
new file mode 100644
index 00000000..8481a11e
--- /dev/null
+++ b/src/perl/irc/Client.xs
@@ -0,0 +1,5 @@
+#include "module.h"
+
+MODULE = Irssi::Irc::Client PACKAGE = Irssi::Irc
+PROTOTYPES: ENABLE
+
diff --git a/src/perl/irc/Irc.xs b/src/perl/irc/Irc.xs
index 3fda1e68..251efb8b 100644
--- a/src/perl/irc/Irc.xs
+++ b/src/perl/irc/Irc.xs
@@ -144,6 +144,19 @@ static void perl_notifylist_fill_hash(HV *hv, NOTIFYLIST_REC *notify)
hv_store(hv, "ircnets", 7, newRV_noinc((SV*)av), 0);
}
+static void perl_client_fill_hash(HV *hv, CLIENT_REC *client)
+{
+ hv_store(hv, "nick", 4, new_pv(client->nick), 0);
+ hv_store(hv, "host", 4, new_pv(client->host), 0);
+ hv_store(hv, "proxy_address", 13, new_pv(client->proxy_address), 0);
+ hv_store(hv, "server", 6, iobject_bless(client->server), 0);
+ hv_store(hv, "pass_sent", 9, newSViv(client->pass_sent), 0);
+ hv_store(hv, "user_sent", 9, newSViv(client->user_sent), 0);
+ hv_store(hv, "connected", 9, newSViv(client->connected), 0);
+ hv_store(hv, "want_ctcp", 9, newSViv(client->want_ctcp), 0);
+ hv_store(hv, "ircnet", 6, new_pv(client->listen->ircnet), 0);
+}
+
static PLAIN_OBJECT_INIT_REC irc_plains[] = {
{ "Irssi::Irc::Ban", (PERL_OBJECT_FUNC) perl_ban_fill_hash },
{ "Irssi::Irc::Dcc", (PERL_OBJECT_FUNC) perl_dcc_fill_hash },
@@ -151,6 +164,7 @@ static PLAIN_OBJECT_INIT_REC irc_plains[] = {
{ "Irssi::Irc::Netsplitserver", (PERL_OBJECT_FUNC) perl_netsplit_server_fill_hash },
{ "Irssi::Irc::Netsplitchannel", (PERL_OBJECT_FUNC) perl_netsplit_channel_fill_hash },
{ "Irssi::Irc::Notifylist", (PERL_OBJECT_FUNC) perl_notifylist_fill_hash },
+ { "Irssi::Irc::Client", (PERL_OBJECT_FUNC) perl_client_fill_hash },
{ NULL, NULL }
};
@@ -209,3 +223,4 @@ BOOT:
irssi_boot(Irc__Notifylist);
irssi_boot(Irc__Query);
irssi_boot(Irc__Server);
+ irssi_boot(Irc__Client);
diff --git a/src/perl/irc/module.h b/src/perl/irc/module.h
index 4f0ce06d..91c19c7a 100644
--- a/src/perl/irc/module.h
+++ b/src/perl/irc/module.h
@@ -20,6 +20,8 @@
#include "dcc/dcc-send.h"
#include "notifylist/notifylist.h"
+#include "proxy/proxy.h"
+
typedef IRC_SERVER_REC *Irssi__Irc__Server;
typedef IRC_SERVER_CONNECT_REC *Irssi__Irc__Connect;
typedef IRC_CHANNEL_REC *Irssi__Irc__Channel;
@@ -35,3 +37,5 @@ typedef NETSPLIT_REC *Irssi__Irc__Netsplit;
typedef NETSPLIT_SERVER_REC *Irssi__Irc__Netsplitserver;
typedef NETSPLIT_CHAN_REC *Irssi__Irc__Netsplitchannel;
typedef NOTIFYLIST_REC *Irssi__Irc__Notifylist;
+
+typedef CLIENT_REC *Irssi__Irc__Client;
diff --git a/src/perl/irc/typemap b/src/perl/irc/typemap
index d5604a77..9bf87647 100644
--- a/src/perl/irc/typemap
+++ b/src/perl/irc/typemap
@@ -14,6 +14,7 @@ Irssi::Irc::Netsplit T_PlainObj
Irssi::Irc::Netsplitserver T_PlainObj
Irssi::Irc::Netsplitchannel T_PlainObj
Irssi::Irc::Notifylist T_PlainObj
+Irssi::Irc::Client T_IrssiObj
INPUT