diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-07 16:35:14 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-07 16:35:14 +0000 |
commit | 95f1be0b6f88cf93d164659d01832d6084483c2b (patch) | |
tree | 01f3c7101b2727d16b0a69b84053ef462b72227c /src/modules/m_spanningtree | |
parent | 8460f081ada5ae3fe98a67e6c52e2646e2446b8a (diff) |
Slightly tidier capab checks
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6906 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r-- | src/modules/m_spanningtree/treesocket.h | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket1.cpp | 44 |
2 files changed, 30 insertions, 22 deletions
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h index 079d4fe92..e3b177002 100644 --- a/src/modules/m_spanningtree/treesocket.h +++ b/src/modules/m_spanningtree/treesocket.h @@ -406,5 +406,13 @@ struct cmd_validation size_t length; }; +/* Used to validate the length values in CAPAB CAPABILITIES */ +struct cap_validation +{ + const char* reason; + const char* key; + size_t size; +}; + #endif diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 7359d8295..4e4a08447 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -436,42 +436,42 @@ bool TreeSocket::Capab(const std::deque<std::string> ¶ms) else reason = "Modules loaded on these servers are not correctly matched, these modules are not loaded on " + diff; } + + cap_validation valid_capab[] = { + {"Maximum nickname lengths differ or remote nickname length not specified", "NICKMAX", NICKMAX}, + {"Maximum ident lengths differ or remote ident length not specified", "IDENTMAX", IDENTMAX}, + {"Maximum channel lengths differ or remote channel length not specified", "CHANMAX", CHANMAX}, + {"Maximum modes per line differ or remote modes per line not specified", "MAXMODES", MAXMODES}, + {"Maximum quit lengths differ or remote quit length not specified", "MAXQUIT", MAXQUIT}, + {"Maximum topic lengths differ or remote topic length not specified", "MAXTOPIC", MAXTOPIC}, + {"Maximum kick lengths differ or remote kick length not specified", "MAXKICK", MAXKICK}, + {"Maximum GECOS (fullname) lengths differ or remote GECOS length not specified", "MAXGECOS", MAXGECOS}, + {"Maximum awaymessage lengths differ or remote awaymessage length not specified", "MAXAWAY", MAXAWAY}, + {"", "", 0} + }; + if (((this->CapKeys.find("IP6SUPPORT") == this->CapKeys.end()) && (ip6support)) || ((this->CapKeys.find("IP6SUPPORT") != this->CapKeys.end()) && (this->CapKeys.find("IP6SUPPORT")->second != ConvToStr(ip6support)))) reason = "We don't both support linking to IPV6 servers"; if (((this->CapKeys.find("IP6NATIVE") != this->CapKeys.end()) && (this->CapKeys.find("IP6NATIVE")->second == "1")) && (!ip6support)) reason = "The remote server is IPV6 native, and we don't support linking to IPV6 servers"; - if (((this->CapKeys.find("NICKMAX") == this->CapKeys.end()) || ((this->CapKeys.find("NICKMAX") != this->CapKeys.end()) && (this->CapKeys.find("NICKMAX")->second != ConvToStr(NICKMAX))))) - reason = "Maximum nickname lengths differ or remote nickname length not specified"; if (((this->CapKeys.find("PROTOCOL") == this->CapKeys.end()) || ((this->CapKeys.find("PROTOCOL") != this->CapKeys.end()) && (this->CapKeys.find("PROTOCOL")->second != ConvToStr(ProtocolVersion))))) { if (this->CapKeys.find("PROTOCOL") != this->CapKeys.end()) - { reason = "Mismatched protocol versions "+this->CapKeys.find("PROTOCOL")->second+" and "+ConvToStr(ProtocolVersion); - } else - { reason = "Protocol version not specified"; - } } + if (((this->CapKeys.find("HALFOP") == this->CapKeys.end()) && (Instance->Config->AllowHalfop)) || ((this->CapKeys.find("HALFOP") != this->CapKeys.end()) && (this->CapKeys.find("HALFOP")->second != ConvToStr(Instance->Config->AllowHalfop)))) reason = "We don't both have halfop support enabled/disabled identically"; - if (((this->CapKeys.find("IDENTMAX") == this->CapKeys.end()) || ((this->CapKeys.find("IDENTMAX") != this->CapKeys.end()) && (this->CapKeys.find("IDENTMAX")->second != ConvToStr(IDENTMAX))))) - reason = "Maximum ident lengths differ or remote ident length not specified"; - if (((this->CapKeys.find("CHANMAX") == this->CapKeys.end()) || ((this->CapKeys.find("CHANMAX") != this->CapKeys.end()) && (this->CapKeys.find("CHANMAX")->second != ConvToStr(CHANMAX))))) - reason = "Maximum channel lengths differ or remote channel length not specified"; - if (((this->CapKeys.find("MAXMODES") == this->CapKeys.end()) || ((this->CapKeys.find("MAXMODES") != this->CapKeys.end()) && (this->CapKeys.find("MAXMODES")->second != ConvToStr(MAXMODES))))) - reason = "Maximum modes per line differ or remote modes per line not specified"; - if (((this->CapKeys.find("MAXQUIT") == this->CapKeys.end()) || ((this->CapKeys.find("MAXQUIT") != this->CapKeys.end()) && (this->CapKeys.find("MAXQUIT")->second != ConvToStr(MAXQUIT))))) - reason = "Maximum quit lengths differ or remote quit length not specified"; - if (((this->CapKeys.find("MAXTOPIC") == this->CapKeys.end()) || ((this->CapKeys.find("MAXTOPIC") != this->CapKeys.end()) && (this->CapKeys.find("MAXTOPIC")->second != ConvToStr(MAXTOPIC))))) - reason = "Maximum topic lengths differ or remote topic length not specified"; - if (((this->CapKeys.find("MAXKICK") == this->CapKeys.end()) || ((this->CapKeys.find("MAXKICK") != this->CapKeys.end()) && (this->CapKeys.find("MAXKICK")->second != ConvToStr(MAXKICK))))) - reason = "Maximum kick lengths differ or remote kick length not specified"; - if (((this->CapKeys.find("MAXGECOS") == this->CapKeys.end()) || ((this->CapKeys.find("MAXGECOS") != this->CapKeys.end()) && (this->CapKeys.find("MAXGECOS")->second != ConvToStr(MAXGECOS))))) - reason = "Maximum GECOS (fullname) lengths differ or remote GECOS length not specified"; - if (((this->CapKeys.find("MAXAWAY") == this->CapKeys.end()) || ((this->CapKeys.find("MAXAWAY") != this->CapKeys.end()) && (this->CapKeys.find("MAXAWAY")->second != ConvToStr(MAXAWAY))))) - reason = "Maximum awaymessage lengths differ or remote awaymessage length not specified"; + for (int x = 0; valid_capab[x].size; ++x) + { + if (((this->CapKeys.find(valid_capab[x].key) == this->CapKeys.end()) || ((this->CapKeys.find(valid_capab[x].key) != this->CapKeys.end()) && + (this->CapKeys.find(valid_capab[x].key)->second != ConvToStr(valid_capab[x].size))))) + reason = valid_capab[x].reason; + } + /* Challenge response, store their challenge for our password */ std::map<std::string,std::string>::iterator n = this->CapKeys.find("CHALLENGE"); if (Utils->ChallengeResponse && (n != this->CapKeys.end()) && (Instance->FindModule("m_sha256.so"))) |