From: brain Date: Wed, 21 Dec 2005 14:47:44 +0000 (+0000) Subject: Added CAPAB checking to prevent some obvious n00biness that may occur X-Git-Tag: v2.0.23~9476 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=fb139a504c35d26cd3b360874263bb32f917380c;p=user%2Fhenk%2Fcode%2Finspircd.git 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 --- 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 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 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: