]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Verify cloak keys match during CAPAB negotiation
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 14 Jan 2010 18:22:39 +0000 (18:22 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 14 Jan 2010 18:22:39 +0000 (18:22 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12258 e03df62e-2008-0410-955e-edbf42e46eb7

include/modules.h
src/modules.cpp
src/modules/m_cloaking.cpp
src/modules/m_spanningtree/capab.cpp
src/modules/m_spanningtree/compat.cpp
src/modules/m_spanningtree/treesocket1.cpp

index a3f596091b91df3b41333c588112289567198510..13e3dc28cd1748e0faa5d313a62980768518cffc 100644 (file)
@@ -188,10 +188,12 @@ class CoreExport VersionBase
        /** Server linking description string */
        const std::string link_data;
 
-       /** Initialize version class
-        */
+       /** Simple module version */
        VersionBase(const std::string &desc, int flags = VF_NONE);
 
+       /** Complex version information, including linking compatability data */
+       VersionBase(const std::string &desc, int flags, const std::string& linkdata);
+
        virtual ~VersionBase() {}
 
        /** Return true if the module can link (default is identity comparison) */
index f460a6a28401b9df0baaa7c8e06cdbc0559c19ce..cbd6c7b3871a7270f8549418550a89fc10daef35 100644 (file)
 
 // Version is a simple class for holding a modules version number
 template<>
-VersionBase<API_VERSION>::VersionBase(const std::string &modv, int flags)
-: description(modv), Flags(flags)
+VersionBase<API_VERSION>::VersionBase(const std::string &desc, int flags)
+: description(desc), Flags(flags)
+{
+}
+
+template<>
+VersionBase<API_VERSION>::VersionBase(const std::string &desc, int flags, const std::string& linkdata)
+: description(desc), Flags(flags), link_data(linkdata)
 {
 }
 
index 1f9854a78eeeb6d9da7b6cc969578e4174b81baf..22114c54e7930a5069fe184e29bcc77f45d66d6a 100644 (file)
@@ -332,9 +332,23 @@ class ModuleCloaking : public Module
 
        Version GetVersion()
        {
-               // returns the version number of the module to be
-               // listed in /MODULES
-               return Version("Provides masking of user hostnames", VF_COMMON|VF_VENDOR);
+               std::string testcloak;
+               switch (mode)
+               {
+                       case MODE_COMPAT_HOST:
+                               testcloak = prefix + "-" + Hash->sumIV(compatkey, xtab[0], "*").substr(0,10);
+                               break;
+                       case MODE_COMPAT_IPONLY:
+                               testcloak = Hash->sumIV(compatkey, xtab[0], "*").substr(0,10);
+                               break;
+                       case MODE_HALF_CLOAK:
+                               testcloak = prefix + SegmentCloak("*", 3);
+                               break;
+                       case MODE_OPAQUE:
+                       default:
+                               testcloak = prefix + SegmentCloak("*", 4);
+               }
+               return Version("Provides masking of user hostnames", VF_COMMON|VF_VENDOR, testcloak);
        }
 
        void OnRehash(User* user)
index 91f60d3c39cc61890555d7bd70ec0004d8c567ae..de97b6c70dbc39ca0d303990987bcd06e36a5c4e 100644 (file)
@@ -33,8 +33,18 @@ std::string TreeSocket::MyModules(int filter)
        for (unsigned int i = 0; i < modlist.size(); i++)
        {
                if (i)
-                       capabilities = capabilities + ",";
-               capabilities = capabilities + modlist[i];
+                       capabilities.push_back(',');
+               capabilities.append(modlist[i]);
+               Module* m = ServerInstance->Modules->Find(modlist[i]);
+               if (m && proto_version >= 1202)
+               {
+                       Version v = m->GetVersion();
+                       if (!v.link_data.empty())
+                       {
+                               capabilities.push_back('=');
+                               capabilities.append(v.link_data);
+                       }
+               }
        }
        return capabilities;
 }
index b00992eca190160fe1de9fc8ec64c75e128f3468..625a2611e7220f42866e7b7e188628ea6fd4c1b6 100644 (file)
@@ -30,6 +30,7 @@ static const char* const forge_common_1201[] = {
 };
 
 static std::string wide_newline("\r\n");
+static std::string newline("\n");
 
 void TreeSocket::CompatAddModules(std::vector<std::string>& modlist)
 {
@@ -122,5 +123,8 @@ void TreeSocket::WriteLine(std::string line)
 
        ServerInstance->Logs->Log("m_spanningtree",DEBUG, "S[%d] O %s", this->GetFd(), line.c_str());
        this->WriteData(line);
-       this->WriteData(wide_newline);
+       if (proto_version < 1202)
+               this->WriteData(wide_newline);
+       else
+               this->WriteData(newline);
 }
index e05c099670b8e50e73af4c1cf6da97438225dca7..c96bf3bc9bbb72e1bbab43b08c8b61a3b7bef74a 100644 (file)
@@ -218,20 +218,18 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
 void TreeSocket::OnDataReady()
 {
        Utils->Creator->loopCall = true;
-       /* While there is at least one new line in the buffer,
-        * do something useful (we hope!) with it.
-        */
-       while (recvq.find("\n") != std::string::npos)
+       std::string line;
+       while (GetNextLine(line))
        {
-               std::string ret = recvq.substr(0,recvq.find("\n")-1);
-               recvq = recvq.substr(recvq.find("\n")+1,recvq.length()-recvq.find("\n"));
-               /* Use rfind here not find, as theres more
-                * chance of the \r being near the end of the
-                * string, not the start.
-                */
-               if (ret.find("\r") != std::string::npos)
-                       ret = recvq.substr(0,recvq.find("\r")-1);
-               ProcessLine(ret);
+               std::string::size_type rline = line.find('\r');
+               if (rline != std::string::npos)
+                       line = line.substr(0,rline);
+               if (line.find('\0') != std::string::npos)
+               {
+                       SendError("Read null character from socket");
+                       break;
+               }
+               ProcessLine(line);
        }
        Utils->Creator->loopCall = false;
 }