summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2016-03-29 12:49:25 +0200
committerAttila Molnar <attilamolnar@hush.com>2016-03-29 12:49:25 +0200
commitea258053f694ff17980e2f39ea182f3a2de9ba5b (patch)
tree1e25f03448a158990401816b70b0d8824800491c /src/modules/m_spanningtree
parent610a74ecea1d4b70f0c7eb3de04b8f7ff27e1fed (diff)
m_spanningtree Add SpanningTreeUtilities::FindRouteTarget()
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r--src/modules/m_spanningtree/utils.cpp13
-rw-r--r--src/modules/m_spanningtree/utils.h5
2 files changed, 18 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp
index 05b77bb62..6de47de94 100644
--- a/src/modules/m_spanningtree/utils.cpp
+++ b/src/modules/m_spanningtree/utils.cpp
@@ -89,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
diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h
index 6d0d094e7..a2f7212f6 100644
--- a/src/modules/m_spanningtree/utils.h
+++ b/src/modules/m_spanningtree/utils.h
@@ -148,6 +148,11 @@ class SpanningTreeUtilities : public classbase
*/
TreeServer* FindServerID(const std::string &id);
+ /** 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* FindRouteTarget(const std::string& target);
+
/** Find a server by glob mask
*/
TreeServer* FindServerMask(const std::string &ServerName);