diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-02 15:37:16 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-02 15:37:16 +0000 |
commit | 789fc05c20bf4a088194075c43c606c6a3a40696 (patch) | |
tree | 5bbc5a900b014c2b5516a26acfd59bfeb9c31aa0 /src | |
parent | bec20ca4531c5a6634a8deb991396ecd22aeb644 (diff) |
Add SAVE s2s protocol command
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11660 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_spanningtree/nickcollide.cpp | 15 | ||||
-rw-r--r-- | src/modules/m_spanningtree/save.cpp | 52 | ||||
-rw-r--r-- | src/modules/m_spanningtree/svsnick.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket.h | 3 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 4 |
5 files changed, 67 insertions, 9 deletions
diff --git a/src/modules/m_spanningtree/nickcollide.cpp b/src/modules/m_spanningtree/nickcollide.cpp index ba83b62db..a723c114f 100644 --- a/src/modules/m_spanningtree/nickcollide.cpp +++ b/src/modules/m_spanningtree/nickcollide.cpp @@ -25,7 +25,7 @@ * Yes, this function looks a little ugly. * However, in some circumstances we may not have a User, so we need to do things this way. * Returns 1 if colliding local client, 2 if colliding remote, 3 if colliding both. - * Sends SVSNICKs as appropriate and forces nickchanges too. + * Sends SAVEs as appropriate and forces nickchanges too. */ int TreeSocket::DoCollision(User *u, time_t remotets, const std::string &remoteident, const std::string &remoteip, const std::string &remoteuid) { @@ -86,11 +86,11 @@ int TreeSocket::DoCollision(User *u, time_t remotets, const std::string &remotei /* * Cheat a little here. Instead of a dedicated command to change UID, - * use SVSNICK and accept the losing client with its UID (as we know the SVSNICK will + * use SAVE and accept the losing client with its UID (as we know the SAVE will * not fail under any circumstances -- UIDs are netwide exclusive). * * This means that each side of a collide will generate one extra NICK back to where - * they have just linked (and where it got the SVSNICK from), however, it will + * they have just linked (and where it got the SAVE from), however, it will * be dropped harmlessly as it will come in as :928AAAB NICK 928AAAB, and we already * have 928AAAB's nick set to that. * -- w00t @@ -100,13 +100,12 @@ int TreeSocket::DoCollision(User *u, time_t remotets, const std::string &remotei { /* * Local-side nick needs to change. Just in case we are hub, and - * this "local" nick is actually behind us, send an SVSNICK out. + * this "local" nick is actually behind us, send an SAVE out. */ parameterlist params; params.push_back(u->uuid); - params.push_back(u->uuid); params.push_back(ConvToStr(u->age)); - Utils->DoOneToMany(ServerInstance->Config->GetSID(),"SVSNICK",params); + Utils->DoOneToMany(ServerInstance->Config->GetSID(),"SAVE",params); u->ForceNickChange(u->uuid.c_str()); @@ -119,9 +118,9 @@ int TreeSocket::DoCollision(User *u, time_t remotets, const std::string &remotei /* * remote side needs to change. If this happens, we will modify * the UID or halt the propagation of the nick change command, - * so other servers don't need to see the SVSNICK + * so other servers don't need to see the SAVE */ - WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" SVSNICK "+remoteuid+" " + remoteuid + " " + ConvToStr(remotets)); + WriteLine(std::string(":")+ServerInstance->Config->GetSID()+" SAVE "+remoteuid+" "+ ConvToStr(remotets)); if (remote) { diff --git a/src/modules/m_spanningtree/save.cpp b/src/modules/m_spanningtree/save.cpp new file mode 100644 index 000000000..25f811267 --- /dev/null +++ b/src/modules/m_spanningtree/save.cpp @@ -0,0 +1,52 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#include "inspircd.h" +#include "commands/cmd_whois.h" +#include "commands/cmd_stats.h" +#include "socket.h" +#include "xline.h" +#include "../transport.h" +#include "socketengine.h" + +#include "main.h" +#include "utils.h" +#include "treeserver.h" +#include "treesocket.h" + +/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */ + +/** + * SAVE command - force nick change to UID on timestamp match + */ +bool TreeSocket::ForceNick(const std::string &prefix, parameterlist ¶ms) +{ + if (params.size() < 2) + return true; + + User* u = this->ServerInstance->FindNick(params[0]); + time_t ts = atol(params[1].c_str()); + + if (u && u->age == ts) + { + Utils->DoOneToAllButSender(prefix,"SAVE",params,prefix); + + if (!u->ForceNickChange(u->uuid.c_str())) + { + this->ServerInstance->Users->QuitUser(u, "Nickname collision"); + } + } + + return true; +} + diff --git a/src/modules/m_spanningtree/svsnick.cpp b/src/modules/m_spanningtree/svsnick.cpp index fe08b9ee2..48e0c638a 100644 --- a/src/modules/m_spanningtree/svsnick.cpp +++ b/src/modules/m_spanningtree/svsnick.cpp @@ -29,7 +29,7 @@ /** Because Andy insists that services-compatible servers must * implement SVSNICK and SVSJOIN, that's exactly what we do :p */ -bool TreeSocket::ForceNick(const std::string &prefix, parameterlist ¶ms) +bool TreeSocket::SVSNick(const std::string &prefix, parameterlist ¶ms) { if (params.size() < 3) return true; diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h index e9830f9ad..390978791 100644 --- a/src/modules/m_spanningtree/treesocket.h +++ b/src/modules/m_spanningtree/treesocket.h @@ -294,6 +294,9 @@ class TreeSocket : public BufferedSocket /** Because Andy insists that services-compatible servers must * implement SVSNICK and SVSJOIN, that's exactly what we do :p */ + bool SVSNick(const std::string &prefix, parameterlist ¶ms); + + /** SAVE to resolve nick collisions without killing */ bool ForceNick(const std::string &prefix, parameterlist ¶ms); /** PRIVMSG or NOTICE with server origin ONLY diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 085f14117..e76b98568 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -413,6 +413,10 @@ bool TreeSocket::ProcessLine(std::string &line) } else if (command == "SVSNICK") { + return this->SVSNick(prefix,params); + } + else if (command == "SAVE") + { return this->ForceNick(prefix,params); } else if (command == "OPERQUIT") |