-/* 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 ValueContainerChar (&ServerConfig::MoronBanner), DT_CHARPTR, NULL},
- {"server", "name", "", new ValueContainerChar (&ServerConfig::ServerName), DT_HOSTNAME, ValidateServerName},
- {"server", "description", "Configure Me", new ValueContainerChar (&ServerConfig::ServerDesc), DT_CHARPTR, NULL},
- {"server", "network", "Network", new ValueContainerChar (&ServerConfig::Network), DT_NOSPACES, NULL},
- {"server", "id", "", new ValueContainerChar (&ServerConfig::sid), DT_CHARPTR, ValidateSID},
- {"admin", "name", "", new ValueContainerChar (&ServerConfig::AdminName), DT_CHARPTR, NULL},
- {"admin", "email", "Mis@configu.red", new ValueContainerChar (&ServerConfig::AdminEmail), DT_CHARPTR, NULL},
- {"admin", "nick", "Misconfigured", new ValueContainerChar (&ServerConfig::AdminNick), DT_CHARPTR, NULL},
- {"files", "motd", "", new ValueContainerChar (&ServerConfig::motd), DT_CHARPTR, ValidateMotd},
- {"files", "rules", "", new ValueContainerChar (&ServerConfig::rules), DT_CHARPTR, ValidateRules},
- {"power", "diepass", "", new ValueContainerChar (&ServerConfig::diepass), DT_CHARPTR, ValidateNotEmpty},
- {"power", "pause", "", new ValueContainerInt (&ServerConfig::DieDelay), DT_INTEGER, NULL},
- {"power", "hash", "", new ValueContainerChar (&ServerConfig::powerhash), DT_CHARPTR, NULL},
- {"power", "restartpass", "", new ValueContainerChar (&ServerConfig::restartpass), DT_CHARPTR, ValidateNotEmpty},
- {"options", "prefixquit", "", new ValueContainerChar (&ServerConfig::PrefixQuit), DT_CHARPTR, NULL},
- {"options", "suffixquit", "", new ValueContainerChar (&ServerConfig::SuffixQuit), DT_CHARPTR, NULL},
- {"options", "fixedquit", "", new ValueContainerChar (&ServerConfig::FixedQuit), DT_CHARPTR, NULL},
- {"options", "prefixpart", "", new ValueContainerChar (&ServerConfig::PrefixPart), DT_CHARPTR, NULL},
- {"options", "suffixpart", "", new ValueContainerChar (&ServerConfig::SuffixPart), DT_CHARPTR, NULL},
- {"options", "fixedpart", "", new ValueContainerChar (&ServerConfig::FixedPart), DT_CHARPTR, NULL},
- {"performance", "netbuffersize","10240", new ValueContainerInt (&ServerConfig::NetBufferSize), DT_INTEGER, ValidateNetBufferSize},
- {"performance", "maxwho", "128", new ValueContainerInt (&ServerConfig::MaxWhoResults), DT_INTEGER, ValidateMaxWho},
- {"options", "allowhalfop", "0", new ValueContainerBool (&ServerConfig::AllowHalfop), DT_BOOLEAN, ValidateHalfOp},
- {"dns", "server", "", new ValueContainerChar (&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 ValueContainerChar (&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 ValueContainerChar(&ServerConfig::SetUser), DT_CHARPTR, NULL},
- {"security", "runasgroup", "", new ValueContainerChar(&ServerConfig::SetGroup), DT_CHARPTR, NULL},
- {"security", "userstats", "", new ValueContainerChar (&ServerConfig::UserStats), DT_CHARPTR, NULL},
- {"security", "customversion","", new ValueContainerChar (&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 ValueContainerChar (&ServerConfig::HideWhoisServer), DT_NOSPACES, NULL},
- {"security", "hidekills", "", new ValueContainerChar (&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 ValueContainerChar (&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 ValueContainerChar (&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},
-};
+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");
+ 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.");
+
+ ConfigTagList tags = ConfTags("uline");
+ for(ConfigIter i = tags.first; i != tags.second; ++i)
+ {
+ ConfigTag* tag = i->second;
+ std::string server;
+ if (!tag->readString("server", server))
+ throw CoreException("<uline> tag missing server at " + tag->getTagLocation());
+ ulines[assign(server)] = tag->getBool("silent");
+ }
+
+ tags = ConfTags("banlist");
+ for(ConfigIter i = tags.first; i != tags.second; ++i)
+ {
+ ConfigTag* tag = i->second;
+ std::string chan;
+ if (!tag->readString("chan", chan))
+ throw CoreException("<banlist> tag missing chan at " + tag->getTagLocation());
+ maxbans[chan] = tag->getInt("limit");
+ }
+
+ ReadXLine(this, "badip", "ipmask", ServerInstance->XLines->GetFactory("Z"));
+ ReadXLine(this, "badnick", "nick", ServerInstance->XLines->GetFactory("Q"));
+ ReadXLine(this, "badhost", "host", ServerInstance->XLines->GetFactory("K"));
+ ReadXLine(this, "exception", "host", ServerInstance->XLines->GetFactory("E"));
+
+ memset(DisabledUModes, 0, sizeof(DisabledUModes));
+ for (const unsigned char* p = (const unsigned char*)ConfValue("disabled")->getString("usermodes").c_str(); *p; ++p)
+ {
+ if (*p < 'A' || *p > ('A' + 64)) throw CoreException(std::string("Invalid usermode ")+(char)*p+" was found.");
+ DisabledUModes[*p - 'A'] = 1;
+ }