]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_cloaking.cpp
Remove NULL checks from various Channel functions
[user/henk/code/inspircd.git] / src / modules / m_cloaking.cpp
index 3ad0c7ab31123b529e4dc9e73a523ff2eaf01d8b..ccc98e557e7ca96e99ff5b26c0c4b8c6c55ca25e 100644 (file)
@@ -24,7 +24,7 @@
 
 
 #include "inspircd.h"
-#include "hash.h"
+#include "modules/hash.h"
 
 /* $ModDesc: Provides masking of user hostnames */
 
@@ -45,7 +45,6 @@ class CloakUser : public ModeHandler
 {
  public:
        LocalStringExt ext;
-
        std::string debounce_uid;
        time_t debounce_ts;
        int debounce_count;
@@ -119,7 +118,6 @@ class CloakUser : public ModeHandler
                        return MODEACTION_ALLOW;
                }
        }
-
 };
 
 class CommandCloak : public Command
@@ -150,7 +148,7 @@ class ModuleCloaking : public Module
        {
        }
 
-       void init()
+       void init() CXX11_OVERRIDE
        {
                OnRehash(NULL);
 
@@ -286,7 +284,7 @@ class ModuleCloaking : public Module
                return rv;
        }
 
-       ModResult OnCheckBan(User* user, Channel* chan, const std::string& mask)
+       ModResult OnCheckBan(User* user, Channel* chan, const std::string& mask) CXX11_OVERRIDE
        {
                LocalUser* lu = IS_LOCAL(user);
                if (!lu)
@@ -297,9 +295,8 @@ class ModuleCloaking : public Module
                /* Check if they have a cloaked host, but are not using it */
                if (cloak && *cloak != user->dhost)
                {
-                       char cmask[MAXBUF];
-                       snprintf(cmask, MAXBUF, "%s!%s@%s", user->nick.c_str(), user->ident.c_str(), cloak->c_str());
-                       if (InspIRCd::Match(cmask,mask))
+                       const std::string cloakMask = user->nick + "!" + user->ident + "@" + *cloak;
+                       if (InspIRCd::Match(cloakMask, mask))
                                return MOD_RES_DENY;
                }
                return MOD_RES_PASSTHRU;
@@ -313,7 +310,7 @@ class ModuleCloaking : public Module
 
        // this unsets umode +x on every host change. If we are actually doing a +x
        // mode change, we will call SetMode back to true AFTER the host change is done.
-       void OnChangeHost(User* u, const std::string& host)
+       void OnChangeHost(User* u, const std::string& host) CXX11_OVERRIDE
        {
                if(u->IsModeSet('x'))
                {
@@ -322,11 +319,7 @@ class ModuleCloaking : public Module
                }
        }
 
-       ~ModuleCloaking()
-       {
-       }
-
-       Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
                std::string testcloak = "broken";
                if (Hash)
@@ -343,7 +336,7 @@ class ModuleCloaking : public Module
                return Version("Provides masking of user hostnames", VF_COMMON|VF_VENDOR, testcloak);
        }
 
-       void OnRehash(User* user)
+       void OnRehash(User* user) CXX11_OVERRIDE
        {
                ConfigTag* tag = ServerInstance->Config->ConfValue("cloak");
                prefix = tag->getString("prefix");
@@ -383,7 +376,7 @@ class ModuleCloaking : public Module
                return chost;
        }
 
-       void OnUserConnect(LocalUser* dest)
+       void OnUserConnect(LocalUser* dest) CXX11_OVERRIDE
        {
                std::string* cloak = cu.ext.get(dest);
                if (cloak)
@@ -404,7 +397,7 @@ CmdResult CommandCloak::Handle(const std::vector<std::string> &parameters, User
        else
                cloak = mod->GenCloak(sa, "", parameters[0]);
 
-       user->WriteServ("NOTICE %s :*** Cloak for %s is %s", user->nick.c_str(), parameters[0].c_str(), cloak.c_str());
+       user->WriteNotice("*** Cloak for " + parameters[0] + " is " + cloak);
 
        return CMD_SUCCESS;
 }