aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/m_ident.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-06-29 16:29:56 +0100
committerGravatar Sadie Powell2023-06-29 17:01:25 +0100
commit29705306f21d713c2928d8896f48a3cbb640eacc (patch)
tree5642409ba5a61ab578eb84a11cce5ba81e493187 /src/modules/m_ident.cpp
parentMerge branch 'insp3' into master. (diff)
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.
Diffstat (limited to 'src/modules/m_ident.cpp')
-rw-r--r--src/modules/m_ident.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index 4e324d87c..0cadd3644 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -246,11 +246,11 @@ public:
continue;
/* Add the next char to the result and see if it's still a valid ident,
- * according to IsIdent(). If it isn't, then erase what we just added and
+ * according to IsUser(). If it isn't, then erase what we just added and
* we're done.
*/
result += chr;
- if (!ServerInstance->IsIdent(result))
+ if (!ServerInstance->IsUser(result))
{
result.pop_back();
break;
@@ -280,27 +280,27 @@ private:
SimpleExtItem<IdentRequestSocket, Cullable::Deleter> socket;
IntExtItem state;
- static void PrefixIdent(LocalUser* user)
+ static void PrefixUser(LocalUser* user)
{
// Check that they haven't been prefixed already.
- if (user->ident[0] == '~')
+ if (user->GetRealUser().front() == '~')
return;
// All invalid usernames are prefixed with a tilde.
- std::string newident(user->ident);
- newident.insert(newident.begin(), '~');
+ std::string newuser(user->GetRealUser());
+ newuser.insert(newuser.begin(), '~');
// If the username is too long then truncate it.
- if (newident.length() > ServerInstance->Config->Limits.MaxUser)
- newident.erase(ServerInstance->Config->Limits.MaxUser);
+ if (newuser.length() > ServerInstance->Config->Limits.MaxUser)
+ newuser.erase(ServerInstance->Config->Limits.MaxUser);
// Apply the new username.
- user->ChangeIdent(newident);
+ user->ChangeRealUser(newuser, user->GetDisplayedUser() == user->GetRealUser());
}
public:
ModuleIdent()
- : Module(VF_VENDOR, "Allows the usernames (idents) of users to be looked up using the RFC 1413 Identification Protocol.")
+ : Module(VF_VENDOR, "Allows the usernames of users to be looked up using the RFC 1413 Identification Protocol.")
, socket(this, "ident-socket", ExtensionType::USER)
, state(this, "ident-state", ExtensionType::USER)
{
@@ -362,7 +362,7 @@ public:
{
if (prefixunqueried && state.Get(user) == IDENT_SKIPPED)
{
- PrefixIdent(user);
+ PrefixUser(user);
state.Set(user, IDENT_PREFIXED);
}
return MOD_RES_PASSTHRU;
@@ -375,8 +375,8 @@ public:
{
/* Ident timeout */
state.Set(user, IDENT_MISSING);
- PrefixIdent(user);
- user->WriteNotice("*** Ident lookup timed out, using " + user->ident + " instead.");
+ PrefixUser(user);
+ user->WriteNotice("*** Ident lookup timed out, using " + user->GetRealUser() + " instead.");
}
else if (!isock->HasResult())
{
@@ -388,14 +388,14 @@ public:
else if (isock->result.empty())
{
state.Set(user, IDENT_MISSING);
- PrefixIdent(user);
- user->WriteNotice("*** Could not find your ident, using " + user->ident + " instead.");
+ PrefixUser(user);
+ user->WriteNotice("*** Could not find your ident, using " + user->GetRealUser() + " instead.");
}
else
{
state.Set(user, IDENT_FOUND);
- user->ChangeIdent(isock->result);
- user->WriteNotice("*** Found your ident, '" + user->ident + "'");
+ user->ChangeRealUser(isock->result, user->GetDisplayedUser() == user->GetRealUser());
+ user->WriteNotice("*** Found your ident, '" + user->GetRealUser() + "'");
}
isock->Close();