summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree/compat.cpp
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-04-12 16:40:16 +0200
committerattilamolnar <attilamolnar@hush.com>2013-04-13 16:22:03 +0200
commit1626437cbf963b16ce44ef6cc829957fd3a7e2ff (patch)
tree1ea562260984c5c049bb5ea3f5b9ec8215a603ac /src/modules/m_spanningtree/compat.cpp
parentdebe102133f478e2fbff597f6da92215bb8c2524 (diff)
m_spanningtree Introduce IJOIN and RESYNC
When a local user joins an existing channel, instead of an FJOIN, send an IJOIN with the channel name being the first parameter. If the joining user received prefix modes, append the channel TS and the prefix mode letters as the second and third parameters. When receiving an IJOIN, first check if the target channel exists. If it does not exist, ignore the join (that is, do not create the channel) and send a RESYNC back to the source. If the channel does exist then join the user, and in case any prefix modes were sent (found in the 3rd parameter), compare the TS of the channel to the TS in the IJOIN (2nd parameter). If the timestamps match, set the modes on the user, otherwise ignore the modes. Outgoing IJOINs to 1202 protocol servers are converted to FJOINs, but the channel mode parameter is left empty ("+").
Diffstat (limited to 'src/modules/m_spanningtree/compat.cpp')
-rw-r--r--src/modules/m_spanningtree/compat.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp
index 32bdb3df8..bfc2d1560 100644
--- a/src/modules/m_spanningtree/compat.cpp
+++ b/src/modules/m_spanningtree/compat.cpp
@@ -39,6 +39,58 @@ void TreeSocket::WriteLine(std::string line)
std::string command = line.substr(a + 1, b-a-1);
// now try to find a translation entry
// TODO a more efficient lookup method will be needed later
+ if (proto_version < 1205)
+ {
+ if (command == "IJOIN")
+ {
+ // Convert
+ // :<uid> IJOIN <chan> [<ts> [<flags>]]
+ // to
+ // :<sid> FJOIN <chan> <ts> + [<flags>],<uuid>
+ std::string::size_type c = line.find(' ', b + 1);
+ if (c == std::string::npos)
+ {
+ // No TS or modes in the command
+ // :22DAAAAAB IJOIN #chan
+ const std::string channame = line.substr(b+1, c-b-1);
+ Channel* chan = ServerInstance->FindChan(channame);
+ if (!chan)
+ return;
+
+ line.push_back(' ');
+ line.append(ConvToStr(chan->age));
+ line.append(" + ,");
+ }
+ else
+ {
+ std::string::size_type d = line.find(' ', c + 1);
+ if (d == std::string::npos)
+ {
+ // TS present, no modes
+ // :22DAAAAAC IJOIN #chan 12345
+ line.append(" + ,");
+ }
+ else
+ {
+ // Both TS and modes are present
+ // :22DAAAAAC IJOIN #chan 12345 ov
+ std::string::size_type e = line.find(' ', d + 1);
+ if (e != std::string::npos)
+ line.erase(e);
+
+ line.insert(d, " +");
+ line.push_back(',');
+ }
+ }
+
+ // Move the uuid to the end and replace the I with an F
+ line.append(line.substr(1, 9));
+ line.erase(4, 6);
+ line[5] = 'F';
+ }
+ else if (command == "RESYNC")
+ return;
+ }
}
}