From b305a8d5e2e690af9e280851503d9608a218bd43 Mon Sep 17 00:00:00 2001 From: peavey Date: Sun, 15 Feb 2009 13:19:05 +0000 Subject: Target route SANICK and when we hit the target let NICK do the propogating for desync-safe operation. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11112 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_sanick.cpp | 53 ++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/modules/m_sanick.cpp b/src/modules/m_sanick.cpp index d681fb01a..3e3e0745c 100644 --- a/src/modules/m_sanick.cpp +++ b/src/modules/m_sanick.cpp @@ -30,41 +30,50 @@ class CommandSanick : public Command CmdResult Handle (const std::vector& parameters, User *user) { User* target = ServerInstance->FindNick(parameters[0]); - if (target) + + /* Do local sanity checks and bails */ + if (IS_LOCAL(user)) { - if (ServerInstance->ULine(target->server)) + if (target && ServerInstance->ULine(target->server)) { user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str()); return CMD_FAILURE; } - std::string oldnick = user->nick; - if (IS_LOCAL(user) && !ServerInstance->IsNick(parameters[1].c_str(), ServerInstance->Config->Limits.NickMax)) + + if (!target) { - user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick.c_str(), parameters[1].c_str()); + user->WriteServ("NOTICE %s :*** No such nickname: '%s'", user->nick.c_str(), parameters[0].c_str()); + return CMD_FAILURE; } - else + + if (!ServerInstance->IsNick(parameters[1].c_str(), ServerInstance->Config->Limits.NickMax)) { - if (target->ForceNickChange(parameters[1].c_str())) - { - ServerInstance->SNO->WriteToSnoMask('A', oldnick+" used SANICK to change "+parameters[0]+" to "+parameters[1]); - return CMD_SUCCESS; - } - else - { - /* We couldnt change the nick */ - ServerInstance->SNO->WriteToSnoMask('A', oldnick+" failed SANICK (from "+parameters[0]+" to "+parameters[1]+")"); - return CMD_FAILURE; - } + user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick.c_str(), parameters[1].c_str()); + return CMD_FAILURE; } - - return CMD_FAILURE; } - else + + /* Have we hit users server yet? */ + if (target && IS_LOCAL(target)) { - user->WriteServ("NOTICE %s :*** No such nickname: '%s'", user->nick.c_str(), parameters[0].c_str()); + std::string oldnick = user->nick; + std::string newnick = target->nick; + if (target->ForceNickChange(parameters[1].c_str())) + { + ServerInstance->SNO->WriteToSnoMask('A', oldnick+" used SANICK to change "+newnick+" to "+parameters[1]); + ServerInstance->PI->SendSNONotice("A", oldnick+" used SANICK to change "+newnick+" to "+parameters[1]); + } + else + { + ServerInstance->SNO->WriteToSnoMask('A', oldnick+" failed SANICK (from "+newnick+" to "+parameters[1]+")"); + ServerInstance->PI->SendSNONotice("A", oldnick+" failed SANICK (from "+newnick+" to "+parameters[1]+")"); + } + /* hit user and have sent our NICK out, we can now bail */ + return CMD_LOCALONLY; } - return CMD_FAILURE; + /* no, route it on */ + return CMD_SUCCESS; } }; -- cgit v1.2.3