From 8e8022058fdc0f7c72e8c43ff581936c0af2924f Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Fri, 1 Jun 2012 01:21:08 +0200 Subject: Remove sorcery with HandleInternal in NICK handler --- src/commands/cmd_nick.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp index e41ccd609..f76e28487 100644 --- a/src/commands/cmd_nick.cpp +++ b/src/commands/cmd_nick.cpp @@ -53,11 +53,10 @@ CmdResult CommandNick::Handle (const std::vector& parameters, User { // Special case, Fake a /nick UIDHERE. Useful for evading "ERR: NICK IN USE" on connect etc. std::vector p2; - std::deque dummy; p2.push_back(user->uuid); - this->HandleInternal(1, dummy); + allowinvalid = true; this->Handle(p2, user); - this->HandleInternal(0, dummy); + allowinvalid = false; return CMD_SUCCESS; } -- cgit v1.3.1-10-gc9f91 From 68293244a6d2537f61e166cb188ebf11ac01c5b1 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Thu, 7 Jun 2012 20:55:01 +0200 Subject: Fix /NICK 0 not working on registration, allow changing to uid using /NICK --- src/commands/cmd_nick.cpp | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp index f76e28487..9a3f2705b 100644 --- a/src/commands/cmd_nick.cpp +++ b/src/commands/cmd_nick.cpp @@ -45,24 +45,45 @@ CmdResult CommandNick::Handle (const std::vector& parameters, User return CMD_FAILURE; } - if (((!ServerInstance->IsNick(parameters[0].c_str(), ServerInstance->Config->Limits.NickMax))) && (IS_LOCAL(user))) + if ((IS_LOCAL(user)) && (!allowinvalid) && (!ServerInstance->IsNick(parameters[0].c_str(), ServerInstance->Config->Limits.NickMax)) && (parameters[0] != user->uuid)) { - if (!allowinvalid) + if (parameters[0] == "0") { - if (parameters[0] == "0") + // Special case, fake a /nick UIDHERE. Useful for evading "ERR: NICK IN USE" on connect etc. + if (user->registered & REG_NICK) { - // Special case, Fake a /nick UIDHERE. Useful for evading "ERR: NICK IN USE" on connect etc. + /* The user has either registered OR still in the registration phase but already sent + * at least one NICK that changed his nick from his uuid (see below). + * Pretend him doing a NICK . + */ std::vector p2; p2.push_back(user->uuid); allowinvalid = true; - this->Handle(p2, user); + CmdResult result = this->Handle(p2, user); allowinvalid = false; - return CMD_SUCCESS; + return result; } + else + { + /* If the user hasn't registered yet and wants to register with his UID, allow him. + * By default every user gets his uuid as his nick even without sending any commands, + * that means in this case it's enough to just flip the REG_NICK bit. + */ - user->WriteNumeric(432, "%s %s :Erroneous Nickname", user->nick.c_str(),parameters[0].c_str()); - return CMD_FAILURE; + user->registered |= REG_NICK; + if (user->registered == REG_NICKUSER) + { + int MOD_RESULT = 0; + FOREACH_RESULT(I_OnUserRegister,OnUserRegister(user)); + if (MOD_RESULT > 0) + return CMD_FAILURE; + } + return CMD_SUCCESS; + } } + + user->WriteNumeric(432, "%s %s :Erroneous Nickname", user->nick.c_str(),parameters[0].c_str()); + return CMD_FAILURE; } if (assign(user->nick) == parameters[0]) -- cgit v1.3.1-10-gc9f91