diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-06-10 17:37:16 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-06-10 17:37:16 +0200 |
commit | ad6a02809585ac1ad805e66b8aa0113815d9a957 (patch) | |
tree | daee27037992f73baa82a2c19a9d40bbf3fa97f4 /src/modules/m_spanningtree/compat.cpp | |
parent | a63882846432fda67e6282e979ab8ad248f4b574 (diff) |
Add channel TS to server-to-server INVITE to detect and drop unauthorized invites
The syntax of the server-to-server INVITE command changes from
:<source> INVITE <target> <channel> [<expire>]
to
:<source> INVITE <target> <channel> <chants> [<expire>]
Diffstat (limited to 'src/modules/m_spanningtree/compat.cpp')
-rw-r--r-- | src/modules/m_spanningtree/compat.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp index 98b6826e2..ca9fbfa6a 100644 --- a/src/modules/m_spanningtree/compat.cpp +++ b/src/modules/m_spanningtree/compat.cpp @@ -169,6 +169,25 @@ void TreeSocket::WriteLine(const std::string& original_line) line.erase(colon, 1); } } + else if (command == "INVITE") + { + // :22D INVITE 22DAAAAAN #chan TS ExpirationTime + // A B C D E + if (b == std::string::npos) + return; + + std::string::size_type c = line.find(' ', b + 1); + if (c == std::string::npos) + return; + + std::string::size_type d = line.find(' ', c + 1); + if (d == std::string::npos) + return; + + std::string::size_type e = line.find(' ', d + 1); + // If there is no expiration time then everything will be erased from 'd' + line.erase(d, e-d); + } } ServerInstance->Logs->Log(MODNAME, LOG_RAWIO, "S[%d] O %s", this->GetFd(), line.c_str()); this->WriteData(line); @@ -297,6 +316,13 @@ bool TreeSocket::PreProcessOldProtocolMessage(User*& who, std::string& cmd, std: { return false; } + else if (cmd == "INVITE") + { + // :20D INVITE 22DAAABBB #chan + // :20D INVITE 22DAAABBB #chan 123456789 + // Insert channel timestamp after the channel name; the 3rd parameter, if there, is the invite expiration time + return InsertCurrentChannelTS(params, 1, 2); + } return true; // Passthru } |