mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
CTCP forwarding fixes by Valentin Batz
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3133 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
bb441ebbde
commit
6122035f2f
@ -33,7 +33,6 @@
|
|||||||
GSList *proxy_listens;
|
GSList *proxy_listens;
|
||||||
GSList *proxy_clients;
|
GSList *proxy_clients;
|
||||||
|
|
||||||
static CLIENT_REC *ctcp_client;
|
|
||||||
static GString *next_line;
|
static GString *next_line;
|
||||||
static int ignore_next;
|
static int ignore_next;
|
||||||
|
|
||||||
@ -44,9 +43,6 @@ static void remove_client(CLIENT_REC *rec)
|
|||||||
proxy_clients = g_slist_remove(proxy_clients, rec);
|
proxy_clients = g_slist_remove(proxy_clients, rec);
|
||||||
rec->listen->clients = g_slist_remove(rec->listen->clients, rec);
|
rec->listen->clients = g_slist_remove(rec->listen->clients, rec);
|
||||||
|
|
||||||
if (ctcp_client == rec)
|
|
||||||
ctcp_client = NULL;
|
|
||||||
|
|
||||||
signal_emit("proxy client disconnected", 1, rec);
|
signal_emit("proxy client disconnected", 1, rec);
|
||||||
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
printtext(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
|
||||||
"Proxy: Client disconnected from %s", rec->host);
|
"Proxy: Client disconnected from %s", rec->host);
|
||||||
@ -139,6 +135,7 @@ static void handle_client_connect_cmd(CLIENT_REC *client,
|
|||||||
static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args,
|
static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args,
|
||||||
const char *data)
|
const char *data)
|
||||||
{
|
{
|
||||||
|
GSList *tmp;
|
||||||
if (!client->connected) {
|
if (!client->connected) {
|
||||||
handle_client_connect_cmd(client, cmd, args);
|
handle_client_connect_cmd(client, cmd, args);
|
||||||
return;
|
return;
|
||||||
@ -170,14 +167,25 @@ static void handle_client_cmd(CLIENT_REC *client, char *cmd, char *args,
|
|||||||
if (strcmp(cmd, "PROXY") == 0) {
|
if (strcmp(cmd, "PROXY") == 0) {
|
||||||
if (g_strcasecmp(args, "CTCP ON") == 0) {
|
if (g_strcasecmp(args, "CTCP ON") == 0) {
|
||||||
/* client wants all ctcps */
|
/* client wants all ctcps */
|
||||||
ctcp_client = client;
|
client->want_ctcp = 1;
|
||||||
proxy_outdata(client, ":%s NOTICE %s :You're now receiving all CTCPs sent to proxy\n",
|
for (tmp = proxy_clients; tmp != NULL; tmp = tmp->next) {
|
||||||
client->proxy_address, client->nick);
|
CLIENT_REC *rec = tmp->data;
|
||||||
|
if ((g_strcasecmp(client->server->connrec->chatnet,rec->server->connrec->chatnet) == 0) &&
|
||||||
|
(client->tag != rec->tag)) {
|
||||||
|
if (rec->want_ctcp == 1)
|
||||||
|
proxy_outdata(rec, ":%s NOTICE %s :Another client is now receiving CTCPs sent to %s\n",
|
||||||
|
rec->proxy_address, rec->nick,rec->server->connrec->chatnet);
|
||||||
|
rec->want_ctcp=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
proxy_outdata(client, ":%s NOTICE %s :You're now receiving CTCPs sent to %s\n",
|
||||||
|
client->proxy_address, client->nick,client->server->connrec->chatnet);
|
||||||
} else if (g_strcasecmp(args, "CTCP OFF") == 0) {
|
} else if (g_strcasecmp(args, "CTCP OFF") == 0) {
|
||||||
/* client wants proxy to handle all ctcps */
|
/* client wants proxy to handle all ctcps */
|
||||||
ctcp_client = NULL;
|
client->want_ctcp = 0;
|
||||||
proxy_outdata(client, ":%s NOTICE %s :Proxy is now handling itself all CTCPs\n",
|
proxy_outdata(client, ":%s NOTICE %s :Proxy is now handling itself CTCPs sent to %s\n",
|
||||||
client->proxy_address, client->nick);
|
client->proxy_address, client->nick,client->server->connrec->chatnet);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -357,6 +365,7 @@ static void sig_incoming(IRC_SERVER_REC *server, const char *line)
|
|||||||
static void sig_server_event(IRC_SERVER_REC *server, const char *line,
|
static void sig_server_event(IRC_SERVER_REC *server, const char *line,
|
||||||
const char *nick, const char *address)
|
const char *nick, const char *address)
|
||||||
{
|
{
|
||||||
|
GSList *tmp;
|
||||||
void *client;
|
void *client;
|
||||||
const char *signal;
|
const char *signal;
|
||||||
char *event, *args;
|
char *event, *args;
|
||||||
@ -398,11 +407,18 @@ static void sig_server_event(IRC_SERVER_REC *server, const char *line,
|
|||||||
strstr(args, " :\001") != NULL &&
|
strstr(args, " :\001") != NULL &&
|
||||||
strstr(args, " :\001ACTION") == NULL) {
|
strstr(args, " :\001ACTION") == NULL) {
|
||||||
/* CTCP - either answer ourself or forward it to one client */
|
/* CTCP - either answer ourself or forward it to one client */
|
||||||
if (ctcp_client != NULL) {
|
for (tmp = proxy_clients; tmp != NULL; tmp = tmp->next) {
|
||||||
/* one of the clients answers */
|
CLIENT_REC *rec = tmp->data;
|
||||||
net_transmit(ctcp_client->handle,
|
|
||||||
next_line->str, next_line->len);
|
if (rec->want_ctcp == 1) {
|
||||||
signal_stop();
|
/* one of the clients answers */
|
||||||
|
/* patched, so only CTCP for the chatnet where client is connected to will be forwarded */
|
||||||
|
if (strstr(rec->proxy_address,server->connrec->chatnet) != NULL) {
|
||||||
|
net_transmit(rec->handle,
|
||||||
|
next_line->str, next_line->len);
|
||||||
|
signal_stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g_free(event);
|
g_free(event);
|
||||||
return;
|
return;
|
||||||
@ -441,6 +457,7 @@ static void event_connected(IRC_SERVER_REC *server)
|
|||||||
proxy_outdata(rec, ":%s NOTICE %s :Connected to server\n",
|
proxy_outdata(rec, ":%s NOTICE %s :Connected to server\n",
|
||||||
rec->proxy_address, rec->nick);
|
rec->proxy_address, rec->nick);
|
||||||
rec->server = server;
|
rec->server = server;
|
||||||
|
rec->want_ctcp = 0;
|
||||||
proxy_client_reset_nick(rec);
|
proxy_client_reset_nick(rec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ typedef struct {
|
|||||||
unsigned int pass_sent:1;
|
unsigned int pass_sent:1;
|
||||||
unsigned int user_sent:1;
|
unsigned int user_sent:1;
|
||||||
unsigned int connected:1;
|
unsigned int connected:1;
|
||||||
|
unsigned int want_ctcp:1;
|
||||||
} CLIENT_REC;
|
} CLIENT_REC;
|
||||||
|
|
||||||
extern GSList *proxy_listens;
|
extern GSList *proxy_listens;
|
||||||
|
Loading…
Reference in New Issue
Block a user