diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command.cpp | 2 | ||||
-rw-r--r-- | src/config.cpp | 227 | ||||
-rw-r--r-- | src/init.cpp | 36 | ||||
-rw-r--r-- | src/language.cpp | 2 | ||||
-rw-r--r-- | src/mail.cpp | 26 | ||||
-rw-r--r-- | src/main.cpp | 4 | ||||
-rw-r--r-- | src/messages.cpp | 6 | ||||
-rw-r--r-- | src/misc.cpp | 2 | ||||
-rw-r--r-- | src/modulemanager.cpp | 2 | ||||
-rw-r--r-- | src/protocol.cpp | 18 | ||||
-rw-r--r-- | src/uplink.cpp | 6 | ||||
-rw-r--r-- | src/users.cpp | 6 | ||||
-rw-r--r-- | src/xline.cpp | 4 |
13 files changed, 170 insertions, 171 deletions
diff --git a/src/command.cpp b/src/command.cpp index d5bbca2dd..080e6471d 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -222,7 +222,7 @@ namespace void HandleUnknownCommand(CommandSource& source, const Anope::string &message) { // Try to find a similar command. - size_t distance = Config->GetBlock("options")->Get<size_t>("didyoumeandifference", "4"); + size_t distance = Config->GetBlock("options").Get<size_t>("didyoumeandifference", "4"); Anope::string similar; auto umessage = message.upper(); for (const auto &[command, info] : source.service->commands) diff --git a/src/config.cpp b/src/config.cpp index 47ce6feaa..33d7a8de8 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -43,14 +43,14 @@ int Block::CountBlock(const Anope::string &bname) const return blocks.count(bname); } -const Block *Block::GetBlock(const Anope::string &bname, int num) const +const Block &Block::GetBlock(const Anope::string &bname, int num) const { std::pair<block_map::const_iterator, block_map::const_iterator> it = blocks.equal_range(bname); for (int i = 0; it.first != it.second; ++it.first, ++i) if (i == num) - return &it.first->second; - return &EmptyBlock; + return it.first->second; + return EmptyBlock; } Block *Block::GetMutableBlock(const Anope::string &bname, int num) @@ -127,16 +127,16 @@ Conf::Conf() : Block("") for (int i = 0; i < this->CountBlock("include"); ++i) { - const Block *include = this->GetBlock("include", i); + const Block &include = this->GetBlock("include", i); - const Anope::string &type = include->Get<const Anope::string>("type"), - &file = include->Get<const Anope::string>("name"); + const Anope::string &type = include.Get<const Anope::string>("type"), + &file = include.Get<const Anope::string>("name"); File f(file, type == "executable"); this->LoadConf(f); } - FOREACH_MOD(OnReload, (this)); + FOREACH_MOD(OnReload, (*this)); /* Check for modified values that aren't allowed to be modified */ if (Config) @@ -159,58 +159,58 @@ Conf::Conf() : Block("") for (const auto &tag : noreload) { - if (this->GetBlock(tag.block)->Get<const Anope::string>(tag.name) != Config->GetBlock(tag.block)->Get<const Anope::string>(tag.name)) + if (this->GetBlock(tag.block).Get<const Anope::string>(tag.name) != Config->GetBlock(tag.block).Get<const Anope::string>(tag.name)) throw ConfigException("<" + tag.block + ":" + tag.name + "> can not be modified once set"); } } - const Block *serverinfo = this->GetBlock("serverinfo"), *options = this->GetBlock("options"), - *mail = this->GetBlock("mail"), *networkinfo = this->GetBlock("networkinfo"); + const Block &serverinfo = this->GetBlock("serverinfo"), &options = this->GetBlock("options"), + &mail = this->GetBlock("mail"), &networkinfo = this->GetBlock("networkinfo"); - const Anope::string &servername = serverinfo->Get<Anope::string>("name"); + const Anope::string &servername = serverinfo.Get<Anope::string>("name"); ValidateNotEmptyOrSpaces("serverinfo", "name", servername); if (servername.find(' ') != Anope::string::npos || servername.find('.') == Anope::string::npos) throw ConfigException("serverinfo:name is not a valid server name"); - ValidateNotEmpty("serverinfo", "description", serverinfo->Get<const Anope::string>("description")); - ValidateNotEmpty("serverinfo", "pid", serverinfo->Get<const Anope::string>("pid")); - ValidateNotEmpty("serverinfo", "motd", serverinfo->Get<const Anope::string>("motd")); + ValidateNotEmpty("serverinfo", "description", serverinfo.Get<const Anope::string>("description")); + ValidateNotEmpty("serverinfo", "pid", serverinfo.Get<const Anope::string>("pid")); + ValidateNotEmpty("serverinfo", "motd", serverinfo.Get<const Anope::string>("motd")); - ValidateNotZero("options", "readtimeout", options->Get<time_t>("readtimeout")); + ValidateNotZero("options", "readtimeout", options.Get<time_t>("readtimeout")); - ValidateNotZero("networkinfo", "nicklen", networkinfo->Get<unsigned>("nicklen", "1")); - ValidateNotZero("networkinfo", "userlen", networkinfo->Get<unsigned>("userlen", "1")); - ValidateNotZero("networkinfo", "hostlen", networkinfo->Get<unsigned>("hostlen", "1")); - ValidateNotZero("networkinfo", "chanlen", networkinfo->Get<unsigned>("chanlen", "1")); + ValidateNotZero("networkinfo", "nicklen", networkinfo.Get<unsigned>("nicklen", "1")); + ValidateNotZero("networkinfo", "userlen", networkinfo.Get<unsigned>("userlen", "1")); + ValidateNotZero("networkinfo", "hostlen", networkinfo.Get<unsigned>("hostlen", "1")); + ValidateNotZero("networkinfo", "chanlen", networkinfo.Get<unsigned>("chanlen", "1")); - spacesepstream(options->Get<const Anope::string>("ulineservers")).GetTokens(this->Ulines); + spacesepstream(options.Get<const Anope::string>("ulineservers")).GetTokens(this->Ulines); - if (mail->Get<bool>("usemail")) + if (mail.Get<bool>("usemail")) { Anope::string check[] = { "sendfrom", "registration_subject", "registration_message", "emailchange_subject", "emailchange_message", "memo_subject", "memo_message" }; for (const auto &field : check) - ValidateNotEmpty("mail", field, mail->Get<const Anope::string>(field)); + ValidateNotEmpty("mail", field, mail.Get<const Anope::string>(field)); } - this->ReadTimeout = options->Get<time_t>("readtimeout"); - this->ServiceAlias = options->Get<bool>("servicealias"); + this->ReadTimeout = options.Get<time_t>("readtimeout"); + this->ServiceAlias = options.Get<bool>("servicealias"); { std::vector<Anope::string> defaults; - spacesepstream(this->GetModule("nickserv")->Get<const Anope::string>("defaults")).GetTokens(defaults); + spacesepstream(this->GetModule("nickserv").Get<const Anope::string>("defaults")).GetTokens(defaults); this->DefPrivmsg = std::find(defaults.begin(), defaults.end(), "msg") != defaults.end(); } - this->DefLanguage = options->Get<const Anope::string>("defaultlanguage"); - this->TimeoutCheck = options->Get<time_t>("timeoutcheck"); - this->NickChars = networkinfo->Get<Anope::string>("nick_chars"); + this->DefLanguage = options.Get<const Anope::string>("defaultlanguage"); + this->TimeoutCheck = options.Get<time_t>("timeoutcheck"); + this->NickChars = networkinfo.Get<Anope::string>("nick_chars"); for (int i = 0; i < this->CountBlock("uplink"); ++i) { - const Block *uplink = this->GetBlock("uplink", i); + const Block &uplink = this->GetBlock("uplink", i); int protocol; - const Anope::string &protocolstr = uplink->Get<const Anope::string>("protocol", "ipv4"); + const Anope::string &protocolstr = uplink.Get<const Anope::string>("protocol", "ipv4"); if (protocolstr == "ipv4") protocol = AF_INET; else if (protocolstr == "ipv6") @@ -220,17 +220,17 @@ Conf::Conf() : Block("") else throw ConfigException("uplink:protocol must be set to ipv4, ipv6, or unix"); - const Anope::string &host = uplink->Get<const Anope::string>("host"); + const Anope::string &host = uplink.Get<const Anope::string>("host"); ValidateNotEmptyOrSpaces("uplink", "host", host); int port = 0; if (protocol != AF_UNIX) { - port = uplink->Get<int>("port"); + port = uplink.Get<int>("port"); ValidateNotZero("uplink", "port", port); } - const Anope::string &password = uplink->Get<const Anope::string>("password"); + const Anope::string &password = uplink.Get<const Anope::string>("password"); ValidateNotEmptyOrSpaces("uplink", "password", password); if (password[0] == ':') throw ConfigException("uplink:password is not valid"); @@ -240,9 +240,9 @@ Conf::Conf() : Block("") for (int i = 0; i < this->CountBlock("module"); ++i) { - const Block *module = this->GetBlock("module", i); + const Block &module = this->GetBlock("module", i); - const Anope::string &modname = module->Get<const Anope::string>("name"); + const Anope::string &modname = module.Get<const Anope::string>("name"); ValidateNotEmptyOrSpaces("module", "name", modname); @@ -251,13 +251,13 @@ Conf::Conf() : Block("") for (int i = 0; i < this->CountBlock("opertype"); ++i) { - const Block *opertype = this->GetBlock("opertype", i); + const Block &opertype = this->GetBlock("opertype", i); - const Anope::string &oname = opertype->Get<const Anope::string>("name"), - &modes = opertype->Get<const Anope::string>("modes"), - &inherits = opertype->Get<const Anope::string>("inherits"), - &commands = opertype->Get<const Anope::string>("commands"), - &privs = opertype->Get<const Anope::string>("privs"); + const Anope::string &oname = opertype.Get<const Anope::string>("name"), + &modes = opertype.Get<const Anope::string>("modes"), + &inherits = opertype.Get<const Anope::string>("inherits"), + &commands = opertype.Get<const Anope::string>("commands"), + &privs = opertype.Get<const Anope::string>("privs"); ValidateNotEmpty("opertype", "name", oname); @@ -294,15 +294,15 @@ Conf::Conf() : Block("") for (int i = 0; i < this->CountBlock("oper"); ++i) { - const Block *oper = this->GetBlock("oper", i); + const Block &oper = this->GetBlock("oper", i); - const Anope::string &nname = oper->Get<const Anope::string>("name"), - &type = oper->Get<const Anope::string>("type"), - &password = oper->Get<const Anope::string>("password"), - &certfp = oper->Get<const Anope::string>("certfp"), - &host = oper->Get<const Anope::string>("host"), - &vhost = oper->Get<const Anope::string>("vhost"); - bool require_oper = oper->Get<bool>("require_oper"); + const Anope::string &nname = oper.Get<const Anope::string>("name"), + &type = oper.Get<const Anope::string>("type"), + &password = oper.Get<const Anope::string>("password"), + &certfp = oper.Get<const Anope::string>("certfp"), + &host = oper.Get<const Anope::string>("host"), + &vhost = oper.Get<const Anope::string>("vhost"); + bool require_oper = oper.Get<bool>("require_oper"); ValidateNotEmptyOrSpaces("oper", "name", nname); ValidateNotEmpty("oper", "type", type); @@ -330,15 +330,15 @@ Conf::Conf() : Block("") bi->conf = false; for (int i = 0; i < this->CountBlock("service"); ++i) { - const Block *service = this->GetBlock("service", i); + const Block &service = this->GetBlock("service", i); - const Anope::string &nick = service->Get<const Anope::string>("nick"), - &user = service->Get<const Anope::string>("user"), - &host = service->Get<const Anope::string>("host"), - &gecos = service->Get<const Anope::string>("gecos"), - &modes = service->Get<const Anope::string>("modes"), - &channels = service->Get<const Anope::string>("channels"), - &alias = service->Get<const Anope::string>("alias", nick.upper()); + const Anope::string &nick = service.Get<const Anope::string>("nick"), + &user = service.Get<const Anope::string>("user"), + &host = service.Get<const Anope::string>("host"), + &gecos = service.Get<const Anope::string>("gecos"), + &modes = service.Get<const Anope::string>("modes"), + &channels = service.Get<const Anope::string>("channels"), + &alias = service.Get<const Anope::string>("alias", nick.upper()); ValidateNotEmptyOrSpaces("service", "nick", nick); ValidateNotEmptyOrSpaces("service", "user", user); @@ -396,7 +396,6 @@ Conf::Conf() : Block("") { size_t ch = oldchannel.find('#'); Anope::string chname = oldchannel.substr(ch != Anope::string::npos ? ch : 0); - bool found = false; for (const auto &botchannel : bi->botchannels) { @@ -421,24 +420,24 @@ Conf::Conf() : Block("") for (int i = 0; i < this->CountBlock("log"); ++i) { - const Block *log = this->GetBlock("log", i); + const Block &log = this->GetBlock("log", i); - int logage = log->Get<int>("logage"); - bool rawio = log->Get<bool>("rawio"); - bool debug = log->Get<bool>("debug"); + int logage = log.Get<int>("logage"); + bool rawio = log.Get<bool>("rawio"); + bool debug = log.Get<bool>("debug"); LogInfo l(logage, rawio, debug); - l.bot = BotInfo::Find(log->Get<const Anope::string>("bot", "Global"), true); - spacesepstream(log->Get<const Anope::string>("target")).GetTokens(l.targets); - spacesepstream(log->Get<const Anope::string>("source")).GetTokens(l.sources); - spacesepstream(log->Get<const Anope::string>("admin")).GetTokens(l.admin); - spacesepstream(log->Get<const Anope::string>("override")).GetTokens(l.override); - spacesepstream(log->Get<const Anope::string>("commands")).GetTokens(l.commands); - spacesepstream(log->Get<const Anope::string>("servers")).GetTokens(l.servers); - spacesepstream(log->Get<const Anope::string>("channels")).GetTokens(l.channels); - spacesepstream(log->Get<const Anope::string>("users")).GetTokens(l.users); - spacesepstream(log->Get<const Anope::string>("other")).GetTokens(l.normal); + l.bot = BotInfo::Find(log.Get<const Anope::string>("bot", "Global"), true); + spacesepstream(log.Get<const Anope::string>("target")).GetTokens(l.targets); + spacesepstream(log.Get<const Anope::string>("source")).GetTokens(l.sources); + spacesepstream(log.Get<const Anope::string>("admin")).GetTokens(l.admin); + spacesepstream(log.Get<const Anope::string>("override")).GetTokens(l.override); + spacesepstream(log.Get<const Anope::string>("commands")).GetTokens(l.commands); + spacesepstream(log.Get<const Anope::string>("servers")).GetTokens(l.servers); + spacesepstream(log.Get<const Anope::string>("channels")).GetTokens(l.channels); + spacesepstream(log.Get<const Anope::string>("users")).GetTokens(l.users); + spacesepstream(log.Get<const Anope::string>("other")).GetTokens(l.normal); this->LogInfos.push_back(l); } @@ -447,14 +446,14 @@ Conf::Conf() : Block("") bi->commands.clear(); for (int i = 0; i < this->CountBlock("command"); ++i) { - const Block *command = this->GetBlock("command", i); + const Block &command = this->GetBlock("command", i); - const Anope::string &service = command->Get<const Anope::string>("service"), - &nname = command->Get<const Anope::string>("name"), - &cmd = command->Get<const Anope::string>("command"), - &permission = command->Get<const Anope::string>("permission"), - &group = command->Get<const Anope::string>("group"); - bool hide = command->Get<bool>("hide"); + const Anope::string &service = command.Get<const Anope::string>("service"), + &nname = command.Get<const Anope::string>("name"), + &cmd = command.Get<const Anope::string>("command"), + &permission = command.Get<const Anope::string>("permission"), + &group = command.Get<const Anope::string>("group"); + bool hide = command.Get<bool>("hide"); ValidateNotEmptyOrSpaces("command", "service", service); ValidateNotEmpty("command", "name", nname); @@ -472,25 +471,25 @@ Conf::Conf() : Block("") PrivilegeManager::ClearPrivileges(); for (int i = 0; i < this->CountBlock("privilege"); ++i) { - const Block *privilege = this->GetBlock("privilege", i); + const Block &privilege = this->GetBlock("privilege", i); - const Anope::string &nname = privilege->Get<const Anope::string>("name"), - &desc = privilege->Get<const Anope::string>("desc"); - int rank = privilege->Get<int>("rank"); + const Anope::string &nname = privilege.Get<const Anope::string>("name"), + &desc = privilege.Get<const Anope::string>("desc"); + int rank = privilege.Get<int>("rank"); PrivilegeManager::AddPrivilege(Privilege(nname, desc, rank)); } for (int i = 0; i < this->CountBlock("fantasy"); ++i) { - const Block *fantasy = this->GetBlock("fantasy", i); + const Block &fantasy = this->GetBlock("fantasy", i); - const Anope::string &nname = fantasy->Get<const Anope::string>("name"), - &service = fantasy->Get<const Anope::string>("command"), - &permission = fantasy->Get<const Anope::string>("permission"), - &group = fantasy->Get<const Anope::string>("group"); - bool hide = fantasy->Get<bool>("hide"), - prepend_channel = fantasy->Get<bool>("prepend_channel", "yes"); + const Anope::string &nname = fantasy.Get<const Anope::string>("name"), + &service = fantasy.Get<const Anope::string>("command"), + &permission = fantasy.Get<const Anope::string>("permission"), + &group = fantasy.Get<const Anope::string>("group"); + bool hide = fantasy.Get<bool>("hide"), + prepend_channel = fantasy.Get<bool>("prepend_channel", "yes"); ValidateNotEmpty("fantasy", "name", nname); ValidateNotEmptyOrSpaces("fantasy", "command", service); @@ -505,10 +504,10 @@ Conf::Conf() : Block("") for (int i = 0; i < this->CountBlock("command_group"); ++i) { - const Block *command_group = this->GetBlock("command_group", i); + const Block &command_group = this->GetBlock("command_group", i); - const Anope::string &nname = command_group->Get<const Anope::string>("name"), - &description = command_group->Get<const Anope::string>("description"); + const Anope::string &nname = command_group.Get<const Anope::string>("name"), + &description = command_group.Get<const Anope::string>("description"); CommandGroup gr; gr.name = nname; @@ -544,19 +543,19 @@ Conf::Conf() : Block("") Log() << "Tied oper " << na->nc->display << " to type " << o->ot->GetName(); } - if (options->Get<const Anope::string>("casemap", "ascii") == "ascii") + if (options.Get<const Anope::string>("casemap", "ascii") == "ascii") Anope::casemap = std::locale(std::locale(), new Anope::ascii_ctype<char>()); - else if (options->Get<const Anope::string>("casemap") == "rfc1459") + else if (options.Get<const Anope::string>("casemap") == "rfc1459") Anope::casemap = std::locale(std::locale(), new Anope::rfc1459_ctype<char>()); else { try { - Anope::casemap = std::locale(options->Get<const Anope::string>("casemap").c_str()); + Anope::casemap = std::locale(options.Get<const Anope::string>("casemap").c_str()); } catch (const std::runtime_error &) { - Log() << "Unknown casemap " << options->Get<const Anope::string>("casemap") << " - casemap not changed"; + Log() << "Unknown casemap " << options.Get<const Anope::string>("casemap") << " - casemap not changed"; } } Anope::CaseMapRebuild(); @@ -620,30 +619,30 @@ void Conf::Post(Conf *old) } } -Block *Conf::GetModule(const Module *m) +Block &Conf::GetModule(const Module *m) { if (!m) - return &Block::EmptyBlock; + return Block::EmptyBlock; return GetModule(m->name); } -Block *Conf::GetModule(const Anope::string &mname) +Block &Conf::GetModule(const Anope::string &mname) { std::map<Anope::string, Block *>::iterator it = modules.find(mname); if (it != modules.end()) - return it->second; + return *it->second; Block *&block = modules[mname]; /* Search for the block */ for (std::pair<block_map::iterator, block_map::iterator> iters = blocks.equal_range("module"); iters.first != iters.second; ++iters.first) { - Block *b = &iters.first->second; + Block &b = iters.first->second; - if (b->Get<const Anope::string>("name") == mname) + if (b.Get<const Anope::string>("name") == mname) { - block = b; + block = &b; break; } } @@ -660,25 +659,25 @@ BotInfo *Conf::GetClient(const Anope::string &cname) if (it != bots.end()) return BotInfo::Find(!it->second.empty() ? it->second : cname, true); - Block *block = GetModule(cname.lower()); - const Anope::string &client = block->Get<const Anope::string>("client"); + Block &block = GetModule(cname.lower()); + const Anope::string &client = block.Get<const Anope::string>("client"); bots[cname] = client; return GetClient(cname); } -const Block *Conf::GetCommand(CommandSource &source) +const Block &Conf::GetCommand(CommandSource &source) { const Anope::string &block_name = source.c ? "fantasy" : "command"; for (std::pair<block_map::iterator, block_map::iterator> iters = blocks.equal_range(block_name); iters.first != iters.second; ++iters.first) { - Block *b = &iters.first->second; + Block &b = iters.first->second; - if (b->Get<Anope::string>("name") == source.command) + if (b.Get<Anope::string>("name") == source.command) return b; } - return &Block::EmptyBlock; + return Block::EmptyBlock; } File::File(const Anope::string &n, bool e) : name(n), executable(e) @@ -929,12 +928,12 @@ void Conf::LoadConf(File &file) /* Check defines */ for (int i = 0; i < this->CountBlock("define"); ++i) { - const Block *define = this->GetBlock("define", i); + const Block &define = this->GetBlock("define", i); - const Anope::string &dname = define->Get<const Anope::string>("name"); + const Anope::string &dname = define.Get<const Anope::string>("name"); - if (dname == wordbuffer && define != b) - wordbuffer = define->Get<const Anope::string>("value"); + if (dname == wordbuffer && &define != b) + wordbuffer = define.Get<const Anope::string>("value"); } if (b) diff --git a/src/init.cpp b/src/init.cpp index 0508ab94f..4befb9ea1 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -215,7 +215,7 @@ static void InitSignals() static void remove_pidfile() { - auto pidfile = Anope::ExpandData(Config->GetBlock("serverinfo")->Get<const Anope::string>("pid")); + auto pidfile = Anope::ExpandData(Config->GetBlock("serverinfo").Get<const Anope::string>("pid")); if (!pidfile.empty()) remove(pidfile.c_str()); } @@ -224,7 +224,7 @@ static void remove_pidfile() static void write_pidfile() { - auto pidfile = Anope::ExpandData(Config->GetBlock("serverinfo")->Get<const Anope::string>("pid")); + auto pidfile = Anope::ExpandData(Config->GetBlock("serverinfo").Get<const Anope::string>("pid")); if (Anope::NoPID || pidfile.empty()) return; @@ -242,25 +242,25 @@ static void write_pidfile() static void setuidgid() { #ifndef _WIN32 - Configuration::Block *options = Config->GetBlock("options"); + Configuration::Block &options = Config->GetBlock("options"); uid_t uid = -1; gid_t gid = -1; - if (!options->Get<const Anope::string>("user").empty()) + if (!options.Get<const Anope::string>("user").empty()) { errno = 0; - struct passwd *u = getpwnam(options->Get<const Anope::string>("user").c_str()); + struct passwd *u = getpwnam(options.Get<const Anope::string>("user").c_str()); if (u == NULL) - Log() << "Unable to setuid to " << options->Get<const Anope::string>("user") << ": " << Anope::LastError(); + Log() << "Unable to setuid to " << options.Get<const Anope::string>("user") << ": " << Anope::LastError(); else uid = u->pw_uid; } - if (!options->Get<const Anope::string>("group").empty()) + if (!options.Get<const Anope::string>("group").empty()) { errno = 0; - struct group *g = getgrnam(options->Get<const Anope::string>("group").c_str()); + struct group *g = getgrnam(options.Get<const Anope::string>("group").c_str()); if (g == NULL) - Log() << "Unable to setgid to " << options->Get<const Anope::string>("group") << ": " << Anope::LastError(); + Log() << "Unable to setgid to " << options.Get<const Anope::string>("group") << ": " << Anope::LastError(); else gid = g->gr_gid; } @@ -278,16 +278,16 @@ static void setuidgid() if (static_cast<int>(gid) != -1) { if (setgid(gid) == -1) - Log() << "Unable to setgid to " << options->Get<const Anope::string>("group") << ": " << Anope::LastError(); + Log() << "Unable to setgid to " << options.Get<const Anope::string>("group") << ": " << Anope::LastError(); else - Log() << "Successfully set group to " << options->Get<const Anope::string>("group"); + Log() << "Successfully set group to " << options.Get<const Anope::string>("group"); } if (static_cast<int>(uid) != -1) { if (setuid(uid) == -1) - Log() << "Unable to setuid to " << options->Get<const Anope::string>("user") << ": " << Anope::LastError(); + Log() << "Unable to setuid to " << options.Get<const Anope::string>("user") << ": " << Anope::LastError(); else - Log() << "Successfully set user to " << options->Get<const Anope::string>("user"); + Log() << "Successfully set user to " << options.Get<const Anope::string>("user"); } #endif } @@ -493,8 +493,8 @@ bool Anope::Init(int ac, char **av) } /* Create me */ - Configuration::Block *block = Config->GetBlock("serverinfo"); - Me = new Server(NULL, block->Get<const Anope::string>("name"), 0, block->Get<const Anope::string>("description"), block->Get<const Anope::string>("id")); + Configuration::Block &block = Config->GetBlock("serverinfo"); + Me = new Server(NULL, block.Get<const Anope::string>("name"), 0, block.Get<const Anope::string>("description"), block.Get<const Anope::string>("id")); for (const auto &[_, bi] : *BotListByNick) { bi->server = Me; @@ -512,15 +512,15 @@ bool Anope::Init(int ac, char **av) /* load modules */ Log() << "Loading modules..."; for (int i = 0; i < Config->CountBlock("module"); ++i) - ModuleManager::LoadModule(Config->GetBlock("module", i)->Get<const Anope::string>("name"), NULL); + ModuleManager::LoadModule(Config->GetBlock("module", i).Get<const Anope::string>("name"), NULL); #ifndef _WIN32 /* If we're root, issue a warning now */ if (!getuid() && !getgid()) { /* If we are configured to setuid later, don't issue a warning */ - Configuration::Block *options = Config->GetBlock("options"); - if (options->Get<const Anope::string>("user").empty()) + Configuration::Block &options = Config->GetBlock("options"); + if (options.Get<const Anope::string>("user").empty()) { std::cerr << "WARNING: You are currently running Anope as the root superuser. Anope does not" << std::endl; std::cerr << " require root privileges to run, and it is discouraged that you run Anope" << std::endl; diff --git a/src/language.cpp b/src/language.cpp index 8d449d362..440461133 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -36,7 +36,7 @@ void Language::InitLanguages() setlocale(LC_ALL, ""); - spacesepstream sep(Config->GetBlock("options")->Get<const Anope::string>("languages")); + spacesepstream sep(Config->GetBlock("options").Get<const Anope::string>("languages")); Anope::string language; while (sep.GetToken(language)) { diff --git a/src/mail.cpp b/src/mail.cpp index f3adab44c..9fb7aedff 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -15,14 +15,14 @@ Mail::Message::Message(const Anope::string &sf, const Anope::string &mailto, const Anope::string &a, const Anope::string &s, const Anope::string &m) : Thread() - , sendmail_path(Config->GetBlock("mail")->Get<const Anope::string>("sendmailpath", "/usr/sbin/sendmail -it")) + , sendmail_path(Config->GetBlock("mail").Get<const Anope::string>("sendmailpath", "/usr/sbin/sendmail -it")) , send_from(sf) , mail_to(mailto) , addr(a) , subject(s) , message(m) - , content_type(Config->GetBlock("mail")->Get<const Anope::string>("content_type", "text/plain; charset=UTF-8")) - , dont_quote_addresses(Config->GetBlock("mail")->Get<bool>("dontquoteaddresses")) + , content_type(Config->GetBlock("mail").Get<const Anope::string>("content_type", "text/plain; charset=UTF-8")) + , dont_quote_addresses(Config->GetBlock("mail").Get<bool>("dontquoteaddresses")) { } @@ -72,32 +72,32 @@ bool Mail::Send(User *u, NickCore *nc, BotInfo *service, const Anope::string &su if (!nc || !service || subject.empty() || message.empty()) return false; - Configuration::Block *b = Config->GetBlock("mail"); + Configuration::Block &b = Config->GetBlock("mail"); if (!u) { - if (!b->Get<bool>("usemail") || b->Get<const Anope::string>("sendfrom").empty()) + if (!b.Get<bool>("usemail") || b.Get<const Anope::string>("sendfrom").empty()) return false; else if (nc->email.empty()) return false; nc->lastmail = Anope::CurTime; - Thread *t = new Mail::Message(b->Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message); + Thread *t = new Mail::Message(b.Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message); t->Start(); return true; } else { - if (!b->Get<bool>("usemail") || b->Get<const Anope::string>("sendfrom").empty()) + if (!b.Get<bool>("usemail") || b.Get<const Anope::string>("sendfrom").empty()) u->SendMessage(service, _("Services have been configured to not send mail.")); - else if (Anope::CurTime - u->lastmail < b->Get<time_t>("delay")) - u->SendMessage(service, _("Please wait \002%lu\002 seconds and retry."), (unsigned long)b->Get<time_t>("delay") - (Anope::CurTime - u->lastmail)); + else if (Anope::CurTime - u->lastmail < b.Get<time_t>("delay")) + u->SendMessage(service, _("Please wait \002%lu\002 seconds and retry."), (unsigned long)b.Get<time_t>("delay") - (Anope::CurTime - u->lastmail)); else if (nc->email.empty()) u->SendMessage(service, _("Email for \002%s\002 is invalid."), nc->display.c_str()); else { u->lastmail = nc->lastmail = Anope::CurTime; - Thread *t = new Mail::Message(b->Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message); + Thread *t = new Mail::Message(b.Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message); t->Start(); return true; } @@ -108,12 +108,12 @@ bool Mail::Send(User *u, NickCore *nc, BotInfo *service, const Anope::string &su bool Mail::Send(NickCore *nc, const Anope::string &subject, const Anope::string &message) { - Configuration::Block *b = Config->GetBlock("mail"); - if (!b->Get<bool>("usemail") || b->Get<const Anope::string>("sendfrom").empty() || !nc || nc->email.empty() || subject.empty() || message.empty()) + Configuration::Block &b = Config->GetBlock("mail"); + if (!b.Get<bool>("usemail") || b.Get<const Anope::string>("sendfrom").empty() || !nc || nc->email.empty() || subject.empty() || message.empty()) return false; nc->lastmail = Anope::CurTime; - Thread *t = new Mail::Message(b->Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message); + Thread *t = new Mail::Message(b.Get<const Anope::string>("sendfrom"), nc->display, nc->email, subject, message); t->Start(); return true; diff --git a/src/main.cpp b/src/main.cpp index f53b0ba0f..32329043e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -167,8 +167,8 @@ int main(int ac, char **av, char **envp) /* Set up timers */ time_t last_check = Anope::CurTime; - UpdateTimer updateTimer(Config->GetBlock("options")->Get<time_t>("updatetimeout", "2m")); - ExpireTimer expireTimer(Config->GetBlock("options")->Get<time_t>("expiretimeout", "30m")); + UpdateTimer updateTimer(Config->GetBlock("options").Get<time_t>("updatetimeout", "2m")); + ExpireTimer expireTimer(Config->GetBlock("options").Get<time_t>("expiretimeout", "30m")); /*** Main loop. ***/ while (!Anope::Quitting) diff --git a/src/messages.cpp b/src/messages.cpp index ddc6ec380..391b3d330 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -237,7 +237,7 @@ void MOTD::Run(MessageSource &source, const std::vector<Anope::string> ¶ms, if (s != Me) return; - auto motdfile = Anope::ExpandConfig(Config->GetBlock("serverinfo")->Get<const Anope::string>("motd")); + auto motdfile = Anope::ExpandConfig(Config->GetBlock("serverinfo").Get<const Anope::string>("motd")); std::ifstream stream(motdfile.str()); if (!stream.is_open()) { @@ -405,7 +405,7 @@ void Stats::Run(MessageSource &source, const std::vector<Anope::string> ¶ms, case 'o': case 'O': /* Check whether the user is an operator */ - if (!u->HasMode("OPER") && Config->GetBlock("options")->Get<bool>("hidestatso")) + if (!u->HasMode("OPER") && Config->GetBlock("options").Get<bool>("hidestatso")) IRCD->SendNumeric(RPL_STATSLINKINFO, source.GetSource(), params[0][0], "End of /STATS report."); else { @@ -473,7 +473,7 @@ void Whois::Run(MessageSource &source, const std::vector<Anope::string> ¶ms, IRCD->SendNumeric(RPL_WHOISUSER, source.GetSource(), u->nick, u->GetIdent(), u->host, '*', u->realname); if (bi) IRCD->SendNumeric(RPL_WHOISREGNICK, source.GetSource(), bi->nick, "is a registered nick"); - IRCD->SendNumeric(RPL_WHOISSERVER, source.GetSource(), u->nick, Me->GetName(), Config->GetBlock("serverinfo")->Get<const Anope::string>("description")); + IRCD->SendNumeric(RPL_WHOISSERVER, source.GetSource(), u->nick, Me->GetName(), Config->GetBlock("serverinfo").Get<const Anope::string>("description")); if (bi) IRCD->SendNumeric(RPL_WHOISIDLE, source.GetSource(), bi->nick, Anope::CurTime - bi->lastmsg, bi->signon, "seconds idle, signon time"); IRCD->SendNumeric(RPL_WHOISOPERATOR, source.GetSource(), u->nick, "is a Network Service"); diff --git a/src/misc.cpp b/src/misc.cpp index 2c1950ba6..6f0d95833 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -391,7 +391,7 @@ bool Anope::Match(const Anope::string &str, const Anope::string &mask, bool case if (r == NULL || r->GetExpression() != stripped_mask) { - ServiceReference<RegexProvider> provider("Regex", Config->GetBlock("options")->Get<const Anope::string>("regexengine")); + ServiceReference<RegexProvider> provider("Regex", Config->GetBlock("options").Get<const Anope::string>("regexengine")); if (provider) { try diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 07dea3228..11a00e363 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -242,7 +242,7 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) /* Initialize config */ try { - m->OnReload(Config); + m->OnReload(*Config); } catch (const ModuleException &ex) { diff --git a/src/protocol.cpp b/src/protocol.cpp index c66f87653..a45985a0d 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -25,10 +25,10 @@ IRCDProto *IRCD = NULL; IRCDProto::IRCDProto(Module *creator, const Anope::string &p) : Service(creator, "IRCDProto", creator->name) , proto_name(p) - , MaxChannel(Config->GetBlock("networkinfo")->Get<unsigned>("chanlen", "32")) - , MaxHost(Config->GetBlock("networkinfo")->Get<unsigned>("hostlen", "64")) - , MaxNick(Config->GetBlock("networkinfo")->Get<unsigned>("nicklen", "31")) - , MaxUser(Config->GetBlock("networkinfo")->Get<unsigned>("userlen", "10")) + , MaxChannel(Config->GetBlock("networkinfo").Get<unsigned>("chanlen", "32")) + , MaxHost(Config->GetBlock("networkinfo").Get<unsigned>("hostlen", "64")) + , MaxNick(Config->GetBlock("networkinfo").Get<unsigned>("nicklen", "31")) + , MaxUser(Config->GetBlock("networkinfo").Get<unsigned>("userlen", "10")) { if (IRCD == NULL) IRCD = this; @@ -76,7 +76,7 @@ Anope::string IRCDProto::SID_Retrieve() if (!IRCD || !IRCD->RequiresID) return ""; - static Anope::string current_sid = Config->GetBlock("serverinfo")->Get<const Anope::string>("id"); + static Anope::string current_sid = Config->GetBlock("serverinfo").Get<const Anope::string>("id"); if (current_sid.empty()) current_sid = "00A"; @@ -289,8 +289,8 @@ bool IRCDProto::IsHostValid(const Anope::string &host) if (host.empty() || host.length() > IRCD->MaxHost) return false; - const Anope::string &vhostdisablebe = Config->GetBlock("networkinfo")->Get<const Anope::string>("disallow_start_or_end"), - vhostchars = Config->GetBlock("networkinfo")->Get<const Anope::string>("vhost_chars"); + const Anope::string &vhostdisablebe = Config->GetBlock("networkinfo").Get<const Anope::string>("disallow_start_or_end"), + vhostchars = Config->GetBlock("networkinfo").Get<const Anope::string>("vhost_chars"); if (vhostdisablebe.find_first_of(host[0]) != Anope::string::npos) return false; @@ -306,7 +306,7 @@ bool IRCDProto::IsHostValid(const Anope::string &host) return false; } - return dots > 0 || Config->GetBlock("networkinfo")->Get<bool>("allow_undotted_vhosts"); + return dots > 0 || Config->GetBlock("networkinfo").Get<bool>("allow_undotted_vhosts"); } void IRCDProto::SendOper(User *u) @@ -317,7 +317,7 @@ void IRCDProto::SendOper(User *u) size_t IRCDProto::GetMaxListFor(Channel *c, ChannelMode *cm) { - return c->HasMode("LBAN") ? 0 : Config->GetBlock("networkinfo")->Get<size_t>("modelistsize", "100"); + return c->HasMode("LBAN") ? 0 : Config->GetBlock("networkinfo").Get<size_t>("modelistsize", "100"); } Anope::string IRCDProto::NormalizeMask(const Anope::string &mask) diff --git a/src/uplink.cpp b/src/uplink.cpp index c032d6118..100217291 100644 --- a/src/uplink.cpp +++ b/src/uplink.cpp @@ -53,8 +53,8 @@ void Uplink::Connect() Configuration::Uplink &u = Config->Uplinks[Anope::CurrentUplink]; new UplinkSocket(); - if (!Config->GetBlock("serverinfo")->Get<const Anope::string>("localhost").empty()) - UplinkSock->Bind(Config->GetBlock("serverinfo")->Get<const Anope::string>("localhost")); + if (!Config->GetBlock("serverinfo").Get<const Anope::string>("localhost").empty()) + UplinkSock->Bind(Config->GetBlock("serverinfo").Get<const Anope::string>("localhost")); FOREACH_MOD(OnPreServerConnect, ()); Anope::string ip = Anope::Resolve(u.host, u.protocol); Log(LOG_TERMINAL) << "Attempting to connect to uplink #" << (Anope::CurrentUplink + 1) << " " << u.host << " (" << ip << '/' << u.port << ") with protocol " << IRCD->GetProtocolName(); @@ -164,7 +164,7 @@ UplinkSocket::~UplinkSocket() } else if (!Anope::Quitting) { - time_t retry = Config->GetBlock("options")->Get<time_t>("retrywait"); + time_t retry = Config->GetBlock("options").Get<time_t>("retrywait"); Log() << "Disconnected, retrying in " << retry << " seconds"; new ReconnectTimer(retry); diff --git a/src/users.cpp b/src/users.cpp index f6a4adb37..8f8e9570d 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -835,14 +835,14 @@ Anope::string User::Mask() const bool User::BadPassword() { - if (!Config->GetBlock("options")->Get<unsigned int>("badpasslimit")) + if (!Config->GetBlock("options").Get<unsigned int>("badpasslimit")) return false; - if (Config->GetBlock("options")->Get<time_t>("badpasstimeout") > 0 && this->invalid_pw_time > 0 && this->invalid_pw_time < Anope::CurTime - Config->GetBlock("options")->Get<time_t>("badpasstimeout")) + if (Config->GetBlock("options").Get<time_t>("badpasstimeout") > 0 && this->invalid_pw_time > 0 && this->invalid_pw_time < Anope::CurTime - Config->GetBlock("options").Get<time_t>("badpasstimeout")) this->invalid_pw_count = 0; ++this->invalid_pw_count; this->invalid_pw_time = Anope::CurTime; - if (this->invalid_pw_count >= Config->GetBlock("options")->Get<unsigned int>("badpasslimit")) + if (this->invalid_pw_count >= Config->GetBlock("options").Get<unsigned int>("badpasslimit")) { this->Kill(Me, "Too many invalid passwords"); return true; diff --git a/src/xline.cpp b/src/xline.cpp index cdfc2d7c4..9e8dd41bf 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -25,11 +25,11 @@ Serialize::Checker<std::multimap<Anope::string, XLine *, ci::less> > XLineManage void XLine::Init() { - if (this->mask.length() >= 2 && this->mask[0] == '/' && this->mask[this->mask.length() - 1] == '/' && !Config->GetBlock("options")->Get<const Anope::string>("regexengine").empty()) + if (this->mask.length() >= 2 && this->mask[0] == '/' && this->mask[this->mask.length() - 1] == '/' && !Config->GetBlock("options").Get<const Anope::string>("regexengine").empty()) { Anope::string stripped_mask = this->mask.substr(1, this->mask.length() - 2); - ServiceReference<RegexProvider> provider("Regex", Config->GetBlock("options")->Get<const Anope::string>("regexengine")); + ServiceReference<RegexProvider> provider("Regex", Config->GetBlock("options").Get<const Anope::string>("regexengine")); if (provider) { try |