m_spanningtree Add SpanningTreeUtilities::FindRouteTarget()

This commit is contained in:
Attila Molnar 2016-03-29 12:49:25 +02:00
parent 610a74ecea
commit ea258053f6
2 changed files with 18 additions and 0 deletions

View File

@ -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

View File

@ -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);