]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/configreader.cpp
Make the build reproducible by removing time related macros.
[user/henk/code/inspircd.git] / src / configreader.cpp
index a81a1b646f8ea81cc911eae6f2ad2835e21b911f..0aedb874d2ee7348a2b6ca87e9ec267e10b90de8 100644 (file)
 #include <iostream>
 
 ServerLimits::ServerLimits(ConfigTag* tag)
-       : NickMax(tag->getInt("maxnick", 32))
+       : NickMax(tag->getInt("maxnick", 30))
        , ChanMax(tag->getInt("maxchan", 64))
        , MaxModes(tag->getInt("maxmodes", 20))
-       , IdentMax(tag->getInt("maxident", 11))
+       , IdentMax(tag->getInt("maxident", 10))
        , MaxQuit(tag->getInt("maxquit", 255))
        , MaxTopic(tag->getInt("maxtopic", 307))
        , MaxKick(tag->getInt("maxkick", 255))
@@ -46,7 +46,7 @@ ServerLimits::ServerLimits(ConfigTag* tag)
 
 static ConfigTag* CreateEmptyTag()
 {
-       std::vector<KeyVal>* items;
+       ConfigItems* items;
        return ConfigTag::create("empty", "<auto>", 0, items);
 }
 
@@ -55,7 +55,7 @@ ServerConfig::ServerConfig()
        , Limits(EmptyTag)
        , NoSnoticeStack(false)
 {
-       RawLog = HideBans = HideSplits = UndernetMsgPrefix = false;
+       RawLog = HideBans = HideSplits = false;
        WildcardIPv6 = true;
        dns_timeout = 5;
        MaxTargets = 20;
@@ -220,9 +220,9 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
        if (blk_count == 0)
        {
                // No connect blocks found; make a trivial default block
-               std::vector<KeyVal>* items;
+               ConfigItems* items;
                ConfigTag* tag = ConfigTag::create("connect", "<auto>", 0, items);
-               items->push_back(std::make_pair("allow", "*"));
+               (*items)["allow"] = "*";
                config_data.insert(std::make_pair("connect", tag));
                blk_count = 1;
        }
@@ -328,6 +328,14 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current)
                        me->limit = tag->getInt("limit", me->limit);
                        me->resolvehostnames = tag->getBool("resolvehostnames", me->resolvehostnames);
 
+                       std::string ports = tag->getString("port");
+                       if (!ports.empty())
+                       {
+                               irc::portparser portrange(ports, false);
+                               while (int port = portrange.GetToken())
+                                       me->ports.insert(port);
+                       }
+
                        ClassMap::iterator oldMask = oldBlocksByMask.find(typeMask);
                        if (oldMask != oldBlocksByMask.end())
                        {
@@ -362,34 +370,36 @@ struct DeprecatedConfig
 static const DeprecatedConfig ChangedConfig[] = {
        { "bind",        "transport",   "",                 "has been moved to <bind:ssl> as of 2.0" },
        { "die",         "value",       "",                 "you need to reread your config" },
-       { "gnutls",      "starttls",    "",                 "has been replaced with m_starttls as of 2.2" },
+       { "gnutls",      "starttls",    "",                 "has been replaced with m_starttls as of 3.0" },
        { "link",        "autoconnect", "",                 "2.0+ does not use this attribute - define <autoconnect> tags instead" },
        { "link",        "transport",   "",                 "has been moved to <link:ssl> as of 2.0" },
-       { "module",      "name",        "m_chanprotect.so", "has been replaced with m_customprefix as of 2.2" },
-       { "module",      "name",        "m_halfop.so",      "has been replaced with m_customprefix as of 2.2" },
-       { "options",     "cyclehosts",  "",                 "has been replaced with m_hostcycle as of 2.2" },
-       { "performance", "nouserdns",   "",                 "has been moved to <connect:resolvehostnames> as of 2.2" }
+       { "module",      "name",        "m_chanprotect.so", "has been replaced with m_customprefix as of 3.0" },
+       { "module",      "name",        "m_halfop.so",      "has been replaced with m_customprefix as of 3.0" },
+       { "options",     "cyclehosts",  "",                 "has been replaced with m_hostcycle as of 3.0" },
+       { "performance", "nouserdns",   "",                 "has been moved to <connect:resolvehostnames> as of 3.0" }
 };
 
 void ServerConfig::Fill()
 {
        ConfigTag* options = ConfValue("options");
        ConfigTag* security = ConfValue("security");
+       ConfigTag* server = ConfValue("server");
        if (sid.empty())
        {
-               ServerName = ConfValue("server")->getString("name", "irc.example.com");
+               ServerName = server->getString("name", "irc.example.com");
                ValidHost(ServerName, "<server:name>");
 
-               sid = ConfValue("server")->getString("id");
+               sid = server->getString("id");
                if (!sid.empty() && !InspIRCd::IsSID(sid))
                        throw CoreException(sid + " is not a valid server ID. A server ID must be 3 characters long, with the first character a digit and the next two characters a digit or letter.");
        }
        else
        {
-               if (ServerName != ConfValue("server")->getString("name"))
+               std::string name = server->getString("name");
+               if (!name.empty() && name != ServerName)
                        throw CoreException("You must restart to change the server name");
 
-               std::string nsid = ConfValue("server")->getString("id");
+               std::string nsid = server->getString("id");
                if (!nsid.empty() && nsid != sid)
                        throw CoreException("You must restart to change the server id");
        }
@@ -397,8 +407,8 @@ void ServerConfig::Fill()
        CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true);
        MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN);
        XLineMessage = options->getString("xlinemessage", options->getString("moronbanner", "You're banned!"));
-       ServerDesc = ConfValue("server")->getString("description", "Configure Me");
-       Network = ConfValue("server")->getString("network", "Network");
+       ServerDesc = server->getString("description", "Configure Me");
+       Network = server->getString("network", "Network");
        NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240, 1024, 65534);
        dns_timeout = ConfValue("dns")->getInt("timeout", 5);
        DisabledCommands = ConfValue("disabled")->getString("commands", "");
@@ -409,11 +419,11 @@ void ServerConfig::Fill()
        HideBans = security->getBool("hidebans");
        HideWhoisServer = security->getString("hidewhois");
        HideKillsServer = security->getString("hidekills");
+       HideULineKills = security->getBool("hideulinekills");
        RestrictBannedUsers = security->getBool("restrictbannedusers", true);
        GenericOper = security->getBool("genericoper");
        SyntaxHints = options->getBool("syntaxhints");
        CycleHostsFromUser = options->getBool("cyclehostsfromuser");
-       UndernetMsgPrefix = options->getBool("ircumsgprefix");
        FullHostInTopic = options->getBool("hostintopic");
        MaxTargets = security->getInt("maxtargets", 20, 1, 31);
        DefaultModes = options->getString("defaultmodes", "not");
@@ -433,11 +443,11 @@ void ServerConfig::Fill()
                throw CoreException(Network + " is not a valid network name. A network name must not contain spaces.");
 
        std::string defbind = options->getString("defaultbind");
-       if (assign(defbind) == "ipv4")
+       if (stdalgo::string::equalsci(defbind, "ipv4"))
        {
                WildcardIPv6 = false;
        }
-       else if (assign(defbind) == "ipv6")
+       else if (stdalgo::string::equalsci(defbind, "ipv6"))
        {
                WildcardIPv6 = true;
        }
@@ -560,7 +570,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
        }
        catch (CoreException &ce)
        {
-               errstr << ce.GetReason();
+               errstr << ce.GetReason() << std::endl;
        }
 
        // Check errors before dealing with failed binds, since continuing on failed bind is wanted in some circumstances.
@@ -568,7 +578,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
 
        // write once here, to try it out and make sure its ok
        if (valid)
-               ServerInstance->WritePID(this->PID);
+               ServerInstance->WritePID(this->PID, !old);
 
        ConfigTagList binds = ConfTags("bind");
        if (binds.first == binds.second)
@@ -613,7 +623,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
                        std::cout << line << std::endl;
                // If a user is rehashing, tell them directly
                if (user)
-                       user->SendText(":%s NOTICE %s :*** %s", ServerInstance->Config->ServerName.c_str(), user->nick.c_str(), line.c_str());
+                       user->WriteRemoteNotice(InspIRCd::Format("*** %s", line.c_str()));
                // Also tell opers
                ServerInstance->SNO->WriteGlobalSno('a', line);
        }
@@ -627,11 +637,11 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
                ConfigTag *tag = (*it)->config;
                // Make sure our connection class allows motd colors
                if(!tag->getBool("allowmotdcolors"))
-                     continue;
+                       continue;
 
                ConfigFileCache::iterator file = this->Files.find(tag->getString("motd", "motd"));
                if (file != this->Files.end())
-                     InspIRCd::ProcessColors(file->second);
+                       InspIRCd::ProcessColors(file->second);
        }
 
        /* No old configuration -> initial boot, nothing more to do here */
@@ -653,8 +663,7 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
        ApplyModules(user);
 
        if (user)
-               user->SendText(":%s NOTICE %s :*** Successfully rehashed server.",
-                       ServerInstance->Config->ServerName.c_str(), user->nick.c_str());
+               user->WriteRemoteNotice("*** Successfully rehashed server.");
        ServerInstance->SNO->WriteGlobalSno('a', "*** Successfully rehashed server.");
 }
 
@@ -689,33 +698,33 @@ void ServerConfig::ApplyModules(User* user)
                        ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH UNLOADED MODULE: %s", modname.c_str());
 
                        if (user)
-                               user->WriteNumeric(RPL_UNLOADEDMODULE, "%s :Module %s successfully unloaded.", modname.c_str(), modname.c_str());
+                               user->WriteNumeric(RPL_UNLOADEDMODULE, modname, InspIRCd::Format("Module %s successfully unloaded.", modname.c_str()));
                        else
                                ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully unloaded.", modname.c_str());
                }
                else
                {
                        if (user)
-                               user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :Failed to unload module %s: %s", modname.c_str(), modname.c_str(), ServerInstance->Modules->LastError().c_str());
+                               user->WriteNumeric(ERR_CANTUNLOADMODULE, modname, InspIRCd::Format("Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str()));
                        else
-                                ServerInstance->SNO->WriteGlobalSno('a', "Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str());
+                               ServerInstance->SNO->WriteGlobalSno('a', "Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str());
                }
        }
 
        for (std::vector<std::string>::iterator adding = added_modules.begin(); adding != added_modules.end(); adding++)
        {
-               if (ServerInstance->Modules->Load(adding->c_str()))
+               if (ServerInstance->Modules->Load(*adding))
                {
                        ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH LOADED MODULE: %s",adding->c_str());
                        if (user)
-                               user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module %s successfully loaded.", adding->c_str(), adding->c_str());
+                               user->WriteNumeric(RPL_LOADEDMODULE, *adding, InspIRCd::Format("Module %s successfully loaded.", adding->c_str()));
                        else
                                ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully loaded.", adding->c_str());
                }
                else
                {
                        if (user)
-                               user->WriteNumeric(ERR_CANTLOADMODULE, "%s :Failed to load module %s: %s", adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str());
+                               user->WriteNumeric(ERR_CANTLOADMODULE, *adding, InspIRCd::Format("Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str()));
                        else
                                ServerInstance->SNO->WriteGlobalSno('a', "Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str());
                }