Fix broadcasting UID messages to v3 servers.

We have to use the compat layer here as broadcast messages do not
go through the command builder.
This commit is contained in:
Sadie Powell 2024-07-20 12:31:31 +01:00
parent dafaa684e1
commit 42fdbb7234
5 changed files with 18 additions and 21 deletions

View File

@ -102,7 +102,7 @@ public:
: public CmdBuilder
{
public:
Builder(User* user, bool real_user);
Builder(User* user);
};
};

View File

@ -114,6 +114,19 @@ void TreeSocket::WriteLine(const std::string& original_line)
// SQUERY was introduced in PROTO_INSPIRCD_4; convert to PRIVMSG.
line.replace(cmdstart, 6, "PRIVMSG");
}
else if (irc::equals(command, "UID"))
{
// :<sid> UID <uuid> <nickchanged> <nick> <host> <dhost> <user> <duser> <ip.string> <signon> <modes> [<modepara>] :<real>
// ^^^^^^ New in 1206
size_t uuidend = NextToken(line, cmdend);
size_t nickchangedend = NextToken(line, uuidend);
size_t nickend = NextToken(line, nickchangedend);
size_t hostend = NextToken(line, nickend);
size_t dhostend = NextToken(line, hostend);
size_t userend = NextToken(line, dhostend);
if (userend != std::string::npos)
line.erase(dhostend, userend - dhostend);
}
}
WriteLineInternal(line);

View File

@ -497,22 +497,7 @@ void ModuleSpanningTree::OnUserConnect(LocalUser* user)
if (sslapi)
sslapi->GetCertificate(user);
CommandUID::Builder uid(user, true);
CommandUID::Builder olduid(user, false);
// NOTE: we can't do CommandUID::Builder(user).Broadcast() whilst
// we still support the 1205 protocol.
for (const auto* server : Utils->TreeRoot->GetChildren())
{
TreeSocket* socket = server->GetSocket();
if (!socket)
continue; // Should never happen?
if (socket->proto_version >= PROTO_INSPIRCD_4)
socket->WriteLine(uid);
else
socket->WriteLine(olduid);
}
CommandUID::Builder(user).Broadcast();
if (user->IsOper())
CommandOpertype::Builder(user, user->oper).Broadcast();

View File

@ -282,7 +282,7 @@ void TreeSocket::SendUsers(BurstState& bs)
if (!user->IsFullyConnected())
continue;
this->WriteLine(CommandUID::Builder(user, this->proto_version != PROTO_INSPIRCD_3));
this->WriteLine(CommandUID::Builder(user));
if (user->IsOper())
this->WriteLine(CommandOpertype::Builder(user, user->oper));

View File

@ -177,7 +177,7 @@ CmdResult CommandFName::HandleRemote(RemoteUser* src, Params& params)
return CmdResult::SUCCESS;
}
CommandUID::Builder::Builder(User* user, bool real_user)
CommandUID::Builder::Builder(User* user)
: CmdBuilder(TreeServer::Get(user), "UID")
{
push(user->uuid);
@ -185,8 +185,7 @@ CommandUID::Builder::Builder(User* user, bool real_user)
push(user->nick);
push(user->GetRealHost());
push(user->GetDisplayedHost());
if (real_user)
push(user->GetRealUser());
push(user->GetRealUser());
push(user->GetDisplayedUser());
push(user->GetAddress());
push_int(user->signon);