summaryrefslogtreecommitdiff
path: root/src/irc/dcc/dcc.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-11-17 03:08:32 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-11-17 03:08:32 +0000
commit090e88b34db29b681c7579472aafa211832d38af (patch)
tree9b3843423c00c2dbce876518f5518b772011a54a /src/irc/dcc/dcc.c
parent54815d198bd490194710f36b1a87a05111e38a23 (diff)
downloadirssi-090e88b34db29b681c7579472aafa211832d38af.zip
If other side replies to our DCC CHAT request with DCC CHAT request of
their own (maybe we were inside firewall and other side noticed it), connect to it immediately. Don't allow more than one identical DCC request, if more is received just update the port of the previous request. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@844 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/dcc/dcc.c')
-rw-r--r--src/irc/dcc/dcc.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/irc/dcc/dcc.c b/src/irc/dcc/dcc.c
index e8143442..b2223e6a 100644
--- a/src/irc/dcc/dcc.c
+++ b/src/irc/dcc/dcc.c
@@ -284,9 +284,9 @@ static void dcc_ctcp_msg(char *data, IRC_SERVER_REC *server, char *sender, char
char *type, *arg, *addrstr, *portstr, *sizestr, *str;
void *free_arg;
const char *cstr;
- DCC_REC *dcc;
+ DCC_REC *dcc, *olddcc;
long size;
- int port;
+ int dcctype, port;
g_return_if_fail(data != NULL);
g_return_if_fail(sender != NULL);
@@ -298,7 +298,27 @@ static void dcc_ctcp_msg(char *data, IRC_SERVER_REC *server, char *sender, char
if (sscanf(portstr, "%d", &port) != 1) port = 0;
if (sscanf(sizestr, "%ld", &size) != 1) size = 0;
- dcc = dcc_create(SWAP_SENDGET(dcc_str2type(type)), -1, sender, arg, server, chat);
+ dcctype = SWAP_SENDGET(dcc_str2type(type));
+ olddcc = dcc_find_item(dcctype, sender,
+ dcctype == DCC_TYPE_CHAT ? NULL : arg);
+ if (olddcc != NULL) {
+ /* same DCC request offered again */
+ if (olddcc->type == DCC_TYPE_CHAT &&
+ olddcc->handle != -1 && olddcc->starttime == 0) {
+ /* we requested dcc chat, they requested
+ dcc chat from us .. allow it. */
+ dcc_destroy(olddcc);
+ } else {
+ /* if the connection isn't open, update the port,
+ otherwise just ignore */
+ if (olddcc->handle == -1)
+ olddcc->port = port;
+ cmd_params_free(free_arg);
+ return;
+ }
+ }
+
+ dcc = dcc_create(dcctype, -1, sender, arg, server, chat);
dcc_get_address(addrstr, &dcc->addr);
net_ip2host(&dcc->addr, dcc->addrstr);
dcc->port = port;
@@ -327,7 +347,8 @@ static void dcc_ctcp_msg(char *data, IRC_SERVER_REC *server, char *sender, char
case DCC_TYPE_CHAT:
cstr = settings_get_str("dcc_autochat_masks");
- if (*cstr != '\0' && masks_match(SERVER(server), cstr, sender, sendaddr))
+ if (olddcc != NULL ||
+ (*cstr != '\0' && masks_match(SERVER(server), cstr, sender, sendaddr)))
{
/* automatically accept chat */
str = g_strdup_printf("CHAT %s", dcc->nick);