From 23d466c4a1fe94d1a0fcb3c72153d9d8c6a5b9b4 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Wed, 2 Nov 2016 22:19:57 +1100 Subject: [PATCH] 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. --- Changelog | 3 +++ source/dcc.c | 30 +++++++++++++----------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Changelog b/Changelog index 8299287..b70b5ec 100644 --- a/Changelog +++ b/Changelog @@ -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) diff --git a/source/dcc.c b/source/dcc.c index 19d359e..c2b0b63 100644 --- a/source/dcc.c +++ b/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; }