]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Make more config stuff case insensitive.
authorPeter Powell <petpow@saberuk.com>
Tue, 24 Jul 2018 17:29:43 +0000 (18:29 +0100)
committerPeter Powell <petpow@saberuk.com>
Tue, 24 Jul 2018 20:55:10 +0000 (21:55 +0100)
20 files changed:
src/configparser.cpp
src/listensocket.cpp
src/logger.cpp
src/modules/extra/m_ldap.cpp
src/modules/extra/m_mysql.cpp
src/modules/extra/m_pgsql.cpp
src/modules/extra/m_regex_stdlib.cpp
src/modules/extra/m_sqlite3.cpp
src/modules/extra/m_ssl_gnutls.cpp
src/modules/extra/m_ssl_mbedtls.cpp
src/modules/extra/m_ssl_openssl.cpp
src/modules/m_blockamsg.cpp
src/modules/m_cloaking.cpp
src/modules/m_dccallow.cpp
src/modules/m_dnsbl.cpp
src/modules/m_flashpolicyd.cpp
src/modules/m_httpd.cpp
src/modules/m_httpd_acl.cpp
src/modules/m_spanningtree/utils.cpp
src/users.cpp

index 627cd78e19a1961dc89e173ca0a5a557a300e161..8250530443c7b38c96aadd93336c21929f8910a5 100644 (file)
@@ -213,25 +213,25 @@ struct Parser
                        mandatory_tag.clear();
                }
 
-               if (name == "include")
+               if (stdalgo::string::equalsci(name, "include"))
                {
                        stack.DoInclude(tag, flags);
                }
-               else if (name == "files")
+               else if (stdalgo::string::equalsci(name, "files"))
                {
                        for(ConfigItems::iterator i = items->begin(); i != items->end(); i++)
                        {
                                stack.DoReadFile(i->first, i->second, flags, false);
                        }
                }
-               else if (name == "execfiles")
+               else if (stdalgo::string::equalsci(name, "execfiles"))
                {
                        for(ConfigItems::iterator i = items->begin(); i != items->end(); i++)
                        {
                                stack.DoReadFile(i->first, i->second, flags, true);
                        }
                }
-               else if (name == "define")
+               else if (stdalgo::string::equalsci(name, "define"))
                {
                        if (flags & FLAG_USE_COMPAT)
                                throw CoreException("<define> tags may only be used in XML-style config (add <config format=\"xml\">)");
@@ -241,12 +241,12 @@ struct Parser
                                throw CoreException("Variable definition must include variable name");
                        stack.vars[varname] = value;
                }
-               else if (name == "config")
+               else if (stdalgo::string::equalsci(name, "config"))
                {
                        std::string format = tag->getString("format");
-                       if (format == "xml")
+                       if (stdalgo::string::equalsci(format, "xml"))
                                flags &= ~FLAG_USE_COMPAT;
-                       else if (format == "compat")
+                       else if (stdalgo::string::equalsci(format, "compat"))
                                flags |= FLAG_USE_COMPAT;
                        else if (!format.empty())
                                throw CoreException("Unknown configuration format " + format);
index 5ecaab460c4850949e689bff6b5baa77afedfee5..60ee0b449c0d24ef3c1b1452a78f7c23009aa3e3 100644 (file)
@@ -183,7 +183,7 @@ void ListenSocket::OnEventHandlerRead()
        if (res == MOD_RES_PASSTHRU)
        {
                std::string type = bind_tag->getString("type", "clients");
-               if (type == "clients")
+               if (stdalgo::string::equalsci(type, "clients"))
                {
                        ServerInstance->Users->AddUser(incomingSockfd, this, &client, &server);
                        res = MOD_RES_ALLOW;
index 22896bd4f31204b99f096f43d83004605fc8c685..b9f9bae0b7c866795d0382b593524bd7807543ec 100644 (file)
@@ -77,35 +77,35 @@ void LogManager::OpenFileLogs()
        {
                ConfigTag* tag = i->second;
                std::string method = tag->getString("method");
-               if (method != "file")
+               if (!stdalgo::string::equalsci(method, "file"))
                {
                        continue;
                }
                std::string type = tag->getString("type");
                std::string level = tag->getString("level");
                LogLevel loglevel = LOG_DEFAULT;
-               if (level == "rawio")
+               if (stdalgo::string::equalsci(level, "rawio"))
                {
                        loglevel = LOG_RAWIO;
                        ServerInstance->Config->RawLog = true;
                }
-               else if (level == "debug")
+               else if (stdalgo::string::equalsci(level, "debug"))
                {
                        loglevel = LOG_DEBUG;
                }
-               else if (level == "verbose")
+               else if (stdalgo::string::equalsci(level, "verbose"))
                {
                        loglevel = LOG_VERBOSE;
                }
-               else if (level == "default")
+               else if (stdalgo::string::equalsci(level, "default"))
                {
                        loglevel = LOG_DEFAULT;
                }
-               else if (level == "sparse")
+               else if (stdalgo::string::equalsci(level, "sparse"))
                {
                        loglevel = LOG_SPARSE;
                }
-               else if (level == "none")
+               else if (stdalgo::string::equalsci(level, "none"))
                {
                        loglevel = LOG_NONE;
                }
index f3ace540932854886f6f70699a1b160a34166170..8c2752dbf3bea78f4b9a695a2b26b926a1caad5b 100644 (file)
@@ -258,9 +258,9 @@ class LDAPService : public LDAPProvider, public SocketThread
                , con(NULL), config(tag), last_connect(0)
        {
                std::string scope = config->getString("searchscope");
-               if (scope == "base")
+               if (stdalgo::string::equalsci(scope, "base"))
                        searchscope = LDAP_SCOPE_BASE;
-               else if (scope == "onelevel")
+               else if (stdalgo::string::equalsci(scope, "onelevel"))
                        searchscope = LDAP_SCOPE_ONELEVEL;
                else
                        searchscope = LDAP_SCOPE_SUBTREE;
@@ -533,7 +533,7 @@ class ModuleLDAP : public Module
                {
                        const reference<ConfigTag>& tag = i->second;
 
-                       if (tag->getString("module") != "ldap")
+                       if (!stdalgo::string::equalsci(tag->getString("module"), "ldap"))
                                continue;
 
                        std::string id = tag->getString("id");
index 9f17c142662b9573d6bf7ba59926ac386097ee54..45ba67e4ebf23d48b53f5e99313246afff38292a 100644 (file)
@@ -427,7 +427,7 @@ void ModuleSQL::ReadConfig(ConfigStatus& status)
        ConfigTagList tags = ServerInstance->Config->ConfTags("database");
        for(ConfigIter i = tags.first; i != tags.second; i++)
        {
-               if (i->second->getString("module", "mysql") != "mysql")
+               if (!stdalgo::string::equalsci(i->second->getString("provider"), "mysql"))
                        continue;
                std::string id = i->second->getString("id");
                ConnMap::iterator curr = connections.find(id);
index 8beea1265ad011aada3c548153cd263228001e2c..220168b84d719234c32aedf2d6ba805afb4f0f6a 100644 (file)
@@ -546,7 +546,7 @@ class ModulePgSQL : public Module
                ConfigTagList tags = ServerInstance->Config->ConfTags("database");
                for(ConfigIter i = tags.first; i != tags.second; i++)
                {
-                       if (i->second->getString("module", "pgsql") != "pgsql")
+                       if (!stdalgo::string::equalsci(i->second->getString("provider"), "pgsql"))
                                continue;
                        std::string id = i->second->getString("id");
                        ConnMap::iterator curr = connections.find(id);
index 7a888ed722b77b0523ec321a44372b71d76d03b8..42e5c8bf12106ec09984e4582e39d2a339ef2138 100644 (file)
@@ -74,19 +74,19 @@ public:
                ConfigTag* Conf = ServerInstance->Config->ConfValue("stdregex");
                std::string regextype = Conf->getString("type", "ecmascript");
 
-               if(regextype == "bre")
+               if (stdalgo::string::equalsci(regextype, "bre"))
                        ref.regextype = std::regex::basic;
-               else if(regextype == "ere")
+               else if (stdalgo::string::equalsci(regextype, "ere"))
                        ref.regextype = std::regex::extended;
-               else if(regextype == "awk")
+               else if (stdalgo::string::equalsci(regextype, "awk"))
                        ref.regextype = std::regex::awk;
-               else if(regextype == "grep")
+               else if (stdalgo::string::equalsci(regextype, "grep"))
                        ref.regextype = std::regex::grep;
-               else if(regextype == "egrep")
+               else if (stdalgo::string::equalsci(regextype, "egrep"))
                        ref.regextype = std::regex::egrep;
                else
                {
-                       if(regextype != "ecmascript")
+                       if (!stdalgo::string::equalsci(regextype, "ecmascript"))
                                ServerInstance->SNO->WriteToSnoMask('a', "WARNING: Non-existent regex engine '%s' specified. Falling back to ECMAScript.", regextype.c_str());
                        ref.regextype = std::regex::ECMAScript;
                }
index 31821045d39f1261dadf04c95039028b41131bee..2029181bffc34150310b69efebc056649eb5e4d9 100644 (file)
@@ -254,7 +254,7 @@ class ModuleSQLite3 : public Module
                ConfigTagList tags = ServerInstance->Config->ConfTags("database");
                for(ConfigIter i = tags.first; i != tags.second; i++)
                {
-                       if (i->second->getString("module", "sqlite") != "sqlite")
+                       if (!stdalgo::string::equalsci(i->second->getString("provider"), "sqlite"))
                                continue;
                        SQLConn* conn = new SQLConn(this, i->second);
                        conns.insert(std::make_pair(i->second->getString("id"), conn));
index 51410cfb23423e21e2ee0a4c606b83e64ceaad59..d7ca207424724671bd2fe646b55d790f7728e0a0 100644 (file)
@@ -184,12 +184,12 @@ namespace GnuTLS
                                throw Exception("Unknown hash type " + hashname);
                        gnutls_hash_deinit(is_digest, NULL);
 #else
-                       if (hashname == "md5")
+                       if (stdalgo::string::equalsci(hashname, "md5"))
                                hash = GNUTLS_DIG_MD5;
-                       else if (hashname == "sha1")
+                       else if (stdalgo::string::equalsci(hashname, "sha1"))
                                hash = GNUTLS_DIG_SHA1;
 #ifdef INSPIRCD_GNUTLS_ENABLE_SHA256_FINGERPRINT
-                       else if (hashname == "sha256")
+                       else if (stdalgo::string::equalsci(hashname, "sha256"))
                                hash = GNUTLS_DIG_SHA256;
 #endif
                        else
@@ -1298,7 +1298,7 @@ class ModuleSSLGnuTLS : public Module
                for (ConfigIter i = tags.first; i != tags.second; ++i)
                {
                        ConfigTag* tag = i->second;
-                       if (tag->getString("provider") != "gnutls")
+                       if (!stdalgo::string::equalsci(tag->getString("provider"), "gnutls"))
                                continue;
 
                        std::string name = tag->getString("name");
index 8bb0e2bbd5f361bee5171afd5d56617159fb295a..75b25fbc43b579f60797847d6b7bd6e6c7426d6b 100644 (file)
@@ -876,7 +876,7 @@ class ModuleSSLmbedTLS : public Module
                for (ConfigIter i = tags.first; i != tags.second; ++i)
                {
                        ConfigTag* tag = i->second;
-                       if (tag->getString("provider") != "mbedtls")
+                       if (!stdalgo::string::equalsci(tag->getString("provider"), "mbedtls"))
                                continue;
 
                        std::string name = tag->getString("name");
index a70bffb3c016c3d07cd7952d1ad4e149ed536e44..5f61c71a9accbd4802fbc8d77c9c86b595dc1297 100644 (file)
@@ -222,11 +222,11 @@ namespace OpenSSL
 
                        /* Set CRL mode */
                        unsigned long crlflags = X509_V_FLAG_CRL_CHECK;
-                       if (crlmode == "chain")
+                       if (stdalgo::string::equalsci(crlmode, "chain"))
                        {
                                crlflags |= X509_V_FLAG_CRL_CHECK_ALL;
                        }
-                       else if (crlmode != "leaf")
+                       else if (!stdalgo::string::equalsci(crlmode, "leaf"))
                        {
                                throw ModuleException("Unknown mode '" + crlmode + "'; expected either 'chain' (default) or 'leaf'");
                        }
@@ -963,7 +963,7 @@ class ModuleSSLOpenSSL : public Module
                for (ConfigIter i = tags.first; i != tags.second; ++i)
                {
                        ConfigTag* tag = i->second;
-                       if (tag->getString("provider") != "openssl")
+                       if (!stdalgo::string::equalsci(tag->getString("provider"), "openssl"))
                                continue;
 
                        std::string name = tag->getString("name");
index ed0e486e95d616dc306cbaeb0c78be6cb9018627..097041896099dc06216f2e03dba6223e1bcb055c 100644 (file)
@@ -69,13 +69,13 @@ class ModuleBlockAmsg : public Module
                ForgetDelay = tag->getDuration("delay", 3);
                std::string act = tag->getString("action");
 
-               if (act == "notice")
+               if (stdalgo::string::equalsci(act, "notice"))
                        action = IBLOCK_NOTICE;
-               else if (act == "noticeopers")
+               else if (stdalgo::string::equalsci(act, "noticeopers"))
                        action = IBLOCK_NOTICEOPERS;
-               else if (act == "silent")
+               else if (stdalgo::string::equalsci(act, "silent"))
                        action = IBLOCK_SILENT;
-               else if (act == "kill")
+               else if (stdalgo::string::equalsci(act, "kill"))
                        action = IBLOCK_KILL;
                else
                        action = IBLOCK_KILLOPERS;
index 75dc889f9ec6ae388070966ae017072231a2003b..ad4b958c58ac89f6ff4b9a736dcf9c4f597b9082 100644 (file)
@@ -350,12 +350,12 @@ class ModuleCloaking : public Module
                suffix = tag->getString("suffix", ".IP");
 
                std::string modestr = tag->getString("mode");
-               if (modestr == "half")
+               if (stdalgo::string::equalsci(modestr, "half"))
                {
                        mode = MODE_HALF_CLOAK;
                        domainparts = tag->getUInt("domainparts", 3, 1, 10);
                }
-               else if (modestr == "full")
+               else if (stdalgo::string::equalsci(modestr, "full"))
                        mode = MODE_OPAQUE;
                else
                        throw ModuleException("Bad value for <cloak:mode>; must be half or full");
index 9d85f01da36a7981ce428e406f7bc1ed4da99490..647f69e7a4c8455d21485e5b94bb79eb1b6fa360 100644 (file)
@@ -391,7 +391,7 @@ class ModuleDCCAllow : public Module
                                                        if (InspIRCd::Match(filename, bfl[i].filemask, ascii_case_insensitive_map))
                                                        {
                                                                /* We have a matching badfile entry, override whatever the default action is */
-                                                               if (bfl[i].action == "allow")
+                                                               if (stdalgo::string::equalsci(bfl[i].action, "allow"))
                                                                        return MOD_RES_PASSTHRU;
                                                                else
                                                                {
index 10b0e272840cfc6c024e4a4b825cf8e8f5772fe6..e0a827f0442494080817fa98b111e37d5d492401 100644 (file)
@@ -278,7 +278,7 @@ class ModuleDNSBL : public Module, public Stats::EventListener
                        e->reason = tag->getString("reason");
                        e->domain = tag->getString("domain");
 
-                       if (tag->getString("type") == "bitmask")
+                       if (stdalgo::string::equalsci(tag->getString("type"), "bitmask"))
                        {
                                e->type = DNSBLConfEntry::A_BITMASK;
                                e->bitmask = tag->getUInt("bitmask", 0, 0, UINT_MAX);
index 4e7af4b836f7ad06fbab401f11c3bfd0bd47db8f..d7f9a793b617d696006788a122fe07c9e6df5c85 100644 (file)
@@ -84,7 +84,7 @@ class ModuleFlashPD : public Module
  public:
        ModResult OnAcceptConnection(int nfd, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE
        {
-               if (from->bind_tag->getString("type") != "flashpolicyd")
+               if (!stdalgo::string::equalsci(from->bind_tag->getString("type"), "flashpolicyd"))
                        return MOD_RES_PASSTHRU;
 
                if (policy_reply.empty())
@@ -123,7 +123,7 @@ class ModuleFlashPD : public Module
                for (std::vector<ListenSocket*>::const_iterator i = ServerInstance->ports.begin(); i != ServerInstance->ports.end(); ++i)
                {
                                ListenSocket* ls = *i;
-                               if (ls->bind_tag->getString("type", "clients") != "clients" || ls->bind_tag->getString("ssl", "plaintext") != "plaintext")
+                               if (!stdalgo::string::equalsci(ls->bind_tag->getString("type", "clients"), "clients") || !ls->bind_tag->getString("ssl").empty())
                                        continue;
 
                                to_ports.append(ConvToStr(ls->bind_sa.port())).push_back(',');
index a20b85f9d003e7cc9e26e73d4c598046ec68b04e..17f25203d884c87dbfba2a11d09cf865ca61c7b6 100644 (file)
@@ -406,7 +406,7 @@ class ModuleHttpServer : public Module
 
        ModResult OnAcceptConnection(int nfd, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) CXX11_OVERRIDE
        {
-               if (from->bind_tag->getString("type") != "httpd")
+               if (!stdalgo::string::equalsci(from->bind_tag->getString("type"), "httpd"))
                        return MOD_RES_PASSTHRU;
 
                sockets.push_front(new HttpServerSocket(nfd, client->addr(), from, client, server, timeoutsec));
index 3f67fffcac54b03545d30d1e0fb83644998d131a..2dbc1be69c9d510f7bb17dc5da454a126b18fe41 100644 (file)
@@ -67,16 +67,16 @@ class ModuleHTTPAccessList : public Module, public HTTPACLEventListener
 
                        while (sep.GetToken(type))
                        {
-                               if (type == "password")
+                               if (stdalgo::string::equalsci(type, "password"))
                                {
                                        username = c->getString("username");
                                        password = c->getString("password");
                                }
-                               else if (type == "whitelist")
+                               else if (stdalgo::string::equalsci(type, "whitelist"))
                                {
                                        whitelist = c->getString("whitelist");
                                }
-                               else if (type == "blacklist")
+                               else if (stdalgo::string::equalsci(type, "blacklist"))
                                {
                                        blacklist = c->getString("blacklist");
                                }
index f42822daa5da65c43a2f8268fc249fe19a8c2dd7..cde627e21af47aa26b4be649d911a307b71f1e21 100644 (file)
@@ -33,7 +33,7 @@ SpanningTreeUtilities* Utils = NULL;
 
 ModResult ModuleSpanningTree::OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server)
 {
-       if (from->bind_tag->getString("type") != "servers")
+       if (!stdalgo::string::equalsci(from->bind_tag->getString("type"), "servers"))
                return MOD_RES_PASSTHRU;
 
        std::string incomingip = client->addr();
index 7a34b31b174fe69454e5e6d5172934cc7da14478..04a8f959a0160b7eebe3155a6490834350645195 100644 (file)
@@ -1231,7 +1231,7 @@ ConnectClass::ConnectClass(ConfigTag* tag, char t, const std::string& mask, cons
        for (ConfigItems::const_iterator piter = parentkeys.begin(); piter != parentkeys.end(); ++piter)
        {
                // The class name and parent name are not inherited
-               if (piter->first == "name" || piter->first == "parent")
+               if (stdalgo::string::equalsci(piter->first, "name") || stdalgo::string::equalsci(piter->first, "parent"))
                        continue;
 
                // Store the item in the config tag. If this item also