diff options
| author | 2019-01-18 13:12:00 +0000 | |
|---|---|---|
| committer | 2019-02-04 09:16:40 +0000 | |
| commit | 3b9ef1ae8dcaf2d36f0e31e8b39fe5cfea304d74 (patch) | |
| tree | d695c00ffcd7a2b1ff6ab1474f19b6dff872a2b4 /src/modules/m_ident.cpp | |
| parent | Allow multiple fingerprints in an oper block (#1564) (diff) | |
| download | inspircd++-3b9ef1ae8dcaf2d36f0e31e8b39fe5cfea304d74.tar.gz inspircd++-3b9ef1ae8dcaf2d36f0e31e8b39fe5cfea304d74.tar.bz2 inspircd++-3b9ef1ae8dcaf2d36f0e31e8b39fe5cfea304d74.zip | |
ident: Fix making idents longer than maxident when a lookup fails.
Diffstat (limited to 'src/modules/m_ident.cpp')
| -rw-r--r-- | src/modules/m_ident.cpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 803c19846..302db0d97 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -254,9 +254,29 @@ class IdentRequestSocket : public EventHandler class ModuleIdent : public Module { + private: int RequestTimeout; bool NoLookupPrefix; SimpleExtItem<IdentRequestSocket, stdalgo::culldeleter> ext; + + static void PrefixIdent(LocalUser* user) + { + // Check that they haven't been prefixed already. + if (user->ident[0] == '~') + return; + + // All invalid usernames are prefixed with a tilde. + std::string newident(user->ident); + newident.insert(newident.begin(), '~'); + + // If the username is too long then truncate it. + if (newident.length() > ServerInstance->Config->Limits.IdentMax) + newident.erase(ServerInstance->Config->Limits.IdentMax); + + // Apply the new username. + user->ChangeIdent(newident); + } + public: ModuleIdent() : ext("ident_socket", ExtensionItem::EXT_USER, this) @@ -320,8 +340,8 @@ class ModuleIdent : public Module IdentRequestSocket *isock = ext.get(user); if (!isock) { - if ((NoLookupPrefix) && (user->ident[0] != '~')) - user->ident.insert(user->ident.begin(), 1, '~'); + if (NoLookupPrefix) + PrefixIdent(user); return MOD_RES_PASSTHRU; } @@ -343,7 +363,7 @@ class ModuleIdent : public Module /* wooo, got a result (it will be good, or bad) */ if (isock->result.empty()) { - user->ident.insert(user->ident.begin(), 1, '~'); + PrefixIdent(user); user->WriteNotice("*** Could not find your ident, using " + user->ident + " instead."); } else |
