]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_ident.cpp
Update wiki links to use HTTPS and point to the correct pages.
[user/henk/code/inspircd.git] / src / modules / m_ident.cpp
index b046079f0ea36a2bd1c910e21778f53351860ffe..f0ced1db79789ba313711dc97defae384f1dc8b1 100644 (file)
@@ -235,14 +235,20 @@ class IdentRequestSocket : public EventHandler
                 */
                ibuf[recvresult] = '\0';
                std::string buf(ibuf);
-               std::string::size_type lastcolon = buf.rfind(':');
-               if (lastcolon == std::string::npos)
+
+               /* <2 colons: invalid
+                *  2 colons: reply is an error
+                * >3 colons: there is a colon in the ident
+                */
+               if (std::count(buf.begin(), buf.end(), ':') != 3)
                        return;
 
+               std::string::size_type lastcolon = buf.rfind(':');
+
                /* Truncate the ident at any characters we don't like, skip leading spaces */
                for (std::string::const_iterator i = buf.begin()+lastcolon+1; i != buf.end(); ++i)
                {
-                       if (result.size()+1 == ServerInstance->Config->Limits.IdentMax)
+                       if (result.size() == ServerInstance->Config->Limits.IdentMax)
                                /* Ident is getting too long */
                                break;
 
@@ -274,12 +280,13 @@ class ModuleIdent : public Module
 
        void init()
        {
+               ServerInstance->Modules->AddService(ext);
                OnRehash(NULL);
                Implementation eventlist[] = {
                        I_OnRehash, I_OnUserInit, I_OnCheckReady,
                        I_OnUserDisconnect, I_OnSetConnectClass
                };
-               ServerInstance->Modules->Attach(eventlist, this, 5);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
        ~ModuleIdent()
@@ -355,7 +362,7 @@ class ModuleIdent : public Module
                /* wooo, got a result (it will be good, or bad) */
                if (isock->result.empty())
                {
-                       user->ident.insert(0, 1, '~');
+                       user->ident.insert(user->ident.begin(), 1, '~');
                        user->WriteServ("NOTICE Auth :*** Could not find your ident, using %s instead.", user->ident.c_str());
                }
                else
@@ -364,6 +371,7 @@ class ModuleIdent : public Module
                        user->WriteServ("NOTICE Auth :*** Found your ident, '%s'", user->ident.c_str());
                }
 
+               user->InvalidateCache();
                isock->Close();
                ext.unset(user);
                return MOD_RES_PASSTHRU;