}
ServerConfig::ServerPaths::ServerPaths(ConfigTag* tag)
- : Config(tag->getString("configdir", INSPIRCD_CONFIG_PATH))
- , Data(tag->getString("datadir", INSPIRCD_DATA_PATH))
- , Log(tag->getString("logdir", INSPIRCD_LOG_PATH))
- , Module(tag->getString("moduledir", INSPIRCD_MODULE_PATH))
+ : Config(tag->getString("configdir", INSPIRCD_CONFIG_PATH, 1))
+ , Data(tag->getString("datadir", INSPIRCD_DATA_PATH, 1))
+ , Log(tag->getString("logdir", INSPIRCD_LOG_PATH, 1))
+ , Module(tag->getString("moduledir", INSPIRCD_MODULE_PATH, 1))
{
}
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.");
- CaseMapping = options->getString("casemapping", "rfc1459");
+ CaseMapping = options->getString("casemapping", "rfc1459", 1);
if (CaseMapping == "ascii")
national_case_insensitive_map = ascii_case_insensitive_map;
else if (CaseMapping == "rfc1459")
MaxConn = ConfValue("performance")->getUInt("somaxconn", SOMAXCONN);
TimeSkipWarn = ConfValue("performance")->getDuration("timeskipwarn", 2, 0, 30);
XLineMessage = options->getString("xlinemessage", options->getString("moronbanner", "You're banned!"));
- ServerDesc = server->getString("description", "Configure Me");
- Network = server->getString("network", "Network");
+ ServerDesc = server->getString("description", "Configure Me", 1);
+ Network = server->getString("network", "Network", 1);
NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240, 1024, 65534);
CustomVersion = security->getString("customversion");
HideBans = security->getBool("hidebans");
ReadXLine(this, "badhost", "host", ServerInstance->XLines->GetFactory("K"));
ReadXLine(this, "exception", "host", ServerInstance->XLines->GetFactory("E"));
- const std::string restrictbannedusers = options->getString("restrictbannedusers", "yes");
+ const std::string restrictbannedusers = options->getString("restrictbannedusers", "yes", 1);
if (stdalgo::string::equalsci(restrictbannedusers, "no"))
RestrictBannedUsers = ServerConfig::BUT_NORMAL;
else if (stdalgo::string::equalsci(restrictbannedusers, "silent"))
}
ConfigTag* securitytag = ServerInstance->Config->ConfValue("security");
- const std::string announceinvites = securitytag->getString("announceinvites", "dynamic");
+ const std::string announceinvites = securitytag->getString("announceinvites", "dynamic", 1);
Invite::AnnounceState newannouncestate;
if (stdalgo::string::equalsci(announceinvites, "none"))
newannouncestate = Invite::ANNOUNCE_NONE;
LocalUser* localuser = IS_LOCAL(user);
if (localuser)
tag = localuser->GetClass()->config;
- std::string motd_name = tag->getString("motd", "motd");
+
+ const std::string motd_name = tag->getString("motd", "motd", 1);
ConfigFileCache::iterator motd = motds.find(motd_name);
if (motd == motds.end())
{
for (std::vector<ListenSocket*>::const_iterator i = ServerInstance->ports.begin(); i != ServerInstance->ports.end(); ++i)
{
ListenSocket* ls = *i;
- std::string type = ls->bind_tag->getString("type", "clients");
- std::string hook = ls->bind_tag->getString("ssl", "plaintext");
+ const std::string type = ls->bind_tag->getString("type", "clients", 1);
+ const std::string hook = ls->bind_tag->getString("ssl", "plaintext", 1);
stats.AddRow(249, ls->bind_sa.str() + " (" + type + ", " + hook + ")");
}
else
param.append(c->host);
- row.push(param).push(c->config->getString("port", "*"));
+ row.push(param).push(c->config->getString("port", "*", 1));
row.push(ConvToStr(c->GetRecvqMax())).push(ConvToStr(c->GetSendqSoftMax())).push(ConvToStr(c->GetSendqHardMax())).push(ConvToStr(c->GetCommandRate()));
param = ConvToStr(c->GetPenaltyThreshold());
void ReadConfig(ConfigStatus&) CXX11_OVERRIDE
{
ConfigTag* tag = ServerInstance->Config->ConfValue("options");
- const std::string splitwhois = tag->getString("splitwhois", "no");
+ const std::string splitwhois = tag->getString("splitwhois", "no", 1);
SplitWhoisState newsplitstate;
if (stdalgo::string::equalsci(splitwhois, "no"))
newsplitstate = SPLITWHOIS_NONE;
FIRST_MOD_RESULT(OnAcceptConnection, res, (incomingSockfd, this, &client, &server));
if (res == MOD_RES_PASSTHRU)
{
- std::string type = bind_tag->getString("type", "clients");
+ const std::string type = bind_tag->getString("type", "clients", 1);
if (stdalgo::string::equalsci(type, "clients"))
{
ServerInstance->Users->AddUser(incomingSockfd, this, &client, &server);
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
ConfigTag* tag = ServerInstance->Config->ConfValue("maxmind");
- const std::string file = ServerInstance->Config->Paths.PrependConfig(tag->getString("file", "GeoLite2-Country.mmdb"));
+ const std::string file = ServerInstance->Config->Paths.PrependConfig(tag->getString("file", "GeoLite2-Country.mmdb", 1));
// Try to read the new database.
MMDB_s mmdb;
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
ConfigTag* Conf = ServerInstance->Config->ConfValue("stdregex");
- std::string regextype = Conf->getString("type", "ecmascript");
+ const std::string regextype = Conf->getString("type", "ecmascript", 1);
if (stdalgo::string::equalsci(regextype, "bre"))
ref.regextype = std::regex::basic;
else if (stdalgo::string::equalsci(regextype, "ere"))
Config(const std::string& profilename, ConfigTag* tag)
: name(profilename)
- , certstr(ReadFile(tag->getString("certfile", "cert.pem")))
- , keystr(ReadFile(tag->getString("keyfile", "key.pem")))
- , dh(DHParams::Import(ReadFile(tag->getString("dhfile", "dhparams.pem"))))
+ , certstr(ReadFile(tag->getString("certfile", "cert.pem", 1)))
+ , keystr(ReadFile(tag->getString("keyfile", "key.pem", 1)))
+ , dh(DHParams::Import(ReadFile(tag->getString("dhfile", "dhparams.pem", 1))))
, priostr(GetPrioStr(profilename, tag))
, mindh(tag->getUInt("mindhbits", 1024))
- , hashstr(tag->getString("hash", "md5"))
+ , hashstr(tag->getString("hash", "md5", 1))
, requestclientcert(tag->getBool("requestclientcert", true))
{
// Load trusted CA and revocation list, if set
Config(const std::string& profilename, ConfigTag* tag, CTRDRBG& ctr_drbg)
: name(profilename)
, ctrdrbg(ctr_drbg)
- , certstr(ReadFile(tag->getString("certfile", "cert.pem")))
- , keystr(ReadFile(tag->getString("keyfile", "key.pem")))
- , dhstr(ReadFile(tag->getString("dhfile", "dhparams.pem")))
+ , certstr(ReadFile(tag->getString("certfile", "cert.pem", 1)))
+ , keystr(ReadFile(tag->getString("keyfile", "key.pem", 1)))
+ , dhstr(ReadFile(tag->getString("dhfile", "dhparams.pem", 1)))
, ciphersuitestr(tag->getString("ciphersuites"))
, curvestr(tag->getString("curves"))
, mindh(tag->getUInt("mindhbits", 2048))
- , hashstr(tag->getString("hash", "sha256"))
+ , hashstr(tag->getString("hash", "sha256", 1))
, castr(tag->getString("cafile"))
, minver(tag->getUInt("minver", 0))
, maxver(tag->getUInt("maxver", 0))
public:
Profile(const std::string& profilename, ConfigTag* tag)
: name(profilename)
- , dh(ServerInstance->Config->Paths.PrependConfig(tag->getString("dhfile", "dhparams.pem")))
+ , dh(ServerInstance->Config->Paths.PrependConfig(tag->getString("dhfile", "dhparams.pem", 1)))
, ctx(SSL_CTX_new(SSLv23_server_method()))
, clictx(SSL_CTX_new(SSLv23_client_method()))
, allowrenego(tag->getBool("renegotiation")) // Disallow by default
if ((!ctx.SetDH(dh)) || (!clictx.SetDH(dh)))
throw Exception("Couldn't set DH parameters");
- std::string hash = tag->getString("hash", "md5");
+ const std::string hash = tag->getString("hash", "md5", 1);
digest = EVP_get_digestbyname(hash.c_str());
if (digest == NULL)
throw Exception("Unknown hash type " + hash);
}
#ifndef OPENSSL_NO_ECDH
- std::string curvename = tag->getString("ecdhcurve", "prime256v1");
+ const std::string curvename = tag->getString("ecdhcurve", "prime256v1", 1);
if (!curvename.empty())
ctx.SetECDH(curvename);
#endif
/* Load our keys and certificates
* NOTE: OpenSSL's error logging API sucks, don't blame us for this clusterfuck.
*/
- std::string filename = ServerInstance->Config->Paths.PrependConfig(tag->getString("certfile", "cert.pem"));
+ std::string filename = ServerInstance->Config->Paths.PrependConfig(tag->getString("certfile", "cert.pem", 1));
if ((!ctx.SetCerts(filename)) || (!clictx.SetCerts(filename)))
{
ERR_print_errors_cb(error_callback, this);
throw Exception("Can't read certificate file: " + lasterr);
}
- filename = ServerInstance->Config->Paths.PrependConfig(tag->getString("keyfile", "key.pem"));
+ filename = ServerInstance->Config->Paths.PrependConfig(tag->getString("keyfile", "key.pem", 1));
if ((!ctx.SetPrivateKey(filename)) || (!clictx.SetPrivateKey(filename)))
{
ERR_print_errors_cb(error_callback, this);
}
// Load the CAs we trust
- filename = ServerInstance->Config->Paths.PrependConfig(tag->getString("cafile", "ca.pem"));
+ filename = ServerInstance->Config->Paths.PrependConfig(tag->getString("cafile", "ca.pem", 1));
if ((!ctx.SetCA(filename)) || (!clictx.SetCA(filename)))
{
ERR_print_errors_cb(error_callback, this);
}
// Load the CRLs.
- std::string crlfile = tag->getString("crlfile");
- std::string crlpath = tag->getString("crlpath");
- std::string crlmode = tag->getString("crlmode", "chain");
+ const std::string crlfile = tag->getString("crlfile");
+ const std::string crlpath = tag->getString("crlpath");
+ const std::string crlmode = tag->getString("crlmode", "chain", 1);
ctx.SetCRL(crlfile, crlpath, crlmode);
clictx.SetVerifyCert();
ConfigTag* tag = ServerInstance->Config->ConfValue("anticaps");
uppercase.reset();
- const std::string upper = tag->getString("uppercase", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+ const std::string upper = tag->getString("uppercase", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 1);
for (std::string::const_iterator iter = upper.begin(); iter != upper.end(); ++iter)
uppercase.set(static_cast<unsigned char>(*iter));
lowercase.set(static_cast<unsigned char>(*iter));
uppercase.reset();
- const std::string upper = tag->getString("uppercase", tag->getString("capsmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
+ const std::string upper = tag->getString("uppercase", tag->getString("capsmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 1));
for (std::string::const_iterator iter = upper.begin(); iter != upper.end(); ++iter)
uppercase.set(static_cast<unsigned char>(*iter));
}
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
- std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789");
+ ConfigTag* tag = ServerInstance->Config->ConfValue("hostname");
+ const std::string hmap = tag->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789", 1);
cmd.hostmap.reset();
- for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
+ for (std::string::const_iterator n = hmap.begin(); n != hmap.end(); n++)
cmd.hostmap.set(static_cast<unsigned char>(*n));
}
name.c_str(), tag->getTagLocation().c_str());
}
- std::string host = tag->getString("host", "*@*");
+ std::string host = tag->getString("host", "*@*", 1);
std::string title = tag->getString("title");
std::string vhost = tag->getString("vhost");
CustomTitle config(name, pass, hash, host, title, vhost);
ConfigTag* tag = i->second;
// If "target" is not found, try the old "channel" key to keep compatibility with 2.0 configs
- const std::string target = tag->getString("target", tag->getString("channel"));
+ const std::string target = tag->getString("target", tag->getString("channel"), 1);
if (!target.empty())
{
if (target[0] == '#')
for (std::vector<ListenSocket*>::const_iterator i = ServerInstance->ports.begin(); i != ServerInstance->ports.end(); ++i)
{
ListenSocket* ls = *i;
- if (!stdalgo::string::equalsci(ls->bind_tag->getString("type", "clients"), "clients") || !ls->bind_tag->getString("ssl").empty())
+ if (!stdalgo::string::equalsci(ls->bind_tag->getString("type", "clients", 1), "clients"))
+ continue;
+
+ if (!ls->bind_tag->getString("ssl").empty())
continue;
to_ports.append(ConvToStr(ls->bind_sa.port())).push_back(',');
}
}
- const std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789");
+ ConfigTag* tag = ServerInstance->Config->ConfValue("hostname");
+ const std::string hmap = tag->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789", 1);
+
hostmap.reset();
for (std::string::const_iterator iter = hmap.begin(); iter != hmap.end(); ++iter)
hostmap.set(static_cast<unsigned char>(*iter));
{
ConfigTag* tag = ServerInstance->Config->ConfValue("nationalchars");
charset = tag->getString("file");
- std::string casemapping = tag->getString("casemapping", FileSystem::GetFileName(charset));
+ std::string casemapping = tag->getString("casemapping", FileSystem::GetFileName(charset), 1);
if (casemapping.find(' ') != std::string::npos)
throw ModuleException("<nationalchars:casemapping> must not contain any spaces!");
ServerInstance->Config->CaseMapping = casemapping;
try
{
- FileReader reader(conf->getString("file", "opermotd"));
+ FileReader reader(conf->getString("file", "opermotd", 1));
cmd.opermotd = reader.GetVector();
InspIRCd::ProcessColors(cmd.opermotd);
}
ConfigTag* tag = ServerInstance->Config->ConfValue("passforward");
nickrequired = tag->getString("nick", "NickServ");
forwardmsg = tag->getString("forwardmsg", "NOTICE $nick :*** Forwarding PASS to $nickrequired");
- forwardcmd = tag->getString("cmd", "SQUERY $nickrequired :IDENTIFY $pass");
+ forwardcmd = tag->getString("cmd", "SQUERY $nickrequired :IDENTIFY $pass", 1);
}
void FormatStr(std::string& result, const std::string& format, const LocalUser* user)
ConfigTag* conf = ServerInstance->Config->ConfValue("randquote");
prefix = conf->getString("prefix");
suffix = conf->getString("suffix");
- FileReader reader(conf->getString("file", "quotes"));
+ FileReader reader(conf->getString("file", "quotes", 1));
quotes = reader.GetVector();
}
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
- std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789");
+ ConfigTag* tag = ServerInstance->Config->ConfValue("hostname");
+ const std::string hmap = tag->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789", 1);
cmd.hostmap.reset();
- for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
+ for (std::string::const_iterator n = hmap.begin(); n != hmap.end(); n++)
cmd.hostmap.set(static_cast<unsigned char>(*n));
}
else
SQL.SetProvider("SQL/" + dbid);
- query = tag->getString("query", "SELECT * FROM ircd_opers WHERE active=1;");
+ query = tag->getString("query", "SELECT * FROM ircd_opers WHERE active=1;", 1);
// Update sqloper list from the database.
GetOperBlocks();
}
* ...and so is discarding all current in-memory XLines for the ones in the database.
*/
ConfigTag* Conf = ServerInstance->Config->ConfValue("xlinedb");
- xlinedbpath = ServerInstance->Config->Paths.PrependData(Conf->getString("filename", "xline.db"));
+ xlinedbpath = ServerInstance->Config->Paths.PrependData(Conf->getString("filename", "xline.db", 1));
SetInterval(Conf->getDuration("saveperiod", 5));
// Read xlines before attaching to events
}
else if (a->type == CC_DENY)
{
- ServerInstance->Users->QuitUser(this, a->config->getString("reason", "Unauthorised connection"));
+ ServerInstance->Users->QuitUser(this, a->config->getString("reason", "Unauthorised connection", 1));
return;
}
else if (clone_count)