aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree
diff options
context:
space:
mode:
authorGravatar Sadie Powell2024-07-24 19:26:54 +0100
committerGravatar Sadie Powell2024-07-24 19:26:54 +0100
commitcaab65a8313e1c7312583503e58586b7619ab788 (patch)
tree7a424990de263fc8c61090203f2a0b9b09bf0efb /src/modules/m_spanningtree
parentRun irctest against Anope 2.1. (diff)
Move 1205 UID compatibility code to PreProcessOldProtocolMessage.
This should make it more reliable.
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r--src/modules/m_spanningtree/commands.h2
-rw-r--r--src/modules/m_spanningtree/compat.cpp9
-rw-r--r--src/modules/m_spanningtree/uid.cpp13
3 files changed, 16 insertions, 8 deletions
diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h
index c02f3b0d3..8c9c83d87 100644
--- a/src/modules/m_spanningtree/commands.h
+++ b/src/modules/m_spanningtree/commands.h
@@ -93,7 +93,7 @@ class CommandUID final
{
public:
CommandUID(Module* Creator)
- : ServerOnlyServerCommand<CommandUID>(Creator, "UID", 10)
+ : ServerOnlyServerCommand<CommandUID>(Creator, "UID", 11)
{
}
CmdResult HandleServer(TreeServer* server, CommandBase::Params& params);
diff --git a/src/modules/m_spanningtree/compat.cpp b/src/modules/m_spanningtree/compat.cpp
index 8bfe1a15e..145d3667e 100644
--- a/src/modules/m_spanningtree/compat.cpp
+++ b/src/modules/m_spanningtree/compat.cpp
@@ -151,5 +151,14 @@ bool TreeSocket::PreProcessOldProtocolMessage(User*& who, std::string& cmd, Comm
params.insert(params.begin(), { target->uuid.substr(0, 3), cmd });
cmd = "ENCAP";
}
+ else if (irc::equals(cmd, "UID"))
+ {
+ if (params.size() < 6)
+ return false; // Malformed.
+
+ // :<sid> UID <uuid> <nickchanged> <nick> <host> <dhost> <user> <duser> <ip.string> <signon> <modes> [<modepara>] :<real>
+ // ^^^^^^ New in 1206
+ params.insert(params.begin() + 5, params[5]);
+ }
return true;
}
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index 8425984fb..8076fa968 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -38,10 +38,9 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, CommandBase::Params
*
* The `duser` field was introduced in the 1206 (v4) protocol.
*/
- size_t offset = params[9][0] == '+' ? 1 : 0;
time_t nickchanged = ServerCommand::ExtractTS(params[1]);
- time_t signon = ServerCommand::ExtractTS(params[7+offset]);
- const std::string& modestr = params[8+offset];
+ time_t signon = ServerCommand::ExtractTS(params[8]);
+ const std::string& modestr = params[9];
// Check if the length of the uuid is correct and confirm the sid portion of the uuid matches the sid of the server introducing the user
if (params[0].length() != UIDGenerator::UUID_LENGTH || params[0].compare(0, 3, remoteserver->GetId()))
@@ -62,7 +61,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, CommandBase::Params
else if (collideswith)
{
// The user on this side is fully connected, handle the collision
- bool they_change = SpanningTreeUtilities::DoCollision(collideswith, remoteserver, nickchanged, params[5], params[6+offset], params[0], "UID");
+ bool they_change = SpanningTreeUtilities::DoCollision(collideswith, remoteserver, nickchanged, params[5], params[7], params[0], "UID");
if (they_change)
{
// The client being introduced needs to change nick to uuid, change the nick in the message before
@@ -74,7 +73,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, CommandBase::Params
}
irc::sockets::sockaddrs sa(false);
- if (!sa.from(params[6+offset]))
+ if (!sa.from(params[7]))
throw ProtocolException("Invalid IP address or UNIX socket path");
/* For remote users, we pass the UUID they sent to the constructor.
@@ -86,14 +85,14 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, CommandBase::Params
_new->ChangeRealHost(params[3], false);
_new->ChangeDisplayedHost(params[4]);
_new->ChangeRealUser(params[5], false);
- _new->ChangeDisplayedUser(params[5+offset]);
+ _new->ChangeDisplayedUser(params[6]);
_new->ChangeRemoteAddress(sa);
_new->ChangeRealName(params.back());
_new->connected = User::CONN_FULL;
_new->signon = signon;
_new->nickchanged = nickchanged;
- size_t paramptr = 9 + offset;
+ size_t paramptr = 10;
for (const auto& modechr : modestr)
{
// Accept more '+' chars, for now