diff options
author | Adam <Adam@anope.org> | 2010-08-17 19:27:37 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-08-17 19:27:37 -0400 |
commit | e65d8b2f3dfdb40858259b3bb48ef6998c31e62f (patch) | |
tree | fd845bdef5664d025ab19c262ae2c5e9d23d7bb2 /src | |
parent | 2575008baa5c9d0ca789680da1a3b81dc74786f7 (diff) |
Rewrote the config reader to better handle invalid configs.
This prevents Anope from exploding when /os reload has errors.
Diffstat (limited to 'src')
-rw-r--r-- | src/actions.cpp | 8 | ||||
-rw-r--r-- | src/bots.cpp | 20 | ||||
-rw-r--r-- | src/botserv.cpp | 32 | ||||
-rw-r--r-- | src/channels.cpp | 18 | ||||
-rw-r--r-- | src/chanserv.cpp | 28 | ||||
-rw-r--r-- | src/commands.cpp | 4 | ||||
-rw-r--r-- | src/config.cpp | 1183 | ||||
-rw-r--r-- | src/configreader.cpp | 40 | ||||
-rw-r--r-- | src/hostserv.cpp | 8 | ||||
-rw-r--r-- | src/init.cpp | 59 | ||||
-rw-r--r-- | src/language.cpp | 14 | ||||
-rw-r--r-- | src/log.cpp | 8 | ||||
-rw-r--r-- | src/mail.cpp | 16 | ||||
-rw-r--r-- | src/main.cpp | 38 | ||||
-rw-r--r-- | src/memoserv.cpp | 50 | ||||
-rw-r--r-- | src/messages.cpp | 92 | ||||
-rw-r--r-- | src/misc.cpp | 26 | ||||
-rw-r--r-- | src/modes.cpp | 12 | ||||
-rw-r--r-- | src/modulemanager.cpp | 8 | ||||
-rw-r--r-- | src/modules.cpp | 12 | ||||
-rw-r--r-- | src/nickalias.cpp | 8 | ||||
-rw-r--r-- | src/nickcore.cpp | 4 | ||||
-rw-r--r-- | src/nickserv.cpp | 24 | ||||
-rw-r--r-- | src/operserv.cpp | 42 | ||||
-rw-r--r-- | src/protocol.cpp | 12 | ||||
-rw-r--r-- | src/regchannel.cpp | 10 | ||||
-rw-r--r-- | src/send.cpp | 2 | ||||
-rw-r--r-- | src/servers.cpp | 8 | ||||
-rw-r--r-- | src/sessions.cpp | 26 | ||||
-rw-r--r-- | src/users.cpp | 24 |
30 files changed, 873 insertions, 963 deletions
diff --git a/src/actions.cpp b/src/actions.cpp index 17c0a2898..bdc5a041d 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -23,14 +23,14 @@ bool bad_password(User *u) { time_t now = time(NULL); - if (!u || !Config.BadPassLimit) + if (!u || !Config->BadPassLimit) return false; - if (Config.BadPassTimeout > 0 && u->invalid_pw_time > 0 && u->invalid_pw_time < now - Config.BadPassTimeout) + if (Config->BadPassTimeout > 0 && u->invalid_pw_time > 0 && u->invalid_pw_time < now - Config->BadPassTimeout) u->invalid_pw_count = 0; ++u->invalid_pw_count; u->invalid_pw_time = now; - if (u->invalid_pw_count >= Config.BadPassLimit) + if (u->invalid_pw_count >= Config->BadPassLimit) { kill_user("", u->nick, "Too many invalid passwords"); return true; @@ -53,7 +53,7 @@ void kill_user(const Anope::string &source, const Anope::string &user, const Ano if (user.empty()) return; - Anope::string real_source = source.empty() ? Config.ServerName : source; + Anope::string real_source = source.empty() ? Config->ServerName : source; Anope::string buf = real_source + " (" + reason + ")"; diff --git a/src/bots.cpp b/src/bots.cpp index c07b358da..cb7a370c1 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -30,19 +30,19 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A this->chancount = 0; this->lastmsg = this->created = time(NULL); - if (!Config.s_ChanServ.empty() && nnick.equals_ci(Config.s_ChanServ)) + if (!Config->s_ChanServ.empty() && nnick.equals_ci(Config->s_ChanServ)) ChanServ = this; - else if (!Config.s_BotServ.empty() && nnick.equals_ci(Config.s_BotServ)) + else if (!Config->s_BotServ.empty() && nnick.equals_ci(Config->s_BotServ)) BotServ = this; - else if (!Config.s_HostServ.empty() && nnick.equals_ci(Config.s_HostServ)) + else if (!Config->s_HostServ.empty() && nnick.equals_ci(Config->s_HostServ)) HostServ = this; - else if (!Config.s_OperServ.empty() && nnick.equals_ci(Config.s_OperServ)) + else if (!Config->s_OperServ.empty() && nnick.equals_ci(Config->s_OperServ)) OperServ = this; - else if (!Config.s_MemoServ.empty() && nnick.equals_ci(Config.s_MemoServ)) + else if (!Config->s_MemoServ.empty() && nnick.equals_ci(Config->s_MemoServ)) MemoServ = this; - else if (!Config.s_NickServ.empty() && nnick.equals_ci(Config.s_NickServ)) + else if (!Config->s_NickServ.empty() && nnick.equals_ci(Config->s_NickServ)) NickServ = this; - else if (!Config.s_GlobalNoticer.empty() && nnick.equals_ci(Config.s_GlobalNoticer)) + else if (!Config->s_GlobalNoticer.empty() && nnick.equals_ci(Config->s_GlobalNoticer)) Global = this; BotListByNick[this->nick] = this; @@ -94,7 +94,7 @@ void BotInfo::RejoinAll() { ChannelInfo *ci = it->second; - if (ci->bi == this && ci->c && ci->c->users.size() >= Config.BSMinUsers) + if (ci->bi == this && ci->c && ci->c->users.size() >= Config->BSMinUsers) this->Join(ci->c); } } @@ -112,7 +112,7 @@ void BotInfo::Assign(User *u, ChannelInfo *ci) ++this->chancount; ci->bi = this; - if (ci->c && ci->c->users.size() >= Config.BSMinUsers) + if (ci->c && ci->c->users.size() >= Config->BSMinUsers) this->Join(ci->c); } @@ -138,7 +138,7 @@ void BotInfo::UnAssign(User *u, ChannelInfo *ci) void BotInfo::Join(Channel *c) { - if (Config.BSSmartJoin) + if (Config->BSSmartJoin) { /* We check for bans */ if (c->bans && c->bans->count) diff --git a/src/botserv.cpp b/src/botserv.cpp index 381223681..ee6f08f29 100644 --- a/src/botserv.cpp +++ b/src/botserv.cpp @@ -26,7 +26,7 @@ E void moduleAddBotServCmds(); void moduleAddBotServCmds() { - ModuleManager::LoadModuleList(Config.BotServCoreModules); + ModuleManager::LoadModuleList(Config->BotServCoreModules); } /*************************************************************************/ @@ -61,7 +61,7 @@ void get_botserv_stats(long *nrec, long *memuse) void bs_init() { - if (!Config.s_BotServ.empty()) + if (!Config->s_BotServ.empty()) moduleAddBotServCmds(); } @@ -198,25 +198,25 @@ void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf) { BadWord *bw = ci->GetBadWord(i); - if (bw->type == BW_ANY && ((Config.BSCaseSensitive && nbuf.find(bw->word) != Anope::string::npos) || (!Config.BSCaseSensitive && nbuf.find_ci(bw->word) != Anope::string::npos))) + if (bw->type == BW_ANY && ((Config->BSCaseSensitive && nbuf.find(bw->word) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(bw->word) != Anope::string::npos))) mustkick = true; else if (bw->type == BW_SINGLE) { size_t len = bw->word.length(); - if ((Config.BSCaseSensitive && bw->word.equals_cs(nbuf)) || (!Config.BSCaseSensitive && bw->word.equals_ci(nbuf))) + if ((Config->BSCaseSensitive && bw->word.equals_cs(nbuf)) || (!Config->BSCaseSensitive && bw->word.equals_ci(nbuf))) mustkick = true; - else if (nbuf.find(' ') == len && ((Config.BSCaseSensitive && bw->word.equals_cs(nbuf)) || (!Config.BSCaseSensitive && bw->word.equals_ci(nbuf)))) + else if (nbuf.find(' ') == len && ((Config->BSCaseSensitive && bw->word.equals_cs(nbuf)) || (!Config->BSCaseSensitive && bw->word.equals_ci(nbuf)))) mustkick = true; else { - if (nbuf.rfind(' ') == nbuf.length() - len - 1 && ((Config.BSCaseSensitive && nbuf.find(bw->word) == nbuf.length() - len) || (!Config.BSCaseSensitive && nbuf.find_ci(bw->word) == nbuf.length() - len))) + if (nbuf.rfind(' ') == nbuf.length() - len - 1 && ((Config->BSCaseSensitive && nbuf.find(bw->word) == nbuf.length() - len) || (!Config->BSCaseSensitive && nbuf.find_ci(bw->word) == nbuf.length() - len))) mustkick = true; else { Anope::string wordbuf = " " + bw->word + " "; - if ((Config.BSCaseSensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!Config.BSCaseSensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) + if ((Config->BSCaseSensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) mustkick = true; } } @@ -225,13 +225,13 @@ void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf) { size_t len = bw->word.length(); - if ((Config.BSCaseSensitive && nbuf.substr(0, len).equals_cs(bw->word)) || (!Config.BSCaseSensitive && nbuf.substr(0, len).equals_ci(bw->word))) + if ((Config->BSCaseSensitive && nbuf.substr(0, len).equals_cs(bw->word)) || (!Config->BSCaseSensitive && nbuf.substr(0, len).equals_ci(bw->word))) mustkick = true; else { Anope::string wordbuf = " " + bw->word; - if ((Config.BSCaseSensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!Config.BSCaseSensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) + if ((Config->BSCaseSensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) mustkick = true; } } @@ -239,13 +239,13 @@ void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf) { size_t len = bw->word.length(); - if ((Config.BSCaseSensitive && nbuf.substr(nbuf.length() - len).equals_cs(bw->word)) || (!Config.BSCaseSensitive && nbuf.substr(nbuf.length() - len).equals_ci(bw->word))) + if ((Config->BSCaseSensitive && nbuf.substr(nbuf.length() - len).equals_cs(bw->word)) || (!Config->BSCaseSensitive && nbuf.substr(nbuf.length() - len).equals_ci(bw->word))) mustkick = true; else { Anope::string wordbuf = bw->word + " "; - if ((Config.BSCaseSensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!Config.BSCaseSensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) + if ((Config->BSCaseSensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) mustkick = true; } } @@ -253,7 +253,7 @@ void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf) if (mustkick) { check_ban(ci, u, TTB_BADWORDS); - if (Config.BSGentleBWReason) + if (Config->BSGentleBWReason) bot_kick(ci, u, BOT_REASON_BADWORD_GENTLE); else bot_kick(ci, u, BOT_REASON_BADWORD, bw->word.c_str()); @@ -320,12 +320,12 @@ void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf) return; /* Fantaisist commands */ - if (ci->botflags.HasFlag(BS_FANTASY) && buf[0] == Config.BSFantasyCharacter[0] && !was_action) + if (ci->botflags.HasFlag(BS_FANTASY) && buf[0] == Config->BSFantasyCharacter[0] && !was_action) { spacesepstream sep(buf); Anope::string token; - if (sep.GetToken(token) && token[0] == Config.BSFantasyCharacter[0]) + if (sep.GetToken(token) && token[0] == Config->BSFantasyCharacter[0]) { /* Strip off the fantasy character */ token.erase(token.begin()); @@ -396,7 +396,7 @@ static BanData *get_ban_data(Channel *c, User *u) for (bd = c->bd; bd; bd = next) { - if (now - bd->last_use > Config.BSKeepData) + if (now - bd->last_use > Config->BSKeepData) { if (bd->next) bd->next->prev = bd->prev; @@ -452,7 +452,7 @@ static UserData *get_user_data(Channel *c, User *u) time_t now = time(NULL); /* Checks whether data is obsolete */ - if (now - uc->ud.last_use > Config.BSKeepData) + if (now - uc->ud.last_use > Config->BSKeepData) { /* We should not free and realloc, but reset to 0 instead. */ diff --git a/src/channels.cpp b/src/channels.cpp index 9392b70cd..a10a4e675 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -109,9 +109,9 @@ void Channel::JoinUser(User *user) if (this->ci && check_access(user, this->ci, CA_MEMO) && this->ci->memos.memos.size() > 0) { if (this->ci->memos.memos.size() == 1) - notice_lang(Config.s_MemoServ, user, MEMO_X_ONE_NOTICE, this->ci->memos.memos.size(), this->ci->name.c_str()); + notice_lang(Config->s_MemoServ, user, MEMO_X_ONE_NOTICE, this->ci->memos.memos.size(), this->ci->name.c_str()); else - notice_lang(Config.s_MemoServ, user, MEMO_X_MANY_NOTICE, this->ci->memos.memos.size(), this->ci->name.c_str()); + notice_lang(Config->s_MemoServ, user, MEMO_X_MANY_NOTICE, this->ci->memos.memos.size(), this->ci->name.c_str()); } /* Added channelname to entrymsg - 30.03.2004, Certus */ /* Also, don't send the entrymsg when bursting -GD */ @@ -119,7 +119,7 @@ void Channel::JoinUser(User *user) user->SendMessage(whosends(this->ci)->nick, "[%s] %s", this->name.c_str(), this->ci->entry_message.c_str()); } - if (!Config.s_BotServ.empty() && this->ci && this->ci->bi) + if (!Config->s_BotServ.empty() && this->ci && this->ci->bi) { /** * We let the bot join even if it was an ignored user, as if we don't, @@ -129,7 +129,7 @@ void Channel::JoinUser(User *user) * But don't join the bot if the channel is persistant - Adam * But join persistant channels when syncing with our uplink- DP **/ - if ((!Me->IsSynced() || !this->ci->HasFlag(CI_PERSIST)) && this->users.size() >= Config.BSMinUsers && !this->FindUser(this->ci->bi)) + if ((!Me->IsSynced() || !this->ci->HasFlag(CI_PERSIST)) && this->users.size() >= Config->BSMinUsers && !this->FindUser(this->ci->bi)) this->ci->bi->Join(this); /* Only display the greet if the main uplink we're connected * to has synced, or we'll get greet-floods when the net @@ -193,7 +193,7 @@ void Channel::DeleteUser(User *user) /* check for BSMinUsers and part the BotServ bot from the channel * Use <= because the bot is included in this->users.size() */ - if (!Config.s_BotServ.empty() && this->ci && this->ci->bi && this->users.size() <= Config.BSMinUsers && this->FindUser(this->ci->bi)) + if (!Config->s_BotServ.empty() && this->ci && this->ci->bi && this->users.size() <= Config->BSMinUsers && this->FindUser(this->ci->bi)) this->ci->bi->Part(this->ci->c); else if (this->users.empty()) delete this; @@ -278,7 +278,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const Anope::string ¶m, bool } BotInfo *bi = NULL; - if (!Config.s_BotServ.empty()) + if (!Config->s_BotServ.empty()) bi = findbot(param); User *u = bi ? bi : finduser(param); @@ -404,7 +404,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string ¶m, bo } BotInfo *bi = NULL; - if (!Config.s_BotServ.empty()) + if (!Config->s_BotServ.empty()) bi = findbot(param); User *u = bi ? bi : finduser(param); @@ -460,7 +460,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string ¶m, bo if (ci) { ci->UnsetFlag(CI_PERSIST); - if (!Config.s_BotServ.empty() && ci->bi && this->FindUser(ci->bi)) + if (!Config->s_BotServ.empty() && ci->bi && this->FindUser(ci->bi)) this->ci->bi->Part(this); } } @@ -865,7 +865,7 @@ void ChanSetInternalModes(Channel *c, int ac, const char **av) void Channel::KickInternal(const Anope::string &source, const Anope::string &nick, const Anope::string &reason) { BotInfo *bi = NULL; - if (!Config.s_BotServ.empty() && this->ci) + if (!Config->s_BotServ.empty() && this->ci) bi = findbot(nick); User *user = bi ? bi : finduser(nick); if (!user) diff --git a/src/chanserv.cpp b/src/chanserv.cpp index b0d6f4b16..03760b9b6 100644 --- a/src/chanserv.cpp +++ b/src/chanserv.cpp @@ -110,7 +110,7 @@ int levelinfo_maxwidth = 0; void moduleAddChanServCmds() { - ModuleManager::LoadModuleList(Config.ChanServCoreModules); + ModuleManager::LoadModuleList(Config->ChanServCoreModules); } /*************************************************************************/ @@ -263,7 +263,7 @@ void check_modes(Channel *c) if (c->server_modecount >= 3 && c->chanserv_modecount >= 3) { ircdproto->SendGlobops(NULL, "Warning: unable to set modes on channel %s. Are your servers' U:lines configured correctly?", c->name.c_str()); - Alog() << Config.s_ChanServ << ": Bouncy modes on channel " << c->name; + Alog() << Config->s_ChanServ << ": Bouncy modes on channel " << c->name; c->bouncy_modes = 1; return; } @@ -355,7 +355,7 @@ int check_valid_admin(User *user, Channel *chan, int servermode) if (servermode && !check_access(user, chan->ci, CA_AUTOPROTECT)) { - notice_lang(Config.s_ChanServ, user, CHAN_IS_REGISTERED, Config.s_ChanServ.c_str()); + notice_lang(Config->s_ChanServ, user, CHAN_IS_REGISTERED, Config->s_ChanServ.c_str()); chan->RemoveMode(NULL, CMODE_PROTECT, user->nick); return 0; } @@ -391,7 +391,7 @@ int check_valid_op(User *user, Channel *chan, int servermode) if (servermode && !check_access(user, chan->ci, CA_AUTOOP)) { - notice_lang(Config.s_ChanServ, user, CHAN_IS_REGISTERED, Config.s_ChanServ.c_str()); + notice_lang(Config->s_ChanServ, user, CHAN_IS_REGISTERED, Config->s_ChanServ.c_str()); if (owner) chan->RemoveMode(NULL, CMODE_OWNER, user->nick); @@ -479,7 +479,7 @@ void restore_topic(const Anope::string &chan) if (ircd->join2set && whosends(ci) == ChanServ) { ChanServ->Join(chan); - c->SetMode(NULL, CMODE_OP, Config.s_ChanServ); + c->SetMode(NULL, CMODE_OP, Config->s_ChanServ); } ircdproto->SendTopic(whosends(ci), c, c->topic_setter, c->topic); if (ircd->join2set && whosends(ci) == ChanServ) @@ -513,7 +513,7 @@ int check_topiclock(Channel *c, time_t topic_time) { c->topic.clear(); /* Bot assigned & Symbiosis ON?, the bot will set the topic - doc */ - /* Altough whosends() also checks for Config.BSMinUsers -GD */ + /* Altough whosends() also checks for Config->BSMinUsers -GD */ c->topic_setter = whosends(ci)->nick; } @@ -538,7 +538,7 @@ int check_topiclock(Channel *c, time_t topic_time) if (ircd->join2set && whosends(ci) == ChanServ) { ChanServ->Join(c); - c->SetMode(NULL, CMODE_OP, Config.s_ChanServ); + c->SetMode(NULL, CMODE_OP, Config->s_ChanServ); } ircdproto->SendTopic(whosends(ci), c, c->topic_setter, c->topic); @@ -554,7 +554,7 @@ int check_topiclock(Channel *c, time_t topic_time) void expire_chans() { - if (!Config.CSExpire) + if (!Config->CSExpire) return; time_t now = time(NULL); @@ -564,7 +564,7 @@ void expire_chans() ChannelInfo *ci = it->second; ++it; - if (!ci->c && now - ci->last_used >= Config.CSExpire && !ci->HasFlag(CI_FORBIDDEN) && !ci->HasFlag(CI_NO_EXPIRE) && !ci->HasFlag(CI_SUSPENDED)) + if (!ci->c && now - ci->last_used >= Config->CSExpire && !ci->HasFlag(CI_FORBIDDEN) && !ci->HasFlag(CI_NO_EXPIRE) && !ci->HasFlag(CI_SUSPENDED)) { EventReturn MOD_RESULT; FOREACH_RESULT(I_OnPreChanExpire, OnPreChanExpire(ci)); @@ -597,15 +597,15 @@ void cs_remove_nick(const NickCore *nc) if (ci->successor) { NickCore *nc2 = ci->successor; - if (!nc2->IsServicesOper() && Config.CSMaxReg && nc2->channelcount >= Config.CSMaxReg) + if (!nc2->IsServicesOper() && Config->CSMaxReg && nc2->channelcount >= Config->CSMaxReg) { - Alog() << Config.s_ChanServ << ": Successor (" << nc2->display << " ) of " << ci->name << " owns too many channels, deleting channel", + Alog() << Config->s_ChanServ << ": Successor (" << nc2->display << " ) of " << ci->name << " owns too many channels, deleting channel", delete ci; continue; } else { - Alog() << Config.s_ChanServ << ": Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to successor " << nc2->display; + Alog() << Config->s_ChanServ << ": Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to successor " << nc2->display; ci->founder = nc2; ci->successor = NULL; ++nc2->channelcount; @@ -613,7 +613,7 @@ void cs_remove_nick(const NickCore *nc) } else { - Alog() << Config.s_ChanServ << ": Deleting channel " << ci->name << "owned by deleted nick " << nc->display; + Alog() << Config->s_ChanServ << ": Deleting channel " << ci->name << "owned by deleted nick " << nc->display; if (ModeManager::FindChannelModeByName(CMODE_REGISTERED)) { @@ -963,7 +963,7 @@ void stick_all(ChannelInfo *ci) } } -ChanServTimer::ChanServTimer(Channel *chan) : Timer(Config.CSInhabit), c(chan) +ChanServTimer::ChanServTimer(Channel *chan) : Timer(Config->CSInhabit), c(chan) { if (c->ci) c->ci->SetFlag(CI_INHABIT); diff --git a/src/commands.cpp b/src/commands.cpp index 2647ea952..26ca76e65 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -57,7 +57,7 @@ void mod_run_cmd(BotInfo *bi, User *u, Command *c, const Anope::string &command, // Command requires registered users only if (!c->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !u->IsIdentified()) { - notice_lang(bi->nick, u, NICK_IDENTIFY_REQUIRED, Config.s_NickServ.c_str()); + notice_lang(bi->nick, u, NICK_IDENTIFY_REQUIRED, Config->s_NickServ.c_str()); Alog() << "Access denied for unregistered user " << u->nick << " with service " << bi->nick << " and command " << command; return; } @@ -164,7 +164,7 @@ void mod_help_cmd(BotInfo *bi, User *u, const Anope::string &cmd) Anope::string subcommand = tokens.StreamEnd() ? "" : tokens.GetRemaining(); - if (!c || (Config.HidePrivilegedCommands && !c->permission.empty() && (!u->Account() || !u->Account()->HasCommand(c->permission))) || !c->OnHelp(u, subcommand)) + if (!c || (Config->HidePrivilegedCommands && !c->permission.empty() && (!u->Account() || !u->Account()->HasCommand(c->permission))) || !c->OnHelp(u, subcommand)) notice_lang(bi->nick, u, NO_HELP_AVAILABLE, cmd.c_str()); else { diff --git a/src/config.cpp b/src/config.cpp index 7853196ad..0dfc9702e 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -16,7 +16,7 @@ /*************************************************************************/ Anope::string services_conf = "services.conf"; // Services configuration file name -ServerConfig Config; +ServerConfig *Config = NULL; static Anope::string Modules; static Anope::string EncModules; @@ -40,14 +40,319 @@ static Anope::string NSDefaults; /*************************************************************************/ -ServerConfig::ServerConfig() : include_stack(), errstr(""), newconfig(), config_data() +ServerConfig::ServerConfig() : errstr(""), config_data() { - this->ClearStack(); -} + this->Read(); -void ServerConfig::ClearStack() -{ - include_stack.clear(); + if (!temp_nsuserhost.empty()) + { + size_t at = temp_nsuserhost.find('@'); + if (at == Anope::string::npos) + { + this->NSEnforcerUser = temp_nsuserhost; + this->NSEnforcerHost = this->ServiceHost; + } + else + { + this->NSEnforcerUser = temp_nsuserhost.substr(0, at); + this->NSEnforcerHost = temp_nsuserhost.substr(at + 1); + } + } + + if (NSDefaults.empty()) + { + this->NSDefFlags.SetFlag(NI_SECURE); + this->NSDefFlags.SetFlag(NI_MEMO_SIGNON); + this->NSDefFlags.SetFlag(NI_MEMO_RECEIVE); + } + else if (!NSDefaults.equals_ci("none")) + { + spacesepstream options(NSDefaults); + Anope::string option; + while (options.GetToken(option)) + { + if (option.equals_ci("kill")) + this->NSDefFlags.SetFlag(NI_KILLPROTECT); + else if (option.equals_ci("killquick")) + this->NSDefFlags.SetFlag(NI_KILL_QUICK); + else if (option.equals_ci("secure")) + this->NSDefFlags.SetFlag(NI_SECURE); + else if (option.equals_ci("private")) + this->NSDefFlags.SetFlag(NI_PRIVATE); + else if (option.equals_ci("msg")) + { + if (!this->UsePrivmsg) + Alog() << "msg in <nickserv:defaults> can only be used when UsePrivmsg is set"; + else + this->NSDefFlags.SetFlag(NI_MSG); + } + else if (option.equals_ci("hideemail")) + this->NSDefFlags.SetFlag(NI_HIDE_EMAIL); + else if (option.equals_ci("hideusermask")) + this->NSDefFlags.SetFlag(NI_HIDE_MASK); + else if (option.equals_ci("hidequit")) + this->NSDefFlags.SetFlag(NI_HIDE_QUIT); + else if (option.equals_ci("memosignon")) + this->NSDefFlags.SetFlag(NI_MEMO_SIGNON); + else if (option.equals_ci("memoreceive")) + this->NSDefFlags.SetFlag(NI_MEMO_RECEIVE); + else if (option.equals_ci("autoop")) + this->NSDefFlags.SetFlag(NI_AUTOOP); + } + } + + if ((this->NSDefLanguage = langlist[this->NSDefLanguage]) < 0) + this->NSDefLanguage = DEF_LANGUAGE; + + if (this->CSDefBantype < 0 || this->CSDefBantype > 3) + { + throw ConfigException("Value of CSDefBantype must be between 0 and 3 included"); + } + + if (CSDefaults.empty()) + { + this->CSDefFlags.SetFlag(CI_KEEPTOPIC); + this->CSDefFlags.SetFlag(CI_SECURE); + this->CSDefFlags.SetFlag(CI_SECUREFOUNDER); + this->CSDefFlags.SetFlag(CI_SIGNKICK); + } + else if (!CSDefaults.equals_ci("none")) + { + spacesepstream options(CSDefaults); + Anope::string option; + while (options.GetToken(option)) + { + if (option.equals_ci("keeptopic")) + this->CSDefFlags.SetFlag(CI_KEEPTOPIC); + else if (option.equals_ci("topiclock")) + this->CSDefFlags.SetFlag(CI_TOPICLOCK); + else if (option.equals_ci("private")) + this->CSDefFlags.SetFlag(CI_PRIVATE); + else if (option.equals_ci("restricted")) + this->CSDefFlags.SetFlag(CI_RESTRICTED); + else if (option.equals_ci("secure")) + this->CSDefFlags.SetFlag(CI_SECURE); + else if (option.equals_ci("secureops")) + this->CSDefFlags.SetFlag(CI_SECUREOPS); + else if (option.equals_ci("securefounder")) + this->CSDefFlags.SetFlag(CI_SECUREFOUNDER); + else if (option.equals_ci("signkick")) + this->CSDefFlags.SetFlag(CI_SIGNKICK); + else if (option.equals_ci("signkicklevel")) + this->CSDefFlags.SetFlag(CI_SIGNKICK_LEVEL); + else if (option.equals_ci("opnotice")) + this->CSDefFlags.SetFlag(CI_OPNOTICE); + else if (option.equals_ci("xop")) + this->CSDefFlags.SetFlag(CI_XOP); + else if (option.equals_ci("peace")) + this->CSDefFlags.SetFlag(CI_PEACE); + else if (option.equals_ci("persist")) + this->CSDefFlags.SetFlag(CI_PERSIST); + } + } + + if (!BSDefaults.empty()) + { + spacesepstream options(BSDefaults); + Anope::string option; + while (options.GetToken(option)) + { + if (option.equals_ci("dontkickops")) + this->BSDefFlags.SetFlag(BS_DONTKICKOPS); + else if (option.equals_ci("dontkickvoices")) + this->BSDefFlags.SetFlag(BS_DONTKICKVOICES); + else if (option.equals_ci("greet")) + this->BSDefFlags.SetFlag(BS_GREET); + else if (option.equals_ci("fantasy")) + this->BSDefFlags.SetFlag(BS_FANTASY); + else if (option.equals_ci("symbiosis")) + this->BSDefFlags.SetFlag(BS_SYMBIOSIS); + } + } + + this->WallOper = this->WallBadOS = this->WallOSGlobal = this->WallOSMode = this->WallOSClearmodes = this->WallOSKick = this->WallOSAkill = this->WallOSSNLine = this->WallOSSQLine = + this->WallOSSZLine = this->WallOSNoOp = this->WallOSJupe = this->WallAkillExpire = this->WallSNLineExpire = this->WallSQLineExpire = this->WallSZLineExpire = this->WallExceptionExpire = + this->WallGetpass = this->WallSetpass = this->WallForbid = this->WallDrop = false; + if (!OSNotifications.empty()) + { + spacesepstream notifications(OSNotifications); + Anope::string notice; + while (notifications.GetToken(notice)) + { + if (notice.equals_ci("oper")) + this->WallOper = true; + else if (notice.equals_ci("bados")) + this->WallBadOS = true; + else if (notice.equals_ci("osglobal")) + this->WallOSGlobal = true; + else if (notice.equals_ci("osmode")) + this->WallOSMode = true; + else if (notice.equals_ci("osclearmodes")) + this->WallOSClearmodes = true; + else if (notice.equals_ci("oskick")) + this->WallOSKick = true; + else if (notice.equals_ci("osakill")) + this->WallOSAkill = true; + else if (notice.equals_ci("ossnline")) + this->WallOSSNLine = true; + else if (notice.equals_ci("ossqline")) + this->WallOSSQLine = true; + else if (notice.equals_ci("osszline")) + this->WallOSSZLine = true; + else if (notice.equals_ci("osnoop")) + this->WallOSNoOp = true; + else if (notice.equals_ci("osjupe")) + this->WallOSJupe = true; + else if (notice.equals_ci("akillexpire")) + this->WallAkillExpire = true; + else if (notice.equals_ci("snlineexpire")) + this->WallSNLineExpire = true; + else if (notice.equals_ci("sqlineexpire")) + this->WallSQLineExpire = true; + else if (notice.equals_ci("szlineexpire")) + this->WallSZLineExpire = true; + else if (notice.equals_ci("exceptionexpire")) + this->WallExceptionExpire = true; + else if (notice.equals_ci("getpass")) + this->WallGetpass = true; + else if (notice.equals_ci("setpass")) + this->WallSetpass = true; + else if (notice.equals_ci("forbid")) + this->WallForbid = true; + else if (notice.equals_ci("drop")) + this->WallDrop = true; + } + } + + /* Ulines */ + if (!UlineServers.empty()) + { + this->Ulines.clear(); + + spacesepstream ulines(UlineServers); + Anope::string uline; + while (ulines.GetToken(uline)) + this->Ulines.push_back(uline); + } + + /* Modules Autoload building... :P */ + this->ModulesAutoLoad = BuildStringList(Modules); + this->EncModuleList = BuildStringList(EncModules); + this->DBModuleList = BuildStringList(DBModules); + this->HostServCoreModules = BuildStringList(HostCoreModules); + this->MemoServCoreModules = BuildStringList(MemoCoreModules); + this->BotServCoreModules = BuildStringList(BotCoreModules); + this->OperServCoreModules = BuildStringList(OperCoreModules); + this->ChanServCoreModules = BuildStringList(ChanCoreModules); + this->NickServCoreModules = BuildStringList(NickCoreModules); + + if (this->LimitSessions) + { + if (this->MaxSessionKill && !this->SessionAutoKillExpiry) + this->SessionAutoKillExpiry = 1800; /* 30 minutes */ + } + + if (!this->s_BotServ.empty()) + { + if (this->BSFantasyCharacter.empty()) + this->BSFantasyCharacter = "!"; + if (this->BSFantasyCharacter.length() > 1) + printf("*** this->BSFantasyCharacter is more than 1 character long. Only the first\n*** character ('%c') will be used. The others will be ignored.\n", this->BSFantasyCharacter[0]); + } + + /* Check the user keys */ + if (this->UserKey1 == this->UserKey2 || this->UserKey1 == this->UserKey3 || this->UserKey3 == this->UserKey2) + Alog() << "Every UserKey must be different. It's for YOUR safety! Remember that!"; + + /** + * Check all DEFCON dependiencies... + **/ + if (this->DefConLevel) + { + /* Build DefCon's */ + DefCon.resize(6); + DefCon[5].reset(); + for (unsigned int level = 1; level < 5; ++level) + { + DefCon[level] = 0; + Anope::string *levelDefinition = NULL; + switch (level) + { + case 1: + levelDefinition = &DefCon1; + break; + case 2: + levelDefinition = &DefCon2; + break; + case 3: + levelDefinition = &DefCon3; + break; + case 4: + levelDefinition = &DefCon4; + } + spacesepstream operations(*levelDefinition); + Anope::string operation; + while (operations.GetToken(operation)) + { + if (operation.equals_ci("nonewchannels")) + AddDefCon(level, DEFCON_NO_NEW_CHANNELS); + else if (operation.equals_ci("nonewnicks")) + AddDefCon(level, DEFCON_NO_NEW_NICKS); + else if (operation.equals_ci("nomlockchanges")) + AddDefCon(level, DEFCON_NO_MLOCK_CHANGE); + else if (operation.equals_ci("forcechanmodes")) + AddDefCon(level, DEFCON_FORCE_CHAN_MODES); + else if (operation.equals_ci("reducedsessions")) + AddDefCon(level, DEFCON_REDUCE_SESSION); + else if (operation.equals_ci("nonewclients")) + AddDefCon(level, DEFCON_NO_NEW_CLIENTS); + else if (operation.equals_ci("operonly")) + AddDefCon(level, DEFCON_OPER_ONLY); + else if (operation.equals_ci("silentoperonly")) + AddDefCon(level, DEFCON_SILENT_OPER_ONLY); + else if (operation.equals_ci("akillnewclients")) + AddDefCon(level, DEFCON_AKILL_NEW_CLIENTS); + else if (operation.equals_ci("nonewmemos")) + AddDefCon(level, DEFCON_NO_NEW_MEMOS); + } + } + + /* Check any defcon needed settings */ + for (int defconCount = 1; defconCount <= 5; ++defconCount) + { + if (CheckDefCon(defconCount, DEFCON_REDUCE_SESSION)) + { + if (!this->DefConSessionLimit) + { + throw ConfigException("this->DefConSessionLimit missing"); + } + } + if (CheckDefCon(defconCount, DEFCON_AKILL_NEW_CLIENTS)) + { + if (!this->DefConAKILL) + { + throw ConfigException("this->DefConAKILL missing"); + } + if (this->DefConAkillReason.empty()) + { + throw ConfigException("this->DefConAkillReason missing"); + } + } + if (CheckDefCon(defconCount, DEFCON_FORCE_CHAN_MODES)) + { + if (this->DefConChanModes.empty()) + { + throw ConfigException("this->DefConChanModes missing"); + } + } + } + } + + SetDefaultMLock(this); + + /* Disable the log channel if its defined in the conf, but not enabled */ + if (this->LogChannel.empty() && LogChan) + LogChan = false; } bool ServerConfig::CheckOnce(const Anope::string &tag) @@ -171,9 +476,9 @@ bool ValidateNotZero(ServerConfig *, const Anope::string &tag, const Anope::stri return true; } -bool ValidateEmailReg(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) +bool ValidateEmailReg(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data) { - if (Config.NSEmailReg) + if (config->NSEmailReg) { if (value.equals_ci("preregexpire")) { @@ -224,9 +529,9 @@ bool ValidateBantype(ServerConfig *, const Anope::string &, const Anope::string return true; } -bool ValidateBotServ(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) +bool ValidateBotServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data) { - if (!Config.s_BotServ.empty()) + if (!config->s_BotServ.empty()) { if (value.equals_ci("description")) { @@ -247,9 +552,9 @@ bool ValidateBotServ(ServerConfig *, const Anope::string &tag, const Anope::stri return true; } -bool ValidateHostServ(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) +bool ValidateHostServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data) { - if (!Config.s_HostServ.empty()) + if (!config->s_HostServ.empty()) { if (value.equals_ci("description")) { @@ -260,9 +565,9 @@ bool ValidateHostServ(ServerConfig *, const Anope::string &tag, const Anope::str return true; } -bool ValidateLimitSessions(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) +bool ValidateLimitSessions(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data) { - if (Config.LimitSessions) + if (config->LimitSessions) { if (value.equals_ci("maxsessionlimit") || value.equals_ci("exceptionexpiry")) { @@ -273,7 +578,7 @@ bool ValidateLimitSessions(ServerConfig *, const Anope::string &tag, const Anope return true; } -bool ValidateDefCon(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) +bool ValidateDefCon(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data) { if (value.equals_ci("defaultlevel")) { @@ -283,14 +588,14 @@ bool ValidateDefCon(ServerConfig *, const Anope::string &tag, const Anope::strin if (level > 5) throw ConfigException("The value for <defcon:defaultlevel> must be between 1 through 5 if you wish to use DefCon or 0 if you wish to disable it!"); } - else if (Config.DefConLevel) + else if (config->DefConLevel) { if ((value.substr(0, 5).equals_ci("level") && isdigit(value[5])) || value.equals_ci("chanmodes") || value.equals_ci("akillreason")) { if (data.GetValue().empty()) throw ConfigException("The value for <" + tag + ":" + value + "> cannot be empty when DefCon is enabled!"); } - else if (value.equals_ci("message") && Config.GlobalOnDefconMore) + else if (value.equals_ci("message") && config->GlobalOnDefconMore) { if (data.GetValue().empty()) throw ConfigException("The value for <defcon:message> cannot be empty when globalondefconmore is enabled!"); @@ -321,9 +626,9 @@ bool ValidateNickLen(ServerConfig *, const Anope::string &, const Anope::string return true; } -bool ValidateMail(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) +bool ValidateMail(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data) { - if (Config.UseMail) + if (config->UseMail) { if (value.equals_ci("sendmailpath") || value.equals_ci("sendfrom")) { @@ -334,88 +639,69 @@ bool ValidateMail(ServerConfig *, const Anope::string &tag, const Anope::string return true; } -bool ValidateGlobalOnCycle(ServerConfig *, const Anope::string &tag, const Anope::string &value, ValueItem &data) +bool ValidateGlobalOnCycle(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data) { - if (Config.GlobalOnCycle) + if (config->GlobalOnCycle) { if (data.GetValue().empty()) { Alog() << "<" << tag << ":" << value << "> was undefined, disabling <options:globaloncycle>"; - Config.GlobalOnCycle = false; + config->GlobalOnCycle = false; } } return true; } -void ServerConfig::ReportConfigError(const Anope::string &errormessage, bool bail) -{ - Alog() << "There were errors in your configuration file: " << errormessage; - if (bail) - { - // TODO -- Need a way to stop loading in a safe way -- CyberBotX - //ServerInstance->Exit(EXIT_STATUS_CONFIG); - } -} - -bool InitUplinks(ServerConfig *, const Anope::string &, bool bail) +bool InitUplinks(ServerConfig *config, const Anope::string &) { - // If bail is false, we were reloading, don't clear anything - if (!bail) - return true; - if (!Config.Uplinks.empty()) + if (!config->Uplinks.empty()) { - std::list<Uplink *>::iterator curr_uplink = Config.Uplinks.begin(), end_uplink = Config.Uplinks.end(); + std::list<Uplink *>::iterator curr_uplink = config->Uplinks.begin(), end_uplink = config->Uplinks.end(); for (; curr_uplink != end_uplink; ++curr_uplink) delete *curr_uplink; } - Config.Uplinks.clear(); + config->Uplinks.clear(); return true; } -bool DoUplink(ServerConfig *conf, const Anope::string &, const Anope::string *, ValueList &values, int *, bool bail) +bool DoUplink(ServerConfig *config, const Anope::string &, const Anope::string *, ValueList &values, int *) { - // If bail is false, we were reloading, don't even try to add another uplink - if (!bail) - return true; // Validation variables Anope::string host = values[0].GetValue(), password = values[3].GetValue(); int port = values[2].GetInteger(); bool ipv6 = values[1].GetBool(); ValueItem vi_host(host), vi_port(port), vi_password(password); // Validate the host to make sure it is not empty - if (!ValidateNotEmpty(conf, "uplink", "host", vi_host)) + if (!ValidateNotEmpty(config, "uplink", "host", vi_host)) throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information."); // Validate the port to make sure it is a valid port - if (!ValidatePort(conf, "uplink", "port", vi_port)) + if (!ValidatePort(config, "uplink", "port", vi_port)) throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information."); // Validate the password to make sure it is not empty - if (!ValidateNotEmpty(conf, "uplink", "password", vi_password)) + if (!ValidateNotEmpty(config, "uplink", "password", vi_password)) throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information."); // If we get here, all the values are valid, we'll add it to the Uplinks list - Config.Uplinks.push_back(new Uplink(host, port, password, ipv6)); + config->Uplinks.push_back(new Uplink(host, port, password, ipv6)); return true; } -bool DoneUplinks(ServerConfig *, const Anope::string &, bool bail) +bool DoneUplinks(ServerConfig *config, const Anope::string &) { - // If bail is false, we were reloading, ignore this check - if (!bail) - return true; - if (Config.Uplinks.empty()) + if (config->Uplinks.empty()) throw ConfigException("You must define at least one uplink block!"); return true; } -static bool InitOperTypes(ServerConfig *, const Anope::string &, bool) +static bool InitOperTypes(ServerConfig *config, const Anope::string &) { - for (std::list<OperType *>::iterator it = Config.MyOperTypes.begin(), it_end = Config.MyOperTypes.end(); it != it_end; ++it) + for (std::list<OperType *>::iterator it = config->MyOperTypes.begin(), it_end = config->MyOperTypes.end(); it != it_end; ++it) delete *it; - Config.MyOperTypes.clear(); + config->MyOperTypes.clear(); return true; } -static bool DoOperType(ServerConfig *conf, const Anope::string &, const Anope::string *, ValueList &values, int *, bool) +static bool DoOperType(ServerConfig *config, const Anope::string &, const Anope::string *, ValueList &values, int *) { Anope::string name = values[0].GetValue(); Anope::string inherits = values[1].GetValue(); @@ -423,7 +709,7 @@ static bool DoOperType(ServerConfig *conf, const Anope::string &, const Anope::s Anope::string privs = values[3].GetValue(); ValueItem vi(name); - if (!ValidateNotEmpty(conf, "opertype", "name", vi)) + if (!ValidateNotEmpty(config, "opertype", "name", vi)) throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information."); OperType *ot = new OperType(name); @@ -443,7 +729,7 @@ static bool DoOperType(ServerConfig *conf, const Anope::string &, const Anope::s /* Strip leading ' ' after , */ if (tok.length() > 1 && tok[0] == ' ') tok.erase(tok.begin()); - for (std::list<OperType *>::iterator it = Config.MyOperTypes.begin(), it_end = Config.MyOperTypes.end(); it != it_end; ++it) + for (std::list<OperType *>::iterator it = config->MyOperTypes.begin(), it_end = config->MyOperTypes.end(); it != it_end; ++it) { if ((*it)->GetName().equals_ci(tok)) { @@ -454,47 +740,47 @@ static bool DoOperType(ServerConfig *conf, const Anope::string &, const Anope::s } } - Config.MyOperTypes.push_back(ot); + config->MyOperTypes.push_back(ot); return true; } -static bool DoneOperTypes(ServerConfig *, const Anope::string &, bool) +static bool DoneOperTypes(ServerConfig *, const Anope::string &) { return true; } /*************************************************************************/ -static bool InitOpers(ServerConfig *, const Anope::string &, bool) +static bool InitOpers(ServerConfig *config, const Anope::string &) { for (nickcore_map::const_iterator it = NickCoreList.begin(), it_end = NickCoreList.end(); it != it_end; ++it) it->second->ot = NULL; - Config.Opers.clear(); + config->Opers.clear(); return true; } -static bool DoOper(ServerConfig *conf, const Anope::string &, const Anope::string *, ValueList &values, int *, bool) +static bool DoOper(ServerConfig *config, const Anope::string &, const Anope::string *, ValueList &values, int *) { Anope::string name = values[0].GetValue(); Anope::string type = values[1].GetValue(); ValueItem vi(name); - if (!ValidateNotEmpty(conf, "oper", "name", vi)) + if (!ValidateNotEmpty(config, "oper", "name", vi)) throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information."); ValueItem vi2(type); - if (!ValidateNotEmpty(conf, "oper", "type", vi2)) + if (!ValidateNotEmpty(config, "oper", "type", vi2)) throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information."); - Config.Opers.push_back(std::make_pair(name, type)); + config->Opers.push_back(std::make_pair(name, type)); return true; } -static bool DoneOpers(ServerConfig *, const Anope::string &, bool) +static bool DoneOpers(ServerConfig *config, const Anope::string &) { - for (std::list<std::pair<Anope::string, Anope::string> >::iterator it = Config.Opers.begin(), it_end = Config.Opers.end(); it != it_end; ++it) + for (std::list<std::pair<Anope::string, Anope::string> >::iterator it = config->Opers.begin(), it_end = config->Opers.end(); it != it_end; ++it) { Anope::string nick = it->first, type = it->second; @@ -504,10 +790,9 @@ static bool DoneOpers(ServerConfig *, const Anope::string &, bool) continue; if (!na->nc) - // Nick with no core (wtf?) - abort(); + throw CoreException("Nick with no core?"); - for (std::list<OperType *>::iterator tit = Config.MyOperTypes.begin(), tit_end = Config.MyOperTypes.end(); tit != tit_end; ++tit) + for (std::list<OperType *>::iterator tit = config->MyOperTypes.begin(), tit_end = config->MyOperTypes.end(); tit != tit_end; ++tit) { OperType *ot = *tit; if (ot->GetName().equals_ci(type)) @@ -522,13 +807,13 @@ static bool DoneOpers(ServerConfig *, const Anope::string &, bool) /*************************************************************************/ -bool InitModules(ServerConfig *, const Anope::string &, bool) +bool InitModules(ServerConfig *, const Anope::string &) { Modules.clear(); return true; } -bool DoModule(ServerConfig *conf, const Anope::string &, const Anope::string *, ValueList &values, int *, bool) +bool DoModule(ServerConfig *conf, const Anope::string &, const Anope::string *, ValueList &values, int *) { // First we validate that there was a name in the module block Anope::string module = values[0].GetValue(); @@ -543,12 +828,12 @@ bool DoModule(ServerConfig *conf, const Anope::string &, const Anope::string *, return true; } -bool DoneModules(ServerConfig *, const Anope::string &, bool) +bool DoneModules(ServerConfig *, const Anope::string &) { return true; } -int ServerConfig::Read(bool bail) +void ServerConfig::Read() { errstr.clear(); // These tags MUST occur and must ONLY occur once in the config file @@ -608,164 +893,164 @@ int ServerConfig::Read(bool bail) * * We may need to add some other validation functions to handle certain things, we can handle that later. * Any questions about these, w00t, feel free to ask. */ - {"serverinfo", "name", "", new ValueContainerString(&Config.ServerName), DT_HOSTNAME | DT_NORELOAD, ValidateNotEmpty}, - {"serverinfo", "description", "", new ValueContainerString(&Config.ServerDesc), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"serverinfo", "localhost", "", new ValueContainerString(&Config.LocalHost), DT_HOSTNAME | DT_NORELOAD, NoValidation}, - {"serverinfo", "type", "", new ValueContainerString(&Config.IRCDModule), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"serverinfo", "id", "", new ValueContainerString(&Config.Numeric), DT_NOSPACES | DT_NORELOAD, NoValidation}, - {"serverinfo", "ident", "", new ValueContainerString(&Config.ServiceUser), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"serverinfo", "hostname", "", new ValueContainerString(&Config.ServiceHost), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"serverinfo", "pid", "services.pid", new ValueContainerString(&Config.PIDFilename), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"serverinfo", "motd", "services.motd", new ValueContainerString(&Config.MOTDFilename), DT_STRING, ValidateNotEmpty}, - {"networkinfo", "logchannel", "", new ValueContainerString(&Config.LogChannel), DT_STRING, NoValidation}, - {"networkinfo", "logbot", "no", new ValueContainerBool(&Config.LogBot), DT_BOOLEAN, NoValidation}, - {"networkinfo", "networkname", "", new ValueContainerString(&Config.NetworkName), DT_STRING, ValidateNotEmpty}, - {"networkinfo", "nicklen", "0", new ValueContainerUInt(&Config.NickLen), DT_UINTEGER | DT_NORELOAD, ValidateNickLen}, - {"networkinfo", "userlen", "10", new ValueContainerUInt(&Config.UserLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, - {"networkinfo", "hostlen", "64", new ValueContainerUInt(&Config.HostLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, + {"serverinfo", "name", "", new ValueContainerString(&this->ServerName), DT_HOSTNAME | DT_NORELOAD, ValidateNotEmpty}, + {"serverinfo", "description", "", new ValueContainerString(&this->ServerDesc), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"serverinfo", "localhost", "", new ValueContainerString(&this->LocalHost), DT_HOSTNAME | DT_NORELOAD, NoValidation}, + {"serverinfo", "type", "", new ValueContainerString(&this->IRCDModule), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"serverinfo", "id", "", new ValueContainerString(&this->Numeric), DT_NOSPACES | DT_NORELOAD, NoValidation}, + {"serverinfo", "ident", "", new ValueContainerString(&this->ServiceUser), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"serverinfo", "hostname", "", new ValueContainerString(&this->ServiceHost), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"serverinfo", "pid", "services.pid", new ValueContainerString(&this->PIDFilename), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"serverinfo", "motd", "services.motd", new ValueContainerString(&this->MOTDFilename), DT_STRING, ValidateNotEmpty}, + {"networkinfo", "logchannel", "", new ValueContainerString(&this->LogChannel), DT_STRING, NoValidation}, + {"networkinfo", "logbot", "no", new ValueContainerBool(&this->LogBot), DT_BOOLEAN, NoValidation}, + {"networkinfo", "networkname", "", new ValueContainerString(&this->NetworkName), DT_STRING, ValidateNotEmpty}, + {"networkinfo", "nicklen", "0", new ValueContainerUInt(&this->NickLen), DT_UINTEGER | DT_NORELOAD, ValidateNickLen}, + {"networkinfo", "userlen", "10", new ValueContainerUInt(&this->UserLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, + {"networkinfo", "hostlen", "64", new ValueContainerUInt(&this->HostLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, {"options", "encryption", "", new ValueContainerString(&EncModules), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"options", "passlen", "32", new ValueContainerUInt(&Config.PassLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, + {"options", "passlen", "32", new ValueContainerUInt(&this->PassLen), DT_UINTEGER | DT_NORELOAD, NoValidation}, {"options", "database", "", new ValueContainerString(&DBModules), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"options", "socketengine", "", new ValueContainerString(&Config.SocketEngine), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"options", "userkey1", "0", new ValueContainerLUInt(&Config.UserKey1), DT_LUINTEGER, NoValidation}, - {"options", "userkey2", "0", new ValueContainerLUInt(&Config.UserKey2), DT_LUINTEGER, NoValidation}, - {"options", "userkey3", "0", new ValueContainerLUInt(&Config.UserKey3), DT_LUINTEGER, NoValidation}, - {"options", "nobackupokay", "no", new ValueContainerBool(&Config.NoBackupOkay), DT_BOOLEAN, NoValidation}, - {"options", "strictpasswords", "no", new ValueContainerBool(&Config.StrictPasswords), DT_BOOLEAN, NoValidation}, - {"options", "badpasslimit", "0", new ValueContainerUInt(&Config.BadPassLimit), DT_UINTEGER, NoValidation}, - {"options", "badpasstimeout", "0", new ValueContainerTime(&Config.BadPassTimeout), DT_TIME, NoValidation}, - {"options", "updatetimeout", "0", new ValueContainerTime(&Config.UpdateTimeout), DT_TIME, ValidateNotZero}, - {"options", "expiretimeout", "0", new ValueContainerTime(&Config.ExpireTimeout), DT_TIME, ValidateNotZero}, - {"options", "readtimeout", "0", new ValueContainerTime(&Config.ReadTimeout), DT_TIME, ValidateNotZero}, - {"options", "warningtimeout", "0", new ValueContainerTime(&Config.WarningTimeout), DT_TIME, ValidateNotZero}, - {"options", "timeoutcheck", "0", new ValueContainerTime(&Config.TimeoutCheck), DT_TIME, NoValidation}, - {"options", "keeplogs", "0", new ValueContainerInt(&Config.KeepLogs), DT_INTEGER, NoValidation}, - {"options", "keepbackups", "0", new ValueContainerInt(&Config.KeepBackups), DT_INTEGER, NoValidation}, - {"options", "forceforbidreason", "no", new ValueContainerBool(&Config.ForceForbidReason), DT_BOOLEAN, NoValidation}, - {"options", "useprivmsg", "no", new ValueContainerBool(&Config.UsePrivmsg), DT_BOOLEAN, NoValidation}, - {"options", "usestrictprivmsg", "no", new ValueContainerBool(&Config.UseStrictPrivMsg), DT_BOOLEAN, NoValidation}, - {"options", "dumpcore", "yes", new ValueContainerBool(&Config.DumpCore), DT_BOOLEAN | DT_NORELOAD, NoValidation}, - {"options", "logusers", "no", new ValueContainerBool(&Config.LogUsers), DT_BOOLEAN, NoValidation}, - {"options", "hidestatso", "no", new ValueContainerBool(&Config.HideStatsO), DT_BOOLEAN, NoValidation}, - {"options", "globaloncycle", "no", new ValueContainerBool(&Config.GlobalOnCycle), DT_BOOLEAN, NoValidation}, - {"options", "globaloncycledown", "", new ValueContainerString(&Config.GlobalOnCycleMessage), DT_STRING, ValidateGlobalOnCycle}, - {"options", "globaloncycleup", "", new ValueContainerString(&Config.GlobalOnCycleUP), DT_STRING, ValidateGlobalOnCycle}, - {"options", "anonymousglobal", "no", new ValueContainerBool(&Config.AnonymousGlobal), DT_BOOLEAN, NoValidation}, - {"options", "nickregdelay", "0", new ValueContainerUInt(&Config.NickRegDelay), DT_UINTEGER, NoValidation}, - {"options", "restrictopernicks", "no", new ValueContainerBool(&Config.RestrictOperNicks), DT_BOOLEAN, NoValidation}, - {"options", "newscount", "3", new ValueContainerUInt(&Config.NewsCount), DT_UINTEGER, NoValidation}, + {"options", "socketengine", "", new ValueContainerString(&this->SocketEngine), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"options", "userkey1", "0", new ValueContainerLUInt(&this->UserKey1), DT_LUINTEGER, NoValidation}, + {"options", "userkey2", "0", new ValueContainerLUInt(&this->UserKey2), DT_LUINTEGER, NoValidation}, + {"options", "userkey3", "0", new ValueContainerLUInt(&this->UserKey3), DT_LUINTEGER, NoValidation}, + {"options", "nobackupokay", "no", new ValueContainerBool(&this->NoBackupOkay), DT_BOOLEAN, NoValidation}, + {"options", "strictpasswords", "no", new ValueContainerBool(&this->StrictPasswords), DT_BOOLEAN, NoValidation}, + {"options", "badpasslimit", "0", new ValueContainerUInt(&this->BadPassLimit), DT_UINTEGER, NoValidation}, + {"options", "badpasstimeout", "0", new ValueContainerTime(&this->BadPassTimeout), DT_TIME, NoValidation}, + {"options", "updatetimeout", "0", new ValueContainerTime(&this->UpdateTimeout), DT_TIME, ValidateNotZero}, + {"options", "expiretimeout", "0", new ValueContainerTime(&this->ExpireTimeout), DT_TIME, ValidateNotZero}, + {"options", "readtimeout", "0", new ValueContainerTime(&this->ReadTimeout), DT_TIME, ValidateNotZero}, + {"options", "warningtimeout", "0", new ValueContainerTime(&this->WarningTimeout), DT_TIME, ValidateNotZero}, + {"options", "timeoutcheck", "0", new ValueContainerTime(&this->TimeoutCheck), DT_TIME, NoValidation}, + {"options", "keeplogs", "0", new ValueContainerInt(&this->KeepLogs), DT_INTEGER, NoValidation}, + {"options", "keepbackups", "0", new ValueContainerInt(&this->KeepBackups), DT_INTEGER, NoValidation}, + {"options", "forceforbidreason", "no", new ValueContainerBool(&this->ForceForbidReason), DT_BOOLEAN, NoValidation}, + {"options", "useprivmsg", "no", new ValueContainerBool(&this->UsePrivmsg), DT_BOOLEAN, NoValidation}, + {"options", "usestrictprivmsg", "no", new ValueContainerBool(&this->UseStrictPrivMsg), DT_BOOLEAN, NoValidation}, + {"options", "dumpcore", "yes", new ValueContainerBool(&this->DumpCore), DT_BOOLEAN | DT_NORELOAD, NoValidation}, + {"options", "logusers", "no", new ValueContainerBool(&this->LogUsers), DT_BOOLEAN, NoValidation}, + {"options", "hidestatso", "no", new ValueContainerBool(&this->HideStatsO), DT_BOOLEAN, NoValidation}, + {"options", "globaloncycle", "no", new ValueContainerBool(&this->GlobalOnCycle), DT_BOOLEAN, NoValidation}, + {"options", "globaloncycledown", "", new ValueContainerString(&this->GlobalOnCycleMessage), DT_STRING, ValidateGlobalOnCycle}, + {"options", "globaloncycleup", "", new ValueContainerString(&this->GlobalOnCycleUP), DT_STRING, ValidateGlobalOnCycle}, + {"options", "anonymousglobal", "no", new ValueContainerBool(&this->AnonymousGlobal), DT_BOOLEAN, NoValidation}, + {"options", "nickregdelay", "0", new ValueContainerUInt(&this->NickRegDelay), DT_UINTEGER, NoValidation}, + {"options", "restrictopernicks", "no", new ValueContainerBool(&this->RestrictOperNicks), DT_BOOLEAN, NoValidation}, + {"options", "newscount", "3", new ValueContainerUInt(&this->NewsCount), DT_UINTEGER, NoValidation}, {"options", "ulineservers", "", new ValueContainerString(&UlineServers), DT_STRING, NoValidation}, {"options", "enablelogchannel", "no", new ValueContainerBool(&LogChan), DT_BOOLEAN, NoValidation}, - {"options", "mlock", "+nrt", new ValueContainerString(&Config.MLock), DT_STRING, NoValidation}, - {"options", "botmodes", "", new ValueContainerString(&Config.BotModes), DT_STRING, NoValidation}, - {"options", "maxretries", "10", new ValueContainerUInt(&Config.MaxRetries), DT_UINTEGER, NoValidation}, - {"options", "retrywait", "60", new ValueContainerInt(&Config.RetryWait), DT_INTEGER, ValidateNotZero}, - {"options", "hideprivilegedcommands", "no", new ValueContainerBool(&Config.HidePrivilegedCommands), DT_BOOLEAN, ValidateEmailReg}, - {"nickserv", "nick", "NickServ", new ValueContainerString(&Config.s_NickServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"nickserv", "description", "Nickname Registration Service", new ValueContainerString(&Config.desc_NickServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"nickserv", "emailregistration", "no", new ValueContainerBool(&Config.NSEmailReg), DT_BOOLEAN, NoValidation}, + {"options", "mlock", "+nrt", new ValueContainerString(&this->MLock), DT_STRING, NoValidation}, + {"options", "botmodes", "", new ValueContainerString(&this->BotModes), DT_STRING, NoValidation}, + {"options", "maxretries", "10", new ValueContainerUInt(&this->MaxRetries), DT_UINTEGER, NoValidation}, + {"options", "retrywait", "60", new ValueContainerInt(&this->RetryWait), DT_INTEGER, ValidateNotZero}, + {"options", "hideprivilegedcommands", "no", new ValueContainerBool(&this->HidePrivilegedCommands), DT_BOOLEAN, NoValidation}, + {"nickserv", "nick", "NickServ", new ValueContainerString(&this->s_NickServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"nickserv", "description", "Nickname Registration Service", new ValueContainerString(&this->desc_NickServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"nickserv", "emailregistration", "no", new ValueContainerBool(&this->NSEmailReg), DT_BOOLEAN, NoValidation}, {"nickserv", "modules", "", new ValueContainerString(&NickCoreModules), DT_STRING, NoValidation}, - {"nickserv", "forceemail", "no", new ValueContainerBool(&Config.NSForceEmail), DT_BOOLEAN, ValidateEmailReg}, + {"nickserv", "forceemail", "no", new ValueContainerBool(&this->NSForceEmail), DT_BOOLEAN, ValidateEmailReg}, {"nickserv", "defaults", "secure memosignon memoreceive", new ValueContainerString(&NSDefaults), DT_STRING, NoValidation}, - {"nickserv", "defaultlanguage", "0", new ValueContainerUInt(&Config.NSDefLanguage), DT_UINTEGER, ValidateLanguage}, - {"nickserv", "regdelay", "0", new ValueContainerTime(&Config.NSRegDelay), DT_TIME, NoValidation}, - {"nickserv", "resenddelay", "0", new ValueContainerTime(&Config.NSResendDelay), DT_TIME, NoValidation}, - {"nickserv", "expire", "21d", new ValueContainerTime(&Config.NSExpire), DT_TIME, NoValidation}, - {"nickserv", "preregexpire", "0", new ValueContainerTime(&Config.NSRExpire), DT_TIME, ValidateEmailReg}, - {"nickserv", "maxaliases", "0", new ValueContainerInt(&Config.NSMaxAliases), DT_INTEGER, NoValidation}, - {"nickserv", "accessmax", "0", new ValueContainerUInt(&Config.NSAccessMax), DT_UINTEGER, ValidateNotZero}, + {"nickserv", "defaultlanguage", "0", new ValueContainerUInt(&this->NSDefLanguage), DT_UINTEGER, ValidateLanguage}, + {"nickserv", "regdelay", "0", new ValueContainerTime(&this->NSRegDelay), DT_TIME, NoValidation}, + {"nickserv", "resenddelay", "0", new ValueContainerTime(&this->NSResendDelay), DT_TIME, NoValidation}, + {"nickserv", "expire", "21d", new ValueContainerTime(&this->NSExpire), DT_TIME, NoValidation}, + {"nickserv", "preregexpire", "0", new ValueContainerTime(&this->NSRExpire), DT_TIME, ValidateEmailReg}, + {"nickserv", "maxaliases", "0", new ValueContainerInt(&this->NSMaxAliases), DT_INTEGER, NoValidation}, + {"nickserv", "accessmax", "0", new ValueContainerUInt(&this->NSAccessMax), DT_UINTEGER, ValidateNotZero}, {"nickserv", "enforceruser", "", new ValueContainerString(&temp_nsuserhost), DT_STRING, ValidateNotEmpty}, - {"nickserv", "releasetimeout", "0", new ValueContainerTime(&Config.NSReleaseTimeout), DT_TIME, ValidateNotZero}, - {"nickserv", "allowkillimmed", "no", new ValueContainerBool(&Config.NSAllowKillImmed), DT_BOOLEAN | DT_NORELOAD, NoValidation}, - {"nickserv", "nogroupchange", "no", new ValueContainerBool(&Config.NSNoGroupChange), DT_BOOLEAN, NoValidation}, - {"nickserv", "listopersonly", "no", new ValueContainerBool(&Config.NSListOpersOnly), DT_BOOLEAN, NoValidation}, - {"nickserv", "listmax", "0", new ValueContainerUInt(&Config.NSListMax), DT_UINTEGER, ValidateNotZero}, - {"nickserv", "guestnickprefix", "", new ValueContainerString(&Config.NSGuestNickPrefix), DT_STRING, ValidateGuestPrefix}, - {"nickserv", "secureadmins", "no", new ValueContainerBool(&Config.NSSecureAdmins), DT_BOOLEAN, NoValidation}, - {"nickserv", "strictprivileges", "no", new ValueContainerBool(&Config.NSStrictPrivileges), DT_BOOLEAN, NoValidation}, - {"nickserv", "modeonid", "no", new ValueContainerBool(&Config.NSModeOnID), DT_BOOLEAN, NoValidation}, - {"nickserv", "addaccessonreg", "no", new ValueContainerBool(&Config.NSAddAccessOnReg), DT_BOOLEAN, NoValidation}, - {"mail", "usemail", "no", new ValueContainerBool(&Config.UseMail), DT_BOOLEAN, ValidateEmailReg}, - {"mail", "sendmailpath", "", new ValueContainerString(&Config.SendMailPath), DT_STRING, ValidateMail}, - {"mail", "sendfrom", "", new ValueContainerString(&Config.SendFrom), DT_STRING, ValidateMail}, - {"mail", "restrict", "no", new ValueContainerBool(&Config.RestrictMail), DT_BOOLEAN, NoValidation}, - {"mail", "delay", "0", new ValueContainerTime(&Config.MailDelay), DT_TIME, NoValidation}, - {"mail", "dontquoteaddresses", "no", new ValueContainerBool(&Config.DontQuoteAddresses), DT_BOOLEAN, NoValidation}, - {"chanserv", "nick", "ChanServ", new ValueContainerString(&Config.s_ChanServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"chanserv", "description", "Channel Registration Service", new ValueContainerString(&Config.desc_ChanServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"nickserv", "releasetimeout", "0", new ValueContainerTime(&this->NSReleaseTimeout), DT_TIME, ValidateNotZero}, + {"nickserv", "allowkillimmed", "no", new ValueContainerBool(&this->NSAllowKillImmed), DT_BOOLEAN | DT_NORELOAD, NoValidation}, + {"nickserv", "nogroupchange", "no", new ValueContainerBool(&this->NSNoGroupChange), DT_BOOLEAN, NoValidation}, + {"nickserv", "listopersonly", "no", new ValueContainerBool(&this->NSListOpersOnly), DT_BOOLEAN, NoValidation}, + {"nickserv", "listmax", "0", new ValueContainerUInt(&this->NSListMax), DT_UINTEGER, ValidateNotZero}, + {"nickserv", "guestnickprefix", "", new ValueContainerString(&this->NSGuestNickPrefix), DT_STRING, ValidateGuestPrefix}, + {"nickserv", "secureadmins", "no", new ValueContainerBool(&this->NSSecureAdmins), DT_BOOLEAN, NoValidation}, + {"nickserv", "strictprivileges", "no", new ValueContainerBool(&this->NSStrictPrivileges), DT_BOOLEAN, NoValidation}, + {"nickserv", "modeonid", "no", new ValueContainerBool(&this->NSModeOnID), DT_BOOLEAN, NoValidation}, + {"nickserv", "addaccessonreg", "no", new ValueContainerBool(&this->NSAddAccessOnReg), DT_BOOLEAN, NoValidation}, + {"mail", "usemail", "no", new ValueContainerBool(&this->UseMail), DT_BOOLEAN, ValidateEmailReg}, + {"mail", "sendmailpath", "", new ValueContainerString(&this->SendMailPath), DT_STRING, ValidateMail}, + {"mail", "sendfrom", "", new ValueContainerString(&this->SendFrom), DT_STRING, ValidateMail}, + {"mail", "restrict", "no", new ValueContainerBool(&this->RestrictMail), DT_BOOLEAN, NoValidation}, + {"mail", "delay", "0", new ValueContainerTime(&this->MailDelay), DT_TIME, NoValidation}, + {"mail", "dontquoteaddresses", "no", new ValueContainerBool(&this->DontQuoteAddresses), DT_BOOLEAN, NoValidation}, + {"chanserv", "nick", "ChanServ", new ValueContainerString(&this->s_ChanServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"chanserv", "description", "Channel Registration Service", new ValueContainerString(&this->desc_ChanServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, {"chanserv", "modules", "", new ValueContainerString(&ChanCoreModules), DT_STRING, NoValidation}, {"chanserv", "defaults", "keeptopic secure securefounder signkick", new ValueContainerString(&CSDefaults), DT_STRING, NoValidation}, - {"chanserv", "maxregistered", "0", new ValueContainerUInt(&Config.CSMaxReg), DT_UINTEGER, NoValidation}, - {"chanserv", "expire", "14d", new ValueContainerTime(&Config.CSExpire), DT_TIME, NoValidation}, - {"chanserv", "defbantype", "2", new ValueContainerInt(&Config.CSDefBantype), DT_INTEGER, ValidateBantype}, - {"chanserv", "accessmax", "0", new ValueContainerUInt(&Config.CSAccessMax), DT_UINTEGER, ValidateNotZero}, - {"chanserv", "autokickmax", "0", new ValueContainerUInt(&Config.CSAutokickMax), DT_UINTEGER, ValidateNotZero}, - {"chanserv", "autokickreason", "User has been banned from the channel", new ValueContainerString(&Config.CSAutokickReason), DT_STRING, ValidateNotEmpty}, - {"chanserv", "inhabit", "0", new ValueContainerTime(&Config.CSInhabit), DT_TIME, ValidateNotZero}, - {"chanserv", "listopersonly", "no", new ValueContainerBool(&Config.CSListOpersOnly), DT_BOOLEAN, NoValidation}, - {"chanserv", "listmax", "0", new ValueContainerUInt(&Config.CSListMax), DT_UINTEGER, ValidateNotZero}, - {"chanserv", "opersonly", "no", new ValueContainerBool(&Config.CSOpersOnly), DT_BOOLEAN, NoValidation}, - {"memoserv", "nick", "MemoServ", new ValueContainerString(&Config.s_MemoServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"memoserv", "description", "Memo Service", new ValueContainerString(&Config.desc_MemoServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"chanserv", "maxregistered", "0", new ValueContainerUInt(&this->CSMaxReg), DT_UINTEGER, NoValidation}, + {"chanserv", "expire", "14d", new ValueContainerTime(&this->CSExpire), DT_TIME, NoValidation}, + {"chanserv", "defbantype", "2", new ValueContainerInt(&this->CSDefBantype), DT_INTEGER, ValidateBantype}, + {"chanserv", "accessmax", "0", new ValueContainerUInt(&this->CSAccessMax), DT_UINTEGER, ValidateNotZero}, + {"chanserv", "autokickmax", "0", new ValueContainerUInt(&this->CSAutokickMax), DT_UINTEGER, ValidateNotZero}, + {"chanserv", "autokickreason", "User has been banned from the channel", new ValueContainerString(&this->CSAutokickReason), DT_STRING, ValidateNotEmpty}, + {"chanserv", "inhabit", "0", new ValueContainerTime(&this->CSInhabit), DT_TIME, ValidateNotZero}, + {"chanserv", "listopersonly", "no", new ValueContainerBool(&this->CSListOpersOnly), DT_BOOLEAN, NoValidation}, + {"chanserv", "listmax", "0", new ValueContainerUInt(&this->CSListMax), DT_UINTEGER, ValidateNotZero}, + {"chanserv", "opersonly", "no", new ValueContainerBool(&this->CSOpersOnly), DT_BOOLEAN, NoValidation}, + {"memoserv", "nick", "MemoServ", new ValueContainerString(&this->s_MemoServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"memoserv", "description", "Memo Service", new ValueContainerString(&this->desc_MemoServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, {"memoserv", "modules", "", new ValueContainerString(&MemoCoreModules), DT_STRING, NoValidation}, - {"memoserv", "maxmemos", "0", new ValueContainerUInt(&Config.MSMaxMemos), DT_UINTEGER, NoValidation}, - {"memoserv", "senddelay", "0", new ValueContainerTime(&Config.MSSendDelay), DT_TIME, NoValidation}, - {"memoserv", "notifyall", "no", new ValueContainerBool(&Config.MSNotifyAll), DT_BOOLEAN, NoValidation}, - {"memoserv", "memoreceipt", "0", new ValueContainerUInt(&Config.MSMemoReceipt), DT_UINTEGER, NoValidation}, - {"botserv", "nick", "", new ValueContainerString(&Config.s_BotServ), DT_STRING | DT_NORELOAD, NoValidation}, - {"botserv", "description", "Bot Service", new ValueContainerString(&Config.desc_BotServ), DT_STRING | DT_NORELOAD, ValidateBotServ}, + {"memoserv", "maxmemos", "0", new ValueContainerUInt(&this->MSMaxMemos), DT_UINTEGER, NoValidation}, + {"memoserv", "senddelay", "0", new ValueContainerTime(&this->MSSendDelay), DT_TIME, NoValidation}, + {"memoserv", "notifyall", "no", new ValueContainerBool(&this->MSNotifyAll), DT_BOOLEAN, NoValidation}, + {"memoserv", "memoreceipt", "0", new ValueContainerUInt(&this->MSMemoReceipt), DT_UINTEGER, NoValidation}, + {"botserv", "nick", "", new ValueContainerString(&this->s_BotServ), DT_STRING | DT_NORELOAD, NoValidation}, + {"botserv", "description", "Bot Service", new ValueContainerString(&this->desc_BotServ), DT_STRING | DT_NORELOAD, ValidateBotServ}, {"botserv", "modules", "", new ValueContainerString(&BotCoreModules), DT_STRING, NoValidation}, {"botserv", "defaults", "", new ValueContainerString(&BSDefaults), DT_STRING, NoValidation}, - {"botserv", "minusers", "0", new ValueContainerUInt(&Config.BSMinUsers), DT_UINTEGER, ValidateBotServ}, - {"botserv", "badwordsmax", "0", new ValueContainerUInt(&Config.BSBadWordsMax), DT_UINTEGER, ValidateBotServ}, - {"botserv", "keepdata", "0", new ValueContainerTime(&Config.BSKeepData), DT_TIME, ValidateBotServ}, - {"botserv", "smartjoin", "no", new ValueContainerBool(&Config.BSSmartJoin), DT_BOOLEAN, NoValidation}, - {"botserv", "gentlebadwordreason", "no", new ValueContainerBool(&Config.BSGentleBWReason), DT_BOOLEAN, NoValidation}, - {"botserv", "casesensitive", "no", new ValueContainerBool(&Config.BSCaseSensitive), DT_BOOLEAN, NoValidation}, - {"botserv", "fantasycharacter", "!", new ValueContainerString(&Config.BSFantasyCharacter), DT_STRING, NoValidation}, - {"hostserv", "nick", "", new ValueContainerString(&Config.s_HostServ), DT_STRING | DT_NORELOAD, NoValidation}, - {"hostserv", "description", "vHost Service", new ValueContainerString(&Config.desc_HostServ), DT_STRING | DT_NORELOAD, ValidateHostServ}, + {"botserv", "minusers", "0", new ValueContainerUInt(&this->BSMinUsers), DT_UINTEGER, ValidateBotServ}, + {"botserv", "badwordsmax", "0", new ValueContainerUInt(&this->BSBadWordsMax), DT_UINTEGER, ValidateBotServ}, + {"botserv", "keepdata", "0", new ValueContainerTime(&this->BSKeepData), DT_TIME, ValidateBotServ}, + {"botserv", "smartjoin", "no", new ValueContainerBool(&this->BSSmartJoin), DT_BOOLEAN, NoValidation}, + {"botserv", "gentlebadwordreason", "no", new ValueContainerBool(&this->BSGentleBWReason), DT_BOOLEAN, NoValidation}, + {"botserv", "casesensitive", "no", new ValueContainerBool(&this->BSCaseSensitive), DT_BOOLEAN, NoValidation}, + {"botserv", "fantasycharacter", "!", new ValueContainerString(&this->BSFantasyCharacter), DT_STRING, NoValidation}, + {"hostserv", "nick", "", new ValueContainerString(&this->s_HostServ), DT_STRING | DT_NORELOAD, NoValidation}, + {"hostserv", "description", "vHost Service", new ValueContainerString(&this->desc_HostServ), DT_STRING | DT_NORELOAD, ValidateHostServ}, {"hostserv", "modules", "", new ValueContainerString(&HostCoreModules), DT_STRING, NoValidation}, - {"operserv", "nick", "OperServ", new ValueContainerString(&Config.s_OperServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"operserv", "description", "Operator Service", new ValueContainerString(&Config.desc_OperServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"operserv", "globalnick", "Global", new ValueContainerString(&Config.s_GlobalNoticer), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, - {"operserv", "globaldescription", "Global Noticer", new ValueContainerString(&Config.desc_GlobalNoticer), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"operserv", "nick", "OperServ", new ValueContainerString(&this->s_OperServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"operserv", "description", "Operator Service", new ValueContainerString(&this->desc_OperServ), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"operserv", "globalnick", "Global", new ValueContainerString(&this->s_GlobalNoticer), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, + {"operserv", "globaldescription", "Global Noticer", new ValueContainerString(&this->desc_GlobalNoticer), DT_STRING | DT_NORELOAD, ValidateNotEmpty}, {"operserv", "modules", "", new ValueContainerString(&OperCoreModules), DT_STRING, NoValidation}, - {"operserv", "superadmin", "no", new ValueContainerBool(&Config.SuperAdmin), DT_BOOLEAN, NoValidation}, - {"operserv", "logmaxusers", "no", new ValueContainerBool(&Config.LogMaxUsers), DT_BOOLEAN, NoValidation}, - {"operserv", "autokillexpiry", "0", new ValueContainerTime(&Config.AutokillExpiry), DT_TIME, ValidateNotZero}, - {"operserv", "chankillexpiry", "0", new ValueContainerTime(&Config.ChankillExpiry), DT_TIME, ValidateNotZero}, - {"operserv", "snlineexpiry", "0", new ValueContainerTime(&Config.SNLineExpiry), DT_TIME, ValidateNotZero}, - {"operserv", "sqlineexpiry", "0", new ValueContainerTime(&Config.SQLineExpiry), DT_TIME, ValidateNotZero}, - {"operserv", "szlineexpiry", "0", new ValueContainerTime(&Config.SZLineExpiry), DT_TIME, ValidateNotZero}, - {"operserv", "akillonadd", "no", new ValueContainerBool(&Config.AkillOnAdd), DT_BOOLEAN, NoValidation}, - {"operserv", "killonsnline", "no", new ValueContainerBool(&Config.KillonSNline), DT_BOOLEAN, NoValidation}, - {"operserv", "killonsqline", "no", new ValueContainerBool(&Config.KillonSQline), DT_BOOLEAN, NoValidation}, + {"operserv", "superadmin", "no", new ValueContainerBool(&this->SuperAdmin), DT_BOOLEAN, NoValidation}, + {"operserv", "logmaxusers", "no", new ValueContainerBool(&this->LogMaxUsers), DT_BOOLEAN, NoValidation}, + {"operserv", "autokillexpiry", "0", new ValueContainerTime(&this->AutokillExpiry), DT_TIME, ValidateNotZero}, + {"operserv", "chankillexpiry", "0", new ValueContainerTime(&this->ChankillExpiry), DT_TIME, ValidateNotZero}, + {"operserv", "snlineexpiry", "0", new ValueContainerTime(&this->SNLineExpiry), DT_TIME, ValidateNotZero}, + {"operserv", "sqlineexpiry", "0", new ValueContainerTime(&this->SQLineExpiry), DT_TIME, ValidateNotZero}, + {"operserv", "szlineexpiry", "0", new ValueContainerTime(&this->SZLineExpiry), DT_TIME, ValidateNotZero}, + {"operserv", "akillonadd", "no", new ValueContainerBool(&this->AkillOnAdd), DT_BOOLEAN, NoValidation}, + {"operserv", "killonsnline", "no", new ValueContainerBool(&this->KillonSNline), DT_BOOLEAN, NoValidation}, + {"operserv", "killonsqline", "no", new ValueContainerBool(&this->KillonSQline), DT_BOOLEAN, NoValidation}, {"operserv", "notifications", "", new ValueContainerString(&OSNotifications), DT_STRING, NoValidation}, - {"operserv", "limitsessions", "no", new ValueContainerBool(&Config.LimitSessions), DT_BOOLEAN, NoValidation}, - {"operserv", "defaultsessionlimit", "0", new ValueContainerUInt(&Config.DefSessionLimit), DT_UINTEGER, NoValidation}, - {"operserv", "maxsessionlimit", "0", new ValueContainerUInt(&Config.MaxSessionLimit), DT_UINTEGER, ValidateLimitSessions}, - {"operserv", "exceptionexpiry", "0", new ValueContainerTime(&Config.ExceptionExpiry), DT_TIME, ValidateLimitSessions}, - {"operserv", "sessionlimitexceeded", "", new ValueContainerString(&Config.SessionLimitExceeded), DT_STRING, NoValidation}, - {"operserv", "sessionlimitdetailsloc", "", new ValueContainerString(&Config.SessionLimitDetailsLoc), DT_STRING, NoValidation}, - {"operserv", "maxsessionkill", "0", new ValueContainerInt(&Config.MaxSessionKill), DT_INTEGER, NoValidation}, - {"operserv", "sessionautokillexpiry", "0", new ValueContainerTime(&Config.SessionAutoKillExpiry), DT_TIME, NoValidation}, - {"operserv", "addakiller", "no", new ValueContainerBool(&Config.AddAkiller), DT_BOOLEAN, NoValidation}, - {"operserv", "opersonly", "no", new ValueContainerBool(&Config.OSOpersOnly), DT_BOOLEAN, NoValidation}, + {"operserv", "limitsessions", "no", new ValueContainerBool(&this->LimitSessions), DT_BOOLEAN, NoValidation}, + {"operserv", "defaultsessionlimit", "0", new ValueContainerUInt(&this->DefSessionLimit), DT_UINTEGER, NoValidation}, + {"operserv", "maxsessionlimit", "0", new ValueContainerUInt(&this->MaxSessionLimit), DT_UINTEGER, ValidateLimitSessions}, + {"operserv", "exceptionexpiry", "0", new ValueContainerTime(&this->ExceptionExpiry), DT_TIME, ValidateLimitSessions}, + {"operserv", "sessionlimitexceeded", "", new ValueContainerString(&this->SessionLimitExceeded), DT_STRING, NoValidation}, + {"operserv", "sessionlimitdetailsloc", "", new ValueContainerString(&this->SessionLimitDetailsLoc), DT_STRING, NoValidation}, + {"operserv", "maxsessionkill", "0", new ValueContainerInt(&this->MaxSessionKill), DT_INTEGER, NoValidation}, + {"operserv", "sessionautokillexpiry", "0", new ValueContainerTime(&this->SessionAutoKillExpiry), DT_TIME, NoValidation}, + {"operserv", "addakiller", "no", new ValueContainerBool(&this->AddAkiller), DT_BOOLEAN, NoValidation}, + {"operserv", "opersonly", "no", new ValueContainerBool(&this->OSOpersOnly), DT_BOOLEAN, NoValidation}, {"defcon", "defaultlevel", "0", new ValueContainerInt(&DefConLevel), DT_INTEGER, ValidateDefCon}, {"defcon", "level4", "", new ValueContainerString(&DefCon4), DT_STRING, ValidateDefCon}, {"defcon", "level3", "", new ValueContainerString(&DefCon3), DT_STRING, ValidateDefCon}, {"defcon", "level2", "", new ValueContainerString(&DefCon2), DT_STRING, ValidateDefCon}, {"defcon", "level1", "", new ValueContainerString(&DefCon1), DT_STRING, ValidateDefCon}, - {"defcon", "sessionlimit", "0", new ValueContainerInt(&Config.DefConSessionLimit), DT_INTEGER, ValidateDefCon}, - {"defcon", "akillexpire", "0", new ValueContainerTime(&Config.DefConAKILL), DT_TIME, ValidateDefCon}, - {"defcon", "chanmodes", "", new ValueContainerString(&Config.DefConChanModes), DT_STRING, ValidateDefCon}, - {"defcon", "timeout", "0", new ValueContainerTime(&Config.DefConTimeOut), DT_TIME, NoValidation}, - {"defcon", "globalondefcon", "no", new ValueContainerBool(&Config.GlobalOnDefcon), DT_BOOLEAN, NoValidation}, - {"defcon", "globalondefconmore", "no", new ValueContainerBool(&Config.GlobalOnDefconMore), DT_BOOLEAN, NoValidation}, - {"defcon", "message", "", new ValueContainerString(&Config.DefconMessage), DT_STRING, ValidateDefCon}, - {"defcon", "offmessage", "", new ValueContainerString(&Config.DefConOffMessage), DT_STRING, NoValidation}, - {"defcon", "akillreason", "", new ValueContainerString(&Config.DefConAkillReason), DT_STRING, ValidateDefCon}, + {"defcon", "sessionlimit", "0", new ValueContainerInt(&this->DefConSessionLimit), DT_INTEGER, ValidateDefCon}, + {"defcon", "akillexpire", "0", new ValueContainerTime(&this->DefConAKILL), DT_TIME, ValidateDefCon}, + {"defcon", "chanmodes", "", new ValueContainerString(&this->DefConChanModes), DT_STRING, ValidateDefCon}, + {"defcon", "timeout", "0", new ValueContainerTime(&this->DefConTimeOut), DT_TIME, NoValidation}, + {"defcon", "globalondefcon", "no", new ValueContainerBool(&this->GlobalOnDefcon), DT_BOOLEAN, NoValidation}, + {"defcon", "globalondefconmore", "no", new ValueContainerBool(&this->GlobalOnDefconMore), DT_BOOLEAN, NoValidation}, + {"defcon", "message", "", new ValueContainerString(&this->DefconMessage), DT_STRING, ValidateDefCon}, + {"defcon", "offmessage", "", new ValueContainerString(&this->DefConOffMessage), DT_STRING, NoValidation}, + {"defcon", "akillreason", "", new ValueContainerString(&this->DefConAkillReason), DT_STRING, ValidateDefCon}, {"", "", "", NULL, DT_NOTHING, NoValidation} }; @@ -799,17 +1084,8 @@ int ServerConfig::Read(bool bail) NULL, NULL, NULL} }; - // Load and parse the config file, if there are any errors then explode - // Make a copy here so if it fails then we can carry on running with an unaffected config - newconfig.clear(); - if (LoadConf(newconfig, services_conf, errstr)) - // If we succeeded, set the config to the new one - config_data = newconfig; - else - { - ReportConfigError(errstr.str(), bail); - return 0; - } + if (!LoadConf(this->config_data, services_conf)) + throw ConfigException(this->errstr.str()); /* This boolean is set to true when the Values array is completely iterated through, to avoid needing * to do so inside the catch block to clean up the new'd values from the array. */ bool CheckedAllValues = false; @@ -825,19 +1101,13 @@ int ServerConfig::Read(bool bail) dt &= ~DT_ALLOW_NEWLINE; dt &= ~DT_ALLOW_WILD; dt &= ~DT_NORELOAD; - // If the value is set to not allow reloading and we are reloading (bail will be false), skip the item - if (noreload && !bail) - { - delete Values[Index].val; - Values[Index].val = NULL; - continue; - } - ConfValue(config_data, Values[Index].tag, Values[Index].value, Values[Index].default_value, 0, item, allow_newlines); + ConfigDataHash &hash = (noreload && Config ? Config->config_data : this->config_data); + ConfValue(hash, Values[Index].tag, Values[Index].value, Values[Index].default_value, 0, item, allow_newlines); ValueItem vi(item); if (!Values[Index].validation_function(this, Values[Index].tag, Values[Index].value, vi)) - throw ConfigException("One or more values in your configuration file failed to validate. Please see your ircd.log for more information."); + throw ConfigException("One or more values in your configuration file failed to validate. Please see your logfiles for more information."); switch (dt) { @@ -935,7 +1205,7 @@ int ServerConfig::Read(bool bail) * callbacks for these, a 'start', 'item' and 'end' callback. */ for (int Index = 0; !MultiValues[Index].tag.empty(); ++Index) { - MultiValues[Index].init_function(this, MultiValues[Index].tag, bail); + MultiValues[Index].init_function(this, MultiValues[Index].tag); int number_of_tags = ConfValueEnum(config_data, MultiValues[Index].tag); for (int tagnum = 0; tagnum < number_of_tags; ++tagnum) { @@ -948,15 +1218,14 @@ int ServerConfig::Read(bool bail) dt &= ~DT_ALLOW_NEWLINE; dt &= ~DT_ALLOW_WILD; dt &= ~DT_NORELOAD; - // If the value is set to not allow reloading and we are reloading (bail will be false), skip the item - if (noreload && !bail) - continue; + + ConfigDataHash &hash = (noreload && Config ? Config->config_data : this->config_data); switch (dt) { case DT_NOSPACES: { Anope::string item; - if (ConfValue(config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) + if (ConfValue(hash, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) vl.push_back(ValueItem(item)); else vl.push_back(ValueItem("")); @@ -966,7 +1235,7 @@ int ServerConfig::Read(bool bail) case DT_HOSTNAME: { Anope::string item; - if (ConfValue(config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) + if (ConfValue(hash, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) vl.push_back(ValueItem(item)); else vl.push_back(ValueItem("")); @@ -976,7 +1245,7 @@ int ServerConfig::Read(bool bail) case DT_IPADDRESS: { Anope::string item; - if (ConfValue(config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) + if (ConfValue(hash, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) vl.push_back(ValueItem(item)); else vl.push_back(ValueItem("")); @@ -986,7 +1255,7 @@ int ServerConfig::Read(bool bail) case DT_CHARPTR: { Anope::string item; - if (ConfValue(config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) + if (ConfValue(hash, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) vl.push_back(ValueItem(item.c_str())); else vl.push_back(ValueItem("")); @@ -995,7 +1264,7 @@ int ServerConfig::Read(bool bail) case DT_CSSTRING: { Anope::string item; - if (ConfValue(config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) + if (ConfValue(hash, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) vl.push_back(ValueItem(item)); else vl.push_back(ValueItem("")); @@ -1004,7 +1273,7 @@ int ServerConfig::Read(bool bail) case DT_CISTRING: { Anope::string item; - if (ConfValue(config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) + if (ConfValue(hash, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) vl.push_back(ValueItem(item)); else vl.push_back(ValueItem("")); @@ -1013,7 +1282,7 @@ int ServerConfig::Read(bool bail) case DT_STRING: { Anope::string item; - if (ConfValue(config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) + if (ConfValue(hash, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) vl.push_back(ValueItem(item)); else vl.push_back(ValueItem("")); @@ -1024,7 +1293,7 @@ int ServerConfig::Read(bool bail) case DT_LUINTEGER: { int item = 0; - if (ConfValueInteger(config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item)) + if (ConfValueInteger(hash, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item)) vl.push_back(ValueItem(item)); else vl.push_back(ValueItem(0)); @@ -1033,7 +1302,7 @@ int ServerConfig::Read(bool bail) case DT_TIME: { Anope::string item; - if (ConfValue(config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) + if (ConfValue(hash, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum, item, allow_newlines)) { #ifdef _WIN32 long time = static_cast<long>(dotime(item)); @@ -1048,19 +1317,18 @@ int ServerConfig::Read(bool bail) break; case DT_BOOLEAN: { - bool item = ConfValueBool(config_data, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum); + bool item = ConfValueBool(hash, MultiValues[Index].tag, MultiValues[Index].items[valuenum], MultiValues[Index].items_default[valuenum], tagnum); vl.push_back(ValueItem(item)); } } } - MultiValues[Index].validation_function(this, MultiValues[Index].tag, MultiValues[Index].items, vl, MultiValues[Index].datatype, bail); + MultiValues[Index].validation_function(this, MultiValues[Index].tag, MultiValues[Index].items, vl, MultiValues[Index].datatype); } - MultiValues[Index].finish_function(this, MultiValues[Index].tag, bail); + MultiValues[Index].finish_function(this, MultiValues[Index].tag); } } catch (const ConfigException &ce) { - ReportConfigError(ce.GetReason(), bail); if (!CheckedAllValues) { for (int Index = 0; !Values[Index].tag.empty(); ++Index) @@ -1069,17 +1337,15 @@ int ServerConfig::Read(bool bail) delete Values[Index].val; } } - return 0; + throw ConfigException(ce); } Alog(LOG_DEBUG) << "End config"; for (int Index = 0; !Once[Index].empty(); ++Index) - if (!CheckOnce(Once[Index])) - return 0; + CheckOnce(Once[Index]); Alog() << "Done reading configuration file."; - return 1; } -bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filename, std::ostringstream &errorstream) +bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filename) { Anope::string line; Anope::string section, wordbuffer, itemname; @@ -1089,7 +1355,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam KeyValList sectiondata; if (conf.fail()) { - errorstream << "File " << filename << " could not be opened." << std::endl; + errstr << "File " << filename << " could not be opened." << std::endl; return false; } Alog(LOG_DEBUG) << "Start to read conf " << filename; @@ -1134,12 +1400,12 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam // Quotes are valid only in the value position if (section.empty() || itemname.empty()) { - errorstream << "Unexpected quoted string: " << filename << ":" << linenumber << std::endl; + errstr << "Unexpected quoted string: " << filename << ":" << linenumber << std::endl; return false; } if (in_word || !wordbuffer.empty()) { - errorstream << "Unexpected quoted string (prior unhandled words): " << filename << ":" << linenumber << std::endl; + errstr << "Unexpected quoted string (prior unhandled words): " << filename << ":" << linenumber << std::endl; return false; } in_quote = in_word = true; @@ -1149,12 +1415,12 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam { if (section.empty()) { - errorstream << "Config item outside of section (or stray '='): " << filename << ":" << linenumber << std::endl; + errstr << "Config item outside of section (or stray '='): " << filename << ":" << linenumber << std::endl; return false; } if (!itemname.empty()) { - errorstream << "Stray '=' sign or item without value: " << filename << ":" << linenumber << std::endl; + errstr << "Stray '=' sign or item without value: " << filename << ":" << linenumber << std::endl; return false; } if (in_word) @@ -1166,12 +1432,12 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam { if (!section.empty()) { - errorstream << "Section inside another section: " << filename << ":" << linenumber << std::endl; + errstr << "Section inside another section: " << filename << ":" << linenumber << std::endl; return false; } if (wordbuffer.empty()) { - errorstream << "Section without a name or unexpected '{': " << filename << ":" << linenumber << std::endl; + errstr << "Section without a name or unexpected '{': " << filename << ":" << linenumber << std::endl; return false; } if (in_word) @@ -1183,7 +1449,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam { if (section.empty()) { - errorstream << "Stray '}': " << filename << ":" << linenumber << std::endl; + errstr << "Stray '}': " << filename << ":" << linenumber << std::endl; return false; } if (!wordbuffer.empty() || !itemname.empty()) @@ -1192,7 +1458,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam // but will not allow for anything else, such as: section { key = value; key = value } if (!sectiondata.empty()) { - errorstream << "Unexpected end of section: " << filename << ":" << linenumber << std::endl; + errstr << "Unexpected end of section: " << filename << ":" << linenumber << std::endl; return false; } // this is the same as the below section for testing if itemname is non-empty after the loop, but done inside it to allow the above construct @@ -1217,7 +1483,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam { if (!in_word && !wordbuffer.empty()) { - errorstream << "Unexpected word: " << filename << ":" << linenumber << std::endl; + errstr << "Unexpected word: " << filename << ":" << linenumber << std::endl; return false; } wordbuffer += ch; @@ -1235,7 +1501,7 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam { if (wordbuffer.empty()) { - errorstream << "Item without value: " << filename << ":" << linenumber << std::endl; + errstr << "Item without value: " << filename << ":" << linenumber << std::endl; return false; } Alog(LOG_DEBUG) << "ln " << linenumber << " EOL: s='" << section << "' '" << itemname << "' set to '" << wordbuffer << "'"; @@ -1246,22 +1512,22 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const Anope::string &filenam } if (in_ml_comment) { - errorstream << "Unterminated multiline comment at end of file: " << filename << std::endl; + errstr << "Unterminated multiline comment at end of file: " << filename << std::endl; return false; } if (in_quote) { - errorstream << "Unterminated quote at end of file: " << filename << std::endl; + errstr << "Unterminated quote at end of file: " << filename << std::endl; return false; } if (!itemname.empty() || !wordbuffer.empty()) { - errorstream << "Unexpected garbage at end of file: " << filename << std::endl; + errstr << "Unexpected garbage at end of file: " << filename << std::endl; return false; } if (!section.empty()) { - errorstream << "Unterminated section at end of file: " << filename << std::endl; + errstr << "Unterminated section at end of file: " << filename << std::endl; return false; } return true; @@ -1381,7 +1647,7 @@ bool ServerConfig::ConfValueBool(ConfigDataHash &target, const Anope::string &ta return result.equals_ci("yes") || result.equals_ci("true") || result.equals_ci("1"); } -int ServerConfig::ConfValueEnum(ConfigDataHash &target, const Anope::string &tag) +int ServerConfig::ConfValueEnum(const ConfigDataHash &target, const Anope::string &tag) { return target.count(tag); } @@ -1476,377 +1742,4 @@ bool ValueItem::GetBool() const return GetInteger() || v == "yes" || v == "true"; } -/*************************************************************************/ - -/* Print an error message to the log (and the console, if open). */ - -void error(int linenum, const char *message, ...) -{ - char buf[4096]; - va_list args; - - va_start(args, message); - vsnprintf(buf, sizeof(buf), message, args); - va_end(args); - - if (linenum) - Alog() << services_conf << ":" << linenum << ": " << buf; - else - Alog() << services_conf << ": " << buf; - - if (!nofork && isatty(2)) - { - if (linenum) - fprintf(stderr, "%s:%d: %s\n", services_conf.c_str(), linenum, buf); - else - fprintf(stderr, "%s: %s\n", services_conf.c_str(), buf); - } -} - -/*************************************************************************/ - -/* Read the entire configuration file. If an error occurs while reading - * the file or a required directive is not found, print and log an - * appropriate error message and return 0; otherwise, return 1. - * - * If reload is 1, will reload the configuration file. - * --lara - */ - -int read_config(int reload) -{ - int retval = 1; - int defconCount = 0; - - retval = Config.Read(reload ? false : true); - if (!retval) - return 0; // Temporary until most of the below is modified to use the new parser -- CyberBotX - - if (!temp_nsuserhost.empty()) - { - size_t at = temp_nsuserhost.find('@'); - if (at == Anope::string::npos) - { - Config.NSEnforcerUser = temp_nsuserhost; - Config.NSEnforcerHost = Config.ServiceHost; - } - else - { - Config.NSEnforcerUser = temp_nsuserhost.substr(0, at); - Config.NSEnforcerHost = temp_nsuserhost.substr(at + 1); - } - } - - if (NSDefaults.empty()) - { - Config.NSDefFlags.SetFlag(NI_SECURE); - Config.NSDefFlags.SetFlag(NI_MEMO_SIGNON); - Config.NSDefFlags.SetFlag(NI_MEMO_RECEIVE); - } - else if (!NSDefaults.equals_ci("none")) - { - spacesepstream options(NSDefaults); - Anope::string option; - while (options.GetToken(option)) - { - if (option.equals_ci("kill")) - Config.NSDefFlags.SetFlag(NI_KILLPROTECT); - else if (option.equals_ci("killquick")) - Config.NSDefFlags.SetFlag(NI_KILL_QUICK); - else if (option.equals_ci("secure")) - Config.NSDefFlags.SetFlag(NI_SECURE); - else if (option.equals_ci("private")) - Config.NSDefFlags.SetFlag(NI_PRIVATE); - else if (option.equals_ci("msg")) - { - if (!Config.UsePrivmsg) - Alog() << "msg in <nickserv:defaults> can only be used when UsePrivmsg is set"; - else - Config.NSDefFlags.SetFlag(NI_MSG); - } - else if (option.equals_ci("hideemail")) - Config.NSDefFlags.SetFlag(NI_HIDE_EMAIL); - else if (option.equals_ci("hideusermask")) - Config.NSDefFlags.SetFlag(NI_HIDE_MASK); - else if (option.equals_ci("hidequit")) - Config.NSDefFlags.SetFlag(NI_HIDE_QUIT); - else if (option.equals_ci("memosignon")) - Config.NSDefFlags.SetFlag(NI_MEMO_SIGNON); - else if (option.equals_ci("memoreceive")) - Config.NSDefFlags.SetFlag(NI_MEMO_RECEIVE); - else if (option.equals_ci("autoop")) - Config.NSDefFlags.SetFlag(NI_AUTOOP); - } - } - - if (reload) - { - if ((Config.NSDefLanguage = langlist[Config.NSDefLanguage]) < 0) - Config.NSDefLanguage = DEF_LANGUAGE; - } - - if (Config.CSDefBantype < 0 || Config.CSDefBantype > 3) - { - error(0, "Value of CSDefBantype must be between 0 and 3 included"); - retval = 0; - } - - if (CSDefaults.empty()) - { - Config.CSDefFlags.SetFlag(CI_KEEPTOPIC); - Config.CSDefFlags.SetFlag(CI_SECURE); - Config.CSDefFlags.SetFlag(CI_SECUREFOUNDER); - Config.CSDefFlags.SetFlag(CI_SIGNKICK); - } - else if (!CSDefaults.equals_ci("none")) - { - spacesepstream options(CSDefaults); - Anope::string option; - while (options.GetToken(option)) - { - if (option.equals_ci("keeptopic")) - Config.CSDefFlags.SetFlag(CI_KEEPTOPIC); - else if (option.equals_ci("topiclock")) - Config.CSDefFlags.SetFlag(CI_TOPICLOCK); - else if (option.equals_ci("private")) - Config.CSDefFlags.SetFlag(CI_PRIVATE); - else if (option.equals_ci("restricted")) - Config.CSDefFlags.SetFlag(CI_RESTRICTED); - else if (option.equals_ci("secure")) - Config.CSDefFlags.SetFlag(CI_SECURE); - else if (option.equals_ci("secureops")) - Config.CSDefFlags.SetFlag(CI_SECUREOPS); - else if (option.equals_ci("securefounder")) - Config.CSDefFlags.SetFlag(CI_SECUREFOUNDER); - else if (option.equals_ci("signkick")) - Config.CSDefFlags.SetFlag(CI_SIGNKICK); - else if (option.equals_ci("signkicklevel")) - Config.CSDefFlags.SetFlag(CI_SIGNKICK_LEVEL); - else if (option.equals_ci("opnotice")) - Config.CSDefFlags.SetFlag(CI_OPNOTICE); - else if (option.equals_ci("xop")) - Config.CSDefFlags.SetFlag(CI_XOP); - else if (option.equals_ci("peace")) - Config.CSDefFlags.SetFlag(CI_PEACE); - else if (option.equals_ci("persist")) - Config.CSDefFlags.SetFlag(CI_PERSIST); - } - } - - if (!BSDefaults.empty()) - { - spacesepstream options(BSDefaults); - Anope::string option; - while (options.GetToken(option)) - { - if (option.equals_ci("dontkickops")) - Config.BSDefFlags.SetFlag(BS_DONTKICKOPS); - else if (option.equals_ci("dontkickvoices")) - Config.BSDefFlags.SetFlag(BS_DONTKICKVOICES); - else if (option.equals_ci("greet")) - Config.BSDefFlags.SetFlag(BS_GREET); - else if (option.equals_ci("fantasy")) - Config.BSDefFlags.SetFlag(BS_FANTASY); - else if (option.equals_ci("symbiosis")) - Config.BSDefFlags.SetFlag(BS_SYMBIOSIS); - } - } - Config.WallOper = Config.WallBadOS = Config.WallOSGlobal = Config.WallOSMode = Config.WallOSClearmodes = Config.WallOSKick = Config.WallOSAkill = Config.WallOSSNLine = Config.WallOSSQLine = - Config.WallOSSZLine = Config.WallOSNoOp = Config.WallOSJupe = Config.WallAkillExpire = Config.WallSNLineExpire = Config.WallSQLineExpire = Config.WallSZLineExpire = Config.WallExceptionExpire = - Config.WallGetpass = Config.WallSetpass = Config.WallForbid = Config.WallDrop = false; - if (!OSNotifications.empty()) - { - spacesepstream notifications(OSNotifications); - Anope::string notice; - while (notifications.GetToken(notice)) - { - if (notice.equals_ci("oper")) - Config.WallOper = true; - else if (notice.equals_ci("bados")) - Config.WallBadOS = true; - else if (notice.equals_ci("osglobal")) - Config.WallOSGlobal = true; - else if (notice.equals_ci("osmode")) - Config.WallOSMode = true; - else if (notice.equals_ci("osclearmodes")) - Config.WallOSClearmodes = true; - else if (notice.equals_ci("oskick")) - Config.WallOSKick = true; - else if (notice.equals_ci("osakill")) - Config.WallOSAkill = true; - else if (notice.equals_ci("ossnline")) - Config.WallOSSNLine = true; - else if (notice.equals_ci("ossqline")) - Config.WallOSSQLine = true; - else if (notice.equals_ci("osszline")) - Config.WallOSSZLine = true; - else if (notice.equals_ci("osnoop")) - Config.WallOSNoOp = true; - else if (notice.equals_ci("osjupe")) - Config.WallOSJupe = true; - else if (notice.equals_ci("akillexpire")) - Config.WallAkillExpire = true; - else if (notice.equals_ci("snlineexpire")) - Config.WallSNLineExpire = true; - else if (notice.equals_ci("sqlineexpire")) - Config.WallSQLineExpire = true; - else if (notice.equals_ci("szlineexpire")) - Config.WallSZLineExpire = true; - else if (notice.equals_ci("exceptionexpire")) - Config.WallExceptionExpire = true; - else if (notice.equals_ci("getpass")) - Config.WallGetpass = true; - else if (notice.equals_ci("setpass")) - Config.WallSetpass = true; - else if (notice.equals_ci("forbid")) - Config.WallForbid = true; - else if (notice.equals_ci("drop")) - Config.WallDrop = true; - } - } - - /* Ulines */ - if (!UlineServers.empty()) - { - Config.Ulines.clear(); - - spacesepstream ulines(UlineServers); - Anope::string uline; - while (ulines.GetToken(uline)) - Config.Ulines.push_back(uline); - } - - /* Modules Autoload building... :P */ - Config.ModulesAutoLoad = BuildStringList(Modules); - Config.EncModuleList = BuildStringList(EncModules); - Config.DBModuleList = BuildStringList(DBModules); - Config.HostServCoreModules = BuildStringList(HostCoreModules); - Config.MemoServCoreModules = BuildStringList(MemoCoreModules); - Config.BotServCoreModules = BuildStringList(BotCoreModules); - Config.OperServCoreModules = BuildStringList(OperCoreModules); - Config.ChanServCoreModules = BuildStringList(ChanCoreModules); - Config.NickServCoreModules = BuildStringList(NickCoreModules); - - if (Config.LimitSessions) - { - if (Config.MaxSessionKill && !Config.SessionAutoKillExpiry) - Config.SessionAutoKillExpiry = 1800; /* 30 minutes */ - } - - if (!Config.s_BotServ.empty()) - { - if (Config.BSFantasyCharacter.empty()) - Config.BSFantasyCharacter = "!"; - if (Config.BSFantasyCharacter.length() > 1) - printf("*** Config.BSFantasyCharacter is more than 1 character long. Only the first\n*** character ('%c') will be used. The others will be ignored.\n", Config.BSFantasyCharacter[0]); - } - - /* Check the user keys */ - if (Config.UserKey1 == Config.UserKey2 || Config.UserKey1 == Config.UserKey3 || Config.UserKey3 == Config.UserKey2) - Alog() << "Every UserKey must be different. It's for YOUR safety! Remember that!"; - - /** - * Check all DEFCON dependiencies... - **/ - if (Config.DefConLevel) - { - /* Build DefCon's */ - DefCon.resize(6); - DefCon[5].reset(); - for (unsigned int level = 1; level < 5; ++level) - { - DefCon[level] = 0; - Anope::string *levelDefinition = NULL; - switch (level) - { - case 1: - levelDefinition = &DefCon1; - break; - case 2: - levelDefinition = &DefCon2; - break; - case 3: - levelDefinition = &DefCon3; - break; - case 4: - levelDefinition = &DefCon4; - } - spacesepstream operations(*levelDefinition); - Anope::string operation; - while (operations.GetToken(operation)) - { - if (operation.equals_ci("nonewchannels")) - AddDefCon(level, DEFCON_NO_NEW_CHANNELS); - else if (operation.equals_ci("nonewnicks")) - AddDefCon(level, DEFCON_NO_NEW_NICKS); - else if (operation.equals_ci("nomlockchanges")) - AddDefCon(level, DEFCON_NO_MLOCK_CHANGE); - else if (operation.equals_ci("forcechanmodes")) - AddDefCon(level, DEFCON_FORCE_CHAN_MODES); - else if (operation.equals_ci("reducedsessions")) - AddDefCon(level, DEFCON_REDUCE_SESSION); - else if (operation.equals_ci("nonewclients")) - AddDefCon(level, DEFCON_NO_NEW_CLIENTS); - else if (operation.equals_ci("operonly")) - AddDefCon(level, DEFCON_OPER_ONLY); - else if (operation.equals_ci("silentoperonly")) - AddDefCon(level, DEFCON_SILENT_OPER_ONLY); - else if (operation.equals_ci("akillnewclients")) - AddDefCon(level, DEFCON_AKILL_NEW_CLIENTS); - else if (operation.equals_ci("nonewmemos")) - AddDefCon(level, DEFCON_NO_NEW_MEMOS); - } - } - - /* Check any defcon needed settings */ - for (defconCount = 1; defconCount <= 5; ++defconCount) - { - if (CheckDefCon(defconCount, DEFCON_REDUCE_SESSION)) - { - if (!Config.DefConSessionLimit) - { - error(0, "Config.DefConSessionLimit missing"); - retval = 0; - } - } - if (CheckDefCon(defconCount, DEFCON_AKILL_NEW_CLIENTS)) - { - if (!Config.DefConAKILL) - { - error(0, "Config.DefConAKILL missing"); - retval = 0; - } - if (Config.DefConAkillReason.empty()) - { - error(0, "Config.DefConAkillReason missing"); - retval = 0; - } - } - if (CheckDefCon(defconCount, DEFCON_FORCE_CHAN_MODES)) - { - if (Config.DefConChanModes.empty()) - { - error(0, "Config.DefConChanModes missing"); - retval = 0; - } - } - } - } - - SetDefaultMLock(); - - /* Disable the log channel if its defined in the conf, but not enabled */ - if (Config.LogChannel.empty() && LogChan) - LogChan = false; - - if (!retval) - { - printf("\n*** Support resources: Read through the services.conf self-contained \n*** documentation. Read the documentation files found in the 'docs' \n" - "*** folder. Visit our portal located at http://www.anope.org/. Join \n*** our support channel on /server irc.anope.org channel #anope.\n\n"); - } - - return retval; -} - -/*************************************************************************/ diff --git a/src/configreader.cpp b/src/configreader.cpp index 6ba9453f7..90c999cf0 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -1,4 +1,16 @@ -/* +------------------------------------+ +/* Configuration file handling. + * + * (C) 2003-2010 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + +/* Taken from: + * +------------------------------------+ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * @@ -13,21 +25,16 @@ #include "services.h" -ConfigReader::ConfigReader() : data(&Config.config_data), errorlog(new std::ostringstream(std::stringstream::in | std::stringstream::out)), privatehash(false), error(CONF_NO_ERROR) +ConfigReader::ConfigReader() : error(CONF_NO_ERROR) { } -ConfigReader::~ConfigReader() +ConfigReader::ConfigReader(const Anope::string &filename) : error(CONF_NO_ERROR) { - if (this->errorlog) - delete this->errorlog; - if (this->privatehash) - delete this->data; } -ConfigReader::ConfigReader(const Anope::string &filename) : data(new ConfigDataHash), errorlog(new std::ostringstream(std::stringstream::in | std::stringstream::out)), privatehash(true), error(CONF_NO_ERROR) +ConfigReader::~ConfigReader() { - Config.ClearStack(); } Anope::string ConfigReader::ReadValue(const Anope::string &tag, const Anope::string &name, const Anope::string &default_value, int index, bool allow_linefeeds) @@ -35,7 +42,7 @@ Anope::string ConfigReader::ReadValue(const Anope::string &tag, const Anope::str /* Don't need to strlcpy() tag and name anymore, ReadConf() takes const char* */ Anope::string result; - if (!Config.ConfValue(*this->data, tag, name, default_value, index, result, allow_linefeeds)) + if (!Config->ConfValue(Config->config_data, tag, name, default_value, index, result, allow_linefeeds)) this->error = CONF_VALUE_NOT_FOUND; return result; @@ -48,7 +55,7 @@ Anope::string ConfigReader::ReadValue(const Anope::string &tag, const Anope::str bool ConfigReader::ReadFlag(const Anope::string &tag, const Anope::string &name, const Anope::string &default_value, int index) { - return Config.ConfValueBool(*this->data, tag, name, default_value, index); + return Config->ConfValueBool(Config->config_data, tag, name, default_value, index); } bool ConfigReader::ReadFlag(const Anope::string &tag, const Anope::string &name, int index) @@ -60,7 +67,7 @@ int ConfigReader::ReadInteger(const Anope::string &tag, const Anope::string &nam { int result; - if (!Config.ConfValueInteger(*this->data, tag, name, default_value, index, result)) + if (!Config->ConfValueInteger(Config->config_data, tag, name, default_value, index, result)) { this->error = CONF_VALUE_NOT_FOUND; return 0; @@ -87,19 +94,14 @@ long ConfigReader::GetError() return olderr; } -void ConfigReader::DumpErrors(bool bail) -{ - Config.ReportConfigError(this->errorlog->str(), bail); -} - int ConfigReader::Enumerate(const Anope::string &tag) const { - return Config.ConfValueEnum(*this->data, tag); + return Config->ConfValueEnum(Config->config_data, tag); } int ConfigReader::EnumerateValues(const Anope::string &tag, int index) { - return Config.ConfVarEnum(*this->data, tag, index); + return Config->ConfVarEnum(Config->config_data, tag, index); } bool ConfigReader::Verify() diff --git a/src/hostserv.cpp b/src/hostserv.cpp index 86e0c5c85..31ff713f8 100644 --- a/src/hostserv.cpp +++ b/src/hostserv.cpp @@ -19,7 +19,7 @@ E void moduleAddHostServCmds(); void moduleAddHostServCmds() { - ModuleManager::LoadModuleList(Config.HostServCoreModules); + ModuleManager::LoadModuleList(Config->HostServCoreModules); } /*************************************************************************/ @@ -61,7 +61,7 @@ void get_hostserv_stats(long *nrec, long *memuse) */ void hostserv_init() { - if (!Config.s_HostServ.empty()) + if (!Config->s_HostServ.empty()) moduleAddHostServCmds(); } @@ -170,8 +170,8 @@ void do_on_id(User *u) u->UpdateHost(); if (!na->hostinfo.GetIdent().empty()) - notice_lang(Config.s_HostServ, u, HOST_IDENT_ACTIVATED, na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str()); + notice_lang(Config->s_HostServ, u, HOST_IDENT_ACTIVATED, na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str()); else - notice_lang(Config.s_HostServ, u, HOST_ACTIVATED, na->hostinfo.GetHost().c_str()); + notice_lang(Config->s_HostServ, u, HOST_ACTIVATED, na->hostinfo.GetHost().c_str()); } } diff --git a/src/init.cpp b/src/init.cpp index e64a622d9..35407ec81 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -149,7 +149,7 @@ bool GetCommandLineArgument(const Anope::string &name, char shortname, Anope::st static void remove_pidfile() { - remove(Config.PIDFilename.c_str()); + remove(Config->PIDFilename.c_str()); } /*************************************************************************/ @@ -160,7 +160,7 @@ static void write_pidfile() { FILE *pidfile; - pidfile = fopen(Config.PIDFilename.c_str(), "w"); + pidfile = fopen(Config->PIDFilename.c_str(), "w"); if (pidfile) { #ifdef _WIN32 @@ -172,7 +172,7 @@ static void write_pidfile() atexit(remove_pidfile); } else - log_perror("Warning: cannot write to PID file %s", Config.PIDFilename.c_str()); + log_perror("Warning: cannot write to PID file %s", Config->PIDFilename.c_str()); } /*************************************************************************/ @@ -311,15 +311,26 @@ int init_primary(int ac, char **av) } /* Read configuration file; exit if there are problems. */ - if (!read_config(0)) + try + { + Config = new ServerConfig(); + } + catch (const ConfigException &ex) + { + Alog(LOG_TERMINAL) << ex.GetReason(); + Alog(LOG_TERMINAL) << "*** Support resources: Read through the services.conf self-contained"; + Alog(LOG_TERMINAL) << "*** documentation. Read the documentation files found in the 'docs'"; + Alog(LOG_TERMINAL) << "*** folder. Visit our portal located at http://www.anope.org/. Join"; + Alog(LOG_TERMINAL) << "*** our support channel on /server irc.anope.org channel #anope."; return -1; + } /* Add IRCD Protocol Module; exit if there are errors */ if (protocol_module_init()) return -1; /* Create me */ - Me = new Server(NULL, Config.ServerName, 0, Config.ServerDesc, Config.Numeric); + Me = new Server(NULL, Config->ServerName, 0, Config->ServerDesc, Config->Numeric); /* First thing, add our core bots internally. Before modules are loaded and before the database is read * This is used for modules adding commands and for the BotInfo* poiners in the command classes. @@ -333,31 +344,31 @@ int init_primary(int ac, char **av) * Note that it is important this is after loading the protocol module. The ircd struct must exist for * the ts6_ functions */ - if (!Config.s_OperServ.empty()) - new BotInfo(Config.s_OperServ, Config.ServiceUser, Config.ServiceHost, Config.desc_OperServ); - if (!Config.s_NickServ.empty()) - new BotInfo(Config.s_NickServ, Config.ServiceUser, Config.ServiceHost, Config.desc_NickServ); - if (!Config.s_ChanServ.empty()) - new BotInfo(Config.s_ChanServ, Config.ServiceUser, Config.ServiceHost, Config.desc_ChanServ); - if (!Config.s_HostServ.empty()) - new BotInfo(Config.s_HostServ, Config.ServiceUser, Config.ServiceHost, Config.desc_HostServ); - if (!Config.s_MemoServ.empty()) - new BotInfo(Config.s_MemoServ, Config.ServiceUser, Config.ServiceHost, Config.desc_MemoServ); - if (!Config.s_BotServ.empty()) - new BotInfo(Config.s_BotServ, Config.ServiceUser, Config.ServiceHost, Config.desc_BotServ); - if (!Config.s_GlobalNoticer.empty()) - new BotInfo(Config.s_GlobalNoticer, Config.ServiceUser, Config.ServiceHost, Config.desc_GlobalNoticer); + if (!Config->s_OperServ.empty()) + new BotInfo(Config->s_OperServ, Config->ServiceUser, Config->ServiceHost, Config->desc_OperServ); + if (!Config->s_NickServ.empty()) + new BotInfo(Config->s_NickServ, Config->ServiceUser, Config->ServiceHost, Config->desc_NickServ); + if (!Config->s_ChanServ.empty()) + new BotInfo(Config->s_ChanServ, Config->ServiceUser, Config->ServiceHost, Config->desc_ChanServ); + if (!Config->s_HostServ.empty()) + new BotInfo(Config->s_HostServ, Config->ServiceUser, Config->ServiceHost, Config->desc_HostServ); + if (!Config->s_MemoServ.empty()) + new BotInfo(Config->s_MemoServ, Config->ServiceUser, Config->ServiceHost, Config->desc_MemoServ); + if (!Config->s_BotServ.empty()) + new BotInfo(Config->s_BotServ, Config->ServiceUser, Config->ServiceHost, Config->desc_BotServ); + if (!Config->s_GlobalNoticer.empty()) + new BotInfo(Config->s_GlobalNoticer, Config->ServiceUser, Config->ServiceHost, Config->desc_GlobalNoticer); /* Add Encryption Modules */ - ModuleManager::LoadModuleList(Config.EncModuleList); + ModuleManager::LoadModuleList(Config->EncModuleList); /* Add Database Modules */ - ModuleManager::LoadModuleList(Config.DBModuleList); + ModuleManager::LoadModuleList(Config->DBModuleList); /* Load the socket engine */ - if (ModuleManager::LoadModule(Config.SocketEngine, NULL)) + if (ModuleManager::LoadModule(Config->SocketEngine, NULL)) { - Alog(LOG_TERMINAL) << "Unable to load socket engine " << Config.SocketEngine; + Alog(LOG_TERMINAL) << "Unable to load socket engine " << Config->SocketEngine; return -1; } @@ -448,7 +459,7 @@ int init_secondary(int ac, char **av) /* load any custom modules */ if (!nothird) - ModuleManager::LoadModuleList(Config.ModulesAutoLoad); + ModuleManager::LoadModuleList(Config->ModulesAutoLoad); /* Initialize random number generator */ rand_init(); diff --git a/src/language.cpp b/src/language.cpp index 6e9192756..32f96b461 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -168,7 +168,7 @@ void lang_sanitize() { len = strlen(langtexts[i][j]); strscpy(tmp, langtexts[i][j], sizeof(tmp)); - if (Config.UseStrictPrivMsg) + if (Config->UseStrictPrivMsg) strnrepl(tmp, sizeof(tmp), "%R", "/"); else strnrepl(tmp, sizeof(tmp), "%R", "/msg "); @@ -221,8 +221,8 @@ void lang_init() /* Not what I intended to do, but these services are so archaïc * that it's difficult to do more. */ - if ((Config.NSDefLanguage = langlist[Config.NSDefLanguage]) < 0) - Config.NSDefLanguage = DEF_LANGUAGE; + if ((Config->NSDefLanguage = langlist[Config->NSDefLanguage]) < 0) + Config->NSDefLanguage = DEF_LANGUAGE; if (!langtexts[DEF_LANGUAGE]) fatal("Unable to load default language"); @@ -247,7 +247,7 @@ void lang_init() int strftime_lang(char *buf, int size, User *u, int format, struct tm *tm) { - int language = u && u->Account() ? u->Account()->language : Config.NSDefLanguage; + int language = u && u->Account() ? u->Account()->language : Config->NSDefLanguage; char tmpbuf[BUFSIZE], buf2[BUFSIZE]; char *s; int i, ret; @@ -318,7 +318,7 @@ void syntax_error(const Anope::string &service, User *u, const Anope::string &co const char *getstring(NickAlias *na, int index) { // Default to config - int langidx = Config.NSDefLanguage; + int langidx = Config->NSDefLanguage; // If they are registered (na->nc), and NOT forbidden if (na && na->nc && !na->HasFlag(NS_FORBIDDEN)) @@ -330,7 +330,7 @@ const char *getstring(NickAlias *na, int index) const char *getstring(const NickCore *nc, int index) { // Default to config - int langidx = Config.NSDefLanguage; + int langidx = Config->NSDefLanguage; if (nc) langidx = nc->language; @@ -346,7 +346,7 @@ const char *getstring(const User *u, int index) const char *getstring(int index) { // Default to config - int langidx = Config.NSDefLanguage; + int langidx = Config->NSDefLanguage; return langtexts[langidx][index]; } diff --git a/src/log.cpp b/src/log.cpp index 9f5e05ebc..62fa29600 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -45,11 +45,11 @@ static void remove_log() Anope::string name; - if (!Config.KeepLogs) + if (!Config->KeepLogs) return; time(&t); - t -= (60 * 60 * 24 * Config.KeepLogs); + t -= (60 * 60 * 24 * Config->KeepLogs); tm = *localtime(&t); /* removed if from here cause get_logchan is always 1 */ @@ -258,7 +258,7 @@ Alog::~Alog() std::cout << tbuf << " " << buf.str() << std::endl; else if (Level == LOG_TERMINAL) // XXX dont use this yet unless you know we're at terminal and not daemonized std::cout << buf.str() << std::endl; - if (!Config.LogChannel.empty() && LogChan && !debug && findchan(Config.LogChannel)) - ircdproto->SendPrivmsg(Global, Config.LogChannel, "%s", buf.str().c_str()); + if (Config && !Config->LogChannel.empty() && LogChan && !debug && findchan(Config->LogChannel)) + ircdproto->SendPrivmsg(Global, Config->LogChannel, "%s", buf.str().c_str()); errno = errno_save; } diff --git a/src/mail.cpp b/src/mail.cpp index b5e2149f9..1cfdd6c09 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -11,13 +11,13 @@ MailThread::~MailThread() void MailThread::Run() { - FILE *pipe = popen(Config.SendMailPath.c_str(), "w"); + FILE *pipe = popen(Config->SendMailPath.c_str(), "w"); if (!pipe) return; - fprintf(pipe, "From: %s\n", Config.SendFrom.c_str()); - if (Config.DontQuoteAddresses) + fprintf(pipe, "From: %s\n", Config->SendFrom.c_str()); + if (Config->DontQuoteAddresses) fprintf(pipe, "To: %s <%s>\n", MailTo.c_str(), Addr.c_str()); else fprintf(pipe, "To: \"%s\" <%s>\n", MailTo.c_str(), Addr.c_str()); @@ -37,9 +37,9 @@ bool Mail(User *u, NickRequest *nr, const Anope::string &service, const Anope::s time_t t = time(NULL); - if (!Config.UseMail) + if (!Config->UseMail) notice_lang(service, u, MAIL_DISABLED); - else if (t - u->lastmail < Config.MailDelay) + else if (t - u->lastmail < Config->MailDelay) notice_lang(service, u, MAIL_DELAYED, t - u->lastmail); else if (nr->email.empty()) notice_lang(service, u, MAIL_INVALID, nr->nick.c_str()); @@ -60,9 +60,9 @@ bool Mail(User *u, NickCore *nc, const Anope::string &service, const Anope::stri time_t t = time(NULL); - if (!Config.UseMail) + if (!Config->UseMail) notice_lang(service, u, MAIL_DISABLED); - else if (t - u->lastmail < Config.MailDelay) + else if (t - u->lastmail < Config->MailDelay) notice_lang(service, u, MAIL_DELAYED, t - u->lastmail); else if (nc->email.empty()) notice_lang(service, u, MAIL_INVALID, nc->display.c_str()); @@ -78,7 +78,7 @@ bool Mail(User *u, NickCore *nc, const Anope::string &service, const Anope::stri bool Mail(NickCore *nc, const Anope::string &subject, const Anope::string &message) { - if (!Config.UseMail || !nc || nc->email.empty() || subject.empty() || message.empty()) + if (!Config->UseMail || !nc || nc->email.empty() || subject.empty() || message.empty()) return false; nc->lastmail = time(NULL); diff --git a/src/main.cpp b/src/main.cpp index 453dba91b..8132e9d1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -185,7 +185,7 @@ void do_restart_services() if (!it->second->GetUID().empty()) UserListByUID.erase(it->second->GetUID()); } - ircdproto->SendSquit(Config.ServerName, quitmsg); + ircdproto->SendSquit(Config->ServerName, quitmsg); SocketEngine->Process(); delete UplinkSock; close_log(); @@ -230,7 +230,7 @@ static void services_shutdown() UserListByUID.erase(it->second->GetUID()); } - ircdproto->SendSquit(Config.ServerName, quitmsg); + ircdproto->SendSquit(Config->ServerName, quitmsg); while (!UserListByNick.empty()) delete UserListByNick.begin()->second; @@ -268,13 +268,17 @@ void sighandler(int signum) expire_all(); save_databases(); - if (!read_config(1)) + try { - quitmsg = "Error Reading Configuration File (Received SIGHUP)"; - quitting = true; + ServerConfig *newconfig = new ServerConfig(); + delete Config; + Config = newconfig; + FOREACH_MOD(I_OnReload, OnReload(true)); + } + catch (const ConfigException &ex) + { + Alog() << "Error reloading configuration file: " << ex.GetReason(); } - - FOREACH_MOD(I_OnReload, OnReload(true)); return; } @@ -379,7 +383,7 @@ static bool Connect() { /* Connect to the remote server */ int servernum = 1; - for (std::list<Uplink *>::iterator curr_uplink = Config.Uplinks.begin(), end_uplink = Config.Uplinks.end(); curr_uplink != end_uplink; ++curr_uplink, ++servernum) + for (std::list<Uplink *>::iterator curr_uplink = Config->Uplinks.begin(), end_uplink = Config->Uplinks.end(); curr_uplink != end_uplink; ++curr_uplink, ++servernum) { uplink_server = *curr_uplink; @@ -394,7 +398,7 @@ static bool Connect() try { - new UplinkSocket(uplink_server->host, uplink_server->port, Config.LocalHost, uplink_server->ipv6); + new UplinkSocket(uplink_server->host, uplink_server->port, Config->LocalHost, uplink_server->ipv6); } catch (const SocketException &ex) { @@ -479,7 +483,7 @@ int main(int ac, char **av, char **envp) started = true; #ifndef _WIN32 - if (Config.DumpCore) + if (Config->DumpCore) { rlimit rl; if (getrlimit(RLIMIT_CORE, &rl) == -1) @@ -495,8 +499,8 @@ int main(int ac, char **av, char **envp) /* Set up timers */ time_t last_check = time(NULL); - ExpireTimer expireTimer(Config.ExpireTimeout, last_check); - UpdateTimer updateTimer(Config.UpdateTimeout, last_check); + ExpireTimer expireTimer(Config->ExpireTimeout, last_check); + UpdateTimer updateTimer(Config->UpdateTimeout, last_check); /*** Main loop. ***/ while (!quitting) @@ -523,7 +527,7 @@ int main(int ac, char **av, char **envp) break; } - if (t - last_check >= Config.TimeoutCheck) + if (t - last_check >= Config->TimeoutCheck) { TimerManager::TickTimers(t); last_check = t; @@ -566,11 +570,11 @@ int main(int ac, char **av, char **envp) Me->ClearLinks(); unsigned j = 0; - for (; j < (Config.MaxRetries ? Config.MaxRetries : j + 1); ++j) + for (; j < (Config->MaxRetries ? Config->MaxRetries : j + 1); ++j) { - Alog() << "Disconnected from the server, retrying in " << Config.RetryWait << " seconds"; + Alog() << "Disconnected from the server, retrying in " << Config->RetryWait << " seconds"; - sleep(Config.RetryWait); + sleep(Config->RetryWait); if (Connect()) { ircdproto->SendConnect(); @@ -578,7 +582,7 @@ int main(int ac, char **av, char **envp) break; } } - if (Config.MaxRetries && j == Config.MaxRetries) + if (Config->MaxRetries && j == Config->MaxRetries) { Alog() << "Max connection retry limit exceeded"; quitting = true; diff --git a/src/memoserv.cpp b/src/memoserv.cpp index 9a70b195e..0fcf0b6a3 100644 --- a/src/memoserv.cpp +++ b/src/memoserv.cpp @@ -22,7 +22,7 @@ static bool SendMemoMail(NickCore *nc, Memo *m); void moduleAddMemoServCmds() { - ModuleManager::LoadModuleList(Config.MemoServCoreModules); + ModuleManager::LoadModuleList(Config->MemoServCoreModules); } /*************************************************************************/ @@ -66,9 +66,9 @@ void check_memos(User *u) } if (newcnt > 0) { - notice_lang(Config.s_MemoServ, u, newcnt == 1 ? MEMO_HAVE_NEW_MEMO : MEMO_HAVE_NEW_MEMOS, newcnt); + notice_lang(Config->s_MemoServ, u, newcnt == 1 ? MEMO_HAVE_NEW_MEMO : MEMO_HAVE_NEW_MEMOS, newcnt); if (newcnt == 1 && (nc->memos.memos[i - 1]->HasFlag(MF_UNREAD))) - notice_lang(Config.s_MemoServ, u, MEMO_TYPE_READ_LAST, Config.s_MemoServ.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_TYPE_READ_LAST, Config->s_MemoServ.c_str()); else if (newcnt == 1) { for (i = 0; i < end; ++i) @@ -76,17 +76,17 @@ void check_memos(User *u) if (nc->memos.memos[i]->HasFlag(MF_UNREAD)) break; } - notice_lang(Config.s_MemoServ, u, MEMO_TYPE_READ_NUM, Config.s_MemoServ.c_str(), nc->memos.memos[i]->number); + notice_lang(Config->s_MemoServ, u, MEMO_TYPE_READ_NUM, Config->s_MemoServ.c_str(), nc->memos.memos[i]->number); } else - notice_lang(Config.s_MemoServ, u, MEMO_TYPE_LIST_NEW, Config.s_MemoServ.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_TYPE_LIST_NEW, Config->s_MemoServ.c_str()); } if (nc->memos.memomax > 0 && nc->memos.memos.size() >= nc->memos.memomax) { if (nc->memos.memos.size() > nc->memos.memomax) - notice_lang(Config.s_MemoServ, u, MEMO_OVER_LIMIT, nc->memos.memomax); + notice_lang(Config->s_MemoServ, u, MEMO_OVER_LIMIT, nc->memos.memomax); else - notice_lang(Config.s_MemoServ, u, MEMO_AT_LIMIT, nc->memos.memomax); + notice_lang(Config->s_MemoServ, u, MEMO_AT_LIMIT, nc->memos.memomax); } } @@ -175,48 +175,48 @@ void memo_send(User *u, const Anope::string &name, const Anope::string &text, in int is_servoper = u->Account() && u->Account()->IsServicesOper(); if (readonly) - notice_lang(Config.s_MemoServ, u, MEMO_SEND_DISABLED); + notice_lang(Config->s_MemoServ, u, MEMO_SEND_DISABLED); else if (text.empty()) { if (!z) - syntax_error(Config.s_MemoServ, u, "SEND", MEMO_SEND_SYNTAX); + syntax_error(Config->s_MemoServ, u, "SEND", MEMO_SEND_SYNTAX); if (z == 3) - syntax_error(Config.s_MemoServ, u, "RSEND", MEMO_RSEND_SYNTAX); + syntax_error(Config->s_MemoServ, u, "RSEND", MEMO_RSEND_SYNTAX); } else if (!u->IsIdentified() && !u->IsRecognized()) { if (!z || z == 3) - notice_lang(Config.s_MemoServ, u, NICK_IDENTIFY_REQUIRED, Config.s_NickServ.c_str()); + notice_lang(Config->s_MemoServ, u, NICK_IDENTIFY_REQUIRED, Config->s_NickServ.c_str()); } else if (!(mi = getmemoinfo(name, ischan, isforbid))) { if (!z || z == 3) { if (isforbid) - notice_lang(Config.s_MemoServ, u, ischan ? CHAN_X_FORBIDDEN : NICK_X_FORBIDDEN, name.c_str()); + notice_lang(Config->s_MemoServ, u, ischan ? CHAN_X_FORBIDDEN : NICK_X_FORBIDDEN, name.c_str()); else - notice_lang(Config.s_MemoServ, u, ischan ? CHAN_X_NOT_REGISTERED : NICK_X_NOT_REGISTERED, name.c_str()); + notice_lang(Config->s_MemoServ, u, ischan ? CHAN_X_NOT_REGISTERED : NICK_X_NOT_REGISTERED, name.c_str()); } } - else if (z != 2 && Config.MSSendDelay > 0 && u && u->lastmemosend + Config.MSSendDelay > now) + else if (z != 2 && Config->MSSendDelay > 0 && u && u->lastmemosend + Config->MSSendDelay > now) { u->lastmemosend = now; if (!z) - notice_lang(Config.s_MemoServ, u, MEMO_SEND_PLEASE_WAIT, Config.MSSendDelay); + notice_lang(Config->s_MemoServ, u, MEMO_SEND_PLEASE_WAIT, Config->MSSendDelay); if (z == 3) - notice_lang(Config.s_MemoServ, u, MEMO_RSEND_PLEASE_WAIT, Config.MSSendDelay); + notice_lang(Config->s_MemoServ, u, MEMO_RSEND_PLEASE_WAIT, Config->MSSendDelay); } else if (!mi->memomax && !is_servoper) { if (!z || z == 3) - notice_lang(Config.s_MemoServ, u, MEMO_X_GETS_NO_MEMOS, name.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_X_GETS_NO_MEMOS, name.c_str()); } else if (mi->memomax > 0 && mi->memos.size() >= mi->memomax && !is_servoper) { if (!z || z == 3) - notice_lang(Config.s_MemoServ, u, MEMO_X_HAS_TOO_MANY_MEMOS, name.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_X_HAS_TOO_MANY_MEMOS, name.c_str()); } else { @@ -245,14 +245,14 @@ void memo_send(User *u, const Anope::string &name, const Anope::string &text, in if (z == 3) m->SetFlag(MF_RECEIPT); if (!z || z == 3) - notice_lang(Config.s_MemoServ, u, MEMO_SENT, name.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_SENT, name.c_str()); if (!ischan) { NickCore *nc = findnick(name)->nc; FOREACH_MOD(I_OnMemoSend, OnMemoSend(u, nc, m)); - if (Config.MSNotifyAll) + if (Config->MSNotifyAll) { if (nc->HasFlag(NI_MEMO_RECEIVE) && !get_ignore(name)) { @@ -261,13 +261,13 @@ void memo_send(User *u, const Anope::string &name, const Anope::string &text, in NickAlias *na = *it; User *user = finduser(na->nick); if (user && user->IsIdentified()) - notice_lang(Config.s_MemoServ, user, MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config.s_MemoServ.c_str(), m->number); + notice_lang(Config->s_MemoServ, user, MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config->s_MemoServ.c_str(), m->number); } } else { if ((u = finduser(name)) && u->IsIdentified() && nc->HasFlag(NI_MEMO_RECEIVE)) - notice_lang(Config.s_MemoServ, u, MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config.s_MemoServ.c_str(), m->number); + notice_lang(Config->s_MemoServ, u, MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config->s_MemoServ.c_str(), m->number); } /* if (flags & MEMO_RECEIVE) */ } /* if (MSNotifyAll) */ @@ -281,7 +281,7 @@ void memo_send(User *u, const Anope::string &name, const Anope::string &text, in FOREACH_MOD(I_OnMemoSend, OnMemoSend(u, cs_findchan(name), m)); - if (Config.MSNotifyAll && (c = findchan(name))) + if (Config->MSNotifyAll && (c = findchan(name))) { for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) { @@ -290,7 +290,7 @@ void memo_send(User *u, const Anope::string &name, const Anope::string &text, in if (check_access(cu->user, c->ci, CA_MEMO)) { if (cu->user->Account() && cu->user->Account()->HasFlag(NI_MEMO_RECEIVE) && !get_ignore(cu->user->nick)) - notice_lang(Config.s_MemoServ, cu->user, MEMO_NEW_X_MEMO_ARRIVED, c->ci->name.c_str(), Config.s_MemoServ.c_str(), c->ci->name.c_str(), m->number); + notice_lang(Config->s_MemoServ, cu->user, MEMO_NEW_X_MEMO_ARRIVED, c->ci->name.c_str(), Config->s_MemoServ.c_str(), c->ci->name.c_str(), m->number); } } } /* MSNotifyAll */ @@ -376,7 +376,7 @@ void rsend_notify(User *u, Memo *m, const Anope::string &chan) /* Notify recepient of the memo that a notification has been sent to the sender */ - notice_lang(Config.s_MemoServ, u, MEMO_RSEND_USER_NOTIFICATION, nc->display.c_str()); + notice_lang(Config->s_MemoServ, u, MEMO_RSEND_USER_NOTIFICATION, nc->display.c_str()); } /* Remove receipt flag from the original memo */ diff --git a/src/messages.cpp b/src/messages.cpp index 0348eab4b..d40d06712 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -39,7 +39,7 @@ int m_kill(const Anope::string &nick, const Anope::string &msg) BotInfo *bi; /* Recover if someone kills us. */ - if (!Config.s_BotServ.empty() && (bi = findbot(nick))) + if (!Config->s_BotServ.empty() && (bi = findbot(nick))) { introduce_user(nick); bi->RejoinAll(); @@ -62,7 +62,7 @@ int m_time(const Anope::string &source, int ac, const char **av) struct tm *tm = localtime(t); char buf[64]; strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y %Z", tm); - ircdproto->SendNumeric(Config.ServerName, 391, source, "%s :%s", Config.ServerName.c_str(), buf); + ircdproto->SendNumeric(Config->ServerName, 391, source, "%s :%s", Config->ServerName.c_str(), buf); return MOD_CONT; } @@ -73,21 +73,21 @@ int m_motd(const Anope::string &source) if (source.empty()) return MOD_CONT; - FILE *f = fopen(Config.MOTDFilename.c_str(), "r"); + FILE *f = fopen(Config->MOTDFilename.c_str(), "r"); if (f) { - ircdproto->SendNumeric(Config.ServerName, 375, source, ":- %s Message of the Day", Config.ServerName.c_str()); + ircdproto->SendNumeric(Config->ServerName, 375, source, ":- %s Message of the Day", Config->ServerName.c_str()); char buf[BUFSIZE]; while (fgets(buf, sizeof(buf), f)) { buf[strlen(buf) - 1] = 0; - ircdproto->SendNumeric(Config.ServerName, 372, source, ":- %s", buf); + ircdproto->SendNumeric(Config->ServerName, 372, source, ":- %s", buf); } fclose(f); - ircdproto->SendNumeric(Config.ServerName, 376, source, ":End of /MOTD command."); + ircdproto->SendNumeric(Config->ServerName, 376, source, ":End of /MOTD command."); } else - ircdproto->SendNumeric(Config.ServerName, 422, source, ":- MOTD file not found! Please contact your IRC administrator."); + ircdproto->SendNumeric(Config->ServerName, 422, source, ":- MOTD file not found! Please contact your IRC administrator."); return MOD_CONT; } @@ -111,7 +111,7 @@ int m_privmsg(const Anope::string &source, const Anope::string &receiver, const return MOD_CONT; } - if (receiver[0] == '#' && !Config.s_BotServ.empty()) + if (receiver[0] == '#' && !Config->s_BotServ.empty()) { ChannelInfo *ci = cs_findchan(receiver); if (ci) @@ -142,13 +142,13 @@ int m_privmsg(const Anope::string &source, const Anope::string &receiver, const { Anope::string servername(receiver.begin() + s + 1, receiver.end()); botname = botname.substr(0, s); - if (!servername.equals_ci(Config.ServerName)) + if (!servername.equals_ci(Config->ServerName)) return MOD_CONT; } - else if (Config.UseStrictPrivMsg) + else if (Config->UseStrictPrivMsg) { Alog(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << source; - notice_lang(receiver, u, INVALID_TARGET, receiver.c_str(), receiver.c_str(), Config.ServerName.c_str(), receiver.c_str()); + notice_lang(receiver, u, INVALID_TARGET, receiver.c_str(), receiver.c_str(), Config->ServerName.c_str(), receiver.c_str()); return MOD_CONT; } @@ -167,36 +167,36 @@ int m_privmsg(const Anope::string &source, const Anope::string &receiver, const } else if (message.substr(0, 9).equals_ci("\1VERSION\1")) { - ircdproto->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config.ServerName.c_str(), ircd->name, Config.EncModuleList.begin()->c_str(), Anope::Build().c_str()); + ircdproto->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::Build().c_str()); } } - else if (bi->nick.equals_ci(Config.s_NickServ) || bi->nick.equals_ci(Config.s_MemoServ) || (!Config.s_BotServ.empty() && bi->nick.equals_ci(Config.s_BotServ))) + else if (bi->nick.equals_ci(Config->s_NickServ) || bi->nick.equals_ci(Config->s_MemoServ) || (!Config->s_BotServ.empty() && bi->nick.equals_ci(Config->s_BotServ))) mod_run_cmd(bi, u, message); - else if (bi->nick.equals_ci(Config.s_ChanServ)) + else if (bi->nick.equals_ci(Config->s_ChanServ)) { - if (!is_oper(u) && Config.CSOpersOnly) - notice_lang(Config.s_ChanServ, u, ACCESS_DENIED); + if (!is_oper(u) && Config->CSOpersOnly) + notice_lang(Config->s_ChanServ, u, ACCESS_DENIED); else mod_run_cmd(bi, u, message); } - else if (!Config.s_HostServ.empty() && bi->nick.equals_ci(Config.s_HostServ)) + else if (!Config->s_HostServ.empty() && bi->nick.equals_ci(Config->s_HostServ)) { if (!ircd->vhost) - notice_lang(Config.s_HostServ, u, SERVICE_OFFLINE, Config.s_HostServ.c_str()); + notice_lang(Config->s_HostServ, u, SERVICE_OFFLINE, Config->s_HostServ.c_str()); else mod_run_cmd(bi, u, message); } - else if (bi->nick.equals_ci(Config.s_OperServ)) + else if (bi->nick.equals_ci(Config->s_OperServ)) { - if (!is_oper(u) && Config.OSOpersOnly) + if (!is_oper(u) && Config->OSOpersOnly) { - notice_lang(Config.s_OperServ, u, ACCESS_DENIED); - if (Config.WallBadOS) - ircdproto->SendGlobops(OperServ, "Denied access to %s from %s!%s@%s (non-oper)", Config.s_OperServ.c_str(), u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str()); + notice_lang(Config->s_OperServ, u, ACCESS_DENIED); + if (Config->WallBadOS) + ircdproto->SendGlobops(OperServ, "Denied access to %s from %s!%s@%s (non-oper)", Config->s_OperServ.c_str(), u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str()); } else { - Alog() << Config.s_OperServ << ": " << u->nick << ": " << message; + Alog() << Config->s_OperServ << ": " << u->nick << ": " << message; mod_run_cmd(bi, u, message); } } @@ -220,31 +220,31 @@ int m_stats(const Anope::string &source, int ac, const char **av) case 'l': if (u && is_oper(u)) { - ircdproto->SendNumeric(Config.ServerName, 211, source, "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime"); - ircdproto->SendNumeric(Config.ServerName, 211, source, "%s %d %d %d %d %d %d %ld", uplink_server->host.c_str(), UplinkSock->WriteBufferLen(), TotalWritten, -1, UplinkSock->ReadBufferLen(), TotalRead, -1, time(NULL) - start_time); + ircdproto->SendNumeric(Config->ServerName, 211, source, "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime"); + ircdproto->SendNumeric(Config->ServerName, 211, source, "%s %d %d %d %d %d %d %ld", uplink_server->host.c_str(), UplinkSock->WriteBufferLen(), TotalWritten, -1, UplinkSock->ReadBufferLen(), TotalRead, -1, time(NULL) - start_time); } - ircdproto->SendNumeric(Config.ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); + ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); break; case 'o': case 'O': /* Check whether the user is an operator */ - if (u && !is_oper(u) && Config.HideStatsO) - ircdproto->SendNumeric(Config.ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); + if (u && !is_oper(u) && Config->HideStatsO) + ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); else { std::list<std::pair<Anope::string, Anope::string> >::iterator it, it_end; - for (it = Config.Opers.begin(), it_end = Config.Opers.end(); it != it_end; ++it) + for (it = Config->Opers.begin(), it_end = Config->Opers.end(); it != it_end; ++it) { Anope::string nick = it->first, type = it->second; NickCore *nc = findcore(nick); if (nc) - ircdproto->SendNumeric(Config.ServerName, 243, source, "O * * %s %s 0", nick.c_str(), type.c_str()); + ircdproto->SendNumeric(Config->ServerName, 243, source, "O * * %s %s 0", nick.c_str(), type.c_str()); } - ircdproto->SendNumeric(Config.ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); + ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); } break; @@ -252,14 +252,14 @@ int m_stats(const Anope::string &source, int ac, const char **av) case 'u': { int uptime = time(NULL) - start_time; - ircdproto->SendNumeric(Config.ServerName, 242, source, ":Services up %d day%s, %02d:%02d:%02d", uptime / 86400, uptime / 86400 == 1 ? "" : "s", (uptime / 3600) % 24, (uptime / 60) % 60, uptime % 60); - ircdproto->SendNumeric(Config.ServerName, 250, source, ":Current users: %d (%d ops); maximum %d", usercnt, opcnt, maxusercnt); - ircdproto->SendNumeric(Config.ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); + ircdproto->SendNumeric(Config->ServerName, 242, source, ":Services up %d day%s, %02d:%02d:%02d", uptime / 86400, uptime / 86400 == 1 ? "" : "s", (uptime / 3600) % 24, (uptime / 60) % 60, uptime % 60); + ircdproto->SendNumeric(Config->ServerName, 250, source, ":Current users: %d (%d ops); maximum %d", usercnt, opcnt, maxusercnt); + ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); break; } /* case 'u' */ default: - ircdproto->SendNumeric(Config.ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); + ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*'); } return MOD_CONT; } @@ -269,7 +269,7 @@ int m_stats(const Anope::string &source, int ac, const char **av) int m_version(const Anope::string &source, int ac, const char **av) { if (!source.empty()) - ircdproto->SendNumeric(Config.ServerName, 351, source, "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Config.ServerName.c_str(), ircd->name, Config.EncModuleList.begin()->c_str(), Anope::Build().c_str()); + ircdproto->SendNumeric(Config->ServerName, 351, source, "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::Build().c_str()); return MOD_CONT; } @@ -283,11 +283,11 @@ int m_whois(const Anope::string &source, const Anope::string &who) BotInfo *bi = findbot(who); if (bi) { - ircdproto->SendNumeric(Config.ServerName, 311, source, "%s %s %s * :%s", bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); - ircdproto->SendNumeric(Config.ServerName, 307, source, "%s :is a registered nick", bi->nick.c_str()); - ircdproto->SendNumeric(Config.ServerName, 312, source, "%s %s :%s", bi->nick.c_str(), Config.ServerName.c_str(), Config.ServerDesc.c_str()); - ircdproto->SendNumeric(Config.ServerName, 317, source, "%s %ld %ld :seconds idle, signon time", bi->nick.c_str(), time(NULL) - bi->lastmsg, start_time); - ircdproto->SendNumeric(Config.ServerName, 318, source, "%s :End of /WHOIS list.", who.c_str()); + ircdproto->SendNumeric(Config->ServerName, 311, source, "%s %s %s * :%s", bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); + ircdproto->SendNumeric(Config->ServerName, 307, source, "%s :is a registered nick", bi->nick.c_str()); + ircdproto->SendNumeric(Config->ServerName, 312, source, "%s %s :%s", bi->nick.c_str(), Config->ServerName.c_str(), Config->ServerDesc.c_str()); + ircdproto->SendNumeric(Config->ServerName, 317, source, "%s %ld %ld :seconds idle, signon time", bi->nick.c_str(), time(NULL) - bi->lastmsg, start_time); + ircdproto->SendNumeric(Config->ServerName, 318, source, "%s :End of /WHOIS list.", who.c_str()); } else if (!ircd->svshold && (na = findnick(who)) && na->HasFlag(NS_HELD)) { @@ -295,12 +295,12 @@ int m_whois(const Anope::string &source, const Anope::string &who) * We can't just say it doesn't exist here, even tho it does for * other servers :) -GD */ - ircdproto->SendNumeric(Config.ServerName, 311, source, "%s %s %s * :Services Enforcer", na->nick.c_str(), Config.NSEnforcerUser.c_str(), Config.NSEnforcerHost.c_str()); - ircdproto->SendNumeric(Config.ServerName, 312, source, "%s %s :%s", na->nick.c_str(), Config.ServerName.c_str(), Config.ServerDesc.c_str()); - ircdproto->SendNumeric(Config.ServerName, 318, source, "%s :End of /WHOIS list.", who.c_str()); + ircdproto->SendNumeric(Config->ServerName, 311, source, "%s %s %s * :Services Enforcer", na->nick.c_str(), Config->NSEnforcerUser.c_str(), Config->NSEnforcerHost.c_str()); + ircdproto->SendNumeric(Config->ServerName, 312, source, "%s %s :%s", na->nick.c_str(), Config->ServerName.c_str(), Config->ServerDesc.c_str()); + ircdproto->SendNumeric(Config->ServerName, 318, source, "%s :End of /WHOIS list.", who.c_str()); } else - ircdproto->SendNumeric(Config.ServerName, 401, source, "%s :No such service.", who.c_str()); + ircdproto->SendNumeric(Config->ServerName, 401, source, "%s :No such service.", who.c_str()); } return MOD_CONT; } diff --git a/src/misc.cpp b/src/misc.cpp index 86e1c6717..42d56407b 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -411,7 +411,7 @@ bool doValidHost(const Anope::string &host, int type) size_t len = host.length(); - if (len > Config.HostLen) + if (len > Config->HostLen) return false; size_t idx, sec_len = 0, dots = 1; @@ -625,26 +625,26 @@ bool nickIsServices(const Anope::string &tempnick, bool bot) if (at != Anope::string::npos) { Anope::string servername = nick.substr(at + 1); - if (!servername.equals_ci(Config.ServerName)) + if (!servername.equals_ci(Config->ServerName)) return false; nick = nick.substr(0, at); } - if (!Config.s_NickServ.empty() && nick.equals_ci(Config.s_NickServ)) + if (!Config->s_NickServ.empty() && nick.equals_ci(Config->s_NickServ)) return true; - else if (!Config.s_ChanServ.empty() && nick.equals_ci(Config.s_ChanServ)) + else if (!Config->s_ChanServ.empty() && nick.equals_ci(Config->s_ChanServ)) return true; - else if (!Config.s_HostServ.empty() && nick.equals_ci(Config.s_HostServ)) + else if (!Config->s_HostServ.empty() && nick.equals_ci(Config->s_HostServ)) return true; - else if (!Config.s_MemoServ.empty() && nick.equals_ci(Config.s_MemoServ)) + else if (!Config->s_MemoServ.empty() && nick.equals_ci(Config->s_MemoServ)) return true; - else if (!Config.s_BotServ.empty() && nick.equals_ci(Config.s_BotServ)) + else if (!Config->s_BotServ.empty() && nick.equals_ci(Config->s_BotServ)) return true; - else if (!Config.s_OperServ.empty() && nick.equals_ci(Config.s_OperServ)) + else if (!Config->s_OperServ.empty() && nick.equals_ci(Config->s_OperServ)) return true; - else if (!Config.s_GlobalNoticer.empty() && nick.equals_ci(Config.s_GlobalNoticer)) + else if (!Config->s_GlobalNoticer.empty() && nick.equals_ci(Config->s_GlobalNoticer)) return true; - else if (!Config.s_BotServ.empty() && bot) + else if (!Config->s_BotServ.empty() && bot) { for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it) { @@ -743,9 +743,9 @@ void rand_init() */ void add_entropy_userkeys() { - arc4_addrandom(&Config.UserKey1, sizeof(Config.UserKey1)); - arc4_addrandom(&Config.UserKey2, sizeof(Config.UserKey2)); - arc4_addrandom(&Config.UserKey3, sizeof(Config.UserKey3)); + arc4_addrandom(&Config->UserKey1, sizeof(Config->UserKey1)); + arc4_addrandom(&Config->UserKey2, sizeof(Config->UserKey2)); + arc4_addrandom(&Config->UserKey3, sizeof(Config->UserKey3)); /* UserKey3 is also used in mysql_rand() */ } diff --git a/src/modes.cpp b/src/modes.cpp index 83e0cce56..624023e66 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -38,7 +38,7 @@ std::list<ChannelModeStatus *> BotModes; /** Parse the mode string from the config file and set the default mlocked modes */ -void SetDefaultMLock() +void SetDefaultMLock(ServerConfig *config) { DefMLockOn.ClearFlags(); DefMLockOff.ClearFlags(); @@ -46,7 +46,7 @@ void SetDefaultMLock() Flags<ChannelModeName> *ptr = NULL; Anope::string modes, param; - spacesepstream sep(Config.MLock); + spacesepstream sep(config->MLock); sep.GetToken(modes); for (unsigned i = 0, end_mode = modes.length(); i < end_mode; ++i) @@ -82,9 +82,9 @@ void SetDefaultMLock() /* Set Bot Modes */ BotModes.clear(); - for (unsigned i = 0, end_mode = Config.BotModes.length(); i < end_mode; ++i) + for (unsigned i = 0, end_mode = config->BotModes.length(); i < end_mode; ++i) { - ChannelMode *cm = ModeManager::FindChannelModeByChar(Config.BotModes[i]); + ChannelMode *cm = ModeManager::FindChannelModeByChar(config->BotModes[i]); if (cm && cm->Type == MODE_STATUS && std::find(BotModes.begin(), BotModes.end(), cm) == BotModes.end()) BotModes.push_back(debug_cast<ChannelModeStatus *>(cm)); @@ -266,7 +266,7 @@ void ChannelModeBan::AddMask(Channel *chan, const Anope::string &mask) /* Check whether it matches a botserv bot after adding internally * and parsing it through cidr support. ~ Viper */ - if (!Config.s_BotServ.empty() && Config.BSSmartJoin && chan->ci && chan->ci->bi && chan->FindUser(chan->ci->bi)) + if (!Config->s_BotServ.empty() && Config->BSSmartJoin && chan->ci && chan->ci->bi && chan->FindUser(chan->ci->bi)) { BotInfo *bi = chan->ci->bi; @@ -634,7 +634,7 @@ bool ModeManager::AddChannelMode(ChannelMode *cm) ModeManager::Modes.push_back(cm); /* Apply this mode to the new default mlock if its used */ - SetDefaultMLock(); + SetDefaultMLock(Config); FOREACH_MOD(I_OnChannelModeAdd, OnChannelModeAdd(cm)); diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 8ab72eef5..b5f0d51f2 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -203,7 +203,7 @@ int ModuleManager::LoadModule(const Anope::string &modname, User *u) if (u) { ircdproto->SendGlobops(OperServ, "%s loaded module %s", u->nick.c_str(), modname.c_str()); - notice_lang(Config.s_OperServ, u, OPER_MODULE_LOADED, modname.c_str()); + notice_lang(Config->s_OperServ, u, OPER_MODULE_LOADED, modname.c_str()); /* If a user is loading this module, then the core databases have already been loaded * so trigger the event manually @@ -221,21 +221,21 @@ int ModuleManager::UnloadModule(Module *m, User *u) if (!m || !m->handle) { if (u) - notice_lang(Config.s_OperServ, u, OPER_MODULE_REMOVE_FAIL, m->name.c_str()); + notice_lang(Config->s_OperServ, u, OPER_MODULE_REMOVE_FAIL, m->name.c_str()); return MOD_ERR_PARAMS; } if (m->GetPermanent() || m->type == PROTOCOL || m->type == ENCRYPTION || m->type == DATABASE) { if (u) - notice_lang(Config.s_OperServ, u, OPER_MODULE_NO_UNLOAD); + notice_lang(Config->s_OperServ, u, OPER_MODULE_NO_UNLOAD); return MOD_ERR_NOUNLOAD; } if (u) { ircdproto->SendGlobops(OperServ, "%s unloaded module %s", u->nick.c_str(), m->name.c_str()); - notice_lang(Config.s_OperServ, u, OPER_MODULE_UNLOADED, m->name.c_str()); + notice_lang(Config->s_OperServ, u, OPER_MODULE_UNLOADED, m->name.c_str()); } FOREACH_MOD(I_OnModuleUnload, OnModuleUnload(u, m)); diff --git a/src/modules.cpp b/src/modules.cpp index c90410896..0a7d813c5 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -46,19 +46,19 @@ int protocol_module_init() { int ret = 0; - Alog() << "Loading IRCD Protocol Module: [" << Config.IRCDModule << "]"; - ret = ModuleManager::LoadModule(Config.IRCDModule, NULL); + Alog() << "Loading IRCD Protocol Module: [" << Config->IRCDModule << "]"; + ret = ModuleManager::LoadModule(Config->IRCDModule, NULL); if (ret == MOD_ERR_OK) { - FindModule(Config.IRCDModule)->SetType(PROTOCOL); + FindModule(Config->IRCDModule)->SetType(PROTOCOL); /* This is really NOT the correct place to do config checks, but * as we only have the ircd struct filled here, we have to over * here. -GD */ if (ircd->ts6) { - if (Config.Numeric.empty()) + if (Config->Numeric.empty()) { Alog() << "This IRCd protocol requires a server id to be set in Anope's configuration."; ret = -1; @@ -256,7 +256,7 @@ bool moduleMinVersion(int major, int minor, int patch, int build) void Module::NoticeLang(const Anope::string &source, const User *u, int number, ...) const { /* Find the users lang, and use it if we can */ - int mlang = Config.NSDefLanguage; + int mlang = Config->NSDefLanguage; if (u && u->Account()) mlang = u->Account()->language; @@ -289,7 +289,7 @@ const char *Module::GetLangString(User *u, int number) { /* Find the users lang, and use it if we can */ - int mlang = Config.NSDefLanguage; + int mlang = Config->NSDefLanguage; if (u && u->Account()) mlang = u->Account()->language; diff --git a/src/nickalias.cpp b/src/nickalias.cpp index de5682492..4eae63138 100644 --- a/src/nickalias.cpp +++ b/src/nickalias.cpp @@ -39,14 +39,14 @@ NickAlias::NickAlias(const Anope::string &nickname, NickCore *nickcore) NickAliasList[this->nick] = this; - for (std::list<std::pair<Anope::string, Anope::string> >::iterator it = Config.Opers.begin(), it_end = Config.Opers.end(); it != it_end; ++it) + for (std::list<std::pair<Anope::string, Anope::string> >::iterator it = Config->Opers.begin(), it_end = Config->Opers.end(); it != it_end; ++it) { if (this->nc->ot) break; if (!this->nick.equals_ci(it->first)) continue; - for (std::list<OperType *>::iterator tit = Config.MyOperTypes.begin(), tit_end = Config.MyOperTypes.end(); tit != tit_end; ++tit) + for (std::list<OperType *>::iterator tit = Config->MyOperTypes.begin(), tit_end = Config->MyOperTypes.end(); tit != tit_end; ++tit) { OperType *ot = *tit; @@ -135,8 +135,8 @@ void NickAlias::OnCancel(User *) { Anope::string uid = ircd->ts6 ? ts6_uid_retrieve() : ""; - ircdproto->SendClientIntroduction(this->nick, Config.NSEnforcerUser, Config.NSEnforcerHost, "Services Enforcer", "+", uid); - new NickServRelease(this->nick, uid, Config.NSReleaseTimeout); + ircdproto->SendClientIntroduction(this->nick, Config->NSEnforcerUser, Config->NSEnforcerHost, "Services Enforcer", "+", uid); + new NickServRelease(this->nick, uid, Config->NSReleaseTimeout); } } } diff --git a/src/nickcore.cpp b/src/nickcore.cpp index 6f9ff99c9..c75493b4a 100644 --- a/src/nickcore.cpp +++ b/src/nickcore.cpp @@ -17,7 +17,7 @@ NickCore::NickCore(const Anope::string &coredisplay) /* Set default nick core flags */ for (size_t t = NI_BEGIN + 1; t != NI_END; ++t) - if (Config.NSDefFlags.HasFlag(static_cast<NickCoreFlag>(t))) + if (Config->NSDefFlags.HasFlag(static_cast<NickCoreFlag>(t))) this->SetFlag(static_cast<NickCoreFlag>(t)); NickCoreList[this->display] = this; @@ -50,7 +50,7 @@ NickCore::~NickCore() NickCoreList.erase(this->display); /* Log .. */ - Alog() << Config.s_NickServ << ": deleting nickname group " << this->display; + Alog() << Config->s_NickServ << ": deleting nickname group " << this->display; /* Clear access before deleting display name, we want to be able to use the display name in the clear access event */ this->ClearAccess(); diff --git a/src/nickserv.cpp b/src/nickserv.cpp index 50eb67fed..11929ade7 100644 --- a/src/nickserv.cpp +++ b/src/nickserv.cpp @@ -76,7 +76,7 @@ void NickServRelease::Tick(time_t ctime) /* *INDENT-OFF* */ void moduleAddNickServCmds() { - ModuleManager::LoadModuleList(Config.NickServCoreModules); + ModuleManager::LoadModuleList(Config->NickServCoreModules); } /* *INDENT-ON* */ /*************************************************************************/ @@ -166,7 +166,7 @@ int validate_user(User *u) NickRequest *nr = findrequestnick(u->nick); if (nr) { - notice_lang(Config.s_NickServ, u, NICK_IS_PREREG); + notice_lang(Config->s_NickServ, u, NICK_IS_PREREG); return 0; } @@ -176,14 +176,14 @@ int validate_user(User *u) if (na->HasFlag(NS_FORBIDDEN)) { - notice_lang(Config.s_NickServ, u, NICK_MAY_NOT_BE_USED); + notice_lang(Config->s_NickServ, u, NICK_MAY_NOT_BE_USED); u->Collide(na); return 0; } if (na->nc->HasFlag(NI_SUSPENDED)) { - notice_lang(Config.s_NickServ, u, NICK_X_SUSPENDED, u->nick.c_str()); + notice_lang(Config->s_NickServ, u, NICK_X_SUSPENDED, u->nick.c_str()); u->Collide(na); return 0; } @@ -203,26 +203,26 @@ int validate_user(User *u) if (u->IsRecognized() || !na->nc->HasFlag(NI_KILL_IMMED)) { if (na->nc->HasFlag(NI_SECURE)) - notice_lang(Config.s_NickServ, u, NICK_IS_SECURE, Config.s_NickServ.c_str()); + notice_lang(Config->s_NickServ, u, NICK_IS_SECURE, Config->s_NickServ.c_str()); else - notice_lang(Config.s_NickServ, u, NICK_IS_REGISTERED, Config.s_NickServ.c_str()); + notice_lang(Config->s_NickServ, u, NICK_IS_REGISTERED, Config->s_NickServ.c_str()); } if (na->nc->HasFlag(NI_KILLPROTECT) && !u->IsRecognized()) { if (na->nc->HasFlag(NI_KILL_IMMED)) { - notice_lang(Config.s_NickServ, u, FORCENICKCHANGE_NOW); + notice_lang(Config->s_NickServ, u, FORCENICKCHANGE_NOW); u->Collide(na); } else if (na->nc->HasFlag(NI_KILL_QUICK)) { - notice_lang(Config.s_NickServ, u, FORCENICKCHANGE_IN_20_SECONDS); + notice_lang(Config->s_NickServ, u, FORCENICKCHANGE_IN_20_SECONDS); new NickServCollide(na->nick, 20); } else { - notice_lang(Config.s_NickServ, u, FORCENICKCHANGE_IN_1_MINUTE); + notice_lang(Config->s_NickServ, u, FORCENICKCHANGE_IN_1_MINUTE); new NickServCollide(na->nick, 60); } } @@ -253,7 +253,7 @@ void expire_nicks() continue; } - if (Config.NSExpire && now - na->last_seen >= Config.NSExpire && !na->HasFlag(NS_FORBIDDEN) && !na->HasFlag(NS_NO_EXPIRE) && !na->nc->HasFlag(NI_SUSPENDED)) + if (Config->NSExpire && now - na->last_seen >= Config->NSExpire && !na->HasFlag(NS_FORBIDDEN) && !na->HasFlag(NS_NO_EXPIRE) && !na->nc->HasFlag(NI_SUSPENDED)) { EventReturn MOD_RESULT; FOREACH_RESULT(I_OnPreNickExpire, OnPreNickExpire(na)); @@ -275,7 +275,7 @@ void expire_requests() NickRequest *nr = it->second; ++it; - if (Config.NSRExpire && now - nr->requested >= Config.NSRExpire) + if (Config->NSRExpire && now - nr->requested >= Config->NSRExpire) { Alog() << "Request for nick " << nr->nick << " expiring"; delete nr; @@ -356,7 +356,7 @@ void change_core_display(NickCore *nc, const Anope::string &newdisplay) { /* Log ... */ FOREACH_MOD(I_OnChangeCoreDisplay, OnChangeCoreDisplay(nc, newdisplay)); - Alog() << Config.s_NickServ << ": changing " << nc->display << " nickname group display to " << newdisplay; + Alog() << Config->s_NickServ << ": changing " << nc->display << " nickname group display to " << newdisplay; /* Remove the core from the list */ NickCoreList.erase(nc->display); diff --git a/src/operserv.cpp b/src/operserv.cpp index 0582e91ee..89e84a73e 100644 --- a/src/operserv.cpp +++ b/src/operserv.cpp @@ -28,7 +28,7 @@ XLineManager *SGLine, *SZLine, *SQLine, *SNLine; void os_init() { - ModuleManager::LoadModuleList(Config.OperServCoreModules); + ModuleManager::LoadModuleList(Config->OperServCoreModules); /* Yes, these are in this order for a reason. Most violent->least violent. */ XLineManager::RegisterXLineManager(SGLine = new SGLineManager()); @@ -71,8 +71,8 @@ void UnsetDefConParam(ChannelModeName Name) */ bool CheckDefCon(DefconLevel Level) { - if (Config.DefConLevel) - return DefCon[Config.DefConLevel][Level]; + if (Config->DefConLevel) + return DefCon[Config->DefConLevel][Level]; return false; } @@ -108,7 +108,7 @@ void server_global(const Server *s, const Anope::string &message) { /* Do not send the notice to ourselves our juped servers */ if (s != Me && !s->HasFlag(SERVER_JUPED)) - notice_server(Config.s_GlobalNoticer, s, "%s", message.c_str()); + notice_server(Config->s_GlobalNoticer, s, "%s", message.c_str()); if (!s->GetLinks().empty()) { @@ -126,7 +126,7 @@ void oper_global(const Anope::string &nick, const char *fmt, ...) vsnprintf(msg, sizeof(msg), fmt, args); va_end(args); - if (!nick.empty() && !Config.AnonymousGlobal) + if (!nick.empty() && !Config->AnonymousGlobal) { Anope::string rmsg = "[" + nick + "] " + msg; server_global(Me->GetLinks().front(), rmsg); @@ -490,7 +490,7 @@ XLine *SGLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ } Anope::string realreason = reason; - if (u && Config.AddAkiller) + if (u && Config->AddAkiller) realreason = "[" + u->nick + "]" + reason; XLine *x = new XLine(mask, u ? u->nick : "", expires, realreason); @@ -505,7 +505,7 @@ XLine *SGLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ this->AddXLine(x); - if (Config.AkillOnAdd) + if (Config->AkillOnAdd) ircdproto->SendAkill(x); return x; @@ -523,7 +523,7 @@ void SGLineManager::OnMatch(User *u, XLine *x) void SGLineManager::OnExpire(XLine *x) { - if (Config.WallAkillExpire) + if (Config->WallAkillExpire) ircdproto->SendGlobops(OperServ, "AKILL on %s has expired", x->Mask.c_str()); } @@ -564,7 +564,7 @@ XLine *SNLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ this->AddXLine(x); - if (Config.KillonSNline && !ircd->sglineenforce) + if (Config->KillonSNline && !ircd->sglineenforce) { Anope::string rreason = "G-Lined: " + reason; @@ -574,7 +574,7 @@ XLine *SNLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ ++it; if (!is_oper(user) && Anope::Match(user->realname, x->Mask)) - kill_user(Config.ServerName, user->nick, rreason); + kill_user(Config->ServerName, user->nick, rreason); } } @@ -591,12 +591,12 @@ void SNLineManager::OnMatch(User *u, XLine *x) ircdproto->SendSGLine(x); Anope::string reason = "G-Lined: " + x->Reason; - kill_user(Config.s_OperServ, u->nick, reason); + kill_user(Config->s_OperServ, u->nick, reason); } void SNLineManager::OnExpire(XLine *x) { - if (Config.WallSNLineExpire) + if (Config->WallSNLineExpire) ircdproto->SendGlobops(OperServ, "SNLINE on \2%s\2 has expired", x->Mask.c_str()); } @@ -605,14 +605,14 @@ XLine *SQLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ if (mask.find_first_not_of("*") == Anope::string::npos) { if (bi && u) - notice_lang(Config.s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask.c_str()); + notice_lang(Config->s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask.c_str()); return NULL; } if (mask[0] == '#' && !ircd->chansqline) { if (bi && u) - notice_lang(Config.s_OperServ, u, OPER_SQLINE_CHANNELS_UNSUPPORTED); + notice_lang(Config->s_OperServ, u, OPER_SQLINE_CHANNELS_UNSUPPORTED); return NULL; } @@ -644,7 +644,7 @@ XLine *SQLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ this->AddXLine(x); - if (Config.KillonSQline) + if (Config->KillonSQline) { Anope::string rreason = "Q-Lined: " + reason; @@ -675,7 +675,7 @@ XLine *SQLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ ++it; if (!is_oper(user) && Anope::Match(user->nick, x->Mask)) - kill_user(Config.ServerName, user->nick, rreason); + kill_user(Config->ServerName, user->nick, rreason); } } } @@ -695,12 +695,12 @@ void SQLineManager::OnMatch(User *u, XLine *x) ircdproto->SendSQLine(x); Anope::string reason = "Q-Lined: " + x->Reason; - kill_user(Config.s_OperServ, u->nick, reason); + kill_user(Config->s_OperServ, u->nick, reason); } void SQLineManager::OnExpire(XLine *x) { - if (Config.WallSQLineExpire) + if (Config->WallSQLineExpire) ircdproto->SendGlobops(OperServ, "SQLINE on \2%s\2 has expired", x->Mask.c_str()); } @@ -724,13 +724,13 @@ XLine *SZLineManager::Add(BotInfo *bi, User *u, const Anope::string &mask, time_ { if (mask.find('!') != Anope::string::npos || mask.find('@') != Anope::string::npos) { - notice_lang(Config.s_OperServ, u, OPER_SZLINE_ONLY_IPS); + notice_lang(Config->s_OperServ, u, OPER_SZLINE_ONLY_IPS); return NULL; } if (mask.find_first_not_of("*?") == Anope::string::npos) { - notice_lang(Config.s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask.c_str()); + notice_lang(Config->s_OperServ, u, USERHOST_MASK_TOO_WIDE, mask.c_str()); return NULL; } @@ -779,6 +779,6 @@ void SZLineManager::OnMatch(User *u, XLine *x) void SZLineManager::OnExpire(XLine *x) { - if (Config.WallSZLineExpire) + if (Config->WallSZLineExpire) ircdproto->SendGlobops(OperServ, "SZLINE on \2%s\2 has expired", x->Mask.c_str()); } diff --git a/src/protocol.cpp b/src/protocol.cpp index 0ff642cf0..d0cfef071 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -2,7 +2,7 @@ void IRCDProto::SendMessageInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf) { - if (Config.NSDefFlags.HasFlag(NI_MSG)) + if (Config->NSDefFlags.HasFlag(NI_MSG)) SendPrivmsgInternal(bi, dest, buf); else SendNoticeInternal(bi, dest, buf); @@ -39,7 +39,7 @@ void IRCDProto::SendGlobopsInternal(const BotInfo *source, const Anope::string & if (source) send_cmd(ircd->ts6 ? source->GetUID() : source->nick, "GLOBOPS :%s", buf.c_str()); else - send_cmd(Config.ServerName, "GLOBOPS :%s", buf.c_str()); + send_cmd(Config->ServerName, "GLOBOPS :%s", buf.c_str()); } void IRCDProto::SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf) @@ -178,9 +178,9 @@ void IRCDProto::SendQuit(const BotInfo *bi, const char *fmt, ...) void IRCDProto::SendPing(const Anope::string &servname, const Anope::string &who) { if (servname.empty()) - send_cmd(ircd->ts6 ? TS6SID : Config.ServerName, "PING %s", who.c_str()); + send_cmd(ircd->ts6 ? TS6SID : Config->ServerName, "PING %s", who.c_str()); else - send_cmd(ircd->ts6 ? TS6SID : Config.ServerName, "PING %s %s", servname.c_str(), who.c_str()); + send_cmd(ircd->ts6 ? TS6SID : Config->ServerName, "PING %s %s", servname.c_str(), who.c_str()); } /** @@ -192,9 +192,9 @@ void IRCDProto::SendPing(const Anope::string &servname, const Anope::string &who void IRCDProto::SendPong(const Anope::string &servname, const Anope::string &who) { if (servname.empty()) - send_cmd(ircd->ts6 ? TS6SID : Config.ServerName, "PONG %s", who.c_str()); + send_cmd(ircd->ts6 ? TS6SID : Config->ServerName, "PONG %s", who.c_str()); else - send_cmd(ircd->ts6 ? TS6SID : Config.ServerName, "PONG %s %s", servname.c_str(), who.c_str()); + send_cmd(ircd->ts6 ? TS6SID : Config->ServerName, "PONG %s %s", servname.c_str(), who.c_str()); } void IRCDProto::SendInvite(const BotInfo *bi, const Anope::string &chan, const Anope::string &nick) diff --git a/src/regchannel.cpp b/src/regchannel.cpp index 42ccad94e..d055a632b 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -39,16 +39,16 @@ ChannelInfo::ChannelInfo(const Anope::string &chname) size_t t; /* Set default channel flags */ for (t = CI_BEGIN + 1; t != CI_END; ++t) - if (Config.CSDefFlags.HasFlag(static_cast<ChannelInfoFlag>(t))) + if (Config->CSDefFlags.HasFlag(static_cast<ChannelInfoFlag>(t))) this->SetFlag(static_cast<ChannelInfoFlag>(t)); /* Set default bot flags */ for (t = BS_BEGIN + 1; t != BS_END; ++t) - if (Config.BSDefFlags.HasFlag(static_cast<BotServFlag>(t))) + if (Config->BSDefFlags.HasFlag(static_cast<BotServFlag>(t))) this->botflags.SetFlag(static_cast<BotServFlag>(t)); - this->bantype = Config.CSDefBantype; - this->memos.memomax = Config.MSMaxMemos; + this->bantype = Config->CSDefBantype; + this->memos.memomax = Config->MSMaxMemos; this->last_used = this->time_registered = time(NULL); this->ttb = new int16[2 * TTB_SIZE]; @@ -586,7 +586,7 @@ bool ChannelInfo::CheckKick(User *user) get_idealban(this, user, mask); else mask = autokick->mask; - reason = autokick->reason.empty() ? Config.CSAutokickReason : autokick->reason; + reason = autokick->reason.empty() ? Config->CSAutokickReason : autokick->reason; do_kick = true; break; } diff --git a/src/send.cpp b/src/send.cpp index a213d73d6..62f1b8ec5 100644 --- a/src/send.cpp +++ b/src/send.cpp @@ -73,7 +73,7 @@ void notice_server(const Anope::string &source, const Server *s, const char *fmt va_start(args, fmt); vsnprintf(buf, BUFSIZE - 1, fmt, args); - if (Config.NSDefFlags.HasFlag(NI_MSG)) + if (Config->NSDefFlags.HasFlag(NI_MSG)) ircdproto->SendGlobalPrivmsg(findbot(source), s, buf); else ircdproto->SendGlobalNotice(findbot(source), s, buf); diff --git a/src/servers.cpp b/src/servers.cpp index a029890f7..7668cebbf 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -75,7 +75,7 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A /* And some IRCds needs Global joined in the logchan */ if (LogChan && ircd->join2msg) - Global->Join(Config.LogChannel); + Global->Join(Config->LogChannel); } } } @@ -269,7 +269,7 @@ bool Server::IsSynced() const */ bool Server::IsULined() const { - for (std::list<Anope::string>::const_iterator it = Config.Ulines.begin(), it_end = Config.Ulines.end(); it != it_end; ++it) + for (std::list<Anope::string>::const_iterator it = Config->Ulines.begin(), it_end = Config->Ulines.end(); it != it_end; ++it) if (it->equals_ci(this->GetName())) return true; return false; @@ -341,8 +341,8 @@ void do_server(const Anope::string &source, const Anope::string &servername, uns Server *newserver = new Server(s, servername, hops, descript, numeric); /* Announce services being online. */ - if (Config.GlobalOnCycle && !Config.GlobalOnCycleUP.empty()) - notice_server(Config.s_GlobalNoticer, newserver, "%s", Config.GlobalOnCycleUP.c_str()); + if (Config->GlobalOnCycle && !Config->GlobalOnCycleUP.empty()) + notice_server(Config->s_GlobalNoticer, newserver, "%s", Config->GlobalOnCycleUP.c_str()); /* Let modules know about the connection */ FOREACH_MOD(I_OnNewServer, OnNewServer(newserver)); diff --git a/src/sessions.cpp b/src/sessions.cpp index f765a9460..893a45858 100644 --- a/src/sessions.cpp +++ b/src/sessions.cpp @@ -117,14 +117,14 @@ int add_session(const Anope::string &nick, const Anope::string &host, const Anop { exception = find_hostip_exception(host, hostip); - sessionlimit = exception ? exception->limit : Config.DefSessionLimit; + sessionlimit = exception ? exception->limit : Config->DefSessionLimit; if (sessionlimit && session->count >= sessionlimit) { - if (!Config.SessionLimitExceeded.empty()) - ircdproto->SendMessage(OperServ, nick, Config.SessionLimitExceeded.c_str(), host.c_str()); - if (!Config.SessionLimitDetailsLoc.empty()) - ircdproto->SendMessage(OperServ, nick, "%s", Config.SessionLimitDetailsLoc.c_str()); + if (!Config->SessionLimitExceeded.empty()) + ircdproto->SendMessage(OperServ, nick, Config->SessionLimitExceeded.c_str(), host.c_str()); + if (!Config->SessionLimitDetailsLoc.empty()) + ircdproto->SendMessage(OperServ, nick, "%s", Config->SessionLimitDetailsLoc.c_str()); /* Previously on IRCds that send a QUIT (InspIRCD) when a user is killed, the session for a host was * decremented in do_quit, which caused problems and fixed here @@ -134,15 +134,15 @@ int add_session(const Anope::string &nick, const Anope::string &host, const Anop * decremented in do_kill or in do_quit - Adam */ ++session->count; - kill_user(Config.s_OperServ, nick, "Session limit exceeded"); + kill_user(Config->s_OperServ, nick, "Session limit exceeded"); ++session->hits; - if (Config.MaxSessionKill && session->hits >= Config.MaxSessionKill) + if (Config->MaxSessionKill && session->hits >= Config->MaxSessionKill) { Anope::string akillmask = "*@" + host; - XLine *x = new XLine(akillmask, Config.s_OperServ, time(NULL) + Config.SessionAutoKillExpiry, "Session limit exceeded"); + XLine *x = new XLine(akillmask, Config->s_OperServ, time(NULL) + Config->SessionAutoKillExpiry, "Session limit exceeded"); if (x) - x->By = Config.s_OperServ; + x->By = Config->s_OperServ; ircdproto->SendGlobops(OperServ, "Added a temporary AKILL for \2%s\2 due to excessive connections", akillmask.c_str()); } return 0; @@ -166,7 +166,7 @@ int add_session(const Anope::string &nick, const Anope::string &host, const Anop void del_session(const Anope::string &host) { - if (!Config.LimitSessions) + if (!Config->LimitSessions) { Alog(LOG_DEBUG) << "del_session called when LimitSessions is disabled"; return; @@ -222,7 +222,7 @@ void expire_exceptions() if (!e->expires || e->expires > now) continue; - if (Config.WallExceptionExpire) + if (Config->WallExceptionExpire) ircdproto->SendGlobops(OperServ, "Session limit exception for %s has expired.", e->mask.c_str()); delete e; exceptions.erase(curr_it); @@ -272,13 +272,13 @@ int exception_add(User *u, const Anope::string &mask, int limit, const Anope::st { e->limit = limit; if (u) - notice_lang(Config.s_OperServ, u, OPER_EXCEPTION_CHANGED, mask.c_str(), e->limit); + notice_lang(Config->s_OperServ, u, OPER_EXCEPTION_CHANGED, mask.c_str(), e->limit); return -2; } else { if (u) - notice_lang(Config.s_OperServ, u, OPER_EXCEPTION_EXISTS, mask.c_str()); + notice_lang(Config->s_OperServ, u, OPER_EXCEPTION_EXISTS, mask.c_str()); return -1; } } diff --git a/src/users.cpp b/src/users.cpp index f78c505a9..75596124c 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -54,7 +54,7 @@ User::User(const Anope::string &snick, const Anope::string &suid) { maxusercnt = usercnt; maxusertime = time(NULL); - if (Config.LogMaxUsers) + if (Config->LogMaxUsers) Alog() << "user: New maximum user count: "<< maxusercnt; } @@ -190,7 +190,7 @@ User::~User() this->Logout(); - if (Config.LogUsers) + if (Config->LogUsers) { Anope::string srealname = normalizeBuffer(this->realname); @@ -207,7 +207,7 @@ User::~User() while (!this->chans.empty()) this->chans.front()->chan->DeleteUser(this); - if (Config.LimitSessions && !this->server->IsULined()) + if (Config->LimitSessions && !this->server->IsULined()) del_session(this->host); UserListByNick.erase(this->nick); @@ -244,7 +244,7 @@ void User::SendMessage(const Anope::string &source, const Anope::string &msg) co * - The user is not registered and NSDefMsg is enabled * - The user is registered and has set /ns set msg on */ - if (Config.UsePrivmsg && ((!this->nc && Config.NSDefFlags.HasFlag(NI_MSG)) || (this->nc && this->nc->HasFlag(NI_MSG)))) + if (Config->UsePrivmsg && ((!this->nc && Config->NSDefFlags.HasFlag(NI_MSG)) || (this->nc && this->nc->HasFlag(NI_MSG)))) ircdproto->SendPrivmsg(findbot(source), this->nick, "%s", msg.c_str()); else ircdproto->SendNotice(findbot(source), this->nick, "%s", msg.c_str()); @@ -317,14 +317,14 @@ void User::Collide(NickAlias *na) do { - guestnick = Config.NSGuestNickPrefix + stringify(getrandom16()); + guestnick = Config->NSGuestNickPrefix + stringify(getrandom16()); } while (finduser(guestnick)); - notice_lang(Config.s_NickServ, this, FORCENICKCHANGE_CHANGING, guestnick.c_str()); + notice_lang(Config->s_NickServ, this, FORCENICKCHANGE_CHANGING, guestnick.c_str()); ircdproto->SendForceNickChange(this, guestnick, time(NULL)); } else - kill_user(Config.s_NickServ, this->nick, "Services nickname-enforcer kill"); + kill_user(Config->s_NickServ, this->nick, "Services nickname-enforcer kill"); } /** Check if the user should become identified because @@ -726,7 +726,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop Server *serv = Server::Find(server); - if (Config.LogUsers) + if (Config->LogUsers) { /** * Ugly swap routine for Flop's bug :) XXX @@ -770,7 +770,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop if (MOD_RESULT == EVENT_STOP) return finduser(nick); - if (Config.LimitSessions && !serv->IsULined()) + if (Config->LimitSessions && !serv->IsULined()) add_session(nick, host, ipbuf); XLineManager::CheckAll(user); @@ -794,7 +794,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop user->isSuperAdmin = 0; /* Dont let people nick change and stay SuperAdmins */ Alog(LOG_DEBUG) << source << " changes nick to " << nick; - if (Config.LogUsers) + if (Config->LogUsers) { Anope::string logrealname = normalizeBuffer(user->realname); Alog() << "LOGUSERS: " << user->nick << " (" << user->GetIdent() << "@" << user->host << (ircd->vhost ? " => " : "") << (ircd->vhost ? user->GetDisplayedHost() : "") << ") (" << logrealname << ") changed nick to " @@ -837,7 +837,7 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop user->UpdateHost(); do_on_id(user); ircdproto->SetAutoIdentificationToken(user); - Alog() << Config.s_NickServ << ": " << user->GetMask() << " automatically identified for group " << user->Account()->display; + Alog() << Config->s_NickServ << ": " << user->GetMask() << " automatically identified for group " << user->Account()->display; } if (ircd->sqline) @@ -1084,7 +1084,7 @@ void UserSetInternalModes(User *user, int ac, const char **av) if (add) { ++opcnt; - if (Config.WallOper) + if (Config->WallOper) ircdproto->SendGlobops(OperServ, "\2%s\2 is now an IRC operator.", user->nick.c_str()); } else |