1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

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
This commit is contained in:
Timo Sirainen 2000-11-17 03:08:32 +00:00 committed by cras
parent 54815d198b
commit 090e88b34d

View File

@ -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; char *type, *arg, *addrstr, *portstr, *sizestr, *str;
void *free_arg; void *free_arg;
const char *cstr; const char *cstr;
DCC_REC *dcc; DCC_REC *dcc, *olddcc;
long size; long size;
int port; int dcctype, port;
g_return_if_fail(data != NULL); g_return_if_fail(data != NULL);
g_return_if_fail(sender != 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(portstr, "%d", &port) != 1) port = 0;
if (sscanf(sizestr, "%ld", &size) != 1) size = 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); dcc_get_address(addrstr, &dcc->addr);
net_ip2host(&dcc->addr, dcc->addrstr); net_ip2host(&dcc->addr, dcc->addrstr);
dcc->port = port; 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: case DCC_TYPE_CHAT:
cstr = settings_get_str("dcc_autochat_masks"); 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 */ /* automatically accept chat */
str = g_strdup_printf("CHAT %s", dcc->nick); str = g_strdup_printf("CHAT %s", dcc->nick);