diff options
author | Timo Sirainen <cras@irssi.org> | 2002-02-20 15:21:50 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-02-20 15:21:50 +0000 |
commit | db4a0e5003d30103eb4ca8e4feadbdd164dafe65 (patch) | |
tree | e861184d98e021d6a2aa85ca063b3275428c7dcc /src | |
parent | 87946e381f0df4cc2fc5064830f1b09ec8005b90 (diff) | |
download | irssi-db4a0e5003d30103eb4ca8e4feadbdd164dafe65.zip |
PROXY CTCP ON|OFF - proxy clients can send this command to specify that they
want to handle the received CTCP requests.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2522 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/irc/proxy/listen.c | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/src/irc/proxy/listen.c b/src/irc/proxy/listen.c index 60a48380..203551fc 100644 --- a/src/irc/proxy/listen.c +++ b/src/irc/proxy/listen.c @@ -28,11 +28,12 @@ #include "irc.h" #include "irc-channels.h" -#include "fe-common/core/printtext.h" +#include "fe-common/core/printtext.h" /* FIXME: evil. need to do fe-proxy */ GSList *proxy_listens; GSList *proxy_clients; +static CLIENT_REC *ctcp_client; static GString *next_line; static int ignore_next; @@ -42,7 +43,10 @@ static void remove_client(CLIENT_REC *rec) proxy_clients = g_slist_remove(proxy_clients, rec); - signal_emit("proxy client disconnected", 1, rec); + if (ctcp_client == rec) + ctcp_client = NULL; + + signal_emit("proxy client disconnected", 1, rec); printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE, "Proxy: Client disconnected from %s", rec->host); @@ -136,7 +140,9 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args, if (strcmp(cmd, "QUIT") == 0) { remove_client(client); return; - } if (strcmp(cmd, "PING") == 0) { + } + + if (strcmp(cmd, "PING") == 0) { /* Reply to PING, if the target parameter is either proxy_adress, our own nick or empty. */ char *params, *origin, *target; @@ -154,6 +160,21 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args, g_free(params); } + if (strcmp(cmd, "PROXY") == 0) { + if (g_strcasecmp(args, "CTCP ON") == 0) { + /* client wants all ctcps */ + ctcp_client = client; + proxy_outdata(client, ":%s NOTICE %s :You're now receiving all CTCPs sent to proxy\n", + client->proxy_address, client->nick); + } else if (g_strcasecmp(args, "CTCP OFF") == 0) { + /* client wants proxy to handle all ctcps */ + ctcp_client = NULL; + proxy_outdata(client, ":%s NOTICE %s :Proxy is now handling itself all CTCPs\n", + client->proxy_address, client->nick); + } + return; + } + if (client->server == NULL || !client->server->connected) { proxy_outdata(client, ":%s NOTICE %s :Not connected to server\n", client->proxy_address, client->nick); @@ -365,11 +386,22 @@ static void sig_server_event(IRC_SERVER_REC *server, const char *line, } } + if (strcmp(event, "event privmsg") == 0 && + strstr(args, " :\001") != NULL && + strstr(args, " :\001ACTION") == NULL) { + /* CTCP - either answer ourself or forward it to one client */ + if (ctcp_client != NULL) { + /* one of the clients answers */ + net_transmit(ctcp_client->handle, + next_line->str, next_line->len); + signal_stop(); + } + g_free(event); + return; + } + if (strcmp(event, "event ping") == 0 || - strcmp(event, "event pong") == 0 || - (strcmp(event, "event privmsg") == 0 && - strstr(args, " :\001") != NULL && - strstr(args, " :\001ACTION") == NULL)) { + strcmp(event, "event pong") == 0) { /* We want to answer ourself to PINGs and CTCPs. Also hide PONGs from clients. */ g_free(event); |