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/nickcollide.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/modules/m_spanningtree/nickcollide.cpp') diff --git a/src/modules/m_spanningtree/nickcollide.cpp b/src/modules/m_spanningtree/nickcollide.cpp index 97a63e7e3..8ac7f1048 100644 --- a/src/modules/m_spanningtree/nickcollide.cpp +++ b/src/modules/m_spanningtree/nickcollide.cpp @@ -38,7 +38,7 @@ * Sends SAVEs as appropriate and forces nick change of the user 'u' if our side loses or if both lose. * Does not change the nick of the user that is trying to claim the nick of 'u', i.e. the "remote" user. */ -bool SpanningTreeUtilities::DoCollision(User* u, TreeServer* server, time_t remotets, const std::string& remoteident, const std::string& remoteip, const std::string& remoteuid, const char* collidecmd) +bool SpanningTreeUtilities::DoCollision(User* u, TreeServer* server, time_t remotets, const std::string& remoteuser, const std::string& remoteip, const std::string& remoteuid, const char* collidecmd) { // At this point we're sure that a collision happened, increment the counter regardless of who wins ServerInstance->stats.Collisions++; @@ -68,15 +68,15 @@ bool SpanningTreeUtilities::DoCollision(User* u, TreeServer* server, time_t remo const time_t localts = u->nickchanged; if (remotets != localts) { - /* first, let's see if ident@host matches. */ - const std::string& localident = u->ident; + /* first, let's see if user@host matches. */ + const std::string& localuser = u->GetRealUser(); const std::string& localip = u->GetAddress(); - bool SamePerson = (localident == remoteident) + bool SamePerson = (localuser == remoteuser) && (localip == remoteip); /* - * if ident@ip is equal, and theirs is newer, or - * ident@ip differ, and ours is newer + * if user@ip is equal, and theirs is newer, or + * user@ip differ, and ours is newer */ if ((SamePerson && remotets < localts) || (!SamePerson && remotets > localts)) { @@ -91,8 +91,8 @@ bool SpanningTreeUtilities::DoCollision(User* u, TreeServer* server, time_t remo } ServerInstance->Logs.Debug(MODNAME, "Nick collision on \"{}\" caused by {}: {}/{}/{}@{} {} <-> {}/{}/{}@{} {}", u->nick, collidecmd, - u->uuid, localts, u->ident, u->GetAddress(), bChangeLocal, - remoteuid, remotets, remoteident, remoteip, bChangeRemote); + u->uuid, localts, u->GetRealUser(), u->GetAddress(), bChangeLocal, + remoteuid, remotets, remoteuser, remoteip, bChangeRemote); /* * Send SAVE and accept the losing client with its UID (as we know the SAVE will -- cgit v1.3.1-10-gc9f91