Don't show DCC "Handshake failed" message twice
parse_offer_params() was being run unconditionally by check_dcc_init() even if it didn't find a custom init_func() to call, which is the usual case. It then gets called again by the hardwired DCC init function, which led to the error message appearing twice. This has check_dcc_init() only call parse_offer_params() when its about to dispatch to a custom init func. This also improves the message a bit (making it [host:port] rather than the other way around) and combines the 'privileged port' message and "zero address" message together.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
[Changes 1.2.2]
|
||||
|
||||
* Don't show DCC "Handshake failed" message twice, improve the message itself
|
||||
and use the same one for privileged port / zero address. (caf)
|
||||
|
||||
* Use the same format in /DCC LIST for all waiting offers and tweak
|
||||
the DCC_BAR_TYPE 1 format to show DCC state. (caf)
|
||||
|
||||
|
||||
30
source/dcc.c
30
source/dcc.c
@@ -1143,16 +1143,12 @@ static int parse_offer_params(const char *address, const char *port, const char
|
||||
|
||||
*p_addr = strtoul(address, NULL, 10);
|
||||
*p_port = (unsigned)strtoul(port, NULL, 10);
|
||||
if (*p_port < 1024)
|
||||
{
|
||||
put_it("%s", convert_output_format("$G %RDCC%n Privileged port attempt [$0]", "%d", *p_port));
|
||||
return 0;
|
||||
}
|
||||
if (*p_addr == 0)
|
||||
|
||||
if (*p_addr == 0 || *p_port < 1024)
|
||||
{
|
||||
struct in_addr in;
|
||||
in.s_addr = htonl(*p_addr);
|
||||
put_it("%s", convert_output_format("$G %RDCC%n Handshake ignored because of 0 port or address [$0:$1]", "%d %s", *p_port, inet_ntoa(in)));
|
||||
put_it("%s", convert_output_format("$G %RDCC%n Handshake ignored because of privileged port or zero address [$0:$1]", "%s %d", inet_ntoa(in), *p_port));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4293,22 +4289,22 @@ char *nick,
|
||||
static int check_dcc_init(char *nick, char *type, char *description, char *address, char *port, char *size, char *extra, char *uhost)
|
||||
{
|
||||
int i;
|
||||
unsigned long filesize;
|
||||
unsigned long TempLong;
|
||||
unsigned int TempInt;
|
||||
|
||||
if (!parse_offer_params(address, port, size, &TempLong, &TempInt, &filesize))
|
||||
return 0;
|
||||
|
||||
for (i = 0; dcc_types[i]->name; i++)
|
||||
{
|
||||
if (!my_stricmp(type, dcc_types[i]->name))
|
||||
break;
|
||||
}
|
||||
if (!dcc_types[i]->name)
|
||||
return 0;
|
||||
if (dcc_types[i]->init_func)
|
||||
return (*dcc_types[i]->init_func)(type, nick, uhost, description, size, extra, TempLong, TempInt);
|
||||
|
||||
if (dcc_types[i]->name && dcc_types[i]->init_func)
|
||||
{
|
||||
unsigned long filesize;
|
||||
unsigned long TempLong;
|
||||
unsigned int TempInt;
|
||||
|
||||
if (parse_offer_params(address, port, size, &TempLong, &TempInt, &filesize))
|
||||
return dcc_types[i]->init_func(type, nick, uhost, description, size, extra, TempLong, TempInt);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user