]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_ldapoper.cpp
Change httpd modules to use the MODNAME constant in headers.
[user/henk/code/inspircd.git] / src / modules / extra / m_ldapoper.cpp
index 53896878c5e1b255b7bf085b493091d92ba515d5..68e4cbf9f6e2c53aafec310bb17707cce06153bb 100644 (file)
 # pragma comment(lib, "lber.lib")
 #endif
 
-/* $ModDesc: Adds the ability to authenticate opers via LDAP */
 /* $LinkerFlags: -lldap */
 
-// Duplicated code, also found in cmd_oper and m_sqloper
-static bool OneOfMatches(const char* host, const char* ip, const std::string& hostlist)
-{
-       std::stringstream hl(hostlist);
-       std::string xhost;
-       while (hl >> xhost)
-       {
-               if (InspIRCd::Match(host, xhost, ascii_case_insensitive_map) || InspIRCd::MatchCIDR(ip, xhost, ascii_case_insensitive_map))
-               {
-                       return true;
-               }
-       }
-       return false;
-}
-
 struct RAIILDAPString
 {
        char *str;
@@ -97,7 +81,7 @@ class ModuleLDAPAuth : public Module
 
                std::string acceptedhosts = tag->getString("host");
                std::string hostname = user->ident + "@" + user->host;
-               if (!OneOfMatches(hostname.c_str(), user->GetIPString(), acceptedhosts))
+               if (!InspIRCd::MatchMask(acceptedhosts, hostname, user->GetIPString()))
                        return false;
 
                if (!LookupOper(opername, inputpass))
@@ -113,20 +97,20 @@ public:
        {
        }
 
-       void init()
+       void init() CXX11_OVERRIDE
        {
                Implementation eventlist[] = { I_OnRehash, I_OnPreCommand };
                ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
                OnRehash(NULL);
        }
 
-       virtual ~ModuleLDAPAuth()
+       ~ModuleLDAPAuth()
        {
                if (conn)
                        ldap_unbind_ext(conn, NULL, NULL);
        }
 
-       virtual void OnRehash(User* user)
+       void OnRehash(User* user) CXX11_OVERRIDE
        {
                ConfigTag* tag = ServerInstance->Config->ConfValue("ldapoper");
 
@@ -168,7 +152,7 @@ public:
                return true;
        }
 
-       ModResult OnPreCommand(std::string& command, std::vector<std::string>& parameters, LocalUser* user, bool validated, const std::string& original_line)
+       ModResult OnPreCommand(std::string& command, std::vector<std::string>& parameters, LocalUser* user, bool validated, const std::string& original_line) CXX11_OVERRIDE
        {
                if (validated && command == "OPER" && parameters.size() >= 2)
                {
@@ -245,7 +229,7 @@ public:
                }
        }
 
-       virtual Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Adds the ability to authenticate opers via LDAP", VF_VENDOR);
        }