summaryrefslogtreecommitdiff
path: root/src/irc/proxy/listen.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-07-10 19:10:37 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-07-10 19:10:37 +0000
commit3cea29ae82e6d83a3a68cbab01614c7b940b8435 (patch)
tree8e99f5872c1018781f3274a9035c803708d2700a /src/irc/proxy/listen.c
parent2ddba459c056798e4c5aa715b4d01546b18b79e2 (diff)
downloadirssi-3cea29ae82e6d83a3a68cbab01614c7b940b8435.zip
Makefile fixed to use module directory again. If /SET irssiproxy_ports has
'*' as server tag, it will match for any of the servers (useful if you're only using one). Fixed a crash if client sent a request to server and quit before the reply was received. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1608 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/proxy/listen.c')
-rw-r--r--src/irc/proxy/listen.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/irc/proxy/listen.c b/src/irc/proxy/listen.c
index 516dcf95..92f63753 100644
--- a/src/irc/proxy/listen.c
+++ b/src/irc/proxy/listen.c
@@ -65,7 +65,7 @@ static void proxy_redirect_event(CLIENT_REC *client,
group = 0;
while ((event = va_arg(vargs, char *)) != NULL) {
argpos = va_arg(vargs, int);
- g_string_sprintf(str, "proxy %p", client->handle);
+ g_string_sprintf(str, "proxy %p", client);
group = server_redirect_single_event(SERVER(client->server), args, last > 0,
group, event, str->str, argpos);
last--;
@@ -305,7 +305,10 @@ static void sig_listen(LISTEN_REC *listen)
rec->listen = listen;
rec->handle = handle;
rec->proxy_address = g_strdup(listen->ircnet);
- rec->server = IRC_SERVER(server_find_chatnet(listen->ircnet));
+ rec->server = servers == NULL ? NULL :
+ strcmp(listen->ircnet, "*") == 0 ?
+ IRC_SERVER(servers->data) :
+ IRC_SERVER(server_find_chatnet(listen->ircnet));
rec->tag = g_input_add(handle, G_INPUT_READ,
(GInputFunction) sig_listen_client, rec);
@@ -343,7 +346,7 @@ static void sig_server_event(IRC_SERVER_REC *server, const char *line,
if (list != NULL) {
/* we want to send this to one client (or proxy itself) only */
REDIRECT_REC *rec;
- void *handle;
+ void *client;
rec = list->data;
if (g_strncasecmp(rec->name, "proxy ", 6) != 0) {
@@ -352,10 +355,11 @@ static void sig_server_event(IRC_SERVER_REC *server, const char *line,
return;
}
- if (sscanf(rec->name+6, "%p", &handle) == 1) {
+ if (sscanf(rec->name+6, "%p", &client) == 1) {
/* send it to specific client only */
server_redirect_remove_next(SERVER(server), event, list);
- net_transmit(handle, next_line->str, next_line->len);
+ if (g_slist_find(proxy_clients, client) != NULL)
+ net_transmit(((CLIENT_REC *) client)->handle, next_line->str, next_line->len);
g_free(event);
signal_stop();
return;
@@ -391,7 +395,8 @@ static void event_connected(IRC_SERVER_REC *server)
CLIENT_REC *rec = tmp->data;
if (rec->connected && rec->server == NULL &&
- g_strcasecmp(server->connrec->chatnet, rec->listen->ircnet) == 0) {
+ (g_strcasecmp(server->connrec->chatnet, rec->listen->ircnet) == 0 ||
+ strcmp(rec->listen->ircnet, "*") == 0)) {
proxy_outdata(rec, ":%s NOTICE %s :Connected to server",
rec->proxy_address, rec->nick);
rec->server = server;
@@ -483,6 +488,8 @@ static void add_listen(const char *ircnet, int port)
printtext(NULL, NULL, MSGLEVEL_CLIENTERROR,
"Proxy: Listen in port %d failed: %s",
rec->port, g_strerror(errno));
+ g_free(rec->ircnet);
+ g_free(rec);
return;
}