From 29705306f21d713c2928d8896f48a3cbb640eacc Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 29 Jun 2023 16:29:56 +0100 Subject: Retain the "real" username properly like we do for hostnames. This introduces the concept of a real username. This value comes from either the initial USER message or from an ident lookup. Doing this allows us to use it for bans through vidents and cloaking web client users using their remote username. While changing this I also changed all of the uses of "ident" other than RFC 1413 lookups and some compatibility cases to refer to usernames as user(name) instead of ident. Our use of ident in these places was incorrect as that only refers to the RFC 1413 response and is not commonly used in the way we used it by any other IRC server implementations. --- src/modules/m_spanningtree/main.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/modules/m_spanningtree/main.cpp') diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 4ec4b5c79..704d23ac6 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -502,7 +502,22 @@ void ModuleSpanningTree::OnUserConnect(LocalUser* user) if (sslapi) sslapi->GetCertificate(user); - CommandUID::Builder(user).Broadcast(); + 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); + } if (user->IsOper()) CommandOpertype::Builder(user, user->oper).Broadcast(); @@ -578,12 +593,12 @@ void ModuleSpanningTree::OnChangeRealName(User* user, const std::string& real) CmdBuilder(user, "FNAME").push_last(real).Broadcast(); } -void ModuleSpanningTree::OnChangeIdent(User* user, const std::string& ident) +void ModuleSpanningTree::OnChangeUser(User* user, const std::string& newuser) { if (!user->IsFullyConnected() || !IS_LOCAL(user)) return; - CmdBuilder(user, "FIDENT").push(ident).Broadcast(); + CmdBuilder(user, "FIDENT").push(newuser).Broadcast(); } void ModuleSpanningTree::OnUserPart(Membership* memb, std::string& partmessage, CUList& excepts) -- cgit v1.3.1-10-gc9f91