diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-14 18:22:39 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-14 18:22:39 +0000 |
commit | ac002a195d35b12218b912d369570aad45c1839f (patch) | |
tree | c63f858d8cf3c740c33514a12d45d4db16e7b5ae /src/modules | |
parent | c84271be2e581bc50aa89ba2185a219cc8154ef0 (diff) |
Verify cloak keys match during CAPAB negotiation
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12258 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_cloaking.cpp | 20 | ||||
-rw-r--r-- | src/modules/m_spanningtree/capab.cpp | 14 | ||||
-rw-r--r-- | src/modules/m_spanningtree/compat.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket1.cpp | 24 |
4 files changed, 45 insertions, 19 deletions
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 1f9854a78..22114c54e 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -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) diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp index 91f60d3c3..de97b6c70 100644 --- a/src/modules/m_spanningtree/capab.cpp +++ b/src/modules/m_spanningtree/capab.cpp @@ -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; } diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp index b00992eca..625a2611e 100644 --- a/src/modules/m_spanningtree/compat.cpp +++ b/src/modules/m_spanningtree/compat.cpp @@ -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); } diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index e05c09967..c96bf3bc9 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -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; } |