void ServerConfig::Fill() { ConfigTag* options = ConfValue("options"); ConfigTag* security = ConfValue("security"); ConfigTag* server = ConfValue("server"); if (sid.empty()) { ServerName = server->getString("name", "irc.example.com", InspIRCd::IsHost); 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 { std::string name = server->getString("name"); if (!name.empty() && name != ServerName) throw CoreException("You must restart to change the server name"); std::string nsid = server->getString("id"); if (!nsid.empty() && nsid != sid) throw CoreException("You must restart to change the server id"); } SoftLimit = ConfValue("performance")->getUInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10); CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true); MaxConn = ConfValue("performance")->getUInt("somaxconn", SOMAXCONN); TimeSkipWarn = ConfValue("performance")->getDuration("timeskipwarn", 2, 0, 30); XLineMessage = options->getString("xlinemessage", "You're banned!"); ServerDesc = server->getString("description", "Configure Me"); Network = server->getString("network", "Network"); NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240, 1024, 65534); CustomVersion = security->getString("customversion"); HideBans = security->getBool("hidebans"); HideServer = security->getString("hideserver"); SyntaxHints = options->getBool("syntaxhints"); FullHostInTopic = options->getBool("hostintopic"); MaxTargets = security->getUInt("maxtargets", 20, 1, 31); DefaultModes = options->getString("defaultmodes", "not"); PID = ConfValue("pid")->getString("file"); c_ipv4_range = ConfValue("cidr")->getUInt("ipv4clone", 32, 1, 32); c_ipv6_range = ConfValue("cidr")->getUInt("ipv6clone", 128, 1, 128); Limits = ServerLimits(ConfValue("limits")); Paths = ServerPaths(ConfValue("path")); NoSnoticeStack = options->getBool("nosnoticestack", false); std::string defbind = options->getString("defaultbind"); if (stdalgo::string::equalsci(defbind, "ipv4")) { WildcardIPv6 = false; } else if (stdalgo::string::equalsci(defbind, "ipv6")) { WildcardIPv6 = true; } else { WildcardIPv6 = true; int socktest = socket(AF_INET6, SOCK_STREAM, 0); if (socktest < 0) WildcardIPv6 = false; else SocketEngine::Close(socktest); } ServerInstance->XLines->ClearConfigLines(); 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")); const std::string restrictbannedusers = options->getString("restrictbannedusers", "yes"); if (stdalgo::string::equalsci(restrictbannedusers, "no")) RestrictBannedUsers = ServerConfig::BUT_NORMAL; else if (stdalgo::string::equalsci(restrictbannedusers, "silent")) RestrictBannedUsers = ServerConfig::BUT_RESTRICT_SILENT; else if (stdalgo::string::equalsci(restrictbannedusers, "yes")) RestrictBannedUsers = ServerConfig::BUT_RESTRICT_NOTIFY; else throw CoreException(restrictbannedusers + " is an invalid <options:restrictbannedusers> value, at " + options->getTagLocation()); }
void ServerConfig::Fill() { ConfigTag* options = ConfValue("options"); ConfigTag* security = ConfValue("security"); if (sid.empty()) { ServerName = ConfValue("server")->getString("name"); sid = ConfValue("server")->getString("id"); ValidHost(ServerName, "<server:name>"); 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")) throw CoreException("You must restart to change the server name or SID"); std::string nsid = ConfValue("server")->getString("id"); if (!nsid.empty() && nsid != sid) throw CoreException("You must restart to change the server name or SID"); } 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!"); ServerDesc = ConfValue("server")->getString("description", "Configure Me"); Network = ConfValue("server")->getString("network", "Network"); AdminName = ConfValue("admin")->getString("name", ""); AdminEmail = ConfValue("admin")->getString("email", "*****@*****.**"); 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"); RestrictBannedUsers = security->getBool("restrictbannedusers", true); GenericOper = security->getBool("genericoper"); SyntaxHints = options->getBool("syntaxhints"); CycleHosts = options->getBool("cyclehosts"); CycleHostsFromUser = options->getBool("cyclehostsfromuser"); UndernetMsgPrefix = options->getBool("ircumsgprefix"); FullHostInTopic = options->getBool("hostintopic"); MaxTargets = security->getInt("maxtargets", 20); DefaultModes = options->getString("defaultmodes", "nt"); PID = ConfValue("pid")->getString("file"); 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); NoSnoticeStack = options->getBool("nosnoticestack", false); range(SoftLimit, 10, ServerInstance->SE->GetMaxFds(), ServerInstance->SE->GetMaxFds(), "<performance:softlimit>"); if (ConfValue("performance")->getBool("limitsomaxconn", true)) range(MaxConn, 0, SOMAXCONN, SOMAXCONN, "<performance:somaxconn>"); range(MaxTargets, 1, 31, 20, "<security:maxtargets>"); range(NetBufferSize, 1024, 65534, 10240, "<performance:netbuffersize>"); std::string defbind = options->getString("defaultbind"); if (assign(defbind) == "ipv4") { WildcardIPv6 = false; } else if (assign(defbind) == "ipv6") { WildcardIPv6 = true; } else { WildcardIPv6 = true; int socktest = socket(AF_INET6, SOCK_STREAM, 0); if (socktest < 0) WildcardIPv6 = false; else ServerInstance->SE->Close(socktest); } 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"); } 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)); std::string modes = ConfValue("disabled")->getString("usermodes"); for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p) { // Complain when the character is not a-z or A-Z if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z'))) throw CoreException("Invalid usermode " + std::string(1, *p) + " was found."); DisabledUModes[*p - 'A'] = 1; } memset(DisabledCModes, 0, sizeof(DisabledCModes)); modes = ConfValue("disabled")->getString("chanmodes"); for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p) { if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z'))) throw CoreException("Invalid chanmode " + std::string(1, *p) + " was found."); DisabledCModes[*p - 'A'] = 1; } memset(HideModeLists, 0, sizeof(HideModeLists)); modes = ConfValue("security")->getString("hidemodes"); for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p) HideModeLists[(unsigned char) *p] = true; std::string v = security->getString("announceinvites"); if (v == "ops") AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_OPS; else if (v == "all") AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_ALL; else if (v == "dynamic") AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_DYNAMIC; else AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_NONE; v = security->getString("operspywhois"); if (v == "splitmsg") OperSpyWhois = SPYWHOIS_SPLITMSG; else if (v == "on" || v == "yes") OperSpyWhois = SPYWHOIS_SINGLEMSG; else OperSpyWhois = SPYWHOIS_NONE; }
void ServerConfig::Fill() { ConfigTag* options = ConfValue("options"); ConfigTag* security = ConfValue("security"); if (sid.empty()) { ServerName = ConfValue("server")->getString("name", "irc.example.com"); ValidHost(ServerName, "<server:name>"); sid = ConfValue("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")) throw CoreException("You must restart to change the server name"); std::string nsid = ConfValue("server")->getString("id"); if (!nsid.empty() && nsid != sid) throw CoreException("You must restart to change the server id"); } SoftLimit = ConfValue("performance")->getInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10); 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"); NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240, 1024, 65534); 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"); 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"); PID = ConfValue("pid")->getString("file"); MaxChans = ConfValue("channels")->getInt("users", 20); OperMaxChans = ConfValue("channels")->getInt("opers"); 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.MaxHost = ConfValue("limits")->getInt("maxhost", 64); 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); Limits.MaxLine = ConfValue("limits")->getInt("maxline", 512); Paths.Config = ConfValue("path")->getString("configdir", INSPIRCD_CONFIG_PATH); Paths.Data = ConfValue("path")->getString("datadir", INSPIRCD_DATA_PATH); Paths.Log = ConfValue("path")->getString("logdir", INSPIRCD_LOG_PATH); Paths.Module = ConfValue("path")->getString("moduledir", INSPIRCD_MODULE_PATH); InvBypassModes = options->getBool("invitebypassmodes", true); NoSnoticeStack = options->getBool("nosnoticestack", false); if (Network.find(' ') != std::string::npos) 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") { WildcardIPv6 = false; } else if (assign(defbind) == "ipv6") { WildcardIPv6 = true; } else { WildcardIPv6 = true; int socktest = socket(AF_INET6, SOCK_STREAM, 0); if (socktest < 0) WildcardIPv6 = false; else SocketEngine::Close(socktest); } 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)); std::string modes = ConfValue("disabled")->getString("usermodes"); for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p) { // Complain when the character is not a-z or A-Z if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z'))) throw CoreException("Invalid usermode " + std::string(1, *p) + " was found."); DisabledUModes[*p - 'A'] = 1; } memset(DisabledCModes, 0, sizeof(DisabledCModes)); modes = ConfValue("disabled")->getString("chanmodes"); for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p) { if ((*p < 'A') || (*p > 'z') || ((*p < 'a') && (*p > 'Z'))) throw CoreException("Invalid chanmode " + std::string(1, *p) + " was found."); DisabledCModes[*p - 'A'] = 1; } memset(HideModeLists, 0, sizeof(HideModeLists)); modes = ConfValue("security")->getString("hidemodes"); for (std::string::const_iterator p = modes.begin(); p != modes.end(); ++p) HideModeLists[(unsigned char) *p] = true; std::string v = security->getString("announceinvites"); if (v == "ops") AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_OPS; else if (v == "all") AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_ALL; else if (v == "dynamic") AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_DYNAMIC; else AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_NONE; v = security->getString("operspywhois"); if (v == "splitmsg") OperSpyWhois = SPYWHOIS_SPLITMSG; else if (v == "on" || v == "yes") OperSpyWhois = SPYWHOIS_SINGLEMSG; else OperSpyWhois = SPYWHOIS_NONE; }