summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/modules/m_chghost.cpp5
-rw-r--r--src/modules/m_chgident.cpp5
-rw-r--r--src/modules/m_chgname.cpp5
-rw-r--r--src/modules/m_nicklock.cpp10
-rw-r--r--src/modules/m_sajoin.cpp5
-rw-r--r--src/modules/m_sakick.cpp5
-rw-r--r--src/modules/m_sanick.cpp5
-rw-r--r--src/modules/m_sapart.cpp5
-rw-r--r--src/modules/m_saquit.cpp5
-rw-r--r--src/modules/m_silence.cpp5
-rw-r--r--src/modules/m_spanningtree/commandbuilder.h5
-rw-r--r--src/modules/m_spanningtree/postcommand.cpp4
-rw-r--r--src/modules/m_spanningtree/svsjoin.cpp5
-rw-r--r--src/modules/m_spanningtree/svsnick.cpp5
-rw-r--r--src/modules/m_spanningtree/svspart.cpp5
-rw-r--r--src/modules/m_spanningtree/utils.cpp49
-rw-r--r--src/modules/m_spanningtree/utils.h6
-rw-r--r--src/modules/m_uninvite.cpp3
18 files changed, 34 insertions, 103 deletions
diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp
index 163f1f2eb..60146c78b 100644
--- a/src/modules/m_chghost.cpp
+++ b/src/modules/m_chghost.cpp
@@ -77,10 +77,7 @@ class CommandChghost : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* dest = ServerInstance->FindNick(parameters[0]);
- if (dest)
- return ROUTE_OPT_UCAST(dest->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
};
diff --git a/src/modules/m_chgident.cpp b/src/modules/m_chgident.cpp
index 0b4e78f12..8ba5b4a5b 100644
--- a/src/modules/m_chgident.cpp
+++ b/src/modules/m_chgident.cpp
@@ -70,10 +70,7 @@ class CommandChgident : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* dest = ServerInstance->FindNick(parameters[0]);
- if (dest)
- return ROUTE_OPT_UCAST(dest->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
};
diff --git a/src/modules/m_chgname.cpp b/src/modules/m_chgname.cpp
index 3ad9cede9..2582ef652 100644
--- a/src/modules/m_chgname.cpp
+++ b/src/modules/m_chgname.cpp
@@ -66,10 +66,7 @@ class CommandChgname : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* dest = ServerInstance->FindNick(parameters[0]);
- if (dest)
- return ROUTE_OPT_UCAST(dest->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
};
diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp
index a517e95ac..35845c8d8 100644
--- a/src/modules/m_nicklock.cpp
+++ b/src/modules/m_nicklock.cpp
@@ -78,10 +78,7 @@ class CommandNicklock : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* dest = ServerInstance->FindNick(parameters[0]);
- if (dest)
- return ROUTE_OPT_UCAST(dest->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
};
@@ -128,10 +125,7 @@ class CommandNickunlock : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* dest = ServerInstance->FindNick(parameters[0]);
- if (dest)
- return ROUTE_OPT_UCAST(dest->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
};
diff --git a/src/modules/m_sajoin.cpp b/src/modules/m_sajoin.cpp
index cc97c7308..9d87360ec 100644
--- a/src/modules/m_sajoin.cpp
+++ b/src/modules/m_sajoin.cpp
@@ -103,10 +103,7 @@ class CommandSajoin : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* dest = ServerInstance->FindNick(parameters[0]);
- if (dest)
- return ROUTE_OPT_UCAST(dest->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
};
diff --git a/src/modules/m_sakick.cpp b/src/modules/m_sakick.cpp
index 8fc6e741b..ab168ca68 100644
--- a/src/modules/m_sakick.cpp
+++ b/src/modules/m_sakick.cpp
@@ -75,10 +75,7 @@ class CommandSakick : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* dest = ServerInstance->FindNick(parameters[1]);
- if (dest)
- return ROUTE_OPT_UCAST(dest->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[1]);
}
};
diff --git a/src/modules/m_sanick.cpp b/src/modules/m_sanick.cpp
index fd9a825dd..3dc89b4f6 100644
--- a/src/modules/m_sanick.cpp
+++ b/src/modules/m_sanick.cpp
@@ -79,10 +79,7 @@ class CommandSanick : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* dest = ServerInstance->FindNick(parameters[0]);
- if (dest)
- return ROUTE_OPT_UCAST(dest->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
};
diff --git a/src/modules/m_sapart.cpp b/src/modules/m_sapart.cpp
index 65c32cd8a..db1e6fdee 100644
--- a/src/modules/m_sapart.cpp
+++ b/src/modules/m_sapart.cpp
@@ -80,10 +80,7 @@ class CommandSapart : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* dest = ServerInstance->FindNick(parameters[0]);
- if (dest)
- return ROUTE_OPT_UCAST(dest->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
};
diff --git a/src/modules/m_saquit.cpp b/src/modules/m_saquit.cpp
index 4d5ac6e22..c3895ec12 100644
--- a/src/modules/m_saquit.cpp
+++ b/src/modules/m_saquit.cpp
@@ -61,10 +61,7 @@ class CommandSaquit : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* dest = ServerInstance->FindNick(parameters[0]);
- if (dest)
- return ROUTE_OPT_UCAST(dest->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
};
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index 7d3b3f90c..0ec40a92f 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -93,10 +93,7 @@ class CommandSVSSilence : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* target = ServerInstance->FindNick(parameters[0]);
- if (target)
- return ROUTE_OPT_UCAST(target->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
};
diff --git a/src/modules/m_spanningtree/commandbuilder.h b/src/modules/m_spanningtree/commandbuilder.h
index 26eb4587f..59de84052 100644
--- a/src/modules/m_spanningtree/commandbuilder.h
+++ b/src/modules/m_spanningtree/commandbuilder.h
@@ -142,11 +142,6 @@ class CmdBuilder
Utils->DoOneToAllButSender(*this, omit);
}
- bool Unicast(const std::string& target) const
- {
- return Utils->DoOneToOne(*this, target);
- }
-
void Unicast(User* target) const
{
Utils->DoOneToOne(*this, target->server);
diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp
index ae98be946..7b0478229 100644
--- a/src/modules/m_spanningtree/postcommand.cpp
+++ b/src/modules/m_spanningtree/postcommand.cpp
@@ -51,7 +51,9 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm
sdest = static_cast<TreeServer*>(routing.server);
if (!sdest)
{
- sdest = FindServer(routing.serverdest);
+ // Assume the command handler already validated routing.serverdest and have only returned success if the target is something that the
+ // user executing the command is allowed to look up e.g. target is not an uuid if user is local.
+ sdest = FindRouteTarget(routing.serverdest);
if (!sdest)
{
ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Trying to route %s%s to nonexistant server %s", (encap ? "ENCAP " : ""), command.c_str(), routing.serverdest.c_str());
diff --git a/src/modules/m_spanningtree/svsjoin.cpp b/src/modules/m_spanningtree/svsjoin.cpp
index 98443409a..c85e4f412 100644
--- a/src/modules/m_spanningtree/svsjoin.cpp
+++ b/src/modules/m_spanningtree/svsjoin.cpp
@@ -54,8 +54,5 @@ CmdResult CommandSVSJoin::Handle(User* user, std::vector<std::string>& parameter
RouteDescriptor CommandSVSJoin::GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* u = ServerInstance->FindUUID(parameters[0]);
- if (u)
- return ROUTE_OPT_UCAST(u->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
diff --git a/src/modules/m_spanningtree/svsnick.cpp b/src/modules/m_spanningtree/svsnick.cpp
index b3a612ca3..84cf8558c 100644
--- a/src/modules/m_spanningtree/svsnick.cpp
+++ b/src/modules/m_spanningtree/svsnick.cpp
@@ -72,8 +72,5 @@ CmdResult CommandSVSNick::Handle(User* user, std::vector<std::string>& parameter
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;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
diff --git a/src/modules/m_spanningtree/svspart.cpp b/src/modules/m_spanningtree/svspart.cpp
index f86afa367..c4163ef3d 100644
--- a/src/modules/m_spanningtree/svspart.cpp
+++ b/src/modules/m_spanningtree/svspart.cpp
@@ -42,8 +42,5 @@ CmdResult CommandSVSPart::Handle(User* user, std::vector<std::string>& parameter
RouteDescriptor CommandSVSPart::GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* u = ServerInstance->FindUUID(parameters[0]);
- if (u)
- return ROUTE_OPT_UCAST(u->server);
- return ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index bbda2634d..6de47de94 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -67,32 +67,6 @@ TreeServer* SpanningTreeUtilities::FindServer(const std::string &ServerName)
}
}
-/** Returns the locally connected server we must route a
- * message through to reach server 'ServerName'. This
- * only applies to one-to-one and not one-to-many routing.
- * See the comments for the constructor of TreeServer
- * for more details.
- */
-TreeServer* SpanningTreeUtilities::BestRouteTo(const std::string &ServerName)
-{
- TreeServer* Found = FindServer(ServerName);
- if (Found)
- {
- return Found->GetRoute();
- }
- else
- {
- // Cheat a bit. This allows for (better) working versions of routing commands with nick based prefixes, without hassle
- User *u = ServerInstance->FindNick(ServerName);
- if (u)
- {
- return TreeServer::Get(u)->GetRoute();
- }
-
- return NULL;
- }
-}
-
/** Find the first server matching a given glob mask.
* We iterate over the list and match each one until we get a hit.
*/
@@ -115,6 +89,19 @@ TreeServer* SpanningTreeUtilities::FindServerID(const std::string &id)
return NULL;
}
+TreeServer* SpanningTreeUtilities::FindRouteTarget(const std::string& target)
+{
+ TreeServer* const server = FindServer(target);
+ if (server)
+ return server;
+
+ User* const user = ServerInstance->FindNick(target);
+ if (user)
+ return TreeServer::Get(user);
+
+ return NULL;
+}
+
SpanningTreeUtilities::SpanningTreeUtilities(ModuleSpanningTree* C)
: Creator(C), TreeRoot(NULL)
, PingFreq(60) // XXX: TreeServer constructor reads this and TreeRoot is created before the config is read, so init it to something (value doesn't matter) to avoid a valgrind warning in TimerManager on unload
@@ -191,16 +178,6 @@ void SpanningTreeUtilities::DoOneToAllButSender(const CmdBuilder& params, TreeSe
}
}
-bool SpanningTreeUtilities::DoOneToOne(const CmdBuilder& params, const std::string& target)
-{
- TreeServer* Route = this->BestRouteTo(target);
- if (!Route)
- return false;
-
- DoOneToOne(params, Route);
- return true;
-}
-
void SpanningTreeUtilities::DoOneToOne(const CmdBuilder& params, Server* server)
{
TreeServer* ts = static_cast<TreeServer*>(server);
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index 84637bf01..a2f7212f6 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -118,7 +118,6 @@ class SpanningTreeUtilities : public classbase
/** Send a message from this server to one other local or remote
*/
- bool DoOneToOne(const CmdBuilder& params, const std::string& target);
void DoOneToOne(const CmdBuilder& params, Server* target);
/** Send a message from this server to all but one other, local or remote
@@ -149,9 +148,10 @@ class SpanningTreeUtilities : public classbase
*/
TreeServer* FindServerID(const std::string &id);
- /** Find a route to a server by name
+ /** Find a server based on a target string.
+ * @param target Target string where a command should be routed to. May be a server name, a sid, a nickname or a uuid.
*/
- TreeServer* BestRouteTo(const std::string &ServerName);
+ TreeServer* FindRouteTarget(const std::string& target);
/** Find a server by glob mask
*/
diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp
index 19184751d..d3a424dff 100644
--- a/src/modules/m_uninvite.cpp
+++ b/src/modules/m_uninvite.cpp
@@ -105,8 +105,7 @@ class CommandUninvite : public Command
RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
{
- User* u = ServerInstance->FindNick(parameters[0]);
- return u ? ROUTE_OPT_UCAST(u->server) : ROUTE_LOCALONLY;
+ return ROUTE_OPT_UCAST(parameters[0]);
}
};