summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/m_spanningtree/commands.h60
-rw-r--r--src/modules/m_spanningtree/main.cpp18
-rw-r--r--src/modules/m_spanningtree/main.h6
-rw-r--r--src/modules/m_spanningtree/rconnect.cpp4
-rw-r--r--src/modules/m_spanningtree/rconnect.h28
-rw-r--r--src/modules/m_spanningtree/rsquit.cpp4
-rw-r--r--src/modules/m_spanningtree/rsquit.h29
-rw-r--r--src/modules/m_spanningtree/svsjoin.cpp30
-rw-r--r--src/modules/m_spanningtree/svsnick.cpp52
-rw-r--r--src/modules/m_spanningtree/svspart.cpp37
-rw-r--r--src/modules/m_spanningtree/treesocket.h13
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp12
12 files changed, 133 insertions, 160 deletions
diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h
new file mode 100644
index 000000000..d776d49f4
--- /dev/null
+++ b/src/modules/m_spanningtree/commands.h
@@ -0,0 +1,60 @@
+/* +------------------------------------+
+ * | 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.
+ *
+ * ---------------------------------------------------
+ */
+
+#ifndef __COMMANDS_H__
+#define __COMMANDS_H__
+
+/** Handle /RCONNECT
+ */
+class CommandRConnect : public Command
+{
+ SpanningTreeUtilities* Utils; /* Utility class */
+ public:
+ CommandRConnect (Module* Callback, SpanningTreeUtilities* Util);
+ CmdResult Handle (const std::vector<std::string>& parameters, User *user);
+ RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
+};
+
+class CommandRSQuit : public Command
+{
+ SpanningTreeUtilities* Utils; /* Utility class */
+ public:
+ CommandRSQuit(Module* Callback, SpanningTreeUtilities* Util);
+ CmdResult Handle (const std::vector<std::string>& parameters, User *user);
+ RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
+ void NoticeUser(User* user, const std::string &msg);
+};
+
+class CommandSVSJoin : public Command
+{
+ public:
+ CommandSVSJoin(Module* Creator) : Command(Creator, "SVSJOIN", 2) { flags_needed = 'o'; }
+ CmdResult Handle (const std::vector<std::string>& parameters, User *user);
+ RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
+};
+class CommandSVSPart : public Command
+{
+ public:
+ CommandSVSPart(Module* Creator) : Command(Creator, "SVSPART", 2) { flags_needed = 'o'; }
+ CmdResult Handle (const std::vector<std::string>& parameters, User *user);
+ RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
+};
+class CommandSVSNick : public Command
+{
+ public:
+ CommandSVSNick(Module* Creator) : Command(Creator, "SVSNICK", 2) { flags_needed = 'o'; }
+ CmdResult Handle (const std::vector<std::string>& parameters, User *user);
+ RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
+};
+
+#endif
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 0ed9b28ac..4c982356a 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -24,21 +24,24 @@
#include "treeserver.h"
#include "link.h"
#include "treesocket.h"
-#include "rconnect.h"
-#include "rsquit.h"
+#include "commands.h"
#include "protocolinterface.h"
-/* $ModDep: m_spanningtree/cachetimer.h m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h m_spanningtree/rsquit.h m_spanningtree/protocolinterface.h */
-
ModuleSpanningTree::ModuleSpanningTree()
: max_local(0), max_global(0)
{
Utils = new SpanningTreeUtilities(this);
command_rconnect = new CommandRConnect(this, Utils);
- ServerInstance->AddCommand(command_rconnect);
command_rsquit = new CommandRSQuit(this, Utils);
- ServerInstance->AddCommand(command_rsquit);
+ command_svsjoin = new CommandSVSJoin(this);
+ command_svspart = new CommandSVSPart(this);
+ command_svsnick = new CommandSVSNick(this);
RefreshTimer = new CacheRefreshTimer(Utils);
+ ServerInstance->AddCommand(command_rconnect);
+ ServerInstance->AddCommand(command_rsquit);
+ ServerInstance->AddCommand(command_svsjoin);
+ ServerInstance->AddCommand(command_svspart);
+ ServerInstance->AddCommand(command_svsnick);
ServerInstance->Timers->AddTimer(RefreshTimer);
Implementation eventlist[] =
@@ -953,6 +956,9 @@ ModuleSpanningTree::~ModuleSpanningTree()
delete command_rconnect;
delete command_rsquit;
+ delete command_svsjoin;
+ delete command_svspart;
+ delete command_svsnick;
}
Version ModuleSpanningTree::GetVersion()
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index 02513fb2e..b152757b9 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -33,6 +33,9 @@ const long MinCompatProtocol = 1201;
*/
class CommandRConnect;
class CommandRSQuit;
+class CommandSVSJoin;
+class CommandSVSPart;
+class CommandSVSNick;
class SpanningTreeUtilities;
class CacheRefreshTimer;
class TreeServer;
@@ -47,6 +50,9 @@ class ModuleSpanningTree : public Module
unsigned int max_global;
CommandRConnect* command_rconnect;
CommandRSQuit* command_rsquit;
+ CommandSVSJoin* command_svsjoin;
+ CommandSVSPart* command_svspart;
+ CommandSVSNick* command_svsnick;
SpanningTreeUtilities* Utils;
void RedoConfig(Module* mod);
diff --git a/src/modules/m_spanningtree/rconnect.cpp b/src/modules/m_spanningtree/rconnect.cpp
index 5a4c71c3c..77f2c6972 100644
--- a/src/modules/m_spanningtree/rconnect.cpp
+++ b/src/modules/m_spanningtree/rconnect.cpp
@@ -21,9 +21,7 @@
#include "treeserver.h"
#include "link.h"
#include "treesocket.h"
-#include "rconnect.h"
-
-/* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h m_spanningtree/rconnect.h */
+#include "commands.h"
CommandRConnect::CommandRConnect (Module* Creator, SpanningTreeUtilities* Util)
: Command(Creator, "RCONNECT", 2), Utils(Util)
diff --git a/src/modules/m_spanningtree/rconnect.h b/src/modules/m_spanningtree/rconnect.h
deleted file mode 100644
index 1b24ad0f3..000000000
--- a/src/modules/m_spanningtree/rconnect.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* +------------------------------------+
- * | 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.
- *
- * ---------------------------------------------------
- */
-
-#ifndef __RCONNECT_H__
-#define __RCONNECT_H__
-
-/** Handle /RCONNECT
- */
-class CommandRConnect : public Command
-{
- SpanningTreeUtilities* Utils; /* Utility class */
- public:
- CommandRConnect (Module* Callback, SpanningTreeUtilities* Util);
- CmdResult Handle (const std::vector<std::string>& parameters, User *user);
- RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
-};
-
-#endif
diff --git a/src/modules/m_spanningtree/rsquit.cpp b/src/modules/m_spanningtree/rsquit.cpp
index 271e845d5..6b306064d 100644
--- a/src/modules/m_spanningtree/rsquit.cpp
+++ b/src/modules/m_spanningtree/rsquit.cpp
@@ -19,9 +19,7 @@
#include "utils.h"
#include "treeserver.h"
#include "treesocket.h"
-#include "rsquit.h"
-
-/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h m_spanningtree/rsquit.h */
+#include "commands.h"
CommandRSQuit::CommandRSQuit (Module* Creator, SpanningTreeUtilities* Util)
: Command(Creator, "RSQUIT", 1), Utils(Util)
diff --git a/src/modules/m_spanningtree/rsquit.h b/src/modules/m_spanningtree/rsquit.h
deleted file mode 100644
index 887f77b6f..000000000
--- a/src/modules/m_spanningtree/rsquit.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* +------------------------------------+
- * | 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.
- *
- * ---------------------------------------------------
- */
-
-#ifndef __RSQUIT_H__
-#define __RSQUIT_H__
-
-/** Handle /RCONNECT
- */
-class CommandRSQuit : public Command
-{
- SpanningTreeUtilities* Utils; /* Utility class */
- public:
- CommandRSQuit (Module* Callback, SpanningTreeUtilities* Util);
- CmdResult Handle (const std::vector<std::string>& parameters, User *user);
- RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters);
- void NoticeUser(User* user, const std::string &msg);
-};
-
-#endif
diff --git a/src/modules/m_spanningtree/svsjoin.cpp b/src/modules/m_spanningtree/svsjoin.cpp
index d8df6fb95..cd7c7e06d 100644
--- a/src/modules/m_spanningtree/svsjoin.cpp
+++ b/src/modules/m_spanningtree/svsjoin.cpp
@@ -19,29 +19,29 @@
#include "main.h"
#include "utils.h"
#include "treeserver.h"
-#include "treesocket.h"
+#include "commands.h"
-/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
-
-bool TreeSocket::ServiceJoin(const std::string &prefix, parameterlist &params)
+CmdResult CommandSVSJoin::Handle(const std::vector<std::string>& parameters, User *user)
{
- // Check params
- if (params.size() < 2)
- return true;
-
// Check for valid channel name
- if (!ServerInstance->IsChannel(params[1].c_str(), ServerInstance->Config->Limits.ChanMax))
- return true;
+ if (!ServerInstance->IsChannel(parameters[1].c_str(), ServerInstance->Config->Limits.ChanMax))
+ return CMD_FAILURE;
// Check target exists
- User* u = ServerInstance->FindNick(params[0]);
+ User* u = ServerInstance->FindNick(parameters[0]);
if (!u)
- return true;
+ return CMD_FAILURE;
/* only join if it's local, otherwise just pass it on! */
if (IS_LOCAL(u))
- Channel::JoinUser(u, params[1].c_str(), false, "", false, ServerInstance->Time());
- Utils->DoOneToAllButSender(prefix,"SVSJOIN",params,prefix);
- return true;
+ Channel::JoinUser(u, parameters[1].c_str(), false, "", false, ServerInstance->Time());
+ return CMD_SUCCESS;
}
+RouteDescriptor CommandSVSJoin::GetRouting(User* user, const std::vector<std::string>& parameters)
+{
+ User* u = ServerInstance->FindNick(parameters[0]);
+ if (u)
+ return ROUTE_OPT_UCAST(u->server);
+ return ROUTE_LOCALONLY;
+}
diff --git a/src/modules/m_spanningtree/svsnick.cpp b/src/modules/m_spanningtree/svsnick.cpp
index 87b63ec26..742a8e4fb 100644
--- a/src/modules/m_spanningtree/svsnick.cpp
+++ b/src/modules/m_spanningtree/svsnick.cpp
@@ -12,50 +12,40 @@
*/
#include "inspircd.h"
-#include "socket.h"
-#include "xline.h"
-#include "socketengine.h"
#include "main.h"
#include "utils.h"
-#include "treeserver.h"
-#include "treesocket.h"
+#include "commands.h"
-/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
-
-/** Because Andy insists that services-compatible servers must
- * implement SVSNICK and SVSJOIN, that's exactly what we do :p
- */
-bool TreeSocket::SVSNick(const std::string &prefix, parameterlist &params)
+CmdResult CommandSVSNick::Handle(const std::vector<std::string>& parameters, User *user)
{
- if (params.size() < 3)
- return true;
-
- User* u = ServerInstance->FindNick(params[0]);
+ User* u = ServerInstance->FindNick(parameters[0]);
- if (u)
+ if (u && IS_LOCAL(u))
{
- Utils->DoOneToAllButSender(prefix,"SVSNICK",params,prefix);
+ parameterlist par;
+ par.push_back(parameters[1]);
- if (IS_LOCAL(u))
+ if (!u->ForceNickChange(parameters[1].c_str()))
{
- parameterlist par;
- par.push_back(params[1]);
-
- if (!u->ForceNickChange(params[1].c_str()))
+ /* buh. UID them */
+ if (!u->ForceNickChange(u->uuid.c_str()))
{
- /* buh. UID them */
- if (!u->ForceNickChange(u->uuid.c_str()))
- {
- ServerInstance->Users->QuitUser(u, "Nickname collision");
- return true;
- }
+ ServerInstance->Users->QuitUser(u, "Nickname collision");
+ return CMD_SUCCESS;
}
-
- u->age = atoi(params[2].c_str());
}
+
+ u->age = atoi(parameters[2].c_str());
}
- return true;
+ return CMD_SUCCESS;
}
+RouteDescriptor CommandSVSNick::GetRouting(User* user, const std::vector<std::string>& parameters)
+{
+ User* u = ServerInstance->FindNick(parameters[0]);
+ if (u)
+ return ROUTE_OPT_UCAST(u->server);
+ return ROUTE_LOCALONLY;
+}
diff --git a/src/modules/m_spanningtree/svspart.cpp b/src/modules/m_spanningtree/svspart.cpp
index 2a34d23c6..4d73c50bb 100644
--- a/src/modules/m_spanningtree/svspart.cpp
+++ b/src/modules/m_spanningtree/svspart.cpp
@@ -19,31 +19,28 @@
#include "main.h"
#include "utils.h"
#include "treeserver.h"
-#include "treesocket.h"
+#include "commands.h"
-/* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
-
-bool TreeSocket::ServicePart(const std::string &prefix, parameterlist &params)
+CmdResult CommandSVSPart::Handle(const std::vector<std::string>& parameters, User *user)
{
- if (params.size() < 2)
- return true;
-
std::string reason = "Services forced part";
- if (params.size() == 3)
- reason = params[2];
+ if (parameters.size() == 3)
+ reason = parameters[2];
- User* u = ServerInstance->FindNick(params[0]);
- Channel* c = ServerInstance->FindChan(params[1]);
+ User* u = ServerInstance->FindNick(parameters[0]);
+ Channel* c = ServerInstance->FindChan(parameters[1]);
- if (u)
- {
- /* only part if it's local, otherwise just pass it on! */
- if (IS_LOCAL(u))
- c->PartUser(u, reason);
- Utils->DoOneToAllButSender(prefix,"SVSPART",params,prefix);
- }
-
- return true;
+ if (u && IS_LOCAL(u))
+ c->PartUser(u, reason);
+
+ return CMD_SUCCESS;
}
+RouteDescriptor CommandSVSPart::GetRouting(User* user, const std::vector<std::string>& parameters)
+{
+ User* u = ServerInstance->FindNick(parameters[0]);
+ if (u)
+ return ROUTE_OPT_UCAST(u->server);
+ return ROUTE_LOCALONLY;
+}
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index c71799343..92fef1f2d 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -274,11 +274,6 @@ class TreeSocket : public BufferedSocket
/** Remote AWAY */
bool Away(const std::string &prefix, parameterlist &params);
- /** 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 &params);
-
/** SAVE to resolve nick collisions without killing */
bool ForceNick(const std::string &prefix, parameterlist &params);
@@ -290,14 +285,6 @@ class TreeSocket : public BufferedSocket
*/
bool OperQuit(const std::string &prefix, parameterlist &params);
- /** SVSJOIN
- */
- bool ServiceJoin(const std::string &prefix, parameterlist &params);
-
- /** SVSPART
- */
- bool ServicePart(const std::string &prefix, parameterlist &params);
-
/** KILL
*/
bool RemoteKill(const std::string &prefix, parameterlist &params);
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 350531f46..144f30bf8 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -380,10 +380,6 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
{
this->DelLine(prefix,params);
}
- else if (command == "SVSNICK")
- {
- this->SVSNick(prefix,params);
- }
else if (command == "SAVE")
{
this->ForceNick(prefix,params);
@@ -404,14 +400,6 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command,
{
this->Time(prefix,params);
}
- else if (command == "SVSJOIN")
- {
- this->ServiceJoin(prefix,params);
- }
- else if (command == "SVSPART")
- {
- this->ServicePart(prefix,params);
- }
else if (command == "SQUIT")
{
if (params.size() == 2)