diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-21 14:47:44 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-21 14:47:44 +0000 |
commit | fb139a504c35d26cd3b360874263bb32f917380c (patch) | |
tree | 2ba7a5d59716196d8ef7562ce5285771d4a38628 /src/modules | |
parent | 2be5ac472c093ccafcaabdbe463693380eeb3769 (diff) |
Added CAPAB checking to prevent some obvious n00biness that may occur
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2598 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_spanningtree.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index e6b9b2bb2..fe316977b 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -569,6 +569,7 @@ class TreeSocket : public InspSocket : InspSocket(newfd, ip) { this->LinkState = WAIT_AUTH_1; + this->SendCapabilities(); } void InitAES(std::string key,std::string SName) @@ -621,6 +622,7 @@ class TreeSocket : public InspSocket this->InitAES(x->EncryptionKey,x->Name); } } + this->SendCapabilities(); /* found who we're supposed to be connecting to, send the neccessary gubbins. */ this->WriteLine("SERVER "+Srv->GetServerName()+" "+x->SendPass+" 0 :"+Srv->GetServerDescription()); return true; @@ -677,6 +679,51 @@ class TreeSocket : public InspSocket } } + std::string MyCapabilities() + { + ServerConfig* Config = Srv->GetConfig(); + std::vector<std::string> modlist; + std::string capabilities = ""; + + for (int i = 0; i <= MODCOUNT; i++) + { + if ((modules[i]->GetVersion().Flags & VF_STATIC) || (modules[i]->GetVersion().Flags & VF_COMMON)) + modlist.push_back(Config->module_names[i]); + } + sort(modlist.begin(),modlist.end()); + for (unsigned int i = 0; i < modlist.size(); i++) + { + if (i) + capabilities = capabilities + ","; + capabilities = capabilities + modlist[i]; + } + return capabilities; + } + + void SendCapabilities() + { + this->WriteLine("CAPAB "+MyCapabilities()); + } + + bool Capab(std::deque<std::string> params) + { + if (params.size() != 1) + { + this->WriteLine("ERROR :Invalid number of parameters for CAPAB"); + return false; + } + if (params[0] != this->MyCapabilities()) + { + WriteOpers("*** \2ERROR\2: Server '%s' does not have the same set of modules loaded, cannot link!"); + WriteOpers("*** Our networked module set is: '%s'",this->MyCapabilities().c_str()); + WriteOpers("*** Other server's networked module set is: '%s'",params[0].c_str()); + WriteOpers("*** These lists must match exactly on both servers. Please correct these errors, and try again."); + this->WriteLine("ERROR :CAPAB mismatch; My capabilities: '"+this->MyCapabilities()+"'"); + return false; + } + return true; + } + /* This function forces this server to quit, removing this server * and any users on it (and servers and users below that, etc etc). * It's very slow and pretty clunky, but luckily unless your network @@ -1774,6 +1821,10 @@ class TreeSocket : public InspSocket this->WriteLine("ERROR :Client connections to this port are prohibited."); return false; } + else if (command == "CAPAB") + { + return this->Capab(params); + } else { this->WriteLine("ERROR :Invalid command in negotiation phase."); @@ -1807,6 +1858,10 @@ class TreeSocket : public InspSocket { return this->Error(params); } + else if (command == "CAPAB") + { + return this->Capab(params); + } break; case LISTENER: |