diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-08-28 17:42:32 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-08-28 17:42:32 +0000 |
commit | f94e4c9eeb00b19a5b8b0b6d90cd6395dda49952 (patch) | |
tree | 40f334ec63571bcc6b80f5b134c2c1fa05ae5f93 | |
parent | bf0a17da34ed8784edd5bf30e508a97e377ffc5d (diff) |
Add SpanningTreeUtils::issid(). See top of utils.cpp
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7956 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 11 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.h | 5 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index b6cc02378..14126811f 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -29,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, + * contains no '.' chars and starts with a digit. + */ + return (str.length() == 3) && (str[0] != '.' && str[1] != '.' && str[2] != '.') && (isdigit(str[0])); +} + /** Yay for fast searches! * This is hundreds of times faster than recursion * or even scanning a linked list, especially when @@ -37,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()) { diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index f25b7f21a..388ff2d5c 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -195,6 +195,11 @@ class SpanningTreeUtilities void AddBurstingServer(const std::string &ServerName, TreeSocket* s); void DelBurstingServer(TreeSocket* s); + + /** Return true if str looks like a server ID + * @param string to check against + */ + bool issid(const std::string &str); }; #endif |