X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Futils.cpp;h=1e0788623e5d10f4c61493c05c68ea5a079bff71;hb=b0ff1060952215c375ec793206e76344034875d8;hp=b8a634797b8acf691374986caaabf1ead0b48495;hpb=5577604494b8a5fdb023e2fa2843a6736fde52b8;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index b8a634797..1e0788623 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -12,10 +12,6 @@ */ #include "inspircd.h" -#include "configreader.h" -#include "users.h" -#include "channels.h" -#include "modules.h" #include "commands/cmd_whois.h" #include "commands/cmd_stats.h" #include "socket.h" @@ -33,6 +29,14 @@ /* $ModDep: m_spanningtree/timesynctimer.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 */ +bool SpanningTreeUtilities::IsSID(const std::string &str) +{ + /* Returns true if the string given is exactly 3 characters long, + * starts with a digit, and has no '.' in the other 2 + */ + return ((str.length() == 3) && isdigit(str[0]) && (str[1] != '.' && str[2] != '.')); +} + /** Yay for fast searches! * This is hundreds of times faster than recursion * or even scanning a linked list, especially when @@ -41,6 +45,9 @@ */ TreeServer* SpanningTreeUtilities::FindServer(const std::string &ServerName) { + if (IsSID(ServerName)) + return this->FindServerID(ServerName); + server_hash::iterator iter = serverlist.find(ServerName.c_str()); if (iter != serverlist.end()) { @@ -149,6 +156,16 @@ TreeServer* SpanningTreeUtilities::FindServerMask(const std::string &ServerName) return NULL; } +TreeServer* SpanningTreeUtilities::FindServerID(const std::string &id) +{ + ServerInstance->Log(DEBUG,"Looking for id: %s", id.c_str()); + server_hash::iterator iter = sidlist.find(id); + if (iter != sidlist.end()) + return iter->second; + else + return NULL; +} + /* A convenient wrapper that returns true if a server exists */ bool SpanningTreeUtilities::IsServer(const std::string &ServerName) { @@ -161,7 +178,9 @@ SpanningTreeUtilities::SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningT lines_to_apply = 0; - this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc); + ServerInstance->Log(DEBUG, "SpanningTreeUtilities: SID: %s", OurSID.c_str()); + + this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, ServerInstance->Config->GetSID()); modulelist* ml = ServerInstance->FindInterface("InspSocketHook");