diff options
author | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-02-15 13:19:05 +0000 |
---|---|---|
committer | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-02-15 13:19:05 +0000 |
commit | b305a8d5e2e690af9e280851503d9608a218bd43 (patch) | |
tree | d833e12c38962bb591dc29bbc7919aabe19d04da /src/modules | |
parent | 1315213e603bb4c47e23f6f41fc5cbeaf3cd10d3 (diff) |
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
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_sanick.cpp | 53 |
1 files 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<std::string>& 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; } }; |