-/* These tags can occur ONCE or not at all */
-static const InitialConfig Values[] = {
- {"performance", "softlimit", "0", new ValueContainerUInt (&ServerConfig::SoftLimit), DT_INTEGER, ValidateSoftLimit},
- {"performance", "somaxconn", SOMAXCONN_S, new ValueContainerInt (&ServerConfig::MaxConn), DT_INTEGER, ValidateMaxConn},
- {"options", "moronbanner", "You're banned!", new ValueContainerString (&ServerConfig::MoronBanner), DT_CHARPTR, NULL},
- {"server", "name", "", new ValueContainerString (&ServerConfig::ServerName), DT_HOSTNAME, ValidateServerName},
- {"server", "description", "Configure Me", new ValueContainerString (&ServerConfig::ServerDesc), DT_CHARPTR, NULL},
- {"server", "network", "Network", new ValueContainerString (&ServerConfig::Network), DT_NOSPACES, NULL},
- {"server", "id", "", new ValueContainerString (&ServerConfig::sid), DT_CHARPTR, ValidateSID},
- {"admin", "name", "", new ValueContainerString (&ServerConfig::AdminName), DT_CHARPTR, NULL},
- {"admin", "email", "Mis@configu.red", new ValueContainerString (&ServerConfig::AdminEmail), DT_CHARPTR, NULL},
- {"admin", "nick", "Misconfigured", new ValueContainerString (&ServerConfig::AdminNick), DT_CHARPTR, NULL},
- {"files", "motd", "", new ValueContainerString (&ServerConfig::motd), DT_CHARPTR, ValidateMotd},
- {"files", "rules", "", new ValueContainerString (&ServerConfig::rules), DT_CHARPTR, ValidateRules},
- {"power", "diepass", "", new ValueContainerString (&ServerConfig::diepass), DT_CHARPTR, ValidateNotEmpty},
- {"power", "pause", "", new ValueContainerInt (&ServerConfig::DieDelay), DT_INTEGER, NULL},
- {"power", "hash", "", new ValueContainerString (&ServerConfig::powerhash), DT_CHARPTR, NULL},
- {"power", "restartpass", "", new ValueContainerString (&ServerConfig::restartpass), DT_CHARPTR, ValidateNotEmpty},
- {"options", "prefixquit", "", new ValueContainerString (&ServerConfig::PrefixQuit), DT_CHARPTR, NULL},
- {"options", "suffixquit", "", new ValueContainerString (&ServerConfig::SuffixQuit), DT_CHARPTR, NULL},
- {"options", "fixedquit", "", new ValueContainerString (&ServerConfig::FixedQuit), DT_CHARPTR, NULL},
- {"options", "prefixpart", "", new ValueContainerString (&ServerConfig::PrefixPart), DT_CHARPTR, NULL},
- {"options", "suffixpart", "", new ValueContainerString (&ServerConfig::SuffixPart), DT_CHARPTR, NULL},
- {"options", "fixedpart", "", new ValueContainerString (&ServerConfig::FixedPart), DT_CHARPTR, NULL},
- {"performance", "netbuffersize","10240", new ValueContainerInt (&ServerConfig::NetBufferSize), DT_INTEGER, ValidateNetBufferSize},
- {"performance", "maxwho", "1024", new ValueContainerInt (&ServerConfig::MaxWhoResults), DT_INTEGER, ValidateMaxWho},
- {"options", "allowhalfop", "0", new ValueContainerBool (&ServerConfig::AllowHalfop), DT_BOOLEAN, ValidateHalfOp},
- {"dns", "server", "", new ValueContainerString (&ServerConfig::DNSServer), DT_IPADDRESS,ValidateDnsServer},
- {"dns", "timeout", "5", new ValueContainerInt (&ServerConfig::dns_timeout), DT_INTEGER, NULL},
- {"options", "moduledir", MOD_PATH, new ValueContainerString (&ServerConfig::ModPath), DT_CHARPTR, NULL},
- {"disabled", "commands", "", new ValueContainerString (&ServerConfig::DisabledCommands), DT_CHARPTR, NULL},
- {"disabled", "usermodes", "", NULL, DT_NOTHING, ValidateDisabledUModes},
- {"disabled", "chanmodes", "", NULL, DT_NOTHING, ValidateDisabledCModes},
- {"disabled", "fakenonexistant", "0", new ValueContainerBool (&ServerConfig::DisabledDontExist), DT_BOOLEAN, NULL},
-
- {"security", "runasuser", "", new ValueContainerString(&ServerConfig::SetUser), DT_CHARPTR, NULL},
- {"security", "runasgroup", "", new ValueContainerString(&ServerConfig::SetGroup), DT_CHARPTR, NULL},
- {"security", "userstats", "", new ValueContainerString (&ServerConfig::UserStats), DT_CHARPTR, NULL},
- {"security", "customversion","", new ValueContainerString (&ServerConfig::CustomVersion), DT_CHARPTR, NULL},
- {"security", "hidesplits", "0", new ValueContainerBool (&ServerConfig::HideSplits), DT_BOOLEAN, NULL},
- {"security", "hidebans", "0", new ValueContainerBool (&ServerConfig::HideBans), DT_BOOLEAN, NULL},
- {"security", "hidewhois", "", new ValueContainerString (&ServerConfig::HideWhoisServer), DT_NOSPACES, NULL},
- {"security", "hidekills", "", new ValueContainerString (&ServerConfig::HideKillsServer), DT_NOSPACES, NULL},
- {"security", "operspywhois", "0", new ValueContainerBool (&ServerConfig::OperSpyWhois), DT_BOOLEAN, NULL},
- {"security", "restrictbannedusers", "1", new ValueContainerBool (&ServerConfig::RestrictBannedUsers), DT_BOOLEAN, NULL},
- {"security", "genericoper", "0", new ValueContainerBool (&ServerConfig::GenericOper), DT_BOOLEAN, NULL},
- {"performance", "nouserdns", "0", new ValueContainerBool (&ServerConfig::NoUserDns), DT_BOOLEAN, NULL},
- {"options", "syntaxhints", "0", new ValueContainerBool (&ServerConfig::SyntaxHints), DT_BOOLEAN, NULL},
- {"options", "cyclehosts", "0", new ValueContainerBool (&ServerConfig::CycleHosts), DT_BOOLEAN, NULL},
- {"options", "ircumsgprefix","0", new ValueContainerBool (&ServerConfig::UndernetMsgPrefix), DT_BOOLEAN, NULL},
- {"security", "announceinvites", "1", NULL, DT_NOTHING, ValidateInvite},
- {"options", "hostintopic", "1", new ValueContainerBool (&ServerConfig::FullHostInTopic), DT_BOOLEAN, NULL},
- {"security", "hidemodes", "", NULL, DT_NOTHING, ValidateModeLists},
- {"options", "exemptchanops","", NULL, DT_NOTHING, ValidateExemptChanOps},
- {"security", "maxtargets", "20", new ValueContainerUInt (&ServerConfig::MaxTargets), DT_INTEGER, ValidateMaxTargets},
- {"options", "defaultmodes", "nt", new ValueContainerString (&ServerConfig::DefaultModes), DT_CHARPTR, NULL},
- {"pid", "file", "", new ValueContainerString (&ServerConfig::PID), DT_CHARPTR, NULL},
- {"whowas", "groupsize", "10", new ValueContainerInt (&ServerConfig::WhoWasGroupSize), DT_INTEGER, NULL},
- {"whowas", "maxgroups", "10240", new ValueContainerInt (&ServerConfig::WhoWasMaxGroups), DT_INTEGER, NULL},
- {"whowas", "maxkeep", "3600", NULL, DT_NOTHING, ValidateWhoWas},
- {"die", "value", "", new ValueContainerString (&ServerConfig::DieValue), DT_CHARPTR, NULL},
- {"channels", "users", "20", new ValueContainerUInt (&ServerConfig::MaxChans), DT_INTEGER, NULL},
- {"channels", "opers", "60", new ValueContainerUInt (&ServerConfig::OperMaxChans), DT_INTEGER, NULL},
- {"cidr", "ipv4clone", "32", new ValueContainerInt (&ServerConfig::c_ipv4_range), DT_INTEGER, NULL},
- {"cidr", "ipv6clone", "128", new ValueContainerInt (&ServerConfig::c_ipv6_range), DT_INTEGER, NULL},
- {"limits", "maxnick", "32", new ValueContainerLimit (&ServerLimits::NickMax), DT_LIMIT, NULL},
- {"limits", "maxchan", "64", new ValueContainerLimit (&ServerLimits::ChanMax), DT_LIMIT, NULL},
- {"limits", "maxmodes", "20", new ValueContainerLimit (&ServerLimits::MaxModes), DT_LIMIT, NULL},
- {"limits", "maxident", "11", new ValueContainerLimit (&ServerLimits::IdentMax), DT_LIMIT, NULL},
- {"limits", "maxquit", "255", new ValueContainerLimit (&ServerLimits::MaxQuit), DT_LIMIT, NULL},
- {"limits", "maxtopic", "307", new ValueContainerLimit (&ServerLimits::MaxTopic), DT_LIMIT, NULL},
- {"limits", "maxkick", "255", new ValueContainerLimit (&ServerLimits::MaxKick), DT_LIMIT, NULL},
- {"limits", "maxgecos", "128", new ValueContainerLimit (&ServerLimits::MaxGecos), DT_LIMIT, NULL},
- {"limits", "maxaway", "200", new ValueContainerLimit (&ServerLimits::MaxAway), DT_LIMIT, NULL},
- {"options", "invitebypassmodes", "1", new ValueContainerBool (&ServerConfig::InvBypassModes), DT_BOOLEAN, NULL},
-};
-
-/* These tags can occur multiple times, and therefore they have special code to read them
- * which is different to the code for reading the singular tags listed above.
- */
-MultiConfig MultiValues[] = {
-
- {"connect",
- {"allow", "deny", "password", "timeout", "pingfreq",
- "sendq", "recvq", "localmax", "globalmax", "port",
- "name", "parent", "maxchans", "limit", "hash",
- NULL},
- {"", "", "", "", "120",
- "", "", "3", "3", "0",
- "", "", "0", "0", "",
- NULL},
- {DT_IPADDRESS|DT_ALLOW_WILD, DT_IPADDRESS|DT_ALLOW_WILD, DT_CHARPTR, DT_INTEGER, DT_INTEGER,
- DT_INTEGER, DT_INTEGER, DT_INTEGER, DT_INTEGER, DT_INTEGER,
- DT_NOSPACES, DT_NOSPACES, DT_INTEGER, DT_INTEGER, DT_CHARPTR},
- NULL,},
-
- {"uline",
- {"server", "silent", NULL},
- {"", "0", NULL},
- {DT_HOSTNAME, DT_BOOLEAN},
- DoULine},
-
- {"banlist",
- {"chan", "limit", NULL},
- {"", "", NULL},
- {DT_CHARPTR, DT_INTEGER},
- DoMaxBans},
-
- {"module",
- {"name", NULL},
- {"", NULL},
- {DT_CHARPTR},
- NULL},
-
- {"badip",
- {"reason", "ipmask", NULL},
- {"No reason", "", NULL},
- {DT_CHARPTR, DT_IPADDRESS|DT_ALLOW_WILD},
- DoZLine},
-
- {"badnick",
- {"reason", "nick", NULL},
- {"No reason", "", NULL},
- {DT_CHARPTR, DT_CHARPTR},
- DoQLine},
-
- {"badhost",
- {"reason", "host", NULL},
- {"No reason", "", NULL},
- {DT_CHARPTR, DT_CHARPTR},
- DoKLine},
-
- {"exception",
- {"reason", "host", NULL},
- {"No reason", "", NULL},
- {DT_CHARPTR, DT_CHARPTR},
- DoELine},
-
- {"type",
- {"name", "classes", NULL},
- {"", "", NULL},
- {DT_NOSPACES, DT_CHARPTR},
- DoType},
-
- {"class",
- {"name", "commands", "usermodes", "chanmodes", "privs", NULL},
- {"", "", "", "", "", NULL},
- {DT_NOSPACES, DT_CHARPTR, DT_CHARPTR, DT_CHARPTR, DT_CHARPTR},
- DoClass},
-};
-
-/* These tags MUST occur and must ONLY occur once in the config file */
-static const char* Once[] = { "server", "admin", "files", "power", "options" };
-
-// WARNING: it is not safe to use most of the codebase in this function, as it
-// will run in the config reader thread
-void ServerConfig::Read()
-{
- /* Load and parse the config file, if there are any errors then explode */
+void ServerConfig::Fill()
+{
+ ConfigTag* options = ConfValue("options");
+ ConfigTag* security = ConfValue("security");
+ diepass = ConfValue("power")->getString("diepass");
+ restartpass = ConfValue("power")->getString("restartpass");
+ powerhash = ConfValue("power")->getString("hash");
+ PrefixQuit = options->getString("prefixquit");
+ SuffixQuit = options->getString("suffixquit");
+ FixedQuit = options->getString("fixedquit");
+ PrefixPart = options->getString("prefixpart");
+ SuffixPart = options->getString("suffixpart");
+ FixedPart = options->getString("fixedpart");
+ SoftLimit = ConfValue("performance")->getInt("softlimit", ServerInstance->SE->GetMaxFds());
+ MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN);
+ MoronBanner = options->getString("moronbanner", "You're banned!");
+ ServerName = ConfValue("server")->getString("name");
+ ServerDesc = ConfValue("server")->getString("description", "Configure Me");
+ Network = ConfValue("server")->getString("network", "Network");
+ sid = ConfValue("server")->getString("id", "");
+ AdminName = ConfValue("admin")->getString("name", "");
+ AdminEmail = ConfValue("admin")->getString("email", "null@example.com");
+ AdminNick = ConfValue("admin")->getString("nick", "admin");
+ ModPath = ConfValue("path")->getString("moduledir", MOD_PATH);
+ NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240);
+ dns_timeout = ConfValue("dns")->getInt("timeout", 5);
+ DisabledCommands = ConfValue("disabled")->getString("commands", "");
+ DisabledDontExist = ConfValue("disabled")->getBool("fakenonexistant");
+ UserStats = security->getString("userstats");
+ CustomVersion = security->getString("customversion", Network + " IRCd");
+ HideSplits = security->getBool("hidesplits");
+ HideBans = security->getBool("hidebans");
+ HideWhoisServer = security->getString("hidewhois");
+ HideKillsServer = security->getString("hidekills");
+ OperSpyWhois = security->getBool("operspywhois");
+ RestrictBannedUsers = security->getBool("restrictbannedusers", true);
+ GenericOper = security->getBool("genericoper");
+ NoUserDns = ConfValue("performance")->getBool("nouserdns");
+ SyntaxHints = options->getBool("syntaxhints");
+ CycleHosts = options->getBool("cyclehosts");
+ UndernetMsgPrefix = options->getBool("ircumsgprefix");
+ FullHostInTopic = options->getBool("hostintopic");
+ MaxTargets = security->getInt("maxtargets", 20);
+ DefaultModes = options->getString("defaultmodes", "nt");
+ PID = ConfValue("pid")->getString("file");
+ WhoWasGroupSize = ConfValue("whowas")->getInt("groupsize");
+ WhoWasMaxGroups = ConfValue("whowas")->getInt("maxgroups");
+ WhoWasMaxKeep = ServerInstance->Duration(ConfValue("whowas")->getString("maxkeep"));
+ MaxChans = ConfValue("channels")->getInt("users", 20);
+ OperMaxChans = ConfValue("channels")->getInt("opers", 60);
+ c_ipv4_range = ConfValue("cidr")->getInt("ipv4clone", 32);
+ c_ipv6_range = ConfValue("cidr")->getInt("ipv6clone", 128);
+ Limits.NickMax = ConfValue("limits")->getInt("maxnick", 32);
+ Limits.ChanMax = ConfValue("limits")->getInt("maxchan", 64);
+ Limits.MaxModes = ConfValue("limits")->getInt("maxmodes", 20);
+ Limits.IdentMax = ConfValue("limits")->getInt("maxident", 11);
+ Limits.MaxQuit = ConfValue("limits")->getInt("maxquit", 255);
+ Limits.MaxTopic = ConfValue("limits")->getInt("maxtopic", 307);
+ Limits.MaxKick = ConfValue("limits")->getInt("maxkick", 255);
+ Limits.MaxGecos = ConfValue("limits")->getInt("maxgecos", 128);
+ Limits.MaxAway = ConfValue("limits")->getInt("maxaway", 200);
+ InvBypassModes = options->getBool("invitebypassmodes", true);
+
+ range(SoftLimit, 10, ServerInstance->SE->GetMaxFds(), ServerInstance->SE->GetMaxFds(), "<performance:softlimit>");
+ range(MaxConn, 0, SOMAXCONN, SOMAXCONN, "<performance:somaxconn>");
+ range(MaxTargets, 1, 31, 20, "<security:maxtargets>");
+ range(NetBufferSize, 1024, 65534, 10240, "<performance:netbuffersize>");
+ range(WhoWasGroupSize, 0, 10000, 10, "<whowas:groupsize>");
+ range(WhoWasMaxGroups, 0, 1000000, 10240, "<whowas:maxgroups>");
+ range(WhoWasMaxKeep, 3600, INT_MAX, 3600, "<whowas:maxkeep>");
+
+ ValidIP(DNSServer, "<dns:server>");
+ ValidHost(ServerName, "<server:name>");
+ if (!sid.empty() && !ServerInstance->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.");