diff options
Diffstat (limited to 'modules')
214 files changed, 3168 insertions, 4156 deletions
diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp index 874c40015..ac809b952 100644 --- a/modules/commands/bs_assign.cpp +++ b/modules/commands/bs_assign.cpp @@ -27,20 +27,20 @@ class CommandBSAssign : public Command const Anope::string &chan = params[0]; const Anope::string &nick = params[1]; - if (readonly) + if (Anope::ReadOnly) { source.Reply(BOT_ASSIGN_READONLY); return; } - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); return; } - BotInfo *bi = findbot(nick); + BotInfo *bi = BotInfo::Find(nick, true); if (!bi) { source.Reply(BOT_DOES_NOT_EXIST, nick.c_str()); @@ -95,13 +95,13 @@ class CommandBSUnassign : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (readonly) + if (Anope::ReadOnly) { source.Reply(BOT_ASSIGN_READONLY); return; } - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index ad7a49085..36a83b717 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -19,10 +19,10 @@ class BadwordsDelCallback : public NumberList CommandSource &source; ChannelInfo *ci; Command *c; - unsigned Deleted; + unsigned deleted; bool override; public: - BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), Deleted(0), override(false) + BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), override(false) { if (!source.AccessFor(ci).HasPriv("BADWORDS") && source.HasPriv("botserv/administration")) this->override = true; @@ -30,12 +30,12 @@ class BadwordsDelCallback : public NumberList ~BadwordsDelCallback() { - if (!Deleted) + if (!deleted) source.Reply(_("No matching entries on %s bad words list."), ci->name.c_str()); - else if (Deleted == 1) + else if (deleted == 1) source.Reply(_("Deleted 1 entry from %s bad words list."), ci->name.c_str()); else - source.Reply(_("Deleted %d entries from %s bad words list."), Deleted, ci->name.c_str()); + source.Reply(_("Deleted %d entries from %s bad words list."), deleted, ci->name.c_str()); } void HandleNumber(unsigned Number) anope_override @@ -44,7 +44,7 @@ class BadwordsDelCallback : public NumberList return; Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "DEL " << ci->GetBadWord(Number - 1)->word; - ++Deleted; + ++deleted; ci->EraseBadWord(Number - 1); } }; @@ -58,7 +58,7 @@ class CommandBSBadwords : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "LIST"; ListFormatter list; - list.addColumn("Number").addColumn("Word").addColumn("Type"); + list.AddColumn("Number").AddColumn("Word").AddColumn("Type"); if (!ci->GetBadWordCount()) { @@ -86,7 +86,7 @@ class CommandBSBadwords : public Command entry["Number"] = stringify(Number); entry["Word"] = bw->word; entry["Type"] = bw->type == BW_SINGLE ? "(SINGLE)" : (bw->type == BW_START ? "(START)" : (bw->type == BW_END ? "(END)" : "")); - this->list.addEntry(entry); + this->list.AddEntry(entry); } } nl_list(list, ci, word); @@ -105,11 +105,11 @@ class CommandBSBadwords : public Command entry["Number"] = stringify(i + 1); entry["Word"] = bw->word; entry["Type"] = bw->type == BW_SINGLE ? "(SINGLE)" : (bw->type == BW_START ? "(START)" : (bw->type == BW_END ? "(END)" : "")); - list.addEntry(entry); + list.AddEntry(entry); } } - if (list.isEmpty()) + if (list.IsEmpty()) source.Reply(_("No matching entries on %s badword list."), ci->name.c_str()); else { @@ -241,7 +241,7 @@ class CommandBSBadwords : public Command return; } - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -254,7 +254,7 @@ class CommandBSBadwords : public Command return; } - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, channel bad words list modification is temporarily disabled.")); return; diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index de7fa1128..8246692d0 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -23,7 +23,7 @@ class CommandBSBot : public Command const Anope::string &host = params[3]; const Anope::string &real = params[4]; - if (findbot(nick)) + if (BotInfo::Find(nick, true)) { source.Reply(_("Bot \002%s\002 already exists."), nick.c_str()); return; @@ -47,46 +47,30 @@ class CommandBSBot : public Command return; } - /* Check the nick is valid re RFC 2812 */ - if (isdigit(nick[0]) || nick[0] == '-') + if (!IRCD->IsNickValid(nick)) { source.Reply(_("Bot Nicks may only contain valid nick characters.")); return; } - for (unsigned i = 0, end = nick.length(); i < end && i < Config->NickLen; ++i) - if (!isvalidnick(nick[i])) - { - source.Reply(_("Bot Nicks may only contain valid nick characters.")); - return; - } - - /* check for hardcored ircd forbidden nicks */ - if (!ircdproto->IsNickValid(nick)) + /* Check the host is valid */ + if (!IRCD->IsHostValid(host)) { - source.Reply(_("Bot Nicks may only contain valid nick characters.")); + source.Reply(_("Bot Hosts may only contain valid host characters.")); return; } - /* Check the host is valid */ - if (!IsValidHost(host)) + if (!IRCD->IsIdentValid(user)) { - source.Reply(_("Bot Hosts may only contain valid host characters.")); + source.Reply(_("Bot Idents may only contain valid characters.")); return; } - for (unsigned i = 0, end = user.length(); i < end && i < Config->UserLen; ++i) - if (!isalnum(user[i])) - { - source.Reply(_("Bot Idents may only contain valid characters."), Config->UserLen); - return; - } - /* We check whether the nick is registered, and inform the user * if so. You need to drop the nick manually before you can use * it as a bot nick from now on -GD */ - if (findnick(nick)) + if (NickAlias::Find(nick)) { source.Reply(NICK_ALREADY_REGISTERED, nick.c_str()); return; @@ -116,16 +100,16 @@ class CommandBSBot : public Command return; } - BotInfo *bi = findbot(oldnick); + BotInfo *bi = BotInfo::Find(oldnick, true); if (!bi) { source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str()); return; } - if (!oldnick.equals_ci(nick) && nickIsServices(oldnick, false)) + if (bi->HasFlag(BI_CONF)) { - source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str()); + source.Reply(_("Bot %s is not changable."), bi->nick.c_str()); return; } @@ -147,12 +131,6 @@ class CommandBSBot : public Command return; } - if (!oldnick.equals_ci(nick) && nickIsServices(nick, false)) - { - source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str()); - return; - } - /* Checks whether there *are* changes. * Case sensitive because we may want to change just the case. * And we must finally check that the nick is not already @@ -164,42 +142,25 @@ class CommandBSBot : public Command return; } - /* Check the nick is valid re RFC 2812 */ - if (isdigit(nick[0]) || nick[0] == '-') + if (!IRCD->IsNickValid(nick)) { source.Reply(_("Bot Nicks may only contain valid nick characters.")); return; } - for (unsigned i = 0, end = nick.length(); i < end && i < Config->NickLen; ++i) - if (!isvalidnick(nick[i])) - { - source.Reply(_("Bot Nicks may only contain valid nick characters.")); - return; - } - - /* check for hardcored ircd forbidden nicks */ - if (!ircdproto->IsNickValid(nick)) + if (!host.empty() && !IRCD->IsHostValid(host)) { - source.Reply(_("Bot Nicks may only contain valid nick characters.")); + source.Reply(_("Bot Hosts may only contain valid host characters.")); return; } - if (!host.empty() && !IsValidHost(host)) + if (!user.empty() && !IRCD->IsIdentValid(user)) { - source.Reply(_("Bot Hosts may only contain valid host characters.")); + source.Reply(_("Bot Idents may only contain valid characters."), Config->UserLen); return; } - if (!user.empty()) - for (unsigned i = 0, end = user.length(); i < end && i < Config->UserLen; ++i) - if (!isalnum(user[i])) - { - source.Reply(_("Bot Idents may only contain valid characters."), Config->UserLen); - return; - } - - if (!nick.equals_ci(bi->nick) && findbot(nick)) + if (!nick.equals_ci(bi->nick) && BotInfo::Find(nick, true)) { source.Reply(_("Bot \002%s\002 already exists."), nick.c_str()); return; @@ -211,7 +172,7 @@ class CommandBSBot : public Command * if so. You need to drop the nick manually before you can use * it as a bot nick from now on -GD */ - if (findnick(nick)) + if (NickAlias::Find(nick)) { source.Reply(NICK_ALREADY_REGISTERED, nick.c_str()); return; @@ -219,19 +180,17 @@ class CommandBSBot : public Command /* The new nick is really different, so we remove the Q line for the old nick. */ XLine x_del(bi->nick); - ircdproto->SendSQLineDel(&x_del); + IRCD->SendSQLineDel(&x_del); /* Add a Q line for the new nick */ XLine x(nick, "Reserved for services"); - ircdproto->SendSQLine(NULL, &x); + IRCD->SendSQLine(NULL, &x); } if (!user.empty()) - ircdproto->SendQuit(bi, "Quit: Be right back"); + IRCD->SendQuit(bi, "Quit: Be right back"); else - { - ircdproto->SendChangeBotNick(bi, nick); - } + IRCD->SendNickChange(bi, nick); if (!nick.equals_cs(bi->nick)) bi->SetNewNick(nick); @@ -245,7 +204,7 @@ class CommandBSBot : public Command if (!user.empty()) { - ircdproto->SendClientIntroduction(bi); + IRCD->SendClientIntroduction(bi); bi->RejoinAll(); } @@ -266,16 +225,16 @@ class CommandBSBot : public Command return; } - BotInfo *bi = findbot(nick); + BotInfo *bi = BotInfo::Find(nick, true); if (!bi) { source.Reply(BOT_DOES_NOT_EXIST, nick.c_str()); return; } - if (nickIsServices(nick, false)) + if (bi->HasFlag(BI_CONF)) { - source.Reply(BOT_DOES_NOT_EXIST, nick.c_str()); + source.Reply(_("Bot %s is not deletable."), bi->nick.c_str()); return; } @@ -284,7 +243,7 @@ class CommandBSBot : public Command Log(LOG_ADMIN, source, this) << "DEL " << bi->nick; source.Reply(_("Bot \002%s\002 has been deleted."), nick.c_str()); - bi->destroy(); + bi->Destroy(); return; } public: @@ -300,7 +259,7 @@ class CommandBSBot : public Command { const Anope::string &cmd = params[0]; - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, bot modification is temporarily disabled.")); return; diff --git a/modules/commands/bs_botlist.cpp b/modules/commands/bs_botlist.cpp index a4a7c2586..1cdd93c45 100644 --- a/modules/commands/bs_botlist.cpp +++ b/modules/commands/bs_botlist.cpp @@ -27,7 +27,7 @@ class CommandBSBotList : public Command unsigned count = 0; ListFormatter list; - list.addColumn("Nick").addColumn("Mask"); + list.AddColumn("Nick").AddColumn("Mask"); for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) { @@ -39,7 +39,7 @@ class CommandBSBotList : public Command ListFormatter::ListEntry entry; entry["Nick"] = (bi->HasFlag(BI_PRIVATE) ? "* " : "") + bi->nick; entry["Mask"] = bi->GetIdent() + "@" + bi->host; - list.addEntry(entry); + list.AddEntry(entry); } } diff --git a/modules/commands/bs_control.cpp b/modules/commands/bs_control.cpp index 6957d0a78..3ee0401d6 100644 --- a/modules/commands/bs_control.cpp +++ b/modules/commands/bs_control.cpp @@ -26,7 +26,7 @@ class CommandBSSay : public Command { const Anope::string &text = params[1]; - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -57,7 +57,7 @@ class CommandBSSay : public Command return; } - ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", text.c_str()); + IRCD->SendPrivmsg(ci->bi, ci->name, "%s", text.c_str()); ci->bi->lastmsg = Anope::CurTime; // XXX need a way to find if someone is overriding this @@ -88,7 +88,7 @@ class CommandBSAct : public Command { Anope::string message = params[1]; - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -117,7 +117,7 @@ class CommandBSAct : public Command while ((i = message.find(1)) && i != Anope::string::npos) message.erase(i, 1); - ircdproto->SendAction(ci->bi, ci->name, "%s", message.c_str()); + IRCD->SendAction(ci->bi, ci->name, "%s", message.c_str()); ci->bi->lastmsg = Anope::CurTime; // XXX Need to be able to find if someone is overriding this. diff --git a/modules/commands/bs_info.cpp b/modules/commands/bs_info.cpp index 199b17e3e..a4312cea6 100644 --- a/modules/commands/bs_info.cpp +++ b/modules/commands/bs_info.cpp @@ -44,7 +44,7 @@ class CommandBSInfo : public Command { if (!buf.empty()) buf += ", "; - buf += translate(nc, option); + buf += Language::Translate(nc, option); } } @@ -59,7 +59,7 @@ class CommandBSInfo : public Command { const Anope::string &query = params[0]; - const BotInfo *bi = findbot(query); + const BotInfo *bi = BotInfo::Find(query, true); ChannelInfo *ci; InfoFormatter info(source.nc); @@ -68,7 +68,7 @@ class CommandBSInfo : public Command source.Reply(_("Information for bot \002%s\002:"), bi->nick.c_str()); info[_("Mask")] = bi->GetIdent() + "@" + bi->host; info[_("Real name")] = bi->realname; - info[_("Created")] = do_strftime(bi->created); + info[_("Created")] = Anope::strftime(bi->created); info[_("Options")] = bi->HasFlag(BI_PRIVATE) ? _("Private") : _("None"); info[_("Used on")] = stringify(bi->GetChannelCount()) + " channel(s)"; @@ -87,7 +87,7 @@ class CommandBSInfo : public Command } } - else if ((ci = cs_findchan(query))) + else if ((ci = ChannelInfo::Find(query))) { if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("botserv/administration")) { @@ -98,8 +98,8 @@ class CommandBSInfo : public Command source.Reply(CHAN_INFO_HEADER, ci->name.c_str()); info[_("Bot nick")] = ci->bi ? ci->bi->nick : "not assigned yet"; - Anope::string enabled = translate(source.nc, _("Enabled")); - Anope::string disabled = translate(source.nc, _("Disabled")); + Anope::string enabled = Language::Translate(source.nc, _("Enabled")); + Anope::string disabled = Language::Translate(source.nc, _("Disabled")); if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) { diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index eeaccd5f9..3e569696e 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -30,9 +30,9 @@ class CommandBSKick : public Command const Anope::string &value = params[2]; const Anope::string &ttb = params.size() > 3 ? params[3] : ""; - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); - if (readonly) + if (Anope::ReadOnly) source.Reply(_("Sorry, kicker configuration is temporarily disabled.")); else if (ci == NULL) source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -736,14 +736,12 @@ class BSKick : public Module /* Should not use == here because bd.ttb[ttbtype] could possibly be > ci->ttb[ttbtype] * if the TTB was changed after it was not set (0) before and the user had already been * kicked a few times. Bug #1056 - Adam */ - Anope::string mask; bd.ttb[ttbtype] = 0; - get_idealban(ci, u, mask); + Anope::string mask = ci->GetIdealBan(u); - if (ci->c) - ci->c->SetMode(NULL, CMODE_BAN, mask); + ci->c->SetMode(NULL, CMODE_BAN, mask); FOREACH_MOD(I_OnBotBan, OnBotBan(u, ci, mask)); } } @@ -756,7 +754,7 @@ class BSKick : public Module if (!ci || !ci->bi || !ci->c || !u || u->server->IsULined() || !ci->c->FindUser(u)) return; - Anope::string fmt = translate(u, message); + Anope::string fmt = Language::Translate(u, message); va_start(args, message); vsnprintf(buf, sizeof(buf), fmt.c_str(), args); va_end(args); @@ -895,7 +893,7 @@ class BSKick : public Module bool mustkick = false; /* Normalize the buffer */ - Anope::string nbuf = normalizeBuffer(realbuf); + Anope::string nbuf = Anope::NormalizeBuffer(realbuf); for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i) { diff --git a/modules/commands/bs_set.cpp b/modules/commands/bs_set.cpp index e169f3c83..6f458bec0 100644 --- a/modules/commands/bs_set.cpp +++ b/modules/commands/bs_set.cpp @@ -41,7 +41,7 @@ class CommandBSSet : public Command const CommandInfo &info = it->second; if (c_name.find_ci(this_name + " ") == 0) { - service_reference<Command> command("Command", info.name); + ServiceReference<Command> command("Command", info.name); if (command) { source.command = it->first; diff --git a/modules/commands/bs_set_dontkickops.cpp b/modules/commands/bs_set_dontkickops.cpp index 598dfdcea..5346074a6 100644 --- a/modules/commands/bs_set_dontkickops.cpp +++ b/modules/commands/bs_set_dontkickops.cpp @@ -24,7 +24,7 @@ class CommandBSSetDontKickOps : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -38,7 +38,7 @@ class CommandBSSetDontKickOps : public Command return; } - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, bot option setting is temporarily disabled.")); return; diff --git a/modules/commands/bs_set_dontkickvoices.cpp b/modules/commands/bs_set_dontkickvoices.cpp index 05453296b..b4b0cd7ec 100644 --- a/modules/commands/bs_set_dontkickvoices.cpp +++ b/modules/commands/bs_set_dontkickvoices.cpp @@ -24,7 +24,7 @@ class CommandBSSetDontKickVoices : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -38,7 +38,7 @@ class CommandBSSetDontKickVoices : public Command return; } - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, bot option setting is temporarily disabled.")); return; diff --git a/modules/commands/bs_set_fantasy.cpp b/modules/commands/bs_set_fantasy.cpp index 03bd40c70..29c722026 100644 --- a/modules/commands/bs_set_fantasy.cpp +++ b/modules/commands/bs_set_fantasy.cpp @@ -24,7 +24,7 @@ class CommandBSSetFantasy : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); const Anope::string &value = params[1]; if (ci == NULL) @@ -39,7 +39,7 @@ class CommandBSSetFantasy : public Command return; } - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, bot option setting is temporarily disabled.")); return; diff --git a/modules/commands/bs_set_greet.cpp b/modules/commands/bs_set_greet.cpp index b74b0e5dd..ad5220203 100644 --- a/modules/commands/bs_set_greet.cpp +++ b/modules/commands/bs_set_greet.cpp @@ -24,7 +24,7 @@ class CommandBSSetGreet : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); const Anope::string &value = params[1]; if (ci == NULL) @@ -39,7 +39,7 @@ class CommandBSSetGreet : public Command return; } - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, bot option setting is temporarily disabled.")); return; diff --git a/modules/commands/bs_set_nobot.cpp b/modules/commands/bs_set_nobot.cpp index 246864953..f3f749aa5 100644 --- a/modules/commands/bs_set_nobot.cpp +++ b/modules/commands/bs_set_nobot.cpp @@ -24,7 +24,7 @@ class CommandBSSetNoBot : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); const Anope::string &value = params[1]; if (ci == NULL) diff --git a/modules/commands/bs_set_private.cpp b/modules/commands/bs_set_private.cpp index 0cd055d00..920c97d37 100644 --- a/modules/commands/bs_set_private.cpp +++ b/modules/commands/bs_set_private.cpp @@ -24,7 +24,7 @@ class CommandBSSetPrivate : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - BotInfo *bi = findbot(params[0]); + BotInfo *bi = BotInfo::Find(params[0], true); const Anope::string &value = params[1]; if (bi == NULL) diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index 40414a336..ed6f4f7fa 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -36,12 +36,12 @@ class AccessChanAccess : public ChanAccess return this->ci->GetLevel(name) != ACCESS_INVALID && this->level >= this->ci->GetLevel(name); } - Anope::string Serialize() const + Anope::string AccessSerialize() const { return stringify(this->level); } - void Unserialize(const Anope::string &data) anope_override + void AccessUnserialize(const Anope::string &data) anope_override { this->level = convertTo<int>(data); } @@ -119,7 +119,7 @@ class CommandCSAccess : public Command bool override = false; - if ((!highest || *highest <= tmp_access) && !u_access.Founder) + if ((!highest || *highest <= tmp_access) && !u_access.founder) { if (source.HasPriv("chanserv/access/modify")) override = true; @@ -130,9 +130,9 @@ class CommandCSAccess : public Command } } - if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask)) + if (mask.find_first_of("!*@") == Anope::string::npos && !NickAlias::Find(mask)) { - User *targ = finduser(mask); + User *targ = User::Find(mask, true); if (targ != NULL) mask = "*!*@" + targ->GetDisplayedHost(); else @@ -148,7 +148,7 @@ class CommandCSAccess : public Command if (mask.equals_ci(access->mask)) { /* Don't allow lowering from a level >= u_level */ - if ((!highest || *access >= *highest) && !u_access.Founder && !source.HasPriv("chanserv/access/modify")) + if ((!highest || *access >= *highest) && !u_access.founder && !source.HasPriv("chanserv/access/modify")) { source.Reply(ACCESS_DENIED); return; @@ -164,7 +164,7 @@ class CommandCSAccess : public Command return; } - service_reference<AccessProvider> provider("AccessProvider", "access/access"); + ServiceReference<AccessProvider> provider("AccessProvider", "access/access"); if (!provider) return; AccessChanAccess *access = anope_dynamic_static_cast<AccessChanAccess *>(provider->Create()); @@ -188,9 +188,9 @@ class CommandCSAccess : public Command { Anope::string mask = params[2]; - if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask)) + if (mask.find_first_of("!*@") == Anope::string::npos && !NickAlias::Find(mask)) { - User *targ = finduser(mask); + User *targ = User::Find(mask, true); if (targ != NULL) mask = "*!*@" + targ->GetDisplayedHost(); else @@ -209,12 +209,12 @@ class CommandCSAccess : public Command CommandSource &source; ChannelInfo *ci; Command *c; - unsigned Deleted; + unsigned deleted; Anope::string Nicks; bool Denied; bool override; public: - AccessDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), Deleted(0), Denied(false), override(false) + AccessDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), deleted(0), Denied(false), override(false) { if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/access/modify")) this->override = true; @@ -222,18 +222,18 @@ class CommandCSAccess : public Command ~AccessDelCallback() { - if (Denied && !Deleted) + if (Denied && !deleted) source.Reply(ACCESS_DENIED); - else if (!Deleted) + else if (!deleted) source.Reply(_("No matching entries on %s access list."), ci->name.c_str()); else { Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Nicks; - if (Deleted == 1) + if (deleted == 1) source.Reply(_("Deleted 1 entry from %s access list."), ci->name.c_str()); else - source.Reply(_("Deleted %d entries from %s access list."), Deleted, ci->name.c_str()); + source.Reply(_("Deleted %d entries from %s access list."), deleted, ci->name.c_str()); } } @@ -247,13 +247,13 @@ class CommandCSAccess : public Command AccessGroup u_access = source.AccessFor(ci); const ChanAccess *u_highest = u_access.Highest(); - if ((!u_highest || *u_highest <= *access) && !u_access.Founder && !this->override && !access->mask.equals_ci(source.nc->display)) + if ((!u_highest || *u_highest <= *access) && !u_access.founder && !this->override && !access->mask.equals_ci(source.nc->display)) { Denied = true; return; } - ++Deleted; + ++deleted; if (!Nicks.empty()) Nicks += ", " + access->mask; else @@ -277,12 +277,12 @@ class CommandCSAccess : public Command ChanAccess *access = ci->GetAccess(i - 1); if (mask.equals_ci(access->mask)) { - if (!access->mask.equals_ci(source.nc->display) && !u_access.Founder && (!highest || *highest <= *access) && !source.HasPriv("chanserv/access/modify")) + if (!access->mask.equals_ci(source.nc->display) && !u_access.founder && (!highest || *highest <= *access) && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); else { source.Reply(_("\002%s\002 deleted from %s access list."), access->mask.c_str(), ci->name.c_str()); - bool override = !u_access.Founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(source.nc->display); + bool override = !u_access.founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(source.nc->display); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->mask; FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, access)); @@ -333,7 +333,7 @@ class CommandCSAccess : public Command if (access->last_seen == 0) timebuf = "Never"; else - timebuf = do_strftime(access->last_seen, NULL, true); + timebuf = Anope::strftime(access->last_seen, NULL, true); } ListFormatter::ListEntry entry; @@ -342,7 +342,7 @@ class CommandCSAccess : public Command entry["Mask"] = access->mask; entry["By"] = access->creator; entry["Last seen"] = timebuf; - this->list.addEntry(entry); + this->list.AddEntry(entry); } } nl_list(list, ci, nick); @@ -367,7 +367,7 @@ class CommandCSAccess : public Command if (access->last_seen == 0) timebuf = "Never"; else - timebuf = do_strftime(access->last_seen, NULL, true); + timebuf = Anope::strftime(access->last_seen, NULL, true); } ListFormatter::ListEntry entry; @@ -376,11 +376,11 @@ class CommandCSAccess : public Command entry["Mask"] = access->mask; entry["By"] = access->creator; entry["Last seen"] = timebuf; - list.addEntry(entry); + list.AddEntry(entry); } } - if (list.isEmpty()) + if (list.IsEmpty()) source.Reply(_("No matching entries on %s access list."), ci->name.c_str()); else { @@ -407,7 +407,7 @@ class CommandCSAccess : public Command } ListFormatter list; - list.addColumn("Number").addColumn("Level").addColumn("Mask"); + list.AddColumn("Number").AddColumn("Level").AddColumn("Mask"); this->ProcessList(source, ci, params, list); } @@ -420,7 +420,7 @@ class CommandCSAccess : public Command } ListFormatter list; - list.addColumn("Number").addColumn("Level").addColumn("Mask").addColumn("By").addColumn("Last seen"); + list.AddColumn("Number").AddColumn("Level").AddColumn("Mask").AddColumn("By").AddColumn("Last seen"); this->ProcessList(source, ci, params, list); } @@ -460,7 +460,7 @@ class CommandCSAccess : public Command const Anope::string &nick = params.size() > 2 ? params[2] : ""; const Anope::string &s = params.size() > 3 ? params[3] : ""; - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -480,7 +480,7 @@ class CommandCSAccess : public Command has_access = true; else if (is_del) { - const NickAlias *na = findnick(nick); + const NickAlias *na = NickAlias::Find(nick); if (na && na->nc == source.GetAccount()) has_access = true; } @@ -492,7 +492,7 @@ class CommandCSAccess : public Command this->OnSyntaxError(source, cmd); else if (!has_access) source.Reply(ACCESS_DENIED); - else if (readonly && !is_list) + else if (Anope::ReadOnly && !is_list) source.Reply(_("Sorry, channel access list modification is temporarily disabled.")); else if (cmd.equals_ci("ADD")) this->DoAdd(source, ci, params); @@ -652,7 +652,7 @@ class CommandCSLevels : public Command source.Reply(_("Access level settings for channel %s:"), ci->name.c_str()); ListFormatter list; - list.addColumn("Name").addColumn("Level"); + list.AddColumn("Name").AddColumn("Level"); const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges(); @@ -671,7 +671,7 @@ class CommandCSLevels : public Command else entry["Level"] = stringify(j); - list.addEntry(entry); + list.AddEntry(entry); } std::vector<Anope::string> replies; @@ -709,7 +709,7 @@ class CommandCSLevels : public Command const Anope::string &what = params.size() > 2 ? params[2] : ""; const Anope::string &s = params.size() > 3 ? params[3] : ""; - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -744,7 +744,7 @@ class CommandCSLevels : public Command source.Reply(_("The following feature/function names are understood.")); ListFormatter list; - list.addColumn("Name").addColumn("Description"); + list.AddColumn("Name").AddColumn("Description"); const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges(); for (unsigned i = 0; i < privs.size(); ++i) @@ -752,8 +752,8 @@ class CommandCSLevels : public Command const Privilege &p = privs[i]; ListFormatter::ListEntry entry; entry["Name"] = p.name; - entry["Description"] = translate(source.nc, p.desc.c_str()); - list.addEntry(entry); + entry["Description"] = Language::Translate(source.nc, p.desc.c_str()); + list.AddEntry(entry); } std::vector<Anope::string> replies; diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index 1425d1636..29959bf32 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -52,7 +52,7 @@ class CommandCSAKick : public Command { Anope::string mask = params[2]; Anope::string reason = params.size() > 3 ? params[3] : ""; - const NickAlias *na = findnick(mask); + const NickAlias *na = NickAlias::Find(mask); NickCore *nc = NULL; const AutoKick *akick; @@ -178,34 +178,34 @@ class CommandCSAKick : public Command CommandSource &source; ChannelInfo *ci; Command *c; - unsigned Deleted; + unsigned deleted; public: - AkickDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), Deleted(0) + AkickDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0) { } ~AkickDelCallback() { bool override = !source.AccessFor(ci).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Deleted << (Deleted == 1 ? " entry" : " entries"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << deleted << (deleted == 1 ? " entry" : " entries"); - if (!Deleted) + if (!deleted) source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str()); - else if (Deleted == 1) + else if (deleted == 1) source.Reply(_("Deleted 1 entry from %s autokick list."), ci->name.c_str()); else - source.Reply(_("Deleted %d entries from %s autokick list."), Deleted, ci->name.c_str()); + source.Reply(_("Deleted %d entries from %s autokick list."), deleted, ci->name.c_str()); } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned number) anope_override { - if (!Number || Number > ci->GetAkickCount()) + if (!number || number > ci->GetAkickCount()) return; - FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(Number - 1))); + FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(number - 1))); - ++Deleted; - ci->EraseAkick(Number - 1); + ++deleted; + ci->EraseAkick(number - 1); } } delcallback(source, ci, this, mask); @@ -213,7 +213,7 @@ class CommandCSAKick : public Command } else { - const NickAlias *na = findnick(mask); + const NickAlias *na = NickAlias::Find(mask); const NickCore *nc = na ? *na->nc : NULL; for (i = 0, end = ci->GetAkickCount(); i < end; ++i) @@ -266,11 +266,11 @@ class CommandCSAKick : public Command Anope::string timebuf, lastused; if (akick->addtime) - timebuf = do_strftime(akick->addtime, NULL, false); + timebuf = Anope::strftime(akick->addtime, NULL, false); else timebuf = UNKNOWN; if (akick->last_used) - lastused = do_strftime(akick->last_used, NULL, false); + lastused = Anope::strftime(akick->last_used, NULL, false); else lastused = UNKNOWN; @@ -281,7 +281,7 @@ class CommandCSAKick : public Command entry["Created"] = timebuf; entry["Last used"] = lastused; entry["Reason"] = akick->reason; - this->list.addEntry(entry); + this->list.AddEntry(entry); } } nl_list(list, ci, mask); @@ -303,11 +303,11 @@ class CommandCSAKick : public Command Anope::string timebuf, lastused; if (akick->addtime) - timebuf = do_strftime(akick->addtime); + timebuf = Anope::strftime(akick->addtime); else timebuf = UNKNOWN; if (akick->last_used) - lastused = do_strftime(akick->last_used); + lastused = Anope::strftime(akick->last_used); else lastused = UNKNOWN; @@ -318,11 +318,11 @@ class CommandCSAKick : public Command entry["Created"] = timebuf; entry["Last used"] = lastused; entry["Reason"] = akick->reason; - list.addEntry(entry); + list.AddEntry(entry); } } - if (list.isEmpty()) + if (list.IsEmpty()) source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str()); else { @@ -347,7 +347,7 @@ class CommandCSAKick : public Command } ListFormatter list; - list.addColumn("Number").addColumn("Mask").addColumn("Reason"); + list.AddColumn("Number").AddColumn("Mask").AddColumn("Reason"); this->ProcessList(source, ci, params, list); } @@ -360,7 +360,7 @@ class CommandCSAKick : public Command } ListFormatter list; - list.addColumn("Number").addColumn("Mask").addColumn("Creator").addColumn("Created").addColumn("Last used").addColumn("Reason"); + list.AddColumn("Number").AddColumn("Mask").AddColumn("Creator").AddColumn("Created").AddColumn("Last used").AddColumn("Reason"); this->ProcessList(source, ci, params, list); } @@ -416,7 +416,7 @@ class CommandCSAKick : public Command Anope::string cmd = params[1]; Anope::string mask = params.size() > 2 ? params[2] : ""; - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -427,7 +427,7 @@ class CommandCSAKick : public Command this->OnSyntaxError(source, cmd); else if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); - else if (!cmd.equals_ci("LIST") && !cmd.equals_ci("VIEW") && !cmd.equals_ci("ENFORCE") && readonly) + else if (!cmd.equals_ci("LIST") && !cmd.equals_ci("VIEW") && !cmd.equals_ci("ENFORCE") && Anope::ReadOnly) source.Reply(_("Sorry, channel autokick list modification is temporarily disabled.")); else if (cmd.equals_ci("ADD")) this->DoAdd(source, ci, params); diff --git a/modules/commands/cs_appendtopic.cpp b/modules/commands/cs_appendtopic.cpp index 70cde7b7b..2d7c0f278 100644 --- a/modules/commands/cs_appendtopic.cpp +++ b/modules/commands/cs_appendtopic.cpp @@ -52,7 +52,7 @@ class CommandCSAppendTopic : public Command { const Anope::string &newtopic = params[1]; - Channel *c = findchan(params[0]);; + Channel *c = Channel::Find(params[0]);; if (!c) source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index 063d98ab5..e857243f9 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -29,7 +29,7 @@ class CommandCSBan : public Command const Anope::string &target = params[1]; const Anope::string &reason = params.size() > 2 ? params[2] : "Requested"; - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -38,7 +38,7 @@ class CommandCSBan : public Command Channel *c = ci->c; User *u = source.GetUser(); - User *u2 = finduser(target); + User *u2 = User::Find(target, true); AccessGroup u_access = source.AccessFor(ci); @@ -56,14 +56,13 @@ class CommandCSBan : public Command if (u != u2 && ci->HasFlag(CI_PEACE) && u2_access >= u_access) source.Reply(ACCESS_DENIED); - else if (matches_list(ci->c, u2, CMODE_EXCEPT)) + else if (ci->c->MatchesList(u2, CMODE_EXCEPT)) source.Reply(CHAN_EXCEPTED, u2->nick.c_str(), ci->name.c_str()); else if (u2->IsProtected()) source.Reply(ACCESS_DENIED); else { - Anope::string mask; - get_idealban(ci, u2, mask); + Anope::string mask = ci->GetIdealBan(u2); // XXX need a way to detect if someone is overriding Log(LOG_COMMAND, source, this, ci) << "for " << mask; @@ -99,7 +98,7 @@ class CommandCSBan : public Command if (u != uc->user && ci->HasFlag(CI_PEACE) && u2_access >= u_access) continue; - else if (matches_list(ci->c, uc->user, CMODE_EXCEPT)) + else if (ci->c->MatchesList(uc->user, CMODE_EXCEPT)) continue; else if (uc->user->IsProtected()) continue; diff --git a/modules/commands/cs_clearusers.cpp b/modules/commands/cs_clearusers.cpp index d6eed6e4d..3a424e4ce 100644 --- a/modules/commands/cs_clearusers.cpp +++ b/modules/commands/cs_clearusers.cpp @@ -26,7 +26,7 @@ class CommandCSClearUsers : public Command { const Anope::string &chan = params[0]; - Channel *c = findchan(chan); + Channel *c = Channel::Find(chan); Anope::string modebuf; if (!c) diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp index aef48ea4c..19a8ad436 100644 --- a/modules/commands/cs_clone.cpp +++ b/modules/commands/cs_clone.cpp @@ -29,7 +29,7 @@ public: Anope::string what = params.size() > 2 ? params[2] : ""; User *u = source.GetUser(); - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -42,7 +42,7 @@ public: return; } - ChannelInfo *target_ci = cs_findchan(target); + ChannelInfo *target_ci = ChannelInfo::Find(target); if (!target_ci) { source.Reply(CHAN_X_NOT_REGISTERED, target.c_str()); @@ -59,11 +59,11 @@ public: if (what.empty()) { - target_ci->destroy(); + target_ci->Destroy(); target_ci = new ChannelInfo(*ci); target_ci->name = target; (*RegisteredChannelList)[target_ci->name] = target_ci; - target_ci->c = findchan(target_ci->name); + target_ci->c = Channel::Find(target_ci->name); if (target_ci->c) { target_ci->c->ci = target_ci; @@ -88,7 +88,7 @@ public: target_ci->c->SetMode(NULL, CMODE_PERM); if (target_ci->bi && target_ci->c->FindUser(target_ci->bi) == NULL) - target_ci->bi->Join(target_ci->c, &Config->BotModeList); + target_ci->bi->Join(target_ci->c, &ModeManager::DefaultBotModes); } if (target_ci->c && !target_ci->c->topic.empty()) @@ -117,7 +117,7 @@ public: newaccess->creator = taccess->creator; newaccess->last_seen = taccess->last_seen; newaccess->created = taccess->created; - newaccess->Unserialize(taccess->Serialize()); + newaccess->AccessUnserialize(taccess->AccessSerialize()); target_ci->AddAccess(newaccess); } diff --git a/modules/commands/cs_drop.cpp b/modules/commands/cs_drop.cpp index cf8c5040e..829f44026 100644 --- a/modules/commands/cs_drop.cpp +++ b/modules/commands/cs_drop.cpp @@ -26,13 +26,13 @@ class CommandCSDrop : public Command { const Anope::string &chan = params[0]; - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, channel de-registration is temporarily disabled.")); // XXX: READ_ONLY_MODE? return; } - ChannelInfo *ci = cs_findchan(chan); + ChannelInfo *ci = ChannelInfo::Find(chan); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -57,7 +57,7 @@ class CommandCSDrop : public Command FOREACH_MOD(I_OnChanDrop, OnChanDrop(ci)); Channel *c = ci->c; - ci->destroy(); + ci->Destroy(); source.Reply(_("Channel \002%s\002 has been dropped."), chan.c_str()); diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp index 755cd55b4..4622af04b 100644 --- a/modules/commands/cs_enforce.cpp +++ b/modules/commands/cs_enforce.cpp @@ -50,7 +50,7 @@ class CommandCSEnforce : public Command Log(LOG_COMMAND, source, this) << "to enforce secureops"; - /* Dirty hack to allow chan_set_correct_modes to work ok. + /* Dirty hack to allow Channel::SetCorrectModes to work ok. * We pretend like SECUREOPS is on so it doesn't ignore that * part of the code. This way we can enforce SECUREOPS even * if it's off. @@ -66,7 +66,7 @@ class CommandCSEnforce : public Command { UserContainer *uc = *it; - chan_set_correct_modes(uc->user, c, 0, false); + c->SetCorrectModes(uc->user, false, false); } if (hadsecureops) @@ -95,9 +95,8 @@ class CommandCSEnforce : public Command { User *user = users[i]; - Anope::string mask; - get_idealban(ci, user, mask); - Anope::string reason = translate(user, CHAN_NOT_ALLOWED_TO_JOIN); + Anope::string mask = ci->GetIdealBan(user); + Anope::string reason = Language::Translate(user, CHAN_NOT_ALLOWED_TO_JOIN); c->SetMode(NULL, CMODE_BAN, mask); c->Kick(NULL, user, "%s", reason.c_str()); } @@ -106,7 +105,6 @@ class CommandCSEnforce : public Command void DoCModeR(CommandSource &source, Channel *c) { ChannelInfo *ci = c->ci; - Anope::string mask; if (!ci) return; @@ -127,8 +125,8 @@ class CommandCSEnforce : public Command { User *user = users[i]; - get_idealban(ci, user, mask); - Anope::string reason = translate(user, CHAN_NOT_ALLOWED_TO_JOIN); + Anope::string mask = ci->GetIdealBan(user); + Anope::string reason = Language::Translate(user, CHAN_NOT_ALLOWED_TO_JOIN); if (!c->HasMode(CMODE_REGISTEREDONLY)) c->SetMode(NULL, CMODE_BAN, mask); c->Kick(NULL, user, "%s", reason.c_str()); @@ -145,7 +143,7 @@ class CommandCSEnforce : public Command { const Anope::string &what = params.size() > 1 ? params[1] : ""; - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); if (!c) source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index 1fce5fac0..85e428cc1 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -15,7 +15,7 @@ struct EntryMsg : Serializable { - serialize_obj<ChannelInfo> ci; + Serialize::Reference<ChannelInfo> ci; Anope::string creator; Anope::string message; time_t when; @@ -28,31 +28,31 @@ struct EntryMsg : Serializable this->when = ct; } - Serialize::Data serialize() const anope_override + Serialize::Data Serialize() const anope_override { Serialize::Data data; data["ci"] << this->ci->name; data["creator"] << this->creator; data["message"] << this->message; - data["when"].setType(Serialize::DT_INT) << this->when; + data["when"].SetType(Serialize::DT_INT) << this->when; return data; } - static Serializable* unserialize(Serializable *obj, Serialize::Data &data); + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; static unsigned MaxEntries = 0; -struct EntryMessageList : serialize_checker<std::vector<EntryMsg *> >, ExtensibleItem +struct EntryMessageList : Serialize::Checker<std::vector<EntryMsg *> >, ExtensibleItem { - EntryMessageList() : serialize_checker<std::vector<EntryMsg *> >("EntryMsg") { } + EntryMessageList() : Serialize::Checker<std::vector<EntryMsg *> >("EntryMsg") { } }; -Serializable* EntryMsg::unserialize(Serializable *obj, Serialize::Data &data) +Serializable* EntryMsg::Unserialize(Serializable *obj, Serialize::Data &data) { - ChannelInfo *ci = cs_findchan(data["ci"].astr()); + ChannelInfo *ci = ChannelInfo::Find(data["ci"].astr()); if (!ci) return NULL; @@ -99,7 +99,7 @@ class CommandEntryMessage : public Command source.Reply(_("Entry message list for \002%s\002:"), ci->name.c_str()); ListFormatter list; - list.addColumn("Number").addColumn("Creator").addColumn("Created").addColumn("Message"); + list.AddColumn("Number").AddColumn("Creator").AddColumn("Created").AddColumn("Message"); for (unsigned i = 0; i < (*messages)->size(); ++i) { EntryMsg *msg = (*messages)->at(i); @@ -107,9 +107,9 @@ class CommandEntryMessage : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(i + 1); entry["Creator"] = msg->creator; - entry["Created"] = do_strftime(msg->when); + entry["Created"] = Anope::strftime(msg->when); entry["Message"] = msg->message; - list.addEntry(entry); + list.AddEntry(entry); } std::vector<Anope::string> replies; @@ -159,7 +159,7 @@ class CommandEntryMessage : public Command unsigned i = convertTo<unsigned>(message); if (i > 0 && i <= (*messages)->size()) { - (*messages)->at(i - 1)->destroy(); + (*messages)->at(i - 1)->Destroy(); (*messages)->erase((*messages)->begin() + i - 1); if ((*messages)->empty()) ci->Shrink("cs_entrymsg"); @@ -182,7 +182,7 @@ class CommandEntryMessage : public Command if (messages != NULL) { for (unsigned i = 0; i < (*messages)->size(); ++i) - (*messages)->at(i)->destroy(); + (*messages)->at(i)->Destroy(); (*messages)->clear(); ci->Shrink("cs_entrymsg"); } @@ -203,7 +203,7 @@ class CommandEntryMessage : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -258,11 +258,11 @@ class CommandEntryMessage : public Command class CSEntryMessage : public Module { - SerializeType entrymsg_type; + Serialize::Type entrymsg_type; CommandEntryMessage commandentrymsg; public: - CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), entrymsg_type("EntryMsg", EntryMsg::unserialize), commandentrymsg(this) + CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), entrymsg_type("EntryMsg", EntryMsg::Unserialize), commandentrymsg(this) { this->SetAuthor("Anope"); diff --git a/modules/commands/cs_fantasy_stats.cpp b/modules/commands/cs_fantasy_stats.cpp index 7c79593a2..bbe135298 100644 --- a/modules/commands/cs_fantasy_stats.cpp +++ b/modules/commands/cs_fantasy_stats.cpp @@ -66,7 +66,7 @@ class CSStats : public Module { CommandCSStats commandcsstats; CommandCSGStats commandcsgstats; - service_reference<SQLProvider> sql; + ServiceReference<SQLProvider> sql; MySQLInterface sqlinterface; Anope::string prefix; public: @@ -86,7 +86,7 @@ class CSStats : public Module ConfigReader config; prefix = config.ReadValue("chanstats", "prefix", "anope_", 0); Anope::string engine = config.ReadValue("chanstats", "engine", "", 0); - this->sql = service_reference<SQLProvider>("SQLProvider", engine); + this->sql = ServiceReference<SQLProvider>("SQLProvider", engine); } SQLResult RunQuery(const SQLQuery &query) @@ -108,7 +108,7 @@ class CSStats : public Module Anope::string display; if (params.empty()) display = source.nc->display; - else if (const NickAlias *na = findnick(params[0])) + else if (const NickAlias *na = NickAlias::Find(params[0])) display = na->nc->display; else { diff --git a/modules/commands/cs_fantasy_top.cpp b/modules/commands/cs_fantasy_top.cpp index 587b4c525..86e25f122 100644 --- a/modules/commands/cs_fantasy_top.cpp +++ b/modules/commands/cs_fantasy_top.cpp @@ -93,7 +93,7 @@ class CSTop : public Module CommandCSGTop commandcsgtop; CommandCSTop10 commandcstop10; CommandCSGTop10 commandcsgtop10; - service_reference<SQLProvider> sql; + ServiceReference<SQLProvider> sql; MySQLInterface sqlinterface; Anope::string prefix; @@ -115,7 +115,7 @@ class CSTop : public Module ConfigReader config; prefix = config.ReadValue("chanstats", "prefix", "anope_", 0); Anope::string engine = config.ReadValue("chanstats", "engine", "", 0); - this->sql = service_reference<SQLProvider>("SQLProvider", engine); + this->sql = ServiceReference<SQLProvider>("SQLProvider", engine); } SQLResult RunQuery(const SQLQuery &query) diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index c137b55b1..65ae33f2f 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -32,12 +32,12 @@ class FlagsChanAccess : public ChanAccess return false; } - Anope::string Serialize() const + Anope::string AccessSerialize() const { return Anope::string(this->flags.begin(), this->flags.end()); } - void Unserialize(const Anope::string &data) anope_override + void AccessUnserialize(const Anope::string &data) anope_override { for (unsigned i = data.length(); i > 0; --i) this->flags.insert(data[i - 1]); @@ -46,7 +46,7 @@ class FlagsChanAccess : public ChanAccess static Anope::string DetermineFlags(const ChanAccess *access) { if (access->provider->name == "access/flags") - return access->Serialize(); + return access->AccessSerialize(); std::set<char> buffer; @@ -86,9 +86,9 @@ class CommandCSFlags : public Command AccessGroup u_access = source.AccessFor(ci); - if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask)) + if (mask.find_first_of("!*@") == Anope::string::npos && !NickAlias::Find(mask)) { - User *targ = finduser(mask); + User *targ = User::Find(mask, true); if (targ != NULL) mask = "*!*@" + targ->GetDisplayedHost(); else @@ -191,7 +191,7 @@ class CommandCSFlags : public Command return; } - service_reference<AccessProvider> provider("AccessProvider", "access/flags"); + ServiceReference<AccessProvider> provider("AccessProvider", "access/flags"); if (!provider) return; FlagsChanAccess *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create()); @@ -209,8 +209,8 @@ class CommandCSFlags : public Command FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, source, access)); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to modify " << mask << "'s flags to " << access->Serialize(); - source.Reply(_("Access for \002%s\002 on %s set to +\002%s\002"), access->mask.c_str(), ci->name.c_str(), access->Serialize().c_str()); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to modify " << mask << "'s flags to " << access->AccessSerialize(); + source.Reply(_("Access for \002%s\002 on %s set to +\002%s\002"), access->mask.c_str(), ci->name.c_str(), access->AccessSerialize().c_str()); return; } @@ -227,7 +227,7 @@ class CommandCSFlags : public Command ListFormatter list; - list.addColumn("Number").addColumn("Mask").addColumn("Flags").addColumn("Creator").addColumn("Created"); + list.AddColumn("Number").AddColumn("Mask").AddColumn("Flags").AddColumn("Creator").AddColumn("Created"); unsigned count = 0; for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i) @@ -257,11 +257,11 @@ class CommandCSFlags : public Command entry["Mask"] = access->mask; entry["Flags"] = FlagsChanAccess::DetermineFlags(access); entry["Creator"] = access->creator; - entry["Created"] = do_strftime(access->created, source.nc, true); - list.addEntry(entry); + entry["Created"] = Anope::strftime(access->created, source.nc, true); + list.AddEntry(entry); } - if (list.isEmpty()) + if (list.IsEmpty()) source.Reply(_("No matching entries on %s access list."), ci->name.c_str()); else { @@ -311,7 +311,7 @@ class CommandCSFlags : public Command const Anope::string &chan = params[0]; const Anope::string &cmd = params[1]; - ChannelInfo *ci = cs_findchan(chan); + ChannelInfo *ci = ChannelInfo::Find(chan); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); @@ -329,7 +329,7 @@ class CommandCSFlags : public Command if (!has_access) source.Reply(ACCESS_DENIED); - else if (readonly && !is_list) + else if (Anope::ReadOnly && !is_list) source.Reply(_("Sorry, channel access list modification is temporarily disabled.")); else if (cmd.equals_ci("MODIFY")) this->DoModify(source, ci, params); @@ -374,7 +374,7 @@ class CommandCSFlags : public Command Privilege *p = PrivilegeManager::FindPrivilege(it->second); if (p == NULL) continue; - source.Reply(" %c - %s", it->first, translate(source.nc, p->desc.c_str())); + source.Reply(" %c - %s", it->first, Language::Translate(source.nc, p->desc.c_str())); } return true; diff --git a/modules/commands/cs_getkey.cpp b/modules/commands/cs_getkey.cpp index e0205ad03..212388e3f 100644 --- a/modules/commands/cs_getkey.cpp +++ b/modules/commands/cs_getkey.cpp @@ -26,7 +26,7 @@ class CommandCSGetKey : public Command { const Anope::string &chan = params[0]; - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp index 310879135..c485c3cb4 100644 --- a/modules/commands/cs_info.cpp +++ b/modules/commands/cs_info.cpp @@ -22,7 +22,7 @@ class CommandCSInfo : public Command if (!buf.empty()) buf += ", "; - buf += translate(nc, str); + buf += Language::Translate(nc, str); } } @@ -39,7 +39,7 @@ class CommandCSInfo : public Command const Anope::string &chan = params[0]; NickCore *nc = source.nc; - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -65,8 +65,8 @@ class CommandCSInfo : public Command if (!ci->desc.empty()) info["Description"] = ci->desc; - info["Registered"] = do_strftime(ci->time_registered); - info["Last used"] = do_strftime(ci->last_used); + info["Registered"] = Anope::strftime(ci->time_registered); + info["Last used"] = Anope::strftime(ci->last_used); const ModeLock *secret = ci->GetMLock(CMODE_SECRET); if (!ci->last_topic.empty() && (show_all || ((!secret || secret->set == false) && (!ci->c || !ci->c->HasMode(CMODE_SECRET))))) @@ -103,7 +103,7 @@ class CommandCSInfo : public Command info["Mode lock"] = ml; if (!ci->HasFlag(CI_NO_EXPIRE)) - info["Expires on"] = do_strftime(ci->last_used + Config->CSExpire); + info["Expires on"] = Anope::strftime(ci->last_used + Config->CSExpire); } if (ci->HasFlag(CI_SUSPENDED)) { diff --git a/modules/commands/cs_invite.cpp b/modules/commands/cs_invite.cpp index 32ef87e3e..1085947a2 100644 --- a/modules/commands/cs_invite.cpp +++ b/modules/commands/cs_invite.cpp @@ -27,7 +27,7 @@ class CommandCSInvite : public Command const Anope::string &chan = params[0]; User *u = source.GetUser(); - Channel *c = findchan(chan); + Channel *c = Channel::Find(chan); if (!c) { @@ -52,7 +52,7 @@ class CommandCSInvite : public Command if (params.size() == 1) u2 = u; else - u2 = finduser(params[1]); + u2 = User::Find(params[1], true); if (!u2) { @@ -71,7 +71,7 @@ class CommandCSInvite : public Command { bool override = !source.AccessFor(ci).HasPriv("INVITE"); - ircdproto->SendInvite(ci->WhoSends(), c, u2); + IRCD->SendInvite(ci->WhoSends(), c, u2); if (u2 != u) { source.Reply(_("\002%s\002 has been invited to \002%s\002."), u2->nick.c_str(), c->name.c_str()); diff --git a/modules/commands/cs_kick.cpp b/modules/commands/cs_kick.cpp index 97d879416..4073f3fe8 100644 --- a/modules/commands/cs_kick.cpp +++ b/modules/commands/cs_kick.cpp @@ -30,9 +30,9 @@ class CommandCSKick : public Command const Anope::string &reason = params.size() > 2 ? params[2] : "Requested"; User *u = source.GetUser(); - ChannelInfo *ci = cs_findchan(params[0]); - Channel *c = findchan(params[0]); - User *u2 = finduser(target); + ChannelInfo *ci = ChannelInfo::Find(params[0]); + Channel *c = Channel::Find(params[0]); + User *u2 = User::Find(target, true); if (!c) { diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp index db5a5136a..9132d07a8 100644 --- a/modules/commands/cs_list.cpp +++ b/modules/commands/cs_list.cpp @@ -33,8 +33,9 @@ class CommandCSList : public Command if (pattern[0] == '#') { - Anope::string n1 = myStrGetToken(pattern.substr(1), '-', 0), /* Read FROM out */ - n2 = myStrGetTokenRemainder(pattern, '-', 1); + Anope::string n1, n2; + sepstream(pattern.substr(1), '-').GetToken(n1, 0); + sepstream(pattern, '-').GetToken(n2, 1); try { @@ -72,7 +73,7 @@ class CommandCSList : public Command source.Reply(_("List of entries matching \002%s\002:"), pattern.c_str()); ListFormatter list; - list.addColumn("Name").addColumn("Description"); + list.AddColumn("Name").AddColumn("Description"); for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) { @@ -99,7 +100,7 @@ class CommandCSList : public Command entry["Description"] = "[Suspended]"; else entry["Description"] = ci->desc; - list.addEntry(entry); + list.AddEntry(entry); } ++count; } diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp index bd630b4e2..4965ab561 100644 --- a/modules/commands/cs_log.cpp +++ b/modules/commands/cs_log.cpp @@ -28,7 +28,7 @@ public: { const Anope::string &channel = params[0]; - ChannelInfo *ci = cs_findchan(channel); + ChannelInfo *ci = ChannelInfo::Find(channel); if (ci == NULL) source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str()); else if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("chanserv/set")) @@ -40,7 +40,7 @@ public: else { ListFormatter list; - list.addColumn("Number").addColumn("Service").addColumn("Command").addColumn("Method").addColumn(""); + list.AddColumn("Number").AddColumn("Service").AddColumn("Command").AddColumn("Method").AddColumn(""); for (unsigned i = 0; i < ci->log_settings->size(); ++i) { @@ -52,7 +52,7 @@ public: entry["Command"] = log->command_name; entry["Method"] = log->method; entry[""] = log->extra; - list.addEntry(entry); + list.AddEntry(entry); } source.Reply(_("Log list for %s:"), ci->name.c_str()); @@ -79,7 +79,7 @@ public: Anope::string service = command.substr(0, sl), command_name = command.substr(sl + 1); - BotInfo *bi = findbot(service); + BotInfo *bi = BotInfo::Find(service, true); if (bi == NULL || bi->commands.count(command_name) == 0) { @@ -87,7 +87,7 @@ public: return; } - service_reference<Command> c_service("Command", bi->commands[command_name].name); + ServiceReference<Command> c_service("Command", bi->commands[command_name].name); if (!c_service) { source.Reply(_("%s is not a valid command."), command.c_str()); @@ -117,7 +117,7 @@ public: { if (log->extra == extra) { - log->destroy(); + log->Destroy(); ci->log_settings->erase(ci->log_settings->begin() + i - 1); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to remove logging for " << command << " with method " << method << (extra == "" ? "" : " ") << extra; source.Reply(_("Logging for command %s on %s with log method %s%s%s has been removed."), command_name.c_str(), bi->nick.c_str(), method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str()); @@ -194,7 +194,7 @@ class CSLog : public Module void OnLog(Log *l) anope_override { - if (l->Type != LOG_COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced()) + if (l->type != LOG_COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced()) return; for (unsigned i = l->ci->log_settings->size(); i > 0; --i) @@ -207,13 +207,13 @@ class CSLog : public Module if (log->method.equals_ci("MESSAGE") && l->ci->c && l->ci->bi && l->ci->c->FindUser(l->ci->bi) != NULL) { - ircdproto->SendPrivmsg(l->ci->bi, log->extra + l->ci->c->name, "%s", buffer.c_str()); + IRCD->SendPrivmsg(l->ci->bi, log->extra + l->ci->c->name, "%s", buffer.c_str()); l->ci->bi->lastmsg = Anope::CurTime; } else if (log->method.equals_ci("NOTICE") && l->ci->c && l->ci->bi && l->ci->c->FindUser(l->ci->bi) != NULL) - ircdproto->SendNotice(l->ci->bi, log->extra + l->ci->c->name, "%s", buffer.c_str()); - else if (log->method.equals_ci("MEMO") && memoserv && l->ci->WhoSends() != NULL) - memoserv->Send(l->ci->WhoSends()->nick, l->ci->name, buffer, true); + IRCD->SendNotice(l->ci->bi, log->extra + l->ci->c->name, "%s", buffer.c_str()); + else if (log->method.equals_ci("MEMO") && MemoServService && l->ci->WhoSends() != NULL) + MemoServService->Send(l->ci->WhoSends()->nick, l->ci->name, buffer, true); } } } diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index 840912aaf..c33b317a2 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -17,7 +17,7 @@ class CommandCSMode : public Command { bool CanSet(CommandSource &source, ChannelInfo *ci, ChannelMode *cm) { - if (!ci || !cm || cm->Type != MODE_STATUS) + if (!ci || !cm || cm->type != MODE_STATUS) return false; const Anope::string accesses[] = { "VOICE", "HALFOP", "OPDEOP", "PROTECT", "OWNER", "" }; @@ -30,7 +30,7 @@ class CommandCSMode : public Command if (access.HasPriv(accesses[i])) { ChannelMode *cm2 = ModeManager::FindChannelModeByName(modes[i]); - if (cm2 == NULL || cm2->Type != MODE_STATUS) + if (cm2 == NULL || cm2->type != MODE_STATUS) continue; ChannelModeStatus *cms2 = anope_dynamic_static_cast<ChannelModeStatus *>(cm2); if (cms2->Level > u_level) @@ -82,15 +82,15 @@ class CommandCSMode : public Command } Anope::string mode_param; - if (((cm->Type == MODE_STATUS || cm->Type == MODE_LIST) && !sep.GetToken(mode_param)) || (cm->Type == MODE_PARAM && adding && !sep.GetToken(mode_param))) - source.Reply(_("Missing parameter for mode %c."), cm->ModeChar); + if (((cm->type == MODE_STATUS || cm->type == MODE_LIST) && !sep.GetToken(mode_param)) || (cm->type == MODE_PARAM && adding && !sep.GetToken(mode_param))) + source.Reply(_("Missing parameter for mode %c."), cm->mchar); else { ci->SetMLock(cm, adding, mode_param, source.GetNick()); if (!mode_param.empty()) mode_param = " " + mode_param; - source.Reply(_("%c%c%s locked on %s"), adding ? '+' : '-', cm->ModeChar, mode_param.c_str(), ci->name.c_str()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to lock " << (adding ? '+' : '-') << cm->ModeChar << mode_param; + source.Reply(_("%c%c%s locked on %s"), adding ? '+' : '-', cm->mchar, mode_param.c_str(), ci->name.c_str()); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to lock " << (adding ? '+' : '-') << cm->mchar << mode_param; } } } @@ -132,19 +132,19 @@ class CommandCSMode : public Command } Anope::string mode_param; - if (!cm->Type == MODE_REGULAR && !sep.GetToken(mode_param)) - source.Reply(_("Missing parameter for mode %c."), cm->ModeChar); + if (!cm->type == MODE_REGULAR && !sep.GetToken(mode_param)) + source.Reply(_("Missing parameter for mode %c."), cm->mchar); else { if (ci->RemoveMLock(cm, adding, mode_param)) { if (!mode_param.empty()) mode_param = " " + mode_param; - source.Reply(_("%c%c%s has been unlocked from %s."), adding == 1 ? '+' : '-', cm->ModeChar, mode_param.c_str(), ci->name.c_str()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unlock " << (adding ? '+' : '-') << cm->ModeChar << mode_param; + source.Reply(_("%c%c%s has been unlocked from %s."), adding == 1 ? '+' : '-', cm->mchar, mode_param.c_str(), ci->name.c_str()); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unlock " << (adding ? '+' : '-') << cm->mchar << mode_param; } else - source.Reply(_("%c%c is not locked on %s."), adding == 1 ? '+' : '-', cm->ModeChar, ci->name.c_str()); + source.Reply(_("%c%c is not locked on %s."), adding == 1 ? '+' : '-', cm->mchar, ci->name.c_str()); } } } @@ -159,7 +159,7 @@ class CommandCSMode : public Command else { ListFormatter list; - list.addColumn("Mode").addColumn("Param").addColumn("Creator").addColumn("Created"); + list.AddColumn("Mode").AddColumn("Param").AddColumn("Creator").AddColumn("Created"); for (ChannelInfo::ModeList::const_iterator it = mlocks.begin(), it_end = mlocks.end(); it != it_end; ++it) { @@ -169,11 +169,11 @@ class CommandCSMode : public Command continue; ListFormatter::ListEntry entry; - entry["Mode"] = Anope::printf("%c%c", ml->set ? '+' : '-', cm->ModeChar); + entry["Mode"] = Anope::printf("%c%c", ml->set ? '+' : '-', cm->mchar); entry["Param"] = ml->param; entry["Creator"] = ml->setter; - entry["Created"] = do_strftime(ml->created, source.nc, false); - list.addEntry(entry); + entry["Created"] = Anope::strftime(ml->created, source.nc, false); + list.AddEntry(entry); } source.Reply(_("Mode locks for %s:"), ci->name.c_str()); @@ -218,7 +218,7 @@ class CommandCSMode : public Command ChannelMode *cm = ModeManager::ChannelModes[j]; if (!u || cm->CanSet(u)) { - if (cm->Type == MODE_REGULAR || (!adding && cm->Type == MODE_PARAM)) + if (cm->type == MODE_REGULAR || (!adding && cm->type == MODE_PARAM)) { if (adding) ci->c->SetMode(NULL, cm); @@ -234,7 +234,7 @@ class CommandCSMode : public Command ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]); if (!cm || (u && !cm->CanSet(u))) continue; - switch (cm->Type) + switch (cm->type) { case MODE_REGULAR: if (adding) @@ -257,13 +257,13 @@ class CommandCSMode : public Command if (!this->CanSet(source, ci, cm)) { - source.Reply(_("You do not have access to set mode %c."), cm->ModeChar); + source.Reply(_("You do not have access to set mode %c."), cm->mchar); break; } AccessGroup u_access = source.AccessFor(ci); - if (str_is_wildcard(param)) + if (param.find_first_of("*?") != Anope::string::npos) { for (CUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) { @@ -288,7 +288,7 @@ class CommandCSMode : public Command } else { - User *target = finduser(param); + User *target = User::Find(param, true); if (target == NULL) { source.Reply(NICK_X_NOT_IN_USE, param.c_str()); @@ -316,7 +316,7 @@ class CommandCSMode : public Command ci->c->SetMode(NULL, cm, param); else { - std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> its = ci->c->GetModeList(cm->Name); + std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> its = ci->c->GetModeList(cm->name); for (; its.first != its.second;) { const Anope::string &mask = its.first->second; @@ -343,7 +343,7 @@ class CommandCSMode : public Command { const Anope::string &subcommand = params[1]; - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (!ci || !ci->c) source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); diff --git a/modules/commands/cs_modes.cpp b/modules/commands/cs_modes.cpp index 2775e92bc..696c38dde 100644 --- a/modules/commands/cs_modes.cpp +++ b/modules/commands/cs_modes.cpp @@ -18,8 +18,8 @@ class CommandModeBase : public Command void do_mode(CommandSource &source, Command *com, ChannelMode *cm, const Anope::string &chan, const Anope::string &nick, bool set, const Anope::string &level, const Anope::string &levelself) { User *u = source.GetUser(); - User *u2 = finduser(nick); - Channel *c = findchan(chan); + User *u2 = User::Find(nick, true); + Channel *c = Channel::Find(chan); if (!c) { diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp index 28fb931f5..e756482c7 100644 --- a/modules/commands/cs_register.cpp +++ b/modules/commands/cs_register.cpp @@ -29,10 +29,10 @@ class CommandCSRegister : public Command User *u = source.GetUser(); NickCore *nc = source.nc; - Channel *c = findchan(params[0]); - ChannelInfo *ci = cs_findchan(params[0]); + Channel *c = Channel::Find(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); - if (readonly) + if (Anope::ReadOnly) source.Reply(_("Sorry, channel registration is temporarily disabled.")); else if (nc->HasFlag(NI_UNCONFIRMED)) source.Reply(_("You must confirm your account before you can register a channel.")); @@ -40,7 +40,7 @@ class CommandCSRegister : public Command source.Reply(_("Local channels cannot be registered.")); else if (chan[0] != '#') source.Reply(CHAN_SYMBOL_REQUIRED); - else if (!ircdproto->IsChannelValid(chan)) + else if (!IRCD->IsChannelValid(chan)) source.Reply(CHAN_X_INVALID, chan.c_str()); else if (ci) source.Reply(_("Channel \002%s\002 is already registered!"), chan.c_str()); @@ -55,7 +55,7 @@ class CommandCSRegister : public Command if (!chdesc.empty()) ci->desc = chdesc; - for (ChannelInfo::ModeList::iterator it = def_mode_locks.begin(), it_end = def_mode_locks.end(); it != it_end; ++it) + for (ChannelInfo::ModeList::iterator it = ModeManager::DefaultModeLocks.begin(), it_end = ModeManager::DefaultModeLocks.end(); it != it_end; ++it) { ModeLock *ml = new ModeLock(*it->second); ml->setter = source.GetNick(); diff --git a/modules/commands/cs_saset.cpp b/modules/commands/cs_saset.cpp index a4a72ee76..211148e13 100644 --- a/modules/commands/cs_saset.cpp +++ b/modules/commands/cs_saset.cpp @@ -43,7 +43,7 @@ class CommandCSSASet : public Command const CommandInfo &info = it->second; if (c_name.find_ci(this_name + " ") == 0) { - service_reference<Command> command("Command", info.name); + ServiceReference<Command> command("Command", info.name); if (command) { source.command = it->first; diff --git a/modules/commands/cs_saset_noexpire.cpp b/modules/commands/cs_saset_noexpire.cpp index 78d8641d4..1c7b260ec 100644 --- a/modules/commands/cs_saset_noexpire.cpp +++ b/modules/commands/cs_saset_noexpire.cpp @@ -24,7 +24,7 @@ class CommandCSSASetNoexpire : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index d2686e013..18a21d35e 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -38,7 +38,7 @@ struct SeenInfo : Serializable { } - Serialize::Data serialize() const anope_override + Serialize::Data Serialize() const anope_override { Serialize::Data data; @@ -48,12 +48,12 @@ struct SeenInfo : Serializable data["nick2"] << nick2; data["channel"] << channel; data["message"] << message; - data["last"].setType(Serialize::DT_INT) << last; + data["last"].SetType(Serialize::DT_INT) << last; return data; } - static Serializable* unserialize(Serializable *obj, Serialize::Data &data) + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { SeenInfo *s; if (obj) @@ -95,8 +95,8 @@ static SeenInfo *FindInfo(const Anope::string &nick) static bool ShouldHide(const Anope::string &channel, User *u) { - Channel *targetchan = findchan(channel); - const ChannelInfo *targetchan_ci = targetchan ? *targetchan->ci : cs_findchan(channel); + Channel *targetchan = Channel::Find(channel); + const ChannelInfo *targetchan_ci = targetchan ? *targetchan->ci : ChannelInfo::Find(channel); if (targetchan && targetchan->HasMode(CMODE_SECRET)) return true; @@ -137,7 +137,7 @@ class CommandOSSeen : public Command else if (params[0].equals_ci("CLEAR")) { time_t time = 0; - if ((params.size() < 2) || (0 >= (time = dotime(params[1])))) + if ((params.size() < 2) || (0 >= (time = Anope::DoTime(params[1])))) { this->OnSyntaxError(source, params[0]); return; @@ -151,14 +151,14 @@ class CommandOSSeen : public Command ++it; if (time < buf->second->last) { - Log(LOG_DEBUG) << buf->first << " was last seen " << do_strftime(buf->second->last) << ", deleting entry"; - buf->second->destroy(); + Log(LOG_DEBUG) << buf->first << " was last seen " << Anope::strftime(buf->second->last) << ", deleting entry"; + buf->second->Destroy(); database.erase(buf); counter++; } } - Log(LOG_ADMIN, source, this) << "CLEAR and removed " << counter << " nicks that were added after " << do_strftime(time, NULL, true); - source.Reply(_("Database cleared, removed %lu nicks that were added after %s"), counter, do_strftime(time, source.nc, true).c_str()); + Log(LOG_ADMIN, source, this) << "CLEAR and removed " << counter << " nicks that were added after " << Anope::strftime(time, NULL, true); + source.Reply(_("Database cleared, removed %lu nicks that were added after %s"), counter, Anope::strftime(time, source.nc, true).c_str()); } else this->SendSyntax(source); @@ -199,7 +199,7 @@ class CommandSeen : public Command return; } - if (findbot(target) != NULL) + if (BotInfo::Find(target, true) != NULL) { source.Reply(_("%s is a client on services."), target.c_str()); return; @@ -218,15 +218,15 @@ class CommandSeen : public Command return; } - User *u2 = finduser(target); + User *u2 = User::Find(target, true); Anope::string onlinestatus; if (u2) onlinestatus = "."; else onlinestatus = Anope::printf(_(" but %s mysteriously dematerialized."), target.c_str()); - Anope::string timebuf = duration(Anope::CurTime - info->last, source.nc); - Anope::string timebuf2 = do_strftime(info->last, source.nc, true); + Anope::string timebuf = Anope::Duration(Anope::CurTime - info->last, source.nc); + Anope::string timebuf2 = Anope::strftime(info->last, source.nc, true); if (info->type == NEW) { @@ -235,7 +235,7 @@ class CommandSeen : public Command } else if (info->type == NICK_TO) { - u2 = finduser(info->nick2); + u2 = User::Find(info->nick2, true); if (u2) onlinestatus = Anope::printf( _(". %s is still online."), u2->nick.c_str()); else @@ -309,8 +309,8 @@ class DataBasePurger : public CallBack if ((Anope::CurTime - cur->second->last) > purgetime) { - Log(LOG_DEBUG) << cur->first << " was last seen " << do_strftime(cur->second->last) << ", purging entry"; - cur->second->destroy(); + Log(LOG_DEBUG) << cur->first << " was last seen " << Anope::strftime(cur->second->last) << ", purging entry"; + cur->second->Destroy(); database.erase(cur); } } @@ -320,12 +320,12 @@ class DataBasePurger : public CallBack class CSSeen : public Module { - SerializeType seeninfo_type; + Serialize::Type seeninfo_type; CommandSeen commandseen; CommandOSSeen commandosseen; DataBasePurger purger; public: - CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), seeninfo_type("SeenInfo", SeenInfo::unserialize), commandseen(this), commandosseen(this), purger(this) + CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this), purger(this) { this->SetAuthor("Anope"); @@ -344,14 +344,14 @@ class CSSeen : public Module void OnReload() anope_override { ConfigReader config; - purgetime = dotime(config.ReadValue("cs_seen", "purgetime", "30d", 0)); - expiretimeout = dotime(config.ReadValue("cs_seen", "expiretimeout", "1d", 0)); + purgetime = Anope::DoTime(config.ReadValue("cs_seen", "purgetime", "30d", 0)); + expiretimeout = Anope::DoTime(config.ReadValue("cs_seen", "expiretimeout", "1d", 0)); if (purger.GetSecs() != expiretimeout) purger.SetSecs(expiretimeout); } - void OnUserConnect(dynamic_reference<User> &u, bool &exempt) anope_override + void OnUserConnect(Reference<User> &u, bool &exempt) anope_override { if (u) UpdateUser(u, NEW, u->nick, "", "", ""); diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp index 9851a27a1..0ac07e2b2 100644 --- a/modules/commands/cs_set.cpp +++ b/modules/commands/cs_set.cpp @@ -43,7 +43,7 @@ class CommandCSSet : public Command const CommandInfo &info = it->second; if (c_name.find_ci(this_name + " ") == 0) { - service_reference<Command> command("Command", info.name); + ServiceReference<Command> command("Command", info.name); if (command) { source.command = it->first; diff --git a/modules/commands/cs_set_autoop.cpp b/modules/commands/cs_set_autoop.cpp index 8e576be3d..0b00b151b 100644 --- a/modules/commands/cs_set_autoop.cpp +++ b/modules/commands/cs_set_autoop.cpp @@ -24,7 +24,7 @@ class CommandCSSetAutoOp : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_set_bantype.cpp b/modules/commands/cs_set_bantype.cpp index a963720ff..e7dfc52ee 100644 --- a/modules/commands/cs_set_bantype.cpp +++ b/modules/commands/cs_set_bantype.cpp @@ -24,7 +24,7 @@ class CommandCSSetBanType : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_set_chanstats.cpp b/modules/commands/cs_set_chanstats.cpp index 904d7fb22..118387ee4 100644 --- a/modules/commands/cs_set_chanstats.cpp +++ b/modules/commands/cs_set_chanstats.cpp @@ -24,7 +24,7 @@ class CommandCSSetChanstats : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_set_description.cpp b/modules/commands/cs_set_description.cpp index b72c2cf8e..a5ad525ab 100644 --- a/modules/commands/cs_set_description.cpp +++ b/modules/commands/cs_set_description.cpp @@ -24,7 +24,7 @@ class CommandCSSetDescription : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_set_founder.cpp b/modules/commands/cs_set_founder.cpp index a1be1ba91..25b43d481 100644 --- a/modules/commands/cs_set_founder.cpp +++ b/modules/commands/cs_set_founder.cpp @@ -24,7 +24,7 @@ class CommandCSSetFounder : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -48,7 +48,7 @@ class CommandCSSetFounder : public Command return; } - const NickAlias *na = findnick(params[1]); + const NickAlias *na = NickAlias::Find(params[1]); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, params[1].c_str()); diff --git a/modules/commands/cs_set_keeptopic.cpp b/modules/commands/cs_set_keeptopic.cpp index d95d4ac2b..24b3d4f03 100644 --- a/modules/commands/cs_set_keeptopic.cpp +++ b/modules/commands/cs_set_keeptopic.cpp @@ -24,7 +24,7 @@ class CommandCSSetKeepTopic : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index b5a01174e..3bf0e9bbd 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -14,7 +14,7 @@ struct CSMiscData : ExtensibleItem, Serializable { - serialize_obj<ChannelInfo> ci; + Serialize::Reference<ChannelInfo> ci; Anope::string name; Anope::string data; @@ -22,7 +22,7 @@ struct CSMiscData : ExtensibleItem, Serializable { } - Serialize::Data serialize() const anope_override + Serialize::Data Serialize() const anope_override { Serialize::Data sdata; @@ -33,9 +33,9 @@ struct CSMiscData : ExtensibleItem, Serializable return sdata; } - static Serializable* unserialize(Serializable *obj, Serialize::Data &data) + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { - ChannelInfo *ci = cs_findchan(data["ci"].astr()); + ChannelInfo *ci = ChannelInfo::Find(data["ci"].astr()); if (ci == NULL) return NULL; @@ -75,7 +75,7 @@ class CommandCSSetMisc : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -108,12 +108,12 @@ class CommandCSSetMisc : public Command class CSSetMisc : public Module { - SerializeType csmiscdata_type; + Serialize::Type csmiscdata_type; CommandCSSetMisc commandcssetmisc; public: CSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - csmiscdata_type("CSMiscData", CSMiscData::unserialize), commandcssetmisc(this) + csmiscdata_type("CSMiscData", CSMiscData::Unserialize), commandcssetmisc(this) { this->SetAuthor("Anope"); diff --git a/modules/commands/cs_set_peace.cpp b/modules/commands/cs_set_peace.cpp index f7eb8af6b..35459b59b 100644 --- a/modules/commands/cs_set_peace.cpp +++ b/modules/commands/cs_set_peace.cpp @@ -24,7 +24,7 @@ class CommandCSSetPeace : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_set_persist.cpp b/modules/commands/cs_set_persist.cpp index bdd3b9004..03e5d3a84 100644 --- a/modules/commands/cs_set_persist.cpp +++ b/modules/commands/cs_set_persist.cpp @@ -24,7 +24,7 @@ class CommandCSSetPersist : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -60,21 +60,19 @@ class CommandCSSetPersist : public Command ci->bi->Join(c); } - /* No botserv bot, no channel mode */ - /* Give them ChanServ - * Yes, this works fine with no Config->s_BotServ + /* No botserv bot, no channel mode, give them ChanServ. + * Yes, this works fine with no Config->BotServ. */ if (!ci->bi && !cm) { - BotInfo *bi = findbot(Config->ChanServ); - if (!bi) + if (!ChanServ) { source.Reply(_("ChanServ is required to enable persist on this network.")); return; } - bi->Assign(NULL, ci); - if (!ci->c->FindUser(bi)) - bi->Join(ci->c); + ChanServ->Assign(NULL, ci); + if (!ci->c->FindUser(ChanServ)) + ChanServ->Join(ci->c); } /* Set the perm mode */ @@ -111,14 +109,13 @@ class CommandCSSetPersist : public Command */ if (!cm && Config->BotServ.empty() && ci->bi) { - BotInfo *bi = findbot(Config->ChanServ); - if (!bi) + if (!ChanServ) { source.Reply(_("ChanServ is required to enable persist on this network.")); return; } /* Unassign bot */ - bi->UnAssign(NULL, ci); + ChanServ->UnAssign(NULL, ci); } } diff --git a/modules/commands/cs_set_private.cpp b/modules/commands/cs_set_private.cpp index 45741eb20..a677aaf38 100644 --- a/modules/commands/cs_set_private.cpp +++ b/modules/commands/cs_set_private.cpp @@ -24,7 +24,7 @@ class CommandCSSetPrivate : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_set_restricted.cpp b/modules/commands/cs_set_restricted.cpp index 8b520006a..45a9b188e 100644 --- a/modules/commands/cs_set_restricted.cpp +++ b/modules/commands/cs_set_restricted.cpp @@ -23,7 +23,7 @@ class CommandCSSetRestricted : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_set_secure.cpp b/modules/commands/cs_set_secure.cpp index 84ea75121..7659c8674 100644 --- a/modules/commands/cs_set_secure.cpp +++ b/modules/commands/cs_set_secure.cpp @@ -24,7 +24,7 @@ class CommandCSSetSecure : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_set_securefounder.cpp b/modules/commands/cs_set_securefounder.cpp index b8d7ac14f..d3d22f294 100644 --- a/modules/commands/cs_set_securefounder.cpp +++ b/modules/commands/cs_set_securefounder.cpp @@ -24,7 +24,7 @@ class CommandCSSetSecureFounder : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_set_secureops.cpp b/modules/commands/cs_set_secureops.cpp index c92401e59..9a95735be 100644 --- a/modules/commands/cs_set_secureops.cpp +++ b/modules/commands/cs_set_secureops.cpp @@ -24,7 +24,7 @@ class CommandCSSetSecureOps : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_set_signkick.cpp b/modules/commands/cs_set_signkick.cpp index 52d3934af..f3b482a67 100644 --- a/modules/commands/cs_set_signkick.cpp +++ b/modules/commands/cs_set_signkick.cpp @@ -24,7 +24,7 @@ class CommandCSSetSignKick : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_set_successor.cpp b/modules/commands/cs_set_successor.cpp index 64f875dce..8b36d6853 100644 --- a/modules/commands/cs_set_successor.cpp +++ b/modules/commands/cs_set_successor.cpp @@ -24,7 +24,7 @@ class CommandCSSetSuccessor : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -55,7 +55,7 @@ class CommandCSSetSuccessor : public Command if (params.size() > 1) { - const NickAlias *na = findnick(params[1]); + const NickAlias *na = NickAlias::Find(params[1]); if (!na) { diff --git a/modules/commands/cs_set_topiclock.cpp b/modules/commands/cs_set_topiclock.cpp index eb0d75e2a..9212d291d 100644 --- a/modules/commands/cs_set_topiclock.cpp +++ b/modules/commands/cs_set_topiclock.cpp @@ -24,7 +24,7 @@ class CommandCSSetTopicLock : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_status.cpp b/modules/commands/cs_status.cpp index b8ac38f77..4d609eb8d 100644 --- a/modules/commands/cs_status.cpp +++ b/modules/commands/cs_status.cpp @@ -26,7 +26,7 @@ public: { const Anope::string &channel = params[0]; - ChannelInfo *ci = cs_findchan(channel); + ChannelInfo *ci = ChannelInfo::Find(channel); if (ci == NULL) source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str()); else if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && !source.HasPriv("chanserv/access/modify")) @@ -38,20 +38,20 @@ public: nick = params[1]; AccessGroup ag; - User *u = finduser(nick); + User *u = User::Find(nick, true); NickAlias *na = NULL; if (u != NULL) ag = ci->AccessFor(u); else { - na = findnick(nick); + na = NickAlias::Find(nick); if (na != NULL) ag = ci->AccessFor(na->nc); } - if (ag.SuperAdmin) + if (ag.super_admin) source.Reply(_("\2%s\2 is a super administrator."), nick.c_str()); - else if (ag.Founder) + else if (ag.founder) source.Reply(_("\2%s\2 is the channel founder."), nick.c_str()); else if (ag.empty()) source.Reply(_("\2%s\2 has no access on \2%s\2."), nick.c_str(), ci->name.c_str()); @@ -63,7 +63,7 @@ public: { ChanAccess *acc = ag[i]; - source.Reply(_("\2%s\2 matches access entry %s, which has privilege %s."), nick.c_str(), acc->mask.c_str(), acc->Serialize().c_str()); + source.Reply(_("\2%s\2 matches access entry %s, which has privilege %s."), nick.c_str(), acc->mask.c_str(), acc->AccessSerialize().c_str()); } } diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index bce549e79..b380d4c97 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -22,7 +22,7 @@ struct ChanSuspend : ExtensibleItem, Serializable { } - Serialize::Data serialize() const anope_override + Serialize::Data Serialize() const anope_override { Serialize::Data sd; @@ -32,9 +32,9 @@ struct ChanSuspend : ExtensibleItem, Serializable return sd; } - static Serializable* unserialize(Serializable *obj, Serialize::Data &sd) + static Serializable* Unserialize(Serializable *obj, Serialize::Data &sd) { - ChannelInfo *ci = cs_findchan(sd["chan"].astr()); + ChannelInfo *ci = ChannelInfo::Find(sd["chan"].astr()); if (ci == NULL) return NULL; @@ -77,7 +77,7 @@ class CommandCSSuspend : public Command expiry.clear(); } else - expiry_secs = dotime(expiry); + expiry_secs = Anope::DoTime(expiry); if (Config->ForceForbidReason && reason.empty()) { @@ -85,10 +85,10 @@ class CommandCSSuspend : public Command return; } - if (readonly) + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); - ChannelInfo *ci = cs_findchan(chan); + ChannelInfo *ci = ChannelInfo::Find(chan); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); @@ -113,7 +113,7 @@ class CommandCSSuspend : public Command } for (unsigned i = 0; i < users.size(); ++i) - ci->c->Kick(NULL, users[i], "%s", !reason.empty() ? reason.c_str() : translate(users[i], _("This channel has been suspended."))); + ci->c->Kick(NULL, users[i], "%s", !reason.empty() ? reason.c_str() : Language::Translate(users[i], _("This channel has been suspended."))); } if (expiry_secs > 0) @@ -125,7 +125,7 @@ class CommandCSSuspend : public Command ci->Extend("cs_suspend_expire", cs); } - Log(LOG_ADMIN, source, this, ci) << (!reason.empty() ? reason : "No reason") << ", expires in " << (expiry_secs ? do_strftime(Anope::CurTime + expiry_secs) : "never"); + Log(LOG_ADMIN, source, this, ci) << (!reason.empty() ? reason : "No reason") << ", expires in " << (expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); source.Reply(_("Channel \002%s\002 is now suspended."), ci->name.c_str()); FOREACH_MOD(I_OnChanSuspend, OnChanSuspend(ci)); @@ -161,10 +161,10 @@ class CommandCSUnSuspend : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (readonly) + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -206,13 +206,13 @@ class CommandCSUnSuspend : public Command class CSSuspend : public Module { - SerializeType chansuspend_type; + Serialize::Type chansuspend_type; CommandCSSuspend commandcssuspend; CommandCSUnSuspend commandcsunsuspend; public: CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - chansuspend_type("ChanSuspend", ChanSuspend::unserialize), commandcssuspend(this), commandcsunsuspend(this) + chansuspend_type("ChanSuspend", ChanSuspend::Unserialize), commandcssuspend(this), commandcsunsuspend(this) { this->SetAuthor("Anope"); @@ -247,7 +247,7 @@ class CSSuspend : public Module ci->Shrink("suspend_by"); ci->Shrink("suspend_reason"); - Log(LOG_NORMAL, "expire", findbot(Config->ChanServ)) << "Expiring suspend for " << ci->name; + Log(LOG_NORMAL, "expire", ChanServ) << "Expiring suspend for " << ci->name; } } }; diff --git a/modules/commands/cs_sync.cpp b/modules/commands/cs_sync.cpp index e55864f1b..23d6928a1 100644 --- a/modules/commands/cs_sync.cpp +++ b/modules/commands/cs_sync.cpp @@ -22,7 +22,7 @@ class CommandCSSync : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -35,7 +35,7 @@ class CommandCSSync : public Command Log(LOG_COMMAND, source, this, ci); for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) - chan_set_correct_modes((*it)->user, ci->c, 1, false); + ci->c->SetCorrectModes((*it)->user, true, false); source.Reply(_("All user modes on \002%s\002 have been synced."), ci->name.c_str()); } diff --git a/modules/commands/cs_tban.cpp b/modules/commands/cs_tban.cpp index 1120d05d4..40fdfedb9 100644 --- a/modules/commands/cs_tban.cpp +++ b/modules/commands/cs_tban.cpp @@ -22,7 +22,7 @@ static Module *me; class TempBan : public CallBack { private: - dynamic_reference<Channel> chan; + Reference<Channel> chan; Anope::string mask; public: @@ -46,7 +46,7 @@ class CommandCSTBan : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); const Anope::string &nick = params[1]; const Anope::string &time = params[2]; @@ -58,23 +58,22 @@ class CommandCSTBan : public Command source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str()); else if (!source.AccessFor(c->ci).HasPriv("BAN")) source.Reply(ACCESS_DENIED); - else if (!(u2 = finduser(nick))) + else if (!(u2 = User::Find(nick, true))) source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); - else if (matches_list(c, u2, CMODE_EXCEPT)) + else if (c->MatchesList(u2, CMODE_EXCEPT)) source.Reply(CHAN_EXCEPTED, u2->nick.c_str(), c->ci->name.c_str()); else if (u2->IsProtected()) source.Reply(ACCESS_DENIED); else { - time_t t = dotime(time); - Anope::string mask; - get_idealban(c->ci, u2, mask); + time_t t = Anope::DoTime(time); + Anope::string mask = c->ci->GetIdealBan(u2); c->SetMode(NULL, CMODE_BAN, mask); new TempBan(t, c, mask); - Log(LOG_COMMAND, source, this, c->ci) << "for " << mask << " to expire in " << duration(t); + Log(LOG_COMMAND, source, this, c->ci) << "for " << mask << " to expire in " << Anope::Duration(t); - source.Reply(_("%s banned from %s, will auto-expire in %s."), mask.c_str(), c->name.c_str(), duration(t).c_str()); + source.Reply(_("%s banned from %s, will auto-expire in %s."), mask.c_str(), c->name.c_str(), Anope::Duration(t).c_str()); } return; diff --git a/modules/commands/cs_topic.cpp b/modules/commands/cs_topic.cpp index 3474874d6..eccb8b2f6 100644 --- a/modules/commands/cs_topic.cpp +++ b/modules/commands/cs_topic.cpp @@ -27,7 +27,7 @@ class CommandCSTopic : public Command const Anope::string &topic = params.size() > 1 ? params[1] : ""; - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/cs_unban.cpp b/modules/commands/cs_unban.cpp index b60dfebcf..affe8eae9 100644 --- a/modules/commands/cs_unban.cpp +++ b/modules/commands/cs_unban.cpp @@ -24,7 +24,7 @@ class CommandCSUnban : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -45,7 +45,7 @@ class CommandCSUnban : public Command User *u2 = source.GetUser(); if (params.size() > 1) - u2 = finduser(params[1]); + u2 = User::Find(params[1], true); if (!u2) { @@ -55,7 +55,7 @@ class CommandCSUnban : public Command Log(LOG_COMMAND, source, this, ci) << "to unban " << u2->nick; - common_unban(ci, u2, source.GetUser() == u2); + ci->c->Unban(u2, source.GetUser() == u2); if (u2 == source.GetUser()) source.Reply(_("You have been unbanned from \002%s\002."), ci->c->name.c_str()); else diff --git a/modules/commands/cs_updown.cpp b/modules/commands/cs_updown.cpp index 4d84ff5f5..6d46c873e 100644 --- a/modules/commands/cs_updown.cpp +++ b/modules/commands/cs_updown.cpp @@ -32,19 +32,19 @@ class CommandCSUp : public Command for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end(); ++it) { Channel *c = (*it)->chan; - chan_set_correct_modes(u, c, 1, false); + c->SetCorrectModes(u, true, false); } else { const Anope::string &channel = params[0]; - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); if (c == NULL) source.Reply(CHAN_X_NOT_IN_USE, channel.c_str()); else if (!c->ci) source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str()); else - chan_set_correct_modes(u, c, 1, false); + c->SetCorrectModes(u, true, false); } } @@ -67,7 +67,7 @@ class CommandCSDown : public Command { ChannelMode *cm = ModeManager::ChannelModes[i]; - if (cm != NULL && cm->Type == MODE_STATUS) + if (cm != NULL && cm->type == MODE_STATUS) c->RemoveMode(NULL, cm, u->nick); } } @@ -94,7 +94,7 @@ class CommandCSDown : public Command else { const Anope::string &channel = params[0]; - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); if (c == NULL) source.Reply(CHAN_X_NOT_IN_USE, channel.c_str()); diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index 1fc3cbdf0..77f6cb5a0 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -118,7 +118,7 @@ class XOPChanAccess : public ChanAccess return false; } - Anope::string Serialize() const + Anope::string AccessSerialize() const { for (int i = 0; xopAccess[i].type != XOP_UNKNOWN; ++i) { @@ -131,7 +131,7 @@ class XOPChanAccess : public ChanAccess return ""; } - void Unserialize(const Anope::string &data) anope_override + void AccessUnserialize(const Anope::string &data) anope_override { for (int i = 0; xopAccess[i].type != XOP_UNKNOWN; ++i) { @@ -210,7 +210,7 @@ class XOPBase : public Command return; } - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, channel %s list modification is temporarily disabled."), source.command.c_str()); return; @@ -224,7 +224,7 @@ class XOPBase : public Command const ChanAccess *highest = access.Highest(); bool override = false; - if ((!access.Founder && !access.HasPriv("ACCESS_CHANGE")) || ((!highest || *highest <= tmp_access) && !access.Founder)) + if ((!access.founder && !access.HasPriv("ACCESS_CHANGE")) || ((!highest || *highest <= tmp_access) && !access.founder)) { if (source.HasPriv("chanserv/access/modify")) override = true; @@ -235,9 +235,9 @@ class XOPBase : public Command } } - if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask)) + if (mask.find_first_of("!*@") == Anope::string::npos && !NickAlias::Find(mask)) { - User *targ = finduser(mask); + User *targ = User::Find(mask, true); if (targ != NULL) mask = "*!*@" + targ->GetDisplayedHost(); else @@ -253,7 +253,7 @@ class XOPBase : public Command if (a->mask.equals_ci(mask)) { - if ((!highest || *a >= *highest) && !access.Founder && !source.HasPriv("chanserv/access/modify")) + if ((!highest || *a >= *highest) && !access.founder && !source.HasPriv("chanserv/access/modify")) { source.Reply(ACCESS_DENIED); return; @@ -270,7 +270,7 @@ class XOPBase : public Command return; } - service_reference<AccessProvider> provider("AccessProvider", "access/xop"); + ServiceReference<AccessProvider> provider("AccessProvider", "access/xop"); if (!provider) return; XOPChanAccess *acc = anope_dynamic_static_cast<XOPChanAccess *>(provider->Create()); @@ -299,7 +299,7 @@ class XOPBase : public Command return; } - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, channel %s list modification is temporarily disabled."), source.command.c_str()); return; @@ -319,9 +319,9 @@ class XOPBase : public Command const ChanAccess *highest = access.Highest(); bool override = false; - if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask)) + if (mask.find_first_of("!*@") == Anope::string::npos && !NickAlias::Find(mask)) { - User *targ = finduser(mask); + User *targ = User::Find(mask, true); if (targ != NULL) mask = "*!*@" + targ->GetDisplayedHost(); else @@ -331,7 +331,7 @@ class XOPBase : public Command } } - if ((!mask.equals_ci(nc->display) && !access.HasPriv("ACCESS_CHANGE") && !access.Founder) || ((!highest || tmp_access >= *highest) && !access.Founder)) + if ((!mask.equals_ci(nc->display) && !access.HasPriv("ACCESS_CHANGE") && !access.founder) || ((!highest || tmp_access >= *highest) && !access.founder)) { if (source.HasPriv("chanserv/access/modify")) override = true; @@ -350,49 +350,49 @@ class XOPBase : public Command CommandSource &source; ChannelInfo *ci; Command *c; - unsigned Deleted; - Anope::string Nicks; + unsigned deleted; + Anope::string nicks; bool override; XOPType type; public: - XOPDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, bool _override, XOPType _type, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), Deleted(0), override(_override), type(_type) + XOPDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, bool _override, XOPType _type, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), deleted(0), override(_override), type(_type) { } ~XOPDelCallback() { - if (!Deleted) + if (!deleted) source.Reply(_("No matching entries on %s %s list."), ci->name.c_str(), source.command.c_str()); else { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Nicks; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << nicks; - if (Deleted == 1) + if (deleted == 1) source.Reply(_("Deleted one entry from %s %s list."), ci->name.c_str(), source.command.c_str()); else - source.Reply(_("Deleted %d entries from %s %s list."), Deleted, ci->name.c_str(), source.command.c_str()); + source.Reply(_("Deleted %d entries from %s %s list."), deleted, ci->name.c_str(), source.command.c_str()); } } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned number) anope_override { - if (!Number || Number > ci->GetAccessCount()) + if (!number || number > ci->GetAccessCount()) return; - ChanAccess *caccess = ci->GetAccess(Number - 1); + ChanAccess *caccess = ci->GetAccess(number - 1); if (this->type != XOPChanAccess::DetermineLevel(caccess)) return; - ++Deleted; - if (!Nicks.empty()) - Nicks += ", " + caccess->mask; + ++deleted; + if (!nicks.empty()) + nicks += ", " + caccess->mask; else - Nicks = caccess->mask; + nicks = caccess->mask; FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, caccess)); - ci->EraseAccess(Number - 1); + ci->EraseAccess(number - 1); } } delcallback(source, ci, this, override, level, mask); @@ -441,7 +441,7 @@ class XOPBase : public Command } ListFormatter list; - list.addColumn("Number").addColumn("Mask"); + list.AddColumn("Number").AddColumn("Mask"); if (!nick.empty() && nick.find_first_not_of("1234567890,-") == Anope::string::npos) { @@ -468,7 +468,7 @@ class XOPBase : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(Number); entry["Mask"] = a->mask; - this->list.addEntry(entry); + this->list.AddEntry(entry); } } nl_list(list, ci, nick, level); nl_list.Process(); @@ -487,11 +487,11 @@ class XOPBase : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(i + 1); entry["Mask"] = a->mask; - list.addEntry(entry); + list.AddEntry(entry); } } - if (list.isEmpty()) + if (list.IsEmpty()) source.Reply(_("No matching entries on %s access list."), ci->name.c_str()); else { @@ -507,7 +507,7 @@ class XOPBase : public Command void DoClear(CommandSource &source, ChannelInfo *ci, XOPType level) { - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, channel %s list modification is temporarily disabled."), source.command.c_str()); return; @@ -545,7 +545,7 @@ class XOPBase : public Command protected: void DoXop(CommandSource &source, const std::vector<Anope::string> ¶ms, XOPType level) { - ChannelInfo *ci = cs_findchan(params[0]); + ChannelInfo *ci = ChannelInfo::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/gl_global.cpp b/modules/commands/gl_global.cpp index 09d44f9a0..2be0164e3 100644 --- a/modules/commands/gl_global.cpp +++ b/modules/commands/gl_global.cpp @@ -27,12 +27,12 @@ class CommandGLGlobal : public Command { const Anope::string &msg = params[0]; - if (!global) + if (!GlobalService) source.Reply("No global reference, is gl_main loaded?"); else { Log(LOG_ADMIN, source, this); - global->SendGlobal(findbot(Config->Global), source.GetNick(), msg); + GlobalService->SendGlobal(Global, source.GetNick(), msg); } } diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp index de80a6ec1..252406590 100644 --- a/modules/commands/help.cpp +++ b/modules/commands/help.cpp @@ -41,11 +41,12 @@ class CommandHelp : public Command const CommandInfo &info = it->second; // Smaller command exists - Anope::string cmd = myStrGetToken(c_name, ' ', 0); + Anope::string cmd; + spacesepstream(c_name).GetToken(cmd, 0); if (cmd != it->first && map.count(cmd)) continue; - service_reference<Command> c("Command", info.name); + ServiceReference<Command> c("Command", info.name); if (!c) continue; else if (!Config->HidePrivilegedCommands) @@ -76,7 +77,7 @@ class CommandHelp : public Command const CommandInfo &info = it->second; - service_reference<Command> c("Command", info.name); + ServiceReference<Command> c("Command", info.name); if (!c) continue; else if (!Config->HidePrivilegedCommands) diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp index 9ad39a95d..4e2cdc8b7 100644 --- a/modules/commands/hs_del.cpp +++ b/modules/commands/hs_del.cpp @@ -25,7 +25,7 @@ class CommandHSDel : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { const Anope::string &nick = params[0]; - NickAlias *na = findnick(nick); + NickAlias *na = NickAlias::Find(nick); if (na) { Log(LOG_ADMIN, source, this) << "for user " << na->nick; @@ -59,12 +59,12 @@ class CommandHSDelAll : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { const Anope::string &nick = params[0]; - NickAlias *na = findnick(nick); + NickAlias *na = NickAlias::Find(nick); if (na) { FOREACH_MOD(I_OnDeleteVhost, OnDeleteVhost(na)); const NickCore *nc = na->nc; - for (std::list<serialize_obj<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it) + for (std::list<Serialize::Reference<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it) { na = *it; na->RemoveVhost(); diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp index 22538ed1a..5d8bc069e 100644 --- a/modules/commands/hs_group.cpp +++ b/modules/commands/hs_group.cpp @@ -20,7 +20,7 @@ class CommandHSGroup : public Command if (!na || !na->HasVhost()) return; - for (std::list<serialize_obj<NickAlias> >::const_iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end;) + for (std::list<Serialize::Reference<NickAlias> >::const_iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end;) { NickAlias *nick = *it++; if (nick) @@ -37,7 +37,7 @@ class CommandHSGroup : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - NickAlias *na = findnick(source.GetNick()); + NickAlias *na = NickAlias::Find(source.GetNick()); if (na && source.GetAccount() == na->nc && na->HasVhost()) { this->Sync(na); diff --git a/modules/commands/hs_list.cpp b/modules/commands/hs_list.cpp index 9e708f0b4..29fa145b3 100644 --- a/modules/commands/hs_list.cpp +++ b/modules/commands/hs_list.cpp @@ -57,7 +57,7 @@ class CommandHSList : public Command unsigned display_counter = 0; ListFormatter list; - list.addColumn("Number").addColumn("Nick").addColumn("Vhost").addColumn("Creator").addColumn("Created"); + list.AddColumn("Number").AddColumn("Nick").AddColumn("Vhost").AddColumn("Creator").AddColumn("Created"); for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) { @@ -80,8 +80,8 @@ class CommandHSList : public Command else entry["Vhost"] = na->GetVhostHost(); entry["Creator"] = na->GetVhostCreator(); - entry["Created"] = do_strftime(na->GetVhostCreated()); - list.addEntry(entry); + entry["Created"] = Anope::strftime(na->GetVhostCreated()); + list.AddEntry(entry); } } else @@ -101,8 +101,8 @@ class CommandHSList : public Command else entry["Vhost"] = na->GetVhostHost(); entry["Creator"] = na->GetVhostCreator(); - entry["Created"] = do_strftime(na->GetVhostCreated()); - list.addEntry(entry); + entry["Created"] = Anope::strftime(na->GetVhostCreated()); + list.AddEntry(entry); } } ++counter; diff --git a/modules/commands/hs_off.cpp b/modules/commands/hs_off.cpp index 39b701fed..27c6c0756 100644 --- a/modules/commands/hs_off.cpp +++ b/modules/commands/hs_off.cpp @@ -28,13 +28,13 @@ class CommandHSOff : public Command if (!u) return; - const NickAlias *na = findnick(u->nick); + const NickAlias *na = NickAlias::Find(u->nick); if (!na || !na->HasVhost()) source.Reply(HOST_NOT_ASSIGNED); else { - ircdproto->SendVhostDel(u); + IRCD->SendVhostDel(u); Log(LOG_COMMAND, source, this) << "to disable their vhost"; source.Reply(_("Your vhost was removed and the normal cloaking restored.")); } diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp index d02dd7dfe..c4cf2fee8 100644 --- a/modules/commands/hs_on.cpp +++ b/modules/commands/hs_on.cpp @@ -27,10 +27,10 @@ class CommandHSOn : public Command User *u = source.GetUser(); if (!u) return; - else if (!ircdproto->CanSetVHost) + else if (!IRCD->CanSetVHost) return; // HostServ wouldn't even be loaded at this point - const NickAlias *na = findnick(u->nick); + const NickAlias *na = NickAlias::Find(u->nick); if (na && u->Account() == na->nc && na->HasVhost()) { if (!na->GetVhostIdent().empty()) @@ -38,9 +38,9 @@ class CommandHSOn : public Command else source.Reply(_("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str()); Log(LOG_COMMAND, source, this) << "to enable their vhost of " << (!na->GetVhostIdent().empty() ? na->GetVhostIdent() + "@" : "") << na->GetVhostHost(); - ircdproto->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost()); + IRCD->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost()); u->vhost = na->GetVhostHost(); - if (ircdproto->CanSetVIdent && !na->GetVhostIdent().empty()) + if (IRCD->CanSetVIdent && !na->GetVhostIdent().empty()) u->SetVIdent(na->GetVhostIdent()); u->UpdateHost(); } diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index 8a9de386b..b11059f90 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -32,21 +32,21 @@ struct HostRequest : ExtensibleItem, Serializable HostRequest() : Serializable("HostRequest") { } - Serialize::Data serialize() const anope_override + Serialize::Data Serialize() const anope_override { Serialize::Data data; data["nick"] << this->nick; data["ident"] << this->ident; data["host"] << this->host; - data["time"].setType(Serialize::DT_INT) << this->time; + data["time"].SetType(Serialize::DT_INT) << this->time; return data; } - static Serializable* unserialize(Serializable *obj, Serialize::Data &data) + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { - NickAlias *na = findnick(data["nick"].astr()); + NickAlias *na = NickAlias::Find(data["nick"].astr()); if (na == NULL) return NULL; @@ -85,7 +85,7 @@ class CommandHSRequest : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { User *u = source.GetUser(); - NickAlias *na = findnick(source.GetNick()); + NickAlias *na = NickAlias::Find(source.GetNick()); if (!na || na->nc != source.GetAccount()) { source.Reply(ACCESS_DENIED); @@ -118,7 +118,7 @@ class CommandHSRequest : public Command source.Reply(HOST_SET_IDENTTOOLONG, Config->UserLen); return; } - else if (!ircdproto->CanSetVIdent) + else if (!IRCD->CanSetVIdent) { source.Reply(HOST_NO_VIDENT); return; @@ -137,7 +137,7 @@ class CommandHSRequest : public Command return; } - if (!IsValidHost(host)) + if (!IRCD->IsHostValid(host)) { source.Reply(HOST_SET_ERROR); return; @@ -190,15 +190,15 @@ class CommandHSActivate : public Command const Anope::string &nick = params[0]; - NickAlias *na = findnick(nick); + NickAlias *na = NickAlias::Find(nick); HostRequest *req = na ? na->GetExt<HostRequest *>("hs_request") : NULL; if (req) { na->SetVhost(req->ident, req->host, source.GetNick(), req->time); FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); - if (HSRequestMemoUser && memoserv) - memoserv->Send(Config->HostServ, na->nick, _("[auto memo] Your requested vHost has been approved."), true); + if (HSRequestMemoUser && MemoServService) + MemoServService->Send(Config->HostServ, na->nick, _("[auto memo] Your requested vHost has been approved."), true); source.Reply(_("vHost for %s has been activated"), na->nick.c_str()); Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host; @@ -234,13 +234,13 @@ class CommandHSReject : public Command const Anope::string &nick = params[0]; const Anope::string &reason = params.size() > 1 ? params[1] : ""; - NickAlias *na = findnick(nick); + NickAlias *na = NickAlias::Find(nick); HostRequest *req = na ? na->GetExt<HostRequest *>("hs_request") : NULL; if (req) { na->Shrink("hs_request"); - if (HSRequestMemoUser && memoserv) + if (HSRequestMemoUser && MemoServService) { Anope::string message; if (!reason.empty()) @@ -248,7 +248,7 @@ class CommandHSReject : public Command else message = _("[auto memo] Your requested vHost has been rejected."); - memoserv->Send(Config->HostServ, nick, message, true); + MemoServService->Send(Config->HostServ, nick, message, true); } source.Reply(_("vHost for %s has been rejected"), nick.c_str()); @@ -281,7 +281,7 @@ class CommandHSWaiting : public Command unsigned display_counter = 0; ListFormatter list; - list.addColumn("Number").addColumn("Nick").addColumn("Vhost").addColumn("Created"); + list.AddColumn("Number").AddColumn("Nick").AddColumn("Vhost").AddColumn("Created"); for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) { @@ -301,8 +301,8 @@ class CommandHSWaiting : public Command entry["Vhost"] = hr->ident + "@" + hr->host; else entry["Vhost"] = hr->host; - entry["Created"] = do_strftime(hr->time); - list.addEntry(entry); + entry["Created"] = Anope::strftime(hr->time); + list.AddEntry(entry); } ++counter; } @@ -339,7 +339,7 @@ class CommandHSWaiting : public Command class HSRequest : public Module { - SerializeType request_type; + Serialize::Type request_type; CommandHSRequest commandhsrequest; CommandHSActivate commandhsactive; CommandHSReject commandhsreject; @@ -347,11 +347,11 @@ class HSRequest : public Module public: HSRequest(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - request_type("HostRequest", HostRequest::unserialize), commandhsrequest(this), commandhsactive(this), commandhsreject(this), commandhswaiting(this) + request_type("HostRequest", HostRequest::Unserialize), commandhsrequest(this), commandhsactive(this), commandhsreject(this), commandhswaiting(this) { this->SetAuthor("Anope"); - if (!ircdproto || !ircdproto->CanSetVHost) + if (!IRCD || !IRCD->CanSetVHost) throw ModuleException("Your IRCd does not support vhosts"); Implementation i[] = { I_OnReload }; @@ -389,18 +389,18 @@ void req_send_memos(CommandSource &source, const Anope::string &vIdent, const An else host = vHost; - if (HSRequestMemoOper == 1 && memoserv) + if (HSRequestMemoOper == 1 && MemoServService) for (unsigned i = 0; i < Config->Opers.size(); ++i) { Oper *o = Config->Opers[i]; - const NickAlias *na = findnick(o->name); + const NickAlias *na = NickAlias::Find(o->name); if (!na) continue; Anope::string message = Anope::printf(_("[auto memo] vHost \002%s\002 has been requested by %s."), host.c_str(), source.GetNick().c_str()); - memoserv->Send(Config->HostServ, na->nick, message, true); + MemoServService->Send(Config->HostServ, na->nick, message, true); } } diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp index 2189f2483..bb4091da4 100644 --- a/modules/commands/hs_set.cpp +++ b/modules/commands/hs_set.cpp @@ -27,7 +27,7 @@ class CommandHSSet : public Command const Anope::string &nick = params[0]; - NickAlias *na = findnick(nick); + NickAlias *na = NickAlias::Find(nick); if (na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -55,12 +55,12 @@ class CommandHSSet : public Command if (!user.empty()) { - if (!ircdproto->CanSetVIdent) + if (!IRCD->CanSetVIdent) { source.Reply(HOST_NO_VIDENT); return; } - else if (!IsValidIdent(user)) + else if (!IRCD->IsIdentValid(user)) { source.Reply(HOST_SET_IDENT_ERROR); return; @@ -73,7 +73,7 @@ class CommandHSSet : public Command return; } - if (!IsValidHost(host)) + if (!IRCD->IsHostValid(host)) { source.Reply(HOST_SET_ERROR); return; @@ -108,7 +108,7 @@ class CommandHSSetAll : public Command if (!na || !na->HasVhost()) return; - for (std::list<serialize_obj<NickAlias> >::const_iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end;) + for (std::list<Serialize::Reference<NickAlias> >::const_iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end;) { NickAlias *nick = *it++; if (nick) @@ -128,7 +128,7 @@ class CommandHSSetAll : public Command Anope::string nick = params[0]; - NickAlias *na = findnick(nick); + NickAlias *na = NickAlias::Find(nick); if (na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -156,12 +156,12 @@ class CommandHSSetAll : public Command if (!user.empty()) { - if (!ircdproto->CanSetVIdent) + if (!IRCD->CanSetVIdent) { source.Reply(HOST_NO_VIDENT); return; } - else if (!IsValidIdent(user)) + else if (!IRCD->IsIdentValid(user)) { source.Reply(HOST_SET_IDENT_ERROR); return; @@ -174,7 +174,7 @@ class CommandHSSetAll : public Command return; } - if (!IsValidHost(host)) + if (!IRCD->IsHostValid(host)) { source.Reply(HOST_SET_ERROR); return; diff --git a/modules/commands/ms_cancel.cpp b/modules/commands/ms_cancel.cpp index e4ee9375e..8949baf17 100644 --- a/modules/commands/ms_cancel.cpp +++ b/modules/commands/ms_cancel.cpp @@ -25,14 +25,14 @@ class CommandMSCancel : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (!memoserv) + if (!MemoServService) return; const Anope::string &nname = params[0]; bool ischan; - MemoInfo *mi = memoserv->GetMemoInfo(nname, ischan); + MemoInfo *mi = MemoServService->GetMemoInfo(nname, ischan); if (mi == NULL) source.Reply(ischan ? CHAN_X_NOT_REGISTERED : _(NICK_X_NOT_REGISTERED), nname.c_str()); @@ -41,9 +41,9 @@ class CommandMSCancel : public Command ChannelInfo *ci = NULL; NickAlias *na = NULL; if (ischan) - ci = cs_findchan(nname); + ci = ChannelInfo::Find(nname); else - na = findnick(nname); + na = NickAlias::Find(nname); for (int i = mi->memos->size() - 1; i >= 0; --i) if (mi->GetMemo(i)->HasFlag(MF_UNREAD) && source.nc->display.equals_ci(mi->GetMemo(i)->sender)) { @@ -81,7 +81,7 @@ class MSCancel : public Module { this->SetAuthor("Anope"); - if (!memoserv) + if (!MemoServService) throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ms_check.cpp b/modules/commands/ms_check.cpp index 59340b6d7..8f34e7b9a 100644 --- a/modules/commands/ms_check.cpp +++ b/modules/commands/ms_check.cpp @@ -29,7 +29,7 @@ class CommandMSCheck : public Command bool found = false; - const NickAlias *na = findnick(recipient); + const NickAlias *na = NickAlias::Find(recipient); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, recipient.c_str()); @@ -48,9 +48,9 @@ class CommandMSCheck : public Command found = true; /* Yes, we've found the memo */ if (mi->GetMemo(i)->HasFlag(MF_UNREAD)) - source.Reply(_("The last memo you sent to %s (sent on %s) has not yet been read."), na->nick.c_str(), do_strftime(mi->GetMemo(i)->time).c_str()); + source.Reply(_("The last memo you sent to %s (sent on %s) has not yet been read."), na->nick.c_str(), Anope::strftime(mi->GetMemo(i)->time).c_str()); else - source.Reply(_("The last memo you sent to %s (sent on %s) has been read."), na->nick.c_str(), do_strftime(mi->GetMemo(i)->time).c_str()); + source.Reply(_("The last memo you sent to %s (sent on %s) has been read."), na->nick.c_str(), Anope::strftime(mi->GetMemo(i)->time).c_str()); break; } } diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp index 330f45e87..99b388e52 100644 --- a/modules/commands/ms_del.cpp +++ b/modules/commands/ms_del.cpp @@ -23,18 +23,18 @@ class MemoDelCallback : public NumberList { } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned number) anope_override { - if (!Number || Number > mi->memos->size()) + if (!number || number > mi->memos->size()) return; if (ci) - FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(Number - 1))); + FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(number - 1))); else - FOREACH_MOD(I_OnMemoDel, OnMemoDel(source.nc, mi, mi->GetMemo(Number - 1))); + FOREACH_MOD(I_OnMemoDel, OnMemoDel(source.nc, mi, mi->GetMemo(number - 1))); - mi->Del(Number - 1); - source.Reply(_("Memo %d has been deleted."), Number); + mi->Del(number - 1); + source.Reply(_("Memo %d has been deleted."), number); } }; @@ -59,13 +59,13 @@ class CommandMSDel : public Command chan = numstr; numstr = params.size() > 1 ? params[1] : ""; - ci = cs_findchan(chan); + ci = ChannelInfo::Find(chan); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); return; } - else if (readonly) + else if (Anope::ReadOnly) { source.Reply(READ_ONLY_MODE); return; @@ -114,7 +114,7 @@ class CommandMSDel : public Command FOREACH_MOD(I_OnMemoDel, OnMemoDel(ci, mi, mi->GetMemo(i))); else FOREACH_MOD(I_OnMemoDel, OnMemoDel(source.nc, mi, mi->GetMemo(i))); - mi->GetMemo(i)->destroy(); + mi->GetMemo(i)->Destroy(); } mi->memos->clear(); if (!chan.empty()) diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp index 84ce540a8..465714852 100644 --- a/modules/commands/ms_ignore.cpp +++ b/modules/commands/ms_ignore.cpp @@ -26,7 +26,7 @@ class CommandMSIgnore : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (!memoserv) + if (!MemoServService) return; @@ -42,8 +42,8 @@ class CommandMSIgnore : public Command } bool ischan; - MemoInfo *mi = memoserv->GetMemoInfo(channel, ischan); - ChannelInfo *ci = cs_findchan(channel); + MemoInfo *mi = MemoServService->GetMemoInfo(channel, ischan); + ChannelInfo *ci = ChannelInfo::Find(channel); if (!mi) source.Reply(ischan ? CHAN_X_NOT_REGISTERED : _(NICK_X_NOT_REGISTERED), channel.c_str()); else if (ischan && !source.AccessFor(ci).HasPriv("MEMO")) @@ -77,12 +77,12 @@ class CommandMSIgnore : public Command else { ListFormatter list; - list.addColumn("Mask"); + list.AddColumn("Mask"); for (unsigned i = 0; i < mi->ignores.size(); ++i) { ListFormatter::ListEntry entry; entry["Mask"] = mi->ignores[i]; - list.addEntry(entry); + list.AddEntry(entry); } source.Reply(_("Ignore list:")); @@ -120,7 +120,7 @@ class MSIgnore : public Module { this->SetAuthor("Anope"); - if (!memoserv) + if (!MemoServService) throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ms_info.cpp b/modules/commands/ms_info.cpp index d2c7eea3b..b209d0bf4 100644 --- a/modules/commands/ms_info.cpp +++ b/modules/commands/ms_info.cpp @@ -33,7 +33,7 @@ class CommandMSInfo : public Command if (!nname.empty() && nname[0] != '#' && source.HasPriv("memoserv/info")) { - na = findnick(nname); + na = NickAlias::Find(nname); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, nname.c_str()); @@ -44,7 +44,7 @@ class CommandMSInfo : public Command } else if (!nname.empty() && nname[0] == '#') { - ci = cs_findchan(nname); + ci = ChannelInfo::Find(nname); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, nname.c_str()); diff --git a/modules/commands/ms_list.cpp b/modules/commands/ms_list.cpp index f6a92e9df..91196cfee 100644 --- a/modules/commands/ms_list.cpp +++ b/modules/commands/ms_list.cpp @@ -34,7 +34,7 @@ class CommandMSList : public Command chan = param; param = params.size() > 1 ? params[1] : ""; - ci = cs_findchan(chan); + ci = ChannelInfo::Find(chan); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); @@ -63,7 +63,7 @@ class CommandMSList : public Command { ListFormatter list; - list.addColumn("Number").addColumn("Sender").addColumn("Date/Time"); + list.AddColumn("Number").AddColumn("Sender").AddColumn("Date/Time"); if (!param.empty() && isdigit(param[0])) { @@ -77,18 +77,18 @@ class CommandMSList : public Command { } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned number) anope_override { - if (!Number || Number > mi->memos->size()) + if (!number || number > mi->memos->size()) return; - const Memo *m = mi->GetMemo(Number); + const Memo *m = mi->GetMemo(number); ListFormatter::ListEntry entry; - entry["Number"] = (m->HasFlag(MF_UNREAD) ? "* " : " ") + stringify(Number + 1); + entry["Number"] = (m->HasFlag(MF_UNREAD) ? "* " : " ") + stringify(number + 1); entry["Sender"] = m->sender; - entry["Date/Time"] = do_strftime(m->time); - this->list.addEntry(entry); + entry["Date/Time"] = Anope::strftime(m->time); + this->list.AddEntry(entry); } } mlc(list, source, mi, param); @@ -122,8 +122,8 @@ class CommandMSList : public Command ListFormatter::ListEntry entry; entry["Number"] = (m->HasFlag(MF_UNREAD) ? "* " : " ") + stringify(i + 1); entry["Sender"] = m->sender; - entry["Date/Time"] = do_strftime(m->time); - list.addEntry(entry); + entry["Date/Time"] = Anope::strftime(m->time); + list.AddEntry(entry); } } diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp index 5b46ef0dd..6d5adfb05 100644 --- a/modules/commands/ms_read.cpp +++ b/modules/commands/ms_read.cpp @@ -17,10 +17,10 @@ static void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Anope::string &targ) { /* Only send receipt if memos are allowed */ - if (memoserv && !readonly) + if (MemoServService && !Anope::ReadOnly) { /* Get nick alias for sender */ - const NickAlias *na = findnick(m->sender); + const NickAlias *na = NickAlias::Find(m->sender); if (!na) return; @@ -33,10 +33,10 @@ static void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Ano /* Text of the memo varies if the recepient was a nick or channel */ - Anope::string text = Anope::printf(translate(na->nc, _("\002[auto-memo]\002 The memo you sent to %s has been viewed.")), targ.c_str()); + Anope::string text = Anope::printf(Language::Translate(na->nc, _("\002[auto-memo]\002 The memo you sent to %s has been viewed.")), targ.c_str()); /* Send notification */ - memoserv->Send(source.GetNick(), m->sender, text, true); + MemoServService->Send(source.GetNick(), m->sender, text, true); /* Notify recepient of the memo that a notification has been sent to the sender */ @@ -58,21 +58,21 @@ class MemoListCallback : public NumberList { } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned number) anope_override { - if (!Number || Number > mi->memos->size()) + if (!number || number > mi->memos->size()) return; - MemoListCallback::DoRead(source, mi, ci, Number - 1); + MemoListCallback::DoRead(source, mi, ci, number - 1); } static void DoRead(CommandSource &source, MemoInfo *mi, const ChannelInfo *ci, unsigned index) { Memo *m = mi->GetMemo(index); if (ci) - source.Reply(_("Memo %d from %s (%s). To delete, type: \002%s%s DEL %s %d\002"), index + 1, m->sender.c_str(), do_strftime(m->time).c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), ci->name.c_str(), index + 1); + source.Reply(_("Memo %d from %s (%s). To delete, type: \002%s%s DEL %s %d\002"), index + 1, m->sender.c_str(), Anope::strftime(m->time).c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), ci->name.c_str(), index + 1); else - source.Reply(_("Memo %d from %s (%s). To delete, type: \002%s%s DEL %d\002"), index + 1, m->sender.c_str(), do_strftime(m->time).c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), index + 1); + source.Reply(_("Memo %d from %s (%s). To delete, type: \002%s%s DEL %d\002"), index + 1, m->sender.c_str(), Anope::strftime(m->time).c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), index + 1); source.Reply("%s", m->text.c_str()); m->UnsetFlag(MF_UNREAD); @@ -103,7 +103,7 @@ class CommandMSRead : public Command chan = numstr; numstr = params.size() > 1 ? params[1] : ""; - ci = cs_findchan(chan); + ci = ChannelInfo::Find(chan); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); diff --git a/modules/commands/ms_rsend.cpp b/modules/commands/ms_rsend.cpp index 9c47b9f53..b08b9be85 100644 --- a/modules/commands/ms_rsend.cpp +++ b/modules/commands/ms_rsend.cpp @@ -25,7 +25,7 @@ class CommandMSRSend : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (!memoserv) + if (!MemoServService) return; @@ -34,7 +34,7 @@ class CommandMSRSend : public Command const NickAlias *na = NULL; /* prevent user from rsend to themselves */ - if ((na = findnick(nick)) && na->nc == source.GetAccount()) + if ((na = NickAlias::Find(nick)) && na->nc == source.GetAccount()) { source.Reply(_("You can not request a receipt when sending a memo to yourself.")); return; @@ -49,7 +49,7 @@ class CommandMSRSend : public Command } else { - MemoServService::MemoResult result = memoserv->Send(source.GetNick(), nick, text); + MemoServService::MemoResult result = MemoServService->Send(source.GetNick(), nick, text); if (result == MemoServService::MEMO_INVALID_TARGET) source.Reply(_("\002%s\002 is not a registered unforbidden nick or channel."), nick.c_str()); else if (result == MemoServService::MEMO_TOO_FAST) @@ -61,7 +61,7 @@ class CommandMSRSend : public Command source.Reply(_("Memo sent to \002%s\002."), name.c_str()); bool ischan; - MemoInfo *mi = memoserv->GetMemoInfo(nick, ischan); + MemoInfo *mi = MemoServService->GetMemoInfo(nick, ischan); if (mi == NULL) throw CoreException("NULL mi in ms_rsend"); Memo *m = (mi->memos->size() ? mi->GetMemo(mi->memos->size() - 1) : NULL); @@ -98,7 +98,7 @@ class MSRSend : public Module { this->SetAuthor("Anope"); - if (!memoserv) + if (!MemoServService) throw ModuleException("No MemoServ!"); else if (!Config->MSMemoReceipt) throw ModuleException("Invalid value for memoreceipt"); diff --git a/modules/commands/ms_send.cpp b/modules/commands/ms_send.cpp index a2ba53a9e..42024227e 100644 --- a/modules/commands/ms_send.cpp +++ b/modules/commands/ms_send.cpp @@ -25,13 +25,13 @@ class CommandMSSend : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (!memoserv) + if (!MemoServService) return; const Anope::string &nick = params[0]; const Anope::string &text = params[1]; - MemoServService::MemoResult result = memoserv->Send(source.GetNick(), nick, text); + MemoServService::MemoResult result = MemoServService->Send(source.GetNick(), nick, text); if (result == MemoServService::MEMO_SUCCESS) source.Reply(_("Memo sent to \002%s\002."), nick.c_str()); else if (result == MemoServService::MEMO_INVALID_TARGET) @@ -66,7 +66,7 @@ class MSSend : public Module { this->SetAuthor("Anope"); - if (!memoserv) + if (!MemoServService) throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ms_sendall.cpp b/modules/commands/ms_sendall.cpp index 2fba2ecb3..5ade6722b 100644 --- a/modules/commands/ms_sendall.cpp +++ b/modules/commands/ms_sendall.cpp @@ -25,12 +25,12 @@ class CommandMSSendAll : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (!memoserv) + if (!MemoServService) return; const Anope::string &text = params[0]; - if (readonly) + if (Anope::ReadOnly) { source.Reply(MEMO_SEND_DISABLED); return; @@ -41,7 +41,7 @@ class CommandMSSendAll : public Command const NickCore *nc = it->second; if (nc != source.nc) - memoserv->Send(source.GetNick(), nc->display, text); + MemoServService->Send(source.GetNick(), nc->display, text); } source.Reply(_("A massmemo has been sent to all registered users.")); @@ -67,7 +67,7 @@ class MSSendAll : public Module { this->SetAuthor("Anope"); - if (!memoserv) + if (!MemoServService) throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ms_set.cpp b/modules/commands/ms_set.cpp index 02ce8d32c..497dffd4c 100644 --- a/modules/commands/ms_set.cpp +++ b/modules/commands/ms_set.cpp @@ -86,7 +86,7 @@ class CommandMSSet : public Command p2 = p3; p3 = params.size() > 4 ? params[4] : ""; - ci = cs_findchan(chan); + ci = ChannelInfo::Find(chan); if (!ci) { source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str()); @@ -104,7 +104,7 @@ class CommandMSSet : public Command if (!p2.empty() && !p2.equals_ci("HARD") && chan.empty()) { const NickAlias *na; - if (!(na = findnick(p1))) + if (!(na = NickAlias::Find(p1))) { source.Reply(NICK_X_NOT_REGISTERED, p1.c_str()); return; @@ -211,7 +211,7 @@ class CommandMSSet : public Command const Anope::string &cmd = params[0]; MemoInfo *mi = const_cast<MemoInfo *>(&source.nc->memos); - if (readonly) + if (Anope::ReadOnly) source.Reply(_("Sorry, memo option setting is temporarily disabled.")); else if (cmd.equals_ci("NOTIFY")) return this->DoNotify(source, params, mi); diff --git a/modules/commands/ms_staff.cpp b/modules/commands/ms_staff.cpp index 9896d5971..a1fbdf65d 100644 --- a/modules/commands/ms_staff.cpp +++ b/modules/commands/ms_staff.cpp @@ -25,12 +25,12 @@ class CommandMSStaff : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (!memoserv) + if (!MemoServService) return; const Anope::string &text = params[0]; - if (readonly) + if (Anope::ReadOnly) { source.Reply(MEMO_SEND_DISABLED); return; @@ -41,7 +41,7 @@ class CommandMSStaff : public Command const NickCore *nc = it->second; if (source.nc != nc && nc->IsServicesOper()) - memoserv->Send(source.GetNick(), nc->display, text, true); + MemoServService->Send(source.GetNick(), nc->display, text, true); } return; @@ -67,7 +67,7 @@ class MSStaff : public Module { this->SetAuthor("Anope"); - if (!memoserv) + if (!MemoServService) throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ns_access.cpp b/modules/commands/ns_access.cpp index 915b70cb3..f77836909 100644 --- a/modules/commands/ns_access.cpp +++ b/modules/commands/ns_access.cpp @@ -108,7 +108,7 @@ class CommandNSAccess : public Command NickCore *nc; if (!nick.empty()) { - const NickAlias *na = findnick(nick); + const NickAlias *na = NickAlias::Find(nick); if (na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index 46f012c46..54e37ad36 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -15,20 +15,20 @@ struct AJoinEntry; -struct AJoinList : serialize_checker<std::vector<AJoinEntry *> >, ExtensibleItem +struct AJoinList : Serialize::Checker<std::vector<AJoinEntry *> >, ExtensibleItem { - AJoinList() : serialize_checker<std::vector<AJoinEntry *> >("AJoinEntry") { } + AJoinList() : Serialize::Checker<std::vector<AJoinEntry *> >("AJoinEntry") { } }; struct AJoinEntry : Serializable { - serialize_obj<NickCore> owner; + Serialize::Reference<NickCore> owner; Anope::string channel; Anope::string key; AJoinEntry() : Serializable("AJoinEntry") { } - Serialize::Data serialize() const anope_override + Serialize::Data Serialize() const anope_override { Serialize::Data sd; @@ -42,9 +42,9 @@ struct AJoinEntry : Serializable return sd; } - static Serializable* unserialize(Serializable *obj, Serialize::Data &sd) + static Serializable* Unserialize(Serializable *obj, Serialize::Data &sd) { - NickCore *nc = findcore(sd["owner"].astr()); + NickCore *nc = NickCore::Find(sd["owner"].astr()); if (nc == NULL) return NULL; @@ -91,7 +91,7 @@ class CommandNSAJoin : public Command else { ListFormatter list; - list.addColumn("Number").addColumn("Channel").addColumn("Key"); + list.AddColumn("Number").AddColumn("Channel").AddColumn("Key"); for (unsigned i = 0; i < (*channels)->size(); ++i) { AJoinEntry *aj = (*channels)->at(i); @@ -99,7 +99,7 @@ class CommandNSAJoin : public Command entry["Number"] = stringify(i + 1); entry["Channel"] = aj->channel; entry["Key"] = aj->key; - list.addEntry(entry); + list.AddEntry(entry); } source.Reply(_("%s's auto join list:"), nc->display.c_str()); @@ -130,7 +130,7 @@ class CommandNSAJoin : public Command source.Reply(_("Your auto join list is full.")); else if (i != (*channels)->size()) source.Reply(_("%s is already on %s's auto join list."), chan.c_str(), nc->display.c_str()); - else if (ircdproto->IsChannelValid(chan) == false) + else if (IRCD->IsChannelValid(chan) == false) source.Reply(CHAN_X_INVALID, chan.c_str()); else { @@ -161,7 +161,7 @@ class CommandNSAJoin : public Command source.Reply(_("%s was not found on %s's auto join list."), chan.c_str(), nc->display.c_str()); else { - (*channels)->at(i)->destroy(); + (*channels)->at(i)->Destroy(); (*channels)->erase((*channels)->begin() + i); source.Reply(_("%s was removed from %s's auto join list."), chan.c_str(), nc->display.c_str()); } @@ -179,9 +179,9 @@ class CommandNSAJoin : public Command NickCore *nc = source.GetAccount(); Anope::string param, param2; - if (params.size() > 1 && source.IsServicesOper() && ircdproto->IsNickValid(params[1])) + if (params.size() > 1 && source.IsServicesOper() && IRCD->IsNickValid(params[1])) { - NickAlias *na = findnick(params[1]); + NickAlias *na = NickAlias::Find(params[1]); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, params[1].c_str()); @@ -224,12 +224,12 @@ class CommandNSAJoin : public Command class NSAJoin : public Module { - SerializeType ajoinentry_type; + Serialize::Type ajoinentry_type; CommandNSAJoin commandnsajoin; public: NSAJoin(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - ajoinentry_type("AJoinEntry", AJoinEntry::unserialize), commandnsajoin(this) + ajoinentry_type("AJoinEntry", AJoinEntry::Unserialize), commandnsajoin(this) { this->SetAuthor("Anope"); @@ -239,6 +239,9 @@ class NSAJoin : public Module void OnNickIdentify(User *u) anope_override { + if (!NickServ) + return; + AJoinList *channels = u->Account()->GetExt<AJoinList *>("ns_ajoin_channels"); if (channels == NULL) { @@ -246,20 +249,16 @@ class NSAJoin : public Module u->Account()->Extend("ns_ajoin_channels", channels); } - const BotInfo *bi = findbot(Config->NickServ); - if (bi == NULL) - return; - for (unsigned i = 0; i < (*channels)->size(); ++i) { AJoinEntry *entry = (*channels)->at(i); - Channel *c = findchan(entry->channel); + Channel *c = Channel::Find(entry->channel); ChannelInfo *ci; if (c) ci = c->ci; else - ci = cs_findchan(entry->channel); + ci = ChannelInfo::Find(entry->channel); bool need_invite = false; Anope::string key = entry->key; @@ -279,9 +278,9 @@ class NSAJoin : public Module continue; else if (c->HasMode(CMODE_SSL) && !u->HasMode(UMODE_SSL)) continue; - else if (matches_list(c, u, CMODE_BAN) == true && matches_list(c, u, CMODE_EXCEPT) == false) + else if (c->MatchesList(u, CMODE_BAN) == true && c->MatchesList(u, CMODE_EXCEPT) == false) need_invite = true; - else if (c->HasMode(CMODE_INVITE) && matches_list(c, u, CMODE_INVITEOVERRIDE) == false) + else if (c->HasMode(CMODE_INVITE) && c->MatchesList(u, CMODE_INVITEOVERRIDE) == false) need_invite = true; if (c->HasMode(CMODE_KEY)) @@ -315,10 +314,10 @@ class NSAJoin : public Module { if (!ci->AccessFor(u).HasPriv("INVITE")) continue; - ircdproto->SendInvite(bi, c, u); + IRCD->SendInvite(NickServ, c, u); } - ircdproto->SendSVSJoin(bi, u->nick, entry->channel, key); + IRCD->SendSVSJoin(NickServ, u->nick, entry->channel, key); } } }; diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp index ef018ea8b..8da1b8346 100644 --- a/modules/commands/ns_alist.cpp +++ b/modules/commands/ns_alist.cpp @@ -30,7 +30,7 @@ class CommandNSAList : public Command if (params.size() && source.IsServicesOper()) { nick = params[0]; - const NickAlias *na = findnick(nick); + const NickAlias *na = NickAlias::Find(nick); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -42,7 +42,7 @@ class CommandNSAList : public Command ListFormatter list; int chan_count = 0; - list.addColumn("Number").addColumn("Channel").addColumn("Access"); + list.AddColumn("Number").AddColumn("Channel").AddColumn("Access"); source.Reply(_("Channels that \002%s\002 has access on:"), nc->display.c_str()); @@ -57,7 +57,7 @@ class CommandNSAList : public Command entry["Number"] = stringify(chan_count); entry["Channel"] = (ci->HasFlag(CI_NO_EXPIRE) ? "!" : "") + ci->name; entry["Access"] = "Founder"; - list.addEntry(entry); + list.AddEntry(entry); continue; } @@ -70,9 +70,9 @@ class CommandNSAList : public Command entry["Number"] = stringify(chan_count); entry["Channel"] = (ci->HasFlag(CI_NO_EXPIRE) ? "!" : "") + ci->name; for (unsigned i = 0; i < access.size(); ++i) - entry["Access"] = entry["Access"] + ", " + access[i]->Serialize(); + entry["Access"] = entry["Access"] + ", " + access[i]->AccessSerialize(); entry["Access"] = entry["Access"].substr(2); - list.addEntry(entry); + list.AddEntry(entry); } std::vector<Anope::string> replies; diff --git a/modules/commands/ns_cert.cpp b/modules/commands/ns_cert.cpp index a06dd1a3a..6c2100adf 100644 --- a/modules/commands/ns_cert.cpp +++ b/modules/commands/ns_cert.cpp @@ -31,14 +31,14 @@ class CommandNSCert : public Command } ListFormatter list; - list.addColumn("Certificate"); + list.AddColumn("Certificate"); for (unsigned i = 0, end = nc->cert.size(); i < end; ++i) { Anope::string fingerprint = nc->GetCert(i); ListFormatter::ListEntry entry; entry["Certificate"] = fingerprint; - list.addEntry(entry); + list.AddEntry(entry); } source.Reply(_("Certificate list for \002%s\002:"), nc->display.c_str()); @@ -121,13 +121,13 @@ class CommandNSCert : public Command } ListFormatter list; - list.addColumn("Certificate"); + list.AddColumn("Certificate"); for (unsigned i = 0, end = nc->cert.size(); i < end; ++i) { ListFormatter::ListEntry entry; entry["Certificate"] = nc->GetCert(i); - list.addEntry(entry); + list.AddEntry(entry); } source.Reply(_("Certificate list:")); @@ -152,7 +152,7 @@ class CommandNSCert : public Command const Anope::string &mask = params.size() > 1 ? params[1] : ""; const NickAlias *na; - if (cmd.equals_ci("LIST") && source.IsServicesOper() && !mask.empty() && (na = findnick(mask))) + if (cmd.equals_ci("LIST") && source.IsServicesOper() && !mask.empty() && (na = NickAlias::Find(mask))) return this->DoServAdminList(source, na->nc); NickCore *nc = source.nc; @@ -202,9 +202,8 @@ class NSCert : public Module void DoAutoIdentify(User *u) { - const BotInfo *bi = findbot(Config->NickServ); - NickAlias *na = findnick(u->nick); - if (!bi || !na) + NickAlias *na = NickAlias::Find(u->nick); + if (!NickServ || !na) return; if (u->IsIdentified() && u->Account() == na->nc) return; @@ -214,7 +213,7 @@ class NSCert : public Module return; u->Identify(na); - u->SendMessage(bi, _("SSL Fingerprint accepted. You are now identified.")); + u->SendMessage(NickServ, _("SSL Fingerprint accepted. You are now identified.")); Log(u) << "automatically identified for account " << na->nc->display << " using a valid SSL fingerprint"; return; } @@ -225,7 +224,7 @@ class NSCert : public Module { this->SetAuthor("Anope"); - if (!ircdproto || !ircdproto->CanCertFP) + if (!IRCD || !IRCD->CanCertFP) throw ModuleException("Your IRCd does not support ssl client certificates"); Implementation i[] = { I_OnFingerprint }; diff --git a/modules/commands/ns_drop.cpp b/modules/commands/ns_drop.cpp index d5ac7cef8..efd95cf1c 100644 --- a/modules/commands/ns_drop.cpp +++ b/modules/commands/ns_drop.cpp @@ -25,13 +25,13 @@ class CommandNSDrop : public Command { Anope::string nick = !params.empty() ? params[0] : ""; - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, nickname de-registration is temporarily disabled.")); return; } - NickAlias *na = findnick(!nick.empty() ? nick : source.GetNick()); + NickAlias *na = NickAlias::Find(!nick.empty() ? nick : source.GetNick()); if (!na) { source.Reply(NICK_NOT_REGISTERED); @@ -49,13 +49,13 @@ class CommandNSDrop : public Command source.Reply(_("You may not drop other services operators nicknames.")); else { - if (readonly) + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); FOREACH_MOD(I_OnNickDrop, OnNickDrop(source, na)); Log(!is_mine ? LOG_OVERRIDE : LOG_COMMAND, source, this) << "to drop nickname " << na->nick << " (group: " << na->nc->display << ") (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; - na->destroy(); + na->Destroy(); if (!is_mine) { diff --git a/modules/commands/ns_getpass.cpp b/modules/commands/ns_getpass.cpp index 2e5efdf4d..998316f5b 100644 --- a/modules/commands/ns_getpass.cpp +++ b/modules/commands/ns_getpass.cpp @@ -28,13 +28,13 @@ class CommandNSGetPass : public Command Anope::string tmp_pass; const NickAlias *na; - if (!(na = findnick(nick))) + if (!(na = NickAlias::Find(nick))) source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); else if (Config->NSSecureAdmins && na->nc->IsServicesOper()) source.Reply(_("You may not get the password of other services operators.")); else { - if (enc_decrypt(na->nc->pass, tmp_pass) == 1) + if (Anope::Decrypt(na->nc->pass, tmp_pass) == 1) { Log(LOG_ADMIN, source, this) << "for " << nick; source.Reply(_("Password for %s is \002%s\002."), nick.c_str(), tmp_pass.c_str()); @@ -68,7 +68,7 @@ class NSGetPass : public Module this->SetAuthor("Anope"); Anope::string tmp_pass = "plain:tmp"; - if (enc_decrypt(tmp_pass, tmp_pass) == -1) + if (Anope::Decrypt(tmp_pass, tmp_pass) == -1) throw ModuleException("Incompatible with the encryption module being used"); } diff --git a/modules/commands/ns_ghost.cpp b/modules/commands/ns_ghost.cpp index e7289f728..de85a941f 100644 --- a/modules/commands/ns_ghost.cpp +++ b/modules/commands/ns_ghost.cpp @@ -19,7 +19,7 @@ class NSGhostRequest : public IdentifyRequest { CommandSource source; Command *cmd; - dynamic_reference<User> u; + Reference<User> u; public: NSGhostRequest(Module *o, CommandSource &src, Command *c, User *user, const Anope::string &pass) : IdentifyRequest(o, user->nick, pass), source(src), cmd(c), u(user) { } @@ -38,7 +38,7 @@ class NSGhostRequest : public IdentifyRequest { NSGhostExtensibleInfo *ei = new NSGhostExtensibleInfo; for (UChannelList::iterator it = u->chans.begin(), it_end = u->chans.end(); it != it_end; ++it) - (*ei)[(*it)->chan->name] = *(*it)->Status; + (*ei)[(*it)->chan->name] = *(*it)->status; source.GetUser()->Extend("ns_ghost_info", ei); } @@ -50,14 +50,14 @@ class NSGhostRequest : public IdentifyRequest source.Reply(_("Ghost with your nick has been killed.")); if (Config->NSRestoreOnGhost) - ircdproto->SendForceNickChange(source.GetUser(), GetAccount(), Anope::CurTime); + IRCD->SendForceNickChange(source.GetUser(), GetAccount(), Anope::CurTime); } void OnFail() anope_override { if (!u) ; - else if (!findnick(GetAccount())) + else if (!NickAlias::Find(GetAccount())) source.Reply(NICK_X_NOT_REGISTERED, GetAccount().c_str()); else { @@ -66,7 +66,7 @@ class NSGhostRequest : public IdentifyRequest { Log(LOG_COMMAND, source, cmd) << "with an invalid password for " << GetAccount(); if (source.GetUser()) - bad_password(source.GetUser()); + source.GetUser()->BadPassword(); } } } @@ -87,8 +87,8 @@ class CommandNSGhost : public Command const Anope::string &nick = params[0]; const Anope::string &pass = params.size() > 1 ? params[1] : ""; - User *user = finduser(nick); - const NickAlias *na = findnick(nick); + User *user = User::Find(nick, true); + const NickAlias *na = NickAlias::Find(nick); if (!user) source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); @@ -107,7 +107,7 @@ class CommandNSGhost : public Command bool ok = false; if (source.GetAccount() == na->nc) ok = true; - else if (!na->nc->HasFlag(NI_SECURE) && source.GetUser() && is_on_access(source.GetUser(), na->nc)) + else if (!na->nc->HasFlag(NI_SECURE) && source.GetUser() && na->nc->IsOnAccess(source.GetUser())) ok = true; else if (source.GetUser() && !source.GetUser()->fingerprint.empty() && na->nc->FindCert(source.GetUser()->fingerprint)) ok = true; @@ -183,7 +183,7 @@ class NSGhost : public Module if (ei != NULL) for (std::map<Anope::string, ChannelStatus>::iterator it = ei->begin(), it_end = ei->end(); it != it_end; ++it) - ircdproto->SendSVSJoin(findbot(Config->NickServ), u->GetUID(), it->first, ""); + IRCD->SendSVSJoin(NickServ, u->GetUID(), it->first, ""); } } diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp index 58251d76d..f4a464d28 100644 --- a/modules/commands/ns_group.cpp +++ b/modules/commands/ns_group.cpp @@ -18,7 +18,7 @@ class NSGroupRequest : public IdentifyRequest CommandSource source; Command *cmd; Anope::string nick; - dynamic_reference<NickAlias> target; + Reference<NickAlias> target; public: NSGroupRequest(Module *o, CommandSource &src, Command *c, const Anope::string &n, NickAlias *targ, const Anope::string &pass) : IdentifyRequest(o, targ->nc->display, pass), source(src), cmd(c), nick(n), target(targ) { } @@ -29,12 +29,12 @@ class NSGroupRequest : public IdentifyRequest return; User *u = source.GetUser(); - NickAlias *na = findnick(nick); + NickAlias *na = NickAlias::Find(nick); /* If the nick is already registered, drop it. */ if (na) { FOREACH_MOD(I_OnChangeCoreDisplay, OnChangeCoreDisplay(na->nc, u->nick)); - na->destroy(); + na->Destroy(); } na = new NickAlias(nick, target->nc); @@ -45,9 +45,9 @@ class NSGroupRequest : public IdentifyRequest na->time_registered = na->last_seen = Anope::CurTime; u->Login(target->nc); - ircdproto->SendLogin(u); + IRCD->SendLogin(u); if (!Config->NoNicknameOwnership && na->nc == u->Account() && na->nc->HasFlag(NI_UNCONFIRMED) == false) - u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); + u->SetMode(NickServ, UMODE_REGISTERED); FOREACH_MOD(I_OnNickGroup, OnNickGroup(u, target)); Log(LOG_COMMAND, source, cmd) << "makes " << nick << " join group of " << target->nick << " (" << target->nc->display << ") (email: " << (!target->nc->email.empty() ? target->nc->email : "none") << ")"; @@ -64,7 +64,7 @@ class NSGroupRequest : public IdentifyRequest Log(LOG_COMMAND, source, cmd) << "failed group for " << target->nick; source.Reply(PASSWORD_INCORRECT); - bad_password(source.GetUser()); + source.GetUser()->BadPassword(); } }; @@ -88,13 +88,13 @@ class CommandNSGroup : public Command const Anope::string &nick = params[0]; const Anope::string &pass = params.size() > 1 ? params[1] : ""; - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, nickname grouping is temporarily disabled.")); return; } - if (!ircdproto->IsNickValid(u->nick)) + if (!IRCD->IsNickValid(u->nick)) { source.Reply(NICK_CANNOT_BE_REGISTERED, u->nick.c_str()); return; @@ -112,8 +112,8 @@ class CommandNSGroup : public Command } } - NickAlias *target, *na = findnick(u->nick); - if (!(target = findnick(nick))) + NickAlias *target, *na = NickAlias::Find(u->nick); + if (!(target = NickAlias::Find(nick))) source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); else if (Anope::CurTime < u->lastnickreg + Config->NSRegDelay) source.Reply(_("Please wait %d seconds before using the GROUP command again."), (Config->NSRegDelay + u->lastnickreg) - Anope::CurTime); @@ -212,7 +212,7 @@ class CommandNSUngroup : public Command return; Anope::string nick = !params.empty() ? params[0] : ""; - NickAlias *na = findnick(!nick.empty() ? nick : u->nick); + NickAlias *na = NickAlias::Find(!nick.empty() ? nick : u->nick); if (u->Account()->aliases.size() == 1) source.Reply(_("Your nick is not grouped to anything, you can't ungroup it.")); @@ -224,12 +224,12 @@ class CommandNSUngroup : public Command { NickCore *oldcore = na->nc; - std::list<serialize_obj<NickAlias> >::iterator it = std::find(oldcore->aliases.begin(), oldcore->aliases.end(), na); + std::list<Serialize::Reference<NickAlias> >::iterator it = std::find(oldcore->aliases.begin(), oldcore->aliases.end(), na); if (it != oldcore->aliases.end()) oldcore->aliases.erase(it); if (na->nick.equals_ci(oldcore->display)) - change_core_display(oldcore); + oldcore->SetDisplay(oldcore->aliases.front()); NickCore *nc = new NickCore(na->nick); na->nc = nc; @@ -244,10 +244,10 @@ class CommandNSUngroup : public Command source.Reply(_("Nick %s has been ungrouped from %s."), na->nick.c_str(), oldcore->display.c_str()); - User *user = finduser(na->nick); + User *user = User::Find(na->nick); if (user) /* The user on the nick who was ungrouped may be identified to the old group, set -r */ - user->RemoveMode(findbot(Config->NickServ), UMODE_REGISTERED); + user->RemoveMode(NickServ, UMODE_REGISTERED); } return; @@ -281,7 +281,7 @@ class CommandNSGList : public Command if (!nick.empty()) { - const NickAlias *na = findnick(nick); + const NickAlias *na = NickAlias::Find(nick); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -299,8 +299,8 @@ class CommandNSGList : public Command nc = source.GetAccount(); ListFormatter list; - list.addColumn("Nick").addColumn("Expires"); - for (std::list<serialize_obj<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;) + list.AddColumn("Nick").AddColumn("Expires"); + for (std::list<Serialize::Reference<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;) { const NickAlias *na2 = *it++; if (!na2) @@ -308,8 +308,8 @@ class CommandNSGList : public Command ListFormatter::ListEntry entry; entry["Nick"] = na2->nick; - entry["Expires"] = (na2->HasFlag(NS_NO_EXPIRE) || !Config->NSExpire) ? "Does not expire" : ("expires in " + do_strftime(na2->last_seen + Config->NSExpire)); - list.addEntry(entry); + entry["Expires"] = (na2->HasFlag(NS_NO_EXPIRE) || !Config->NSExpire) ? "Does not expire" : ("expires in " + Anope::strftime(na2->last_seen + Config->NSExpire)); + list.AddEntry(entry); } source.Reply(!nick.empty() ? _("List of nicknames in the group of \002%s\002:") : _("List of nicknames in your group:"), nc->display.c_str()); diff --git a/modules/commands/ns_identify.cpp b/modules/commands/ns_identify.cpp index dde24d72d..4796e7bb6 100644 --- a/modules/commands/ns_identify.cpp +++ b/modules/commands/ns_identify.cpp @@ -27,7 +27,7 @@ class NSIdentifyRequest : public IdentifyRequest return; User *u = source.GetUser(); - NickAlias *na = findnick(GetAccount()); + NickAlias *na = NickAlias::Find(GetAccount()); if (!na) source.Reply(NICK_X_NOT_REGISTERED, GetAccount().c_str()); @@ -49,7 +49,7 @@ class NSIdentifyRequest : public IdentifyRequest { Log(LOG_COMMAND, source, cmd) << "and failed to identify"; source.Reply(PASSWORD_INCORRECT); - bad_password(source.GetUser()); + source.GetUser()->BadPassword(); } } }; @@ -74,7 +74,7 @@ class CommandNSIdentify : public Command const Anope::string &nick = params.size() == 2 ? params[0] : u->nick; Anope::string pass = params[params.size() - 1]; - NickAlias *na = findnick(nick); + NickAlias *na = NickAlias::Find(nick); if (na && na->nc->HasFlag(NI_SUSPENDED)) source.Reply(NICK_X_SUSPENDED, na->nick.c_str()); else if (u->Account() && na && u->Account() == na->nc) diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp index 5daf2357e..976589718 100644 --- a/modules/commands/ns_info.cpp +++ b/modules/commands/ns_info.cpp @@ -16,14 +16,14 @@ class CommandNSInfo : public Command { private: - template<typename T, unsigned END> void CheckOptStr(NickCore *core, Anope::string &buf, T opt, const char *str, const Flags<T, END> *nc, bool reverse_logic = false) + template<typename T> void CheckOptStr(NickCore *core, Anope::string &buf, T opt, const char *str, const Flags<T> *nc, bool reverse_logic = false) { if (reverse_logic ? !nc->HasFlag(opt) : nc->HasFlag(opt)) { if (!buf.empty()) buf += ", "; - buf += translate(core, str); + buf += Language::Translate(core, str); } } public: @@ -38,12 +38,12 @@ class CommandNSInfo : public Command { const Anope::string &nick = params.size() ? params[0] : (source.nc ? source.nc->display : source.GetNick()); - NickAlias *na = findnick(nick); + NickAlias *na = NickAlias::Find(nick); bool has_auspex = source.HasPriv("nickserv/auspex"); if (!na) { - if (nickIsServices(nick, true)) + if (BotInfo::Find(nick, true)) source.Reply(_("Nick \002%s\002 is part of this Network's Services."), nick.c_str()); else source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -53,7 +53,7 @@ class CommandNSInfo : public Command bool nick_online = false, show_hidden = false; /* Is the real owner of the nick we're looking up online? -TheShadow */ - User *u2 = finduser(na->nick); + User *u2 = User::Find(na->nick); if (u2 && u2->Account() == na->nc) nick_online = true; @@ -87,10 +87,10 @@ class CommandNSInfo : public Command info[_("Last seen address")] = na->last_realhost; } - info[_("Time registered")] = do_strftime(na->time_registered); + info[_("Time registered")] = Anope::strftime(na->time_registered); if (!nick_online) - info[_("Last seen")] = do_strftime(na->last_seen); + info[_("Last seen")] = Anope::strftime(na->last_seen); if (!na->last_quit.empty() && (show_hidden || !na->nc->HasFlag(NI_HIDE_QUIT))) info[_("Last quit message")] = na->last_quit; @@ -102,7 +102,7 @@ class CommandNSInfo : public Command { if (na->HasVhost()) { - if (ircdproto->CanSetVIdent && !na->GetVhostIdent().empty()) + if (IRCD->CanSetVIdent && !na->GetVhostIdent().empty()) info[_("VHost")] = na->GetVhostIdent() + "@" + na->GetVhostHost(); else info[_("VHost")] = na->GetVhostHost(); @@ -113,14 +113,14 @@ class CommandNSInfo : public Command Anope::string optbuf; - CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_KILLPROTECT, _("Protection"), na->nc); - CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_SECURE, _("Security"), na->nc); - CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_PRIVATE, _("Private"), na->nc); - CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_MSG, _("Message mode"), na->nc); - CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_AUTOOP, _("Auto-op"), na->nc); - CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_SUSPENDED, _("Suspended"), na->nc); - CheckOptStr<NickCoreFlag, NI_END>(source.nc, optbuf, NI_STATS, _("Chanstats"), na->nc); - CheckOptStr<NickNameFlag, NS_END>(source.nc, optbuf, NS_NO_EXPIRE, _("No expire"), na); + CheckOptStr<NickCoreFlag>(source.nc, optbuf, NI_KILLPROTECT, _("Protection"), na->nc); + CheckOptStr<NickCoreFlag>(source.nc, optbuf, NI_SECURE, _("Security"), na->nc); + CheckOptStr<NickCoreFlag>(source.nc, optbuf, NI_PRIVATE, _("Private"), na->nc); + CheckOptStr<NickCoreFlag>(source.nc, optbuf, NI_MSG, _("Message mode"), na->nc); + CheckOptStr<NickCoreFlag>(source.nc, optbuf, NI_AUTOOP, _("Auto-op"), na->nc); + CheckOptStr<NickCoreFlag>(source.nc, optbuf, NI_SUSPENDED, _("Suspended"), na->nc); + CheckOptStr<NickCoreFlag>(source.nc, optbuf, NI_STATS, _("Chanstats"), na->nc); + CheckOptStr<NickNameFlag>(source.nc, optbuf, NS_NO_EXPIRE, _("No expire"), na); info[_("Options")] = optbuf.empty() ? _("None") : optbuf; @@ -129,10 +129,10 @@ class CommandNSInfo : public Command if (na->HasFlag(NS_NO_EXPIRE) || !Config->NSExpire) ; else - info[_("Expires")] = do_strftime(na->last_seen + Config->NSExpire); + info[_("Expires")] = Anope::strftime(na->last_seen + Config->NSExpire); } else - info[_("Expires")] = do_strftime(na->time_registered + Config->NSUnconfirmedExpire); + info[_("Expires")] = Anope::strftime(na->time_registered + Config->NSUnconfirmedExpire); } FOREACH_MOD(I_OnNickInfo, OnNickInfo(source, na, info, show_hidden)); diff --git a/modules/commands/ns_list.cpp b/modules/commands/ns_list.cpp index 89adfc6ea..9c3c164dd 100644 --- a/modules/commands/ns_list.cpp +++ b/modules/commands/ns_list.cpp @@ -36,8 +36,9 @@ class CommandNSList : public Command if (pattern[0] == '#') { - Anope::string n1 = myStrGetToken(pattern.substr(1), '-', 0), /* Read FROM out */ - n2 = myStrGetToken(pattern, '-', 1); + Anope::string n1, n2; + sepstream(pattern.substr(1), '-').GetToken(n1, 0); + sepstream(pattern, '-').GetToken(n2, 1); try { from = convertTo<int>(n1); @@ -72,7 +73,7 @@ class CommandNSList : public Command mync = source.nc; ListFormatter list; - list.addColumn("Nick").addColumn("Last usermask"); + list.AddColumn("Nick").AddColumn("Last usermask"); for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it) { @@ -110,7 +111,7 @@ class CommandNSList : public Command entry["Last usermask"] = "[Unconfirmed]"; else entry["Last usermask"] = na->last_usermask; - list.addEntry(entry); + list.AddEntry(entry); } ++count; } diff --git a/modules/commands/ns_logout.cpp b/modules/commands/ns_logout.cpp index 4e0dc7131..5519e6ae8 100644 --- a/modules/commands/ns_logout.cpp +++ b/modules/commands/ns_logout.cpp @@ -32,16 +32,16 @@ class CommandNSLogout : public Command User *u2; if (!source.IsServicesOper() && !nick.empty()) this->OnSyntaxError(source, ""); - else if (!(u2 = (!nick.empty() ? finduser(nick) : source.GetUser()))) + else if (!(u2 = (!nick.empty() ? User::Find(nick, true) : source.GetUser()))) source.Reply(NICK_X_NOT_IN_USE, !nick.empty() ? nick.c_str() : source.GetNick().c_str()); else if (!nick.empty() && u2->IsServicesOper()) source.Reply(_("You can't logout %s because they are a Services Operator."), nick.c_str()); else { - if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && nickserv) - nickserv->Validate(u2); + if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && NickServService) + NickServService->Validate(u2); - u2->SuperAdmin = 0; /* Dont let people logout and remain a SuperAdmin */ + u2->super_admin = false; /* Dont let people logout and remain a SuperAdmin */ Log(LOG_COMMAND, source, this) << "to logout " << u2->nick; /* Remove founder status from this user in all channels */ @@ -50,8 +50,8 @@ class CommandNSLogout : public Command else source.Reply(_("Your nick has been logged out.")); - ircdproto->SendLogout(u2); - u2->RemoveMode(findbot(Config->NickServ), UMODE_REGISTERED); + IRCD->SendLogout(u2); + u2->RemoveMode(NickServ, UMODE_REGISTERED); u2->Logout(); /* Send out an event */ diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp index 63d503553..54a10f3b4 100644 --- a/modules/commands/ns_recover.cpp +++ b/modules/commands/ns_recover.cpp @@ -18,8 +18,8 @@ class NSRecoverRequest : public IdentifyRequest { CommandSource source; Command *cmd; - dynamic_reference<NickAlias> na; - dynamic_reference<User> u; + Reference<NickAlias> na; + Reference<User> u; public: NSRecoverRequest(Module *m, CommandSource &src, Command *c, User *user, NickAlias *n, const Anope::string &pass) : IdentifyRequest(m, n->nc->display, pass), source(src), cmd(c), na(n), u(user) { } @@ -33,14 +33,14 @@ class NSRecoverRequest : public IdentifyRequest if (u->Account() == na->nc) { - ircdproto->SendLogout(u); - u->RemoveMode(findbot(Config->NickServ), UMODE_REGISTERED); + IRCD->SendLogout(u); + u->RemoveMode(NickServ, UMODE_REGISTERED); } u->Collide(na); /* Convert Config->NSReleaseTimeout seconds to string format */ - Anope::string relstr = duration(Config->NSReleaseTimeout); + Anope::string relstr = Anope::Duration(Config->NSReleaseTimeout); source.Reply(NICK_RECOVERED, Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str(), na->nick.c_str(), relstr.c_str()); } @@ -53,7 +53,7 @@ class NSRecoverRequest : public IdentifyRequest if (!GetPassword().empty()) { Log(LOG_COMMAND, source, cmd) << "with invalid password for " << na->nick; - bad_password(u); + u->BadPassword(); } } }; @@ -76,11 +76,11 @@ class CommandNSRecover : public Command NickAlias *na; User *u2; - if (!(u2 = finduser(nick))) + if (!(u2 = User::Find(nick, true))) source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); else if (u2->server == Me) source.Reply(_("\2%s\2 has already been recovered."), u2->nick.c_str()); - else if (!(na = findnick(u2->nick))) + else if (!(na = NickAlias::Find(u2->nick))) source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); else if (na->nc->HasFlag(NI_SUSPENDED)) source.Reply(NICK_X_SUSPENDED, na->nick.c_str()); @@ -91,7 +91,7 @@ class CommandNSRecover : public Command bool ok = false; if (source.GetAccount() == na->nc) ok = true; - else if (!na->nc->HasFlag(NI_SECURE) && source.GetUser() && is_on_access(source.GetUser(), na->nc)) + else if (!na->nc->HasFlag(NI_SECURE) && source.GetUser() && na->nc->IsOnAccess(source.GetUser())) ok = true; else if (source.GetUser() && !source.GetUser()->fingerprint.empty() && na->nc->FindCert(source.GetUser()->fingerprint)) ok = true; @@ -117,7 +117,7 @@ class CommandNSRecover : public Command bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override { /* Convert Config->NSReleaseTimeout seconds to string format */ - Anope::string relstr = duration(Config->NSReleaseTimeout); + Anope::string relstr = Anope::Duration(Config->NSReleaseTimeout); this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index 0413f8cc8..d16144a18 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -31,7 +31,7 @@ class CommandNSConfirm : public Command if (source.nc && !source.nc->HasFlag(NI_UNCONFIRMED) && source.HasPriv("nickserv/confirm")) { - NickAlias *na = findnick(passcode); + NickAlias *na = NickAlias::Find(passcode); if (na == NULL) source.Reply(NICK_X_NOT_REGISTERED, passcode.c_str()); else if (na->nc->HasFlag(NI_UNCONFIRMED) == false) @@ -56,10 +56,10 @@ class CommandNSConfirm : public Command if (source.GetUser()) { - ircdproto->SendLogin(source.GetUser()); - const NickAlias *na = findnick(source.GetNick()); + IRCD->SendLogin(source.GetUser()); + const NickAlias *na = NickAlias::Find(source.GetNick()); if (!Config->NoNicknameOwnership && na != NULL && na->nc == source.GetAccount() && na->nc->HasFlag(NI_UNCONFIRMED) == false) - source.GetUser()->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); + source.GetUser()->SetMode(NickServ, UMODE_REGISTERED); } } else @@ -118,7 +118,7 @@ class CommandNSRegister : public Command Anope::string pass = params[0]; Anope::string email = params.size() > 1 ? params[1] : ""; - if (readonly) + if (Anope::ReadOnly) { source.Reply(_("Sorry, nickname registration is temporarily disabled.")); return; @@ -147,7 +147,7 @@ class CommandNSRegister : public Command return; } - if (!ircdproto->IsNickValid(u_nick)) + if (!IRCD->IsNickValid(u_nick)) { source.Reply(NICK_CANNOT_BE_REGISTERED, u_nick.c_str()); return; @@ -169,19 +169,19 @@ class CommandNSRegister : public Command this->OnSyntaxError(source, ""); else if (u && Anope::CurTime < u->lastnickreg + Config->NSRegDelay) source.Reply(_("Please wait %d seconds before using the REGISTER command again."), (u->lastnickreg + Config->NSRegDelay) - Anope::CurTime); - else if ((na = findnick(u_nick))) + else if ((na = NickAlias::Find(u_nick))) source.Reply(NICK_ALREADY_REGISTERED, u_nick.c_str()); else if (pass.equals_ci(u_nick) || (Config->StrictPasswords && pass.length() < 5)) source.Reply(MORE_OBSCURE_PASSWORD); else if (pass.length() > Config->PassLen) source.Reply(PASSWORD_TOO_LONG); - else if (!email.empty() && !MailValidate(email)) + else if (!email.empty() && !Mail::Validate(email)) source.Reply(MAIL_X_INVALID, email.c_str()); else { NickCore *nc = new NickCore(u_nick); na = new NickAlias(u_nick, nc); - enc_encrypt(pass, nc->pass); + Anope::Encrypt(pass, nc->pass); if (!email.empty()) nc->email = email; @@ -193,7 +193,7 @@ class CommandNSRegister : public Command u->Login(nc); if (Config->NSAddAccessOnReg) - nc->AddAccess(create_mask(u)); + nc->AddAccess(u->Mask()); } Log(LOG_COMMAND, source, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; @@ -206,7 +206,7 @@ class CommandNSRegister : public Command source.Reply(_("Nickname \002%s\002 registered."), u_nick.c_str()); Anope::string tmp_pass; - if (enc_decrypt(na->nc->pass, tmp_pass) == 1) + if (Anope::Decrypt(na->nc->pass, tmp_pass) == 1) source.Reply(_("Your password is \002%s\002 - remember this for later use."), tmp_pass.c_str()); if (Config->NSRegistration.equals_ci("admin")) @@ -220,16 +220,16 @@ class CommandNSRegister : public Command if (SendRegmail(u, na, source.service)) { source.Reply(_("A passcode has been sent to %s, please type %s%s confirm <passcode> to confirm your email address."), email.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str()); - source.Reply(_("If you do not confirm your email address within %s your account will expire."), duration(Config->NSUnconfirmedExpire).c_str()); + source.Reply(_("If you do not confirm your email address within %s your account will expire."), Anope::Duration(Config->NSUnconfirmedExpire).c_str()); } } else if (Config->NSRegistration.equals_ci("none")) { if (u) { - ircdproto->SendLogin(u); + IRCD->SendLogin(u); if (!Config->NoNicknameOwnership && na->nc == u->Account() && na->nc->HasFlag(NI_UNCONFIRMED) == false) - u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); + u->SetMode(NickServ, UMODE_REGISTERED); } } @@ -290,7 +290,7 @@ class CommandNSResend : public Command if (Config->NSRegistration.equals_ci("mail")) return; - const NickAlias *na = findnick(source.GetNick()); + const NickAlias *na = NickAlias::Find(source.GetNick()); if (na == NULL) source.Reply(NICK_NOT_REGISTERED); @@ -372,8 +372,8 @@ static bool SendRegmail(User *u, const NickAlias *na, const BotInfo *bi) else codebuf = *code; - Anope::string subject = translate(na->nc, Config->MailRegistrationSubject.c_str()); - Anope::string message = translate(na->nc, Config->MailRegistrationMessage.c_str()); + Anope::string subject = Language::Translate(na->nc, Config->MailRegistrationSubject.c_str()); + Anope::string message = Language::Translate(na->nc, Config->MailRegistrationMessage.c_str()); subject = subject.replace_all_cs("%n", na->nick); subject = subject.replace_all_cs("%N", Config->NetworkName); @@ -383,7 +383,7 @@ static bool SendRegmail(User *u, const NickAlias *na, const BotInfo *bi) message = message.replace_all_cs("%N", Config->NetworkName); message = message.replace_all_cs("%c", codebuf); - return Mail(u, nc, bi, subject, message); + return Mail::Send(u, nc, bi, subject, message); } MODULE_INIT(NSRegister) diff --git a/modules/commands/ns_release.cpp b/modules/commands/ns_release.cpp index cd669e707..a3004f462 100644 --- a/modules/commands/ns_release.cpp +++ b/modules/commands/ns_release.cpp @@ -17,7 +17,7 @@ class NSReleaseRequest : public IdentifyRequest { CommandSource source; Command *cmd; - dynamic_reference<NickAlias> na; + Reference<NickAlias> na; public: NSReleaseRequest(Module *m, CommandSource &src, Command *c, NickAlias *n, const Anope::string &pass) : IdentifyRequest(m, n->nc->display, pass), source(src), cmd(c), na(n) { } @@ -40,7 +40,7 @@ class NSReleaseRequest : public IdentifyRequest { Log(LOG_COMMAND, source, cmd) << "with invalid password for " << na->nick; if (!source.GetUser()) - bad_password(source.GetUser()); + source.GetUser()->BadPassword(); } } }; @@ -61,7 +61,7 @@ class CommandNSRelease : public Command Anope::string pass = params.size() > 1 ? params[1] : ""; NickAlias *na; - if (!(na = findnick(nick))) + if (!(na = NickAlias::Find(nick))) source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); else if (na->nc->HasFlag(NI_SUSPENDED)) source.Reply(NICK_X_SUSPENDED, na->nick.c_str()); @@ -74,7 +74,7 @@ class CommandNSRelease : public Command bool ok = override; if (source.GetAccount() == na->nc) ok = true; - else if (source.GetUser() && !na->nc->HasFlag(NI_SECURE) && is_on_access(source.GetUser(), na->nc)) + else if (source.GetUser() && !na->nc->HasFlag(NI_SECURE) && na->nc->IsOnAccess(source.GetUser())) ok = true; else if (source.GetUser() && !source.GetUser()->fingerprint.empty() && na->nc->FindCert(source.GetUser()->fingerprint)) ok = true; @@ -101,7 +101,7 @@ class CommandNSRelease : public Command bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override { /* Convert Config->NSReleaseTimeout seconds to string format */ - Anope::string relstr = duration(Config->NSReleaseTimeout); + Anope::string relstr = Anope::Duration(Config->NSReleaseTimeout); this->SendSyntax(source); source.Reply(" "); diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp index 8965b6a3e..39eead56e 100644 --- a/modules/commands/ns_resetpass.cpp +++ b/modules/commands/ns_resetpass.cpp @@ -31,7 +31,7 @@ class CommandNSResetPass : public Command if (Config->RestrictMail && source.HasCommand("nickserv/resetpass")) source.Reply(ACCESS_DENIED); - else if (!(na = findnick(params[0]))) + else if (!(na = NickAlias::Find(params[0]))) source.Reply(NICK_X_NOT_REGISTERED, params[0].c_str()); else { @@ -82,7 +82,7 @@ class NSResetPass : public Module { if (command->name == "nickserv/confirm" && params.size() > 1) { - NickAlias *na = findnick(params[0]); + NickAlias *na = NickAlias::Find(params[0]); ResetInfo *ri = na ? na->nc->GetExt<ResetInfo *>("ns_resetpass") : NULL; if (na && ri) @@ -135,8 +135,8 @@ static bool SendResetEmail(User *u, const NickAlias *na, const BotInfo *bi) for (idx = 0; idx < 20; ++idx) passcode += chars[1 + static_cast<int>((static_cast<float>(max - min)) * static_cast<uint16_t>(rand()) / 65536.0) + min]; - Anope::string subject = translate(na->nc, Config->MailResetSubject.c_str()); - Anope::string message = translate(na->nc, Config->MailResetMessage.c_str()); + Anope::string subject = Language::Translate(na->nc, Config->MailResetSubject.c_str()); + Anope::string message = Language::Translate(na->nc, Config->MailResetMessage.c_str()); subject = subject.replace_all_cs("%n", na->nick); subject = subject.replace_all_cs("%N", Config->NetworkName); @@ -152,7 +152,7 @@ static bool SendResetEmail(User *u, const NickAlias *na, const BotInfo *bi) NickCore *nc = na->nc; nc->Extend("ns_resetpass", ri); - return Mail(u, nc, bi, subject, message); + return Mail::Send(u, nc, bi, subject, message); } MODULE_INIT(NSResetPass) diff --git a/modules/commands/ns_saset.cpp b/modules/commands/ns_saset.cpp index 8d2ba08d9..ac3cb1d8f 100644 --- a/modules/commands/ns_saset.cpp +++ b/modules/commands/ns_saset.cpp @@ -40,7 +40,7 @@ class CommandNSSASet : public Command if (c_name.find_ci(this_name + " ") == 0) { - service_reference<Command> command("Command", info.name); + ServiceReference<Command> command("Command", info.name); if (command) { source.command = c_name; @@ -66,7 +66,7 @@ class CommandNSSASetPassword : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - const NickAlias *setter_na = findnick(params[0]); + const NickAlias *setter_na = NickAlias::Find(params[0]); if (setter_na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, params[0].c_str()); @@ -92,9 +92,9 @@ class CommandNSSASetPassword : public Command return; } - enc_encrypt(params[1], nc->pass); + Anope::Encrypt(params[1], nc->pass); Anope::string tmp_pass; - if (enc_decrypt(nc->pass, tmp_pass) == 1) + if (Anope::Decrypt(nc->pass, tmp_pass) == 1) source.Reply(_("Password for \002%s\002 changed to \002%s\002."), nc->display.c_str(), tmp_pass.c_str()); else source.Reply(_("Password for \002%s\002 changed."), nc->display.c_str()); diff --git a/modules/commands/ns_saset_noexpire.cpp b/modules/commands/ns_saset_noexpire.cpp index 5ebfdce89..ea3e946ae 100644 --- a/modules/commands/ns_saset_noexpire.cpp +++ b/modules/commands/ns_saset_noexpire.cpp @@ -24,7 +24,7 @@ class CommandNSSASetNoexpire : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - NickAlias *na = findnick(params[0]); + NickAlias *na = NickAlias::Find(params[0]); if (na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/ns_sendpass.cpp b/modules/commands/ns_sendpass.cpp index 5d88fd5a4..e85690e24 100644 --- a/modules/commands/ns_sendpass.cpp +++ b/modules/commands/ns_sendpass.cpp @@ -32,12 +32,12 @@ class CommandNSSendPass : public Command if (Config->RestrictMail && !source.HasCommand("nickserv/sendpass")) source.Reply(ACCESS_DENIED); - else if (!(na = findnick(nick))) + else if (!(na = NickAlias::Find(nick))) source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); else { Anope::string tmp_pass; - if (enc_decrypt(na->nc->pass, tmp_pass) == 1) + if (Anope::Decrypt(na->nc->pass, tmp_pass) == 1) { if (SendPassMail(source.GetUser(), na, source.service, tmp_pass)) { @@ -79,7 +79,7 @@ class NSSendPass : public Module throw ModuleException("Not using mail."); Anope::string tmp_pass = "plain:tmp"; - if (enc_decrypt(tmp_pass, tmp_pass) == -1) + if (Anope::Decrypt(tmp_pass, tmp_pass) == -1) throw ModuleException("Incompatible with the encryption module being used"); } @@ -87,8 +87,8 @@ class NSSendPass : public Module static bool SendPassMail(User *u, const NickAlias *na, const BotInfo *bi, const Anope::string &pass) { - Anope::string subject = translate(na->nc, Config->MailSendpassSubject.c_str()); - Anope::string message = translate(na->nc, Config->MailSendpassMessage.c_str()); + Anope::string subject = Language::Translate(na->nc, Config->MailSendpassSubject.c_str()); + Anope::string message = Language::Translate(na->nc, Config->MailSendpassMessage.c_str()); subject = subject.replace_all_cs("%n", na->nick); subject = subject.replace_all_cs("%N", Config->NetworkName); @@ -98,7 +98,7 @@ static bool SendPassMail(User *u, const NickAlias *na, const BotInfo *bi, const message = message.replace_all_cs("%N", Config->NetworkName); message = message.replace_all_cs("%p", pass); - return Mail(u, na->nc, bi, subject, message); + return Mail::Send(u, na->nc, bi, subject, message); } MODULE_INIT(NSSendPass) diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index 0917d45bd..bc6a67b35 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -41,7 +41,7 @@ class CommandNSSet : public Command if (c_name.find_ci(this_name + " ") == 0) { - service_reference<Command> command("Command", info.name); + ServiceReference<Command> command("Command", info.name); if (command) { source.command = c_name; @@ -81,9 +81,9 @@ class CommandNSSetPassword : public Command return; } - enc_encrypt(param, source.nc->pass); + Anope::Encrypt(param, source.nc->pass); Anope::string tmp_pass; - if (enc_decrypt(source.nc->pass, tmp_pass) == 1) + if (Anope::Decrypt(source.nc->pass, tmp_pass) == 1) source.Reply(_("Password for \002%s\002 changed to \002%s\002."), source.nc->display.c_str(), tmp_pass.c_str()); else source.Reply(_("Password for \002%s\002 changed."), source.nc->display.c_str()); diff --git a/modules/commands/ns_set_autoop.cpp b/modules/commands/ns_set_autoop.cpp index 7e3864420..e6533875b 100644 --- a/modules/commands/ns_set_autoop.cpp +++ b/modules/commands/ns_set_autoop.cpp @@ -24,7 +24,7 @@ class CommandNSSetAutoOp : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - const NickAlias *na = findnick(user); + const NickAlias *na = NickAlias::Find(user); if (na == NULL) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); diff --git a/modules/commands/ns_set_chanstats.cpp b/modules/commands/ns_set_chanstats.cpp index 5bf23907b..7b8f371ff 100644 --- a/modules/commands/ns_set_chanstats.cpp +++ b/modules/commands/ns_set_chanstats.cpp @@ -23,7 +23,7 @@ class CommandNSSetChanstats : public Command } void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - NickAlias *na = findnick(user); + NickAlias *na = NickAlias::Find(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); diff --git a/modules/commands/ns_set_display.cpp b/modules/commands/ns_set_display.cpp index 1980ba116..c532f4cf1 100644 --- a/modules/commands/ns_set_display.cpp +++ b/modules/commands/ns_set_display.cpp @@ -24,7 +24,7 @@ class CommandNSSetDisplay : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - const NickAlias *user_na = findnick(user), *na = findnick(param); + const NickAlias *user_na = NickAlias::Find(user), *na = NickAlias::Find(param); if (user_na == NULL) { @@ -42,7 +42,7 @@ class CommandNSSetDisplay : public Command if (MOD_RESULT == EVENT_STOP) return; - change_core_display(user_na->nc, na->nick); + user_na->nc->SetDisplay(na); source.Reply(NICK_SET_DISPLAY_CHANGED, user_na->nc->display.c_str()); } diff --git a/modules/commands/ns_set_email.cpp b/modules/commands/ns_set_email.cpp index 6966c2a79..82b4a0cc8 100644 --- a/modules/commands/ns_set_email.cpp +++ b/modules/commands/ns_set_email.cpp @@ -40,7 +40,7 @@ static bool SendConfirmMail(User *u, const BotInfo *bi) message = message.replace_all_cs("%N", Config->NetworkName); message = message.replace_all_cs("%c", code); - return Mail(u, u->Account(), bi, subject, message); + return Mail::Send(u, u->Account(), bi, subject, message); } class CommandNSSetEmail : public Command @@ -54,7 +54,7 @@ class CommandNSSetEmail : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - const NickAlias *na = findnick(user); + const NickAlias *na = NickAlias::Find(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); @@ -72,7 +72,7 @@ class CommandNSSetEmail : public Command source.Reply(_("You may not change the email of other services operators.")); return; } - else if (!param.empty() && !MailValidate(param)) + else if (!param.empty() && !Mail::Validate(param)) { source.Reply(MAIL_X_INVALID, param.c_str()); return; diff --git a/modules/commands/ns_set_greet.cpp b/modules/commands/ns_set_greet.cpp index 87ac7d1ee..b28edc2bb 100644 --- a/modules/commands/ns_set_greet.cpp +++ b/modules/commands/ns_set_greet.cpp @@ -24,7 +24,7 @@ class CommandNSSetGreet : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - const NickAlias *na = findnick(user); + const NickAlias *na = NickAlias::Find(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); diff --git a/modules/commands/ns_set_hide.cpp b/modules/commands/ns_set_hide.cpp index 4770653f2..d7fe886ea 100644 --- a/modules/commands/ns_set_hide.cpp +++ b/modules/commands/ns_set_hide.cpp @@ -24,7 +24,7 @@ class CommandNSSetHide : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m, const Anope::string &arg) { - const NickAlias *na = findnick(user); + const NickAlias *na = NickAlias::Find(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); diff --git a/modules/commands/ns_set_kill.cpp b/modules/commands/ns_set_kill.cpp index ca0f804d3..0f62a4ba0 100644 --- a/modules/commands/ns_set_kill.cpp +++ b/modules/commands/ns_set_kill.cpp @@ -24,7 +24,7 @@ class CommandNSSetKill : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - const NickAlias *na = findnick(user); + const NickAlias *na = NickAlias::Find(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); diff --git a/modules/commands/ns_set_language.cpp b/modules/commands/ns_set_language.cpp index 43162d6fd..d2830d4b8 100644 --- a/modules/commands/ns_set_language.cpp +++ b/modules/commands/ns_set_language.cpp @@ -24,7 +24,7 @@ class CommandNSSetLanguage : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - const NickAlias *na = findnick(user); + const NickAlias *na = NickAlias::Find(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); @@ -37,11 +37,11 @@ class CommandNSSetLanguage : public Command if (MOD_RESULT == EVENT_STOP) return; - for (unsigned j = 0; j < languages.size(); ++j) + for (unsigned j = 0; j < Language::Languages.size(); ++j) { - if (param == "en" || languages[j] == param) + if (param == "en" || Language::Languages[j] == param) break; - else if (j + 1 == languages.size()) + else if (j + 1 == Language::Languages.size()) { this->OnSyntaxError(source, ""); return; @@ -69,12 +69,12 @@ class CommandNSSetLanguage : public Command "supported languages:")); source.Reply(" en (English)"); - for (unsigned j = 0; j < languages.size(); ++j) + for (unsigned j = 0; j < Language::Languages.size(); ++j) { - const Anope::string &langname = anope_gettext(languages[j].c_str(), _("English")); + const Anope::string &langname = Language::Translate(Language::Languages[j].c_str(), _("English")); if (langname == "English") continue; - source.Reply(" %s (%s)", languages[j].c_str(), langname.c_str()); + source.Reply(" %s (%s)", Language::Languages[j].c_str(), langname.c_str()); } return true; @@ -104,12 +104,12 @@ class CommandNSSASetLanguage : public CommandNSSetLanguage "\037language\037 should be chosen from the following list of\n" "supported languages:")); source.Reply(" en (English)"); - for (unsigned j = 0; j < languages.size(); ++j) + for (unsigned j = 0; j < Language::Languages.size(); ++j) { - const Anope::string &langname = anope_gettext(languages[j].c_str(), _("English")); + const Anope::string &langname = Language::Translate(Language::Languages[j].c_str(), _("English")); if (langname == "English") continue; - source.Reply(" %s (%s)", languages[j].c_str(), langname.c_str()); + source.Reply(" %s (%s)", Language::Languages[j].c_str(), langname.c_str()); } return true; } diff --git a/modules/commands/ns_set_message.cpp b/modules/commands/ns_set_message.cpp index fa0ad7ec3..f515b22c1 100644 --- a/modules/commands/ns_set_message.cpp +++ b/modules/commands/ns_set_message.cpp @@ -24,7 +24,7 @@ class CommandNSSetMessage : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - const NickAlias *na = findnick(user); + const NickAlias *na = NickAlias::Find(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index 9c805b3ea..1e088a425 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -15,7 +15,7 @@ struct NSMiscData : ExtensibleItem, Serializable { - serialize_obj<NickCore> nc; + Serialize::Reference<NickCore> nc; Anope::string name; Anope::string data; @@ -23,7 +23,7 @@ struct NSMiscData : ExtensibleItem, Serializable { } - Serialize::Data serialize() const anope_override + Serialize::Data Serialize() const anope_override { Serialize::Data sdata; @@ -34,9 +34,9 @@ struct NSMiscData : ExtensibleItem, Serializable return sdata; } - static Serializable* unserialize(Serializable *obj, Serialize::Data &data) + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { - NickCore *nc = findcore(data["nc"].astr()); + NickCore *nc = NickCore::Find(data["nc"].astr()); if (nc == NULL) return NULL; @@ -76,7 +76,7 @@ class CommandNSSetMisc : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - const NickAlias *na = findnick(user); + const NickAlias *na = NickAlias::Find(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); @@ -126,13 +126,13 @@ class CommandNSSASetMisc : public CommandNSSetMisc class NSSetMisc : public Module { - SerializeType nsmiscdata_type; + Serialize::Type nsmiscdata_type; CommandNSSetMisc commandnssetmisc; CommandNSSASetMisc commandnssasetmisc; public: NSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - nsmiscdata_type("NSMiscData", NSMiscData::unserialize), commandnssetmisc(this), commandnssasetmisc(this) + nsmiscdata_type("NSMiscData", NSMiscData::Unserialize), commandnssetmisc(this), commandnssasetmisc(this) { this->SetAuthor("Anope"); diff --git a/modules/commands/ns_set_private.cpp b/modules/commands/ns_set_private.cpp index 358035567..8f953fcc0 100644 --- a/modules/commands/ns_set_private.cpp +++ b/modules/commands/ns_set_private.cpp @@ -24,7 +24,7 @@ class CommandNSSetPrivate : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - const NickAlias *na = findnick(user); + const NickAlias *na = NickAlias::Find(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); diff --git a/modules/commands/ns_set_secure.cpp b/modules/commands/ns_set_secure.cpp index 52eea8e5b..b7dd79969 100644 --- a/modules/commands/ns_set_secure.cpp +++ b/modules/commands/ns_set_secure.cpp @@ -24,7 +24,7 @@ class CommandNSSetSecure : public Command void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) { - const NickAlias *na = findnick(user); + const NickAlias *na = NickAlias::Find(user); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); diff --git a/modules/commands/ns_status.cpp b/modules/commands/ns_status.cpp index 7a5a68a5a..495ae96a1 100644 --- a/modules/commands/ns_status.cpp +++ b/modules/commands/ns_status.cpp @@ -26,13 +26,13 @@ class CommandNSStatus : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { const Anope::string &nick = !params.empty() ? params[0] : source.GetNick(); - const NickAlias *na = findnick(nick); + const NickAlias *na = NickAlias::Find(nick); spacesepstream sep(nick); Anope::string nickbuf; while (sep.GetToken(nickbuf)) { - User *u2 = finduser(nickbuf); + User *u2 = User::Find(nickbuf, true); if (!u2) /* Nick is not online */ source.Reply(_("STATUS %s %d %s"), nickbuf.c_str(), 0, ""); else if (u2->IsIdentified() && na && na->nc == u2->Account()) /* Nick is identified */ diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index 6b316379e..6ff355437 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -22,7 +22,7 @@ struct NickSuspend : ExtensibleItem, Serializable { } - Serialize::Data serialize() const anope_override + Serialize::Data Serialize() const anope_override { Serialize::Data sd; @@ -32,9 +32,9 @@ struct NickSuspend : ExtensibleItem, Serializable return sd; } - static Serializable* unserialize(Serializable *obj, Serialize::Data &sd) + static Serializable* Unserialize(Serializable *obj, Serialize::Data &sd) { - const NickAlias *na = findnick(sd["nick"].astr()); + const NickAlias *na = NickAlias::Find(sd["nick"].astr()); if (na == NULL) return NULL; @@ -71,7 +71,7 @@ class CommandNSSuspend : public Command Anope::string reason = params.size() > 2 ? params[2] : ""; time_t expiry_secs = Config->NSSuspendExpire; - if (readonly) + if (Anope::ReadOnly) { source.Reply(READ_ONLY_MODE); return; @@ -84,9 +84,9 @@ class CommandNSSuspend : public Command expiry.clear(); } else - expiry_secs = dotime(expiry); + expiry_secs = Anope::DoTime(expiry); - NickAlias *na = findnick(nick); + NickAlias *na = NickAlias::Find(nick); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -107,7 +107,7 @@ class CommandNSSuspend : public Command nc->UnsetFlag(NI_KILL_QUICK); nc->UnsetFlag(NI_KILL_IMMED); - for (std::list<serialize_obj<NickAlias> >::iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;) + for (std::list<Serialize::Reference<NickAlias> >::iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;) { NickAlias *na2 = *it++; @@ -115,7 +115,7 @@ class CommandNSSuspend : public Command { na2->last_quit = reason; - User *u2 = finduser(na2->nick); + User *u2 = User::Find(na2->nick); if (u2) { u2->Logout(); @@ -133,7 +133,7 @@ class CommandNSSuspend : public Command nc->Extend("ns_suspend_expire", ns); } - Log(LOG_ADMIN, source, this) << "for " << nick << " (" << (!reason.empty() ? reason : "No reason") << "), expires in " << (expiry_secs ? do_strftime(Anope::CurTime + expiry_secs) : "never"); + Log(LOG_ADMIN, source, this) << "for " << nick << " (" << (!reason.empty() ? reason : "No reason") << "), expires in " << (expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); source.Reply(_("Nick %s is now suspended."), nick.c_str()); FOREACH_MOD(I_OnNickSuspended, OnNickSuspend(na)); @@ -166,13 +166,13 @@ class CommandNSUnSuspend : public Command { const Anope::string &nick = params[0]; - if (readonly) + if (Anope::ReadOnly) { source.Reply(READ_ONLY_MODE); return; } - NickAlias *na = findnick(nick); + NickAlias *na = NickAlias::Find(nick); if (!na) { source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); @@ -207,13 +207,13 @@ class CommandNSUnSuspend : public Command class NSSuspend : public Module { - SerializeType nicksuspend_type; + Serialize::Type nicksuspend_type; CommandNSSuspend commandnssuspend; CommandNSUnSuspend commandnsunsuspend; public: NSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - nicksuspend_type("NickSuspend", NickSuspend::unserialize), commandnssuspend(this), commandnsunsuspend(this) + nicksuspend_type("NickSuspend", NickSuspend::Unserialize), commandnssuspend(this), commandnsunsuspend(this) { this->SetAuthor("Anope"); @@ -241,7 +241,7 @@ class NSSuspend : public Module na->nc->UnsetFlag(NI_SUSPENDED); na->nc->Shrink("ns_suspend_expire"); - Log(LOG_NORMAL, "expire", findbot(Config->NickServ)) << "Expiring suspend for " << na->nick; + Log(LOG_NORMAL, "expire", NickServ) << "Expiring suspend for " << na->nick; } } }; diff --git a/modules/commands/ns_update.cpp b/modules/commands/ns_update.cpp index 5ca8da26d..8f4812b9e 100644 --- a/modules/commands/ns_update.cpp +++ b/modules/commands/ns_update.cpp @@ -28,7 +28,7 @@ class CommandNSUpdate : public Command if (!u) return; - NickAlias *na = findnick(u->nick); + NickAlias *na = NickAlias::Find(u->nick); if (na && na->nc == source.GetAccount()) { diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp index f09d1f87a..89b1d96ae 100644 --- a/modules/commands/os_akill.cpp +++ b/modules/commands/os_akill.cpp @@ -13,38 +13,38 @@ #include "module.h" -static service_reference<XLineManager> akills("XLineManager", "xlinemanager/sgline"); +static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sgline"); class AkillDelCallback : public NumberList { CommandSource &source; - unsigned Deleted; + unsigned deleted; public: - AkillDelCallback(CommandSource &_source, const Anope::string &numlist) : NumberList(numlist, true), source(_source), Deleted(0) + AkillDelCallback(CommandSource &_source, const Anope::string &numlist) : NumberList(numlist, true), source(_source), deleted(0) { } ~AkillDelCallback() { - if (!Deleted) + if (!deleted) source.Reply(_("No matching entries on the AKILL list.")); - else if (Deleted == 1) + else if (deleted == 1) source.Reply(_("Deleted 1 entry from the AKILL list.")); else - source.Reply(_("Deleted %d entries from the AKILL list."), Deleted); + source.Reply(_("Deleted %d entries from the AKILL list."), deleted); } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned number) anope_override { - if (!Number) + if (!number) return; - XLine *x = akills->GetEntry(Number - 1); + XLine *x = akills->GetEntry(number - 1); if (!x) return; - ++Deleted; + ++deleted; DoDel(source, x); } @@ -76,7 +76,7 @@ class CommandOSAKill : public Command sep.GetToken(mask); } - time_t expires = !expiry.empty() ? dotime(expiry) : Config->AutokillExpiry; + time_t expires = !expiry.empty() ? Anope::DoTime(expiry) : Config->AutokillExpiry; /* If the expiry given does not contain a final letter, it's in days, * said the doc. Ah well. */ @@ -127,7 +127,7 @@ class CommandOSAKill : public Command return; } - service_reference<RegexProvider> provider("Regex", Config->RegexEngine); + ServiceReference<RegexProvider> provider("Regex", Config->RegexEngine); if (!provider) { source.Reply(_("Unable to find regex engine %s"), Config->RegexEngine.c_str()); @@ -146,7 +146,7 @@ class CommandOSAKill : public Command } } - User *targ = finduser(mask); + User *targ = User::Find(mask, true); if (targ) mask = "*@" + targ->host; @@ -160,7 +160,7 @@ class CommandOSAKill : public Command XLine *x = new XLine(mask, source.GetNick(), expires, reason); if (Config->AkillIds) - x->UID = XLineManager::GenerateUID(); + x->id = XLineManager::GenerateUID(); unsigned int affected = 0; for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) @@ -172,7 +172,7 @@ class CommandOSAKill : public Command { source.Reply(USERHOST_MASK_TOO_WIDE, mask.c_str()); Log(LOG_ADMIN, source, this) << "tried to akill " << percent << "% of the network (" << affected << " users)"; - x->destroy(); + x->Destroy(); return; } @@ -180,7 +180,7 @@ class CommandOSAKill : public Command FOREACH_RESULT(I_OnAddXLine, OnAddXLine(source, x, akills)); if (MOD_RESULT == EVENT_STOP) { - x->destroy(); + x->Destroy(); return; } @@ -190,8 +190,8 @@ class CommandOSAKill : public Command source.Reply(_("\002%s\002 added to the AKILL list."), mask.c_str()); - Log(LOG_ADMIN, source, this) << "on " << mask << " (" << x->Reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; - if (readonly) + Log(LOG_ADMIN, source, this) << "on " << mask << " (" << x->reason << ") expires in " << (expires ? Anope::Duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); } @@ -230,14 +230,14 @@ class CommandOSAKill : public Command { FOREACH_MOD(I_OnDelXLine, OnDelXLine(source, x, akills)); - source.Reply(_("\002%s\002 deleted from the AKILL list."), x->Mask.c_str()); + source.Reply(_("\002%s\002 deleted from the AKILL list."), x->mask.c_str()); AkillDelCallback::DoDel(source, x); } while ((x = akills->HasEntry(mask))); } - if (readonly) + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); return; @@ -269,12 +269,12 @@ class CommandOSAKill : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(number); - entry["Mask"] = x->Mask; - entry["Creator"] = x->By; - entry["Created"] = do_strftime(x->Created, NULL, true); - entry["Expires"] = expire_left(NULL, x->Expires); - entry["Reason"] = x->Reason; - this->list.addEntry(entry); + entry["Mask"] = x->mask; + entry["Creator"] = x->by; + entry["Created"] = Anope::strftime(x->created, NULL, true); + entry["Expires"] = Anope::Expires(x->expires); + entry["Reason"] = x->reason; + this->list.AddEntry(entry); } } nl_list(list, mask); @@ -286,21 +286,21 @@ class CommandOSAKill : public Command { const XLine *x = akills->GetEntry(i); - if (mask.empty() || mask.equals_ci(x->Mask) || mask == x->UID || Anope::Match(x->Mask, mask, false, true)) + if (mask.empty() || mask.equals_ci(x->mask) || mask == x->id || Anope::Match(x->mask, mask, false, true)) { ListFormatter::ListEntry entry; entry["Number"] = stringify(i + 1); - entry["Mask"] = x->Mask; - entry["Creator"] = x->By; - entry["Created"] = do_strftime(x->Created, NULL, true); - entry["Expires"] = expire_left(source.nc, x->Expires); - entry["Reason"] = x->Reason; - list.addEntry(entry); + entry["Mask"] = x->mask; + entry["Creator"] = x->by; + entry["Created"] = Anope::strftime(x->created, NULL, true); + entry["Expires"] = Anope::Expires(x->expires, source.nc); + entry["Reason"] = x->reason; + list.AddEntry(entry); } } } - if (list.isEmpty()) + if (list.IsEmpty()) source.Reply(_("No matching entries on the AKILL list.")); else { @@ -325,7 +325,7 @@ class CommandOSAKill : public Command } ListFormatter list; - list.addColumn("Number").addColumn("Mask").addColumn("Reason"); + list.AddColumn("Number").AddColumn("Mask").AddColumn("Reason"); this->ProcessList(source, params, list); } @@ -339,7 +339,7 @@ class CommandOSAKill : public Command } ListFormatter list; - list.addColumn("Number").addColumn("Mask").addColumn("Creator").addColumn("Created").addColumn("Expires").addColumn("Reason"); + list.AddColumn("Number").AddColumn("Mask").AddColumn("Creator").AddColumn("Created").AddColumn("Expires").AddColumn("Reason"); this->ProcessList(source, params, list); } diff --git a/modules/commands/os_chankill.cpp b/modules/commands/os_chankill.cpp index 456525a46..c1d71831b 100644 --- a/modules/commands/os_chankill.cpp +++ b/modules/commands/os_chankill.cpp @@ -13,7 +13,7 @@ #include "module.h" -static service_reference<XLineManager> akills("XLineManager", "xlinemanager/sgline"); +static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sgline"); class CommandOSChanKill : public Command { @@ -42,7 +42,7 @@ class CommandOSChanKill : public Command last_param = 2; } - expires = !expiry.empty() ? dotime(expiry) : Config->ChankillExpiry; + expires = !expiry.empty() ? Anope::DoTime(expiry) : Config->ChankillExpiry; if (!expiry.empty() && isdigit(expiry[expiry.length() - 1])) expires *= 86400; if (expires && expires < 60) @@ -70,7 +70,7 @@ class CommandOSChanKill : public Command else realreason = reason; - if ((c = findchan(channel))) + if ((c = Channel::Find(channel))) { for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) { diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp index 11437a087..61cda44c0 100644 --- a/modules/commands/os_config.cpp +++ b/modules/commands/os_config.cpp @@ -117,7 +117,7 @@ class CommandOSConfig : public Command } case DT_TIME: { - time_t time = dotime(vi.GetValue()); + time_t time = Anope::DoTime(vi.GetValue()); ValueContainerTime *vci = anope_dynamic_static_cast<ValueContainerTime *>(v->val); vci->Set(&time, sizeof(time_t)); break; @@ -169,7 +169,7 @@ class CommandOSConfig : public Command continue; ListFormatter lflist; - lflist.addColumn("Name").addColumn("Value"); + lflist.AddColumn("Name").AddColumn("Value"); for (unsigned i = 0; i < list.size(); ++i) { const Anope::string &first = list[i].first, second = list[i].second; @@ -177,7 +177,7 @@ class CommandOSConfig : public Command ListFormatter::ListEntry entry; entry["Name"] = first; entry["Value"] = second; - lflist.addEntry(entry); + lflist.AddEntry(entry); } std::vector<Anope::string> replies; diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index ad08ba77c..1457a57dc 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -34,8 +34,8 @@ bool DefConModesSet = false; struct DefconConfig { std::vector<std::bitset<32> > DefCon; - Flags<ChannelModeName, CMODE_END * 2> DefConModesOn; - Flags<ChannelModeName, CMODE_END * 2> DefConModesOff; + Flags<ChannelModeName> DefConModesOn; + Flags<ChannelModeName> DefConModesOff; std::map<ChannelModeName, Anope::string> DefConModesOnParams; int defaultlevel, sessionlimit; @@ -117,17 +117,17 @@ class DefConTimeout : public CallBack { DConfig.defaultlevel = level; FOREACH_MOD(I_OnDefconLevel, OnDefconLevel(level)); - Log(findbot(Config->OperServ), "operserv/defcon") << "Defcon level timeout, returning to level " << level; + Log(OperServ, "operserv/defcon") << "Defcon level timeout, returning to level " << level; if (DConfig.globalondefcon) { if (!DConfig.offmessage.empty()) - global->SendGlobal(findbot(Config->Global), "", DConfig.offmessage); + GlobalService->SendGlobal(Global, "", DConfig.offmessage); else - global->SendGlobal(findbot(Config->Global), "", Anope::printf(translate(_("The Defcon Level is now at Level: \002%d\002")), DConfig.defaultlevel)); + GlobalService->SendGlobal(Global, "", Anope::printf(Language::Translate(_("The Defcon Level is now at Level: \002%d\002")), DConfig.defaultlevel)); if (!DConfig.message.empty()) - global->SendGlobal(findbot(Config->Global), "", DConfig.message); + GlobalService->SendGlobal(Global, "", DConfig.message); } runDefCon(); @@ -215,12 +215,12 @@ class CommandOSDefcon : public Command if (DConfig.globalondefcon) { if (DConfig.defaultlevel == 5 && !DConfig.offmessage.empty()) - global->SendGlobal(findbot(Config->Global), "", DConfig.offmessage); + GlobalService->SendGlobal(Global, "", DConfig.offmessage); else if (DConfig.defaultlevel != 5) { - global->SendGlobal(findbot(Config->Global), "", Anope::printf(_("The Defcon level is now at: \002%d\002"), DConfig.defaultlevel)); + GlobalService->SendGlobal(Global, "", Anope::printf(_("The Defcon level is now at: \002%d\002"), DConfig.defaultlevel)); if (!DConfig.message.empty()) - global->SendGlobal(findbot(Config->Global), "", DConfig.message); + GlobalService->SendGlobal(Global, "", DConfig.message); } } @@ -242,8 +242,8 @@ class CommandOSDefcon : public Command class OSDefcon : public Module { - service_reference<SessionService> session_service; - service_reference<XLineManager> akills; + ServiceReference<SessionService> session_service; + ServiceReference<XLineManager> akills; CommandOSDefcon commandosdefcon; void ParseModeString() @@ -280,17 +280,17 @@ class OSDefcon : public Module if ((cm = ModeManager::FindChannelModeByChar(mode))) { - if (cm->Type == MODE_STATUS || cm->Type == MODE_LIST || !cm->CanSet(NULL)) + if (cm->type == MODE_STATUS || cm->type == MODE_LIST || !cm->CanSet(NULL)) { Log(this) << "DefConChanModes mode character '" << mode << "' cannot be locked"; continue; } else if (add) { - DConfig.DefConModesOn.SetFlag(cm->Name); - DConfig.DefConModesOff.UnsetFlag(cm->Name); + DConfig.DefConModesOn.SetFlag(cm->name); + DConfig.DefConModesOff.UnsetFlag(cm->name); - if (cm->Type == MODE_PARAM) + if (cm->type == MODE_PARAM) { cmp = anope_dynamic_static_cast<ChannelModeParam *>(cm); @@ -303,21 +303,21 @@ class OSDefcon : public Module if (!cmp->IsValid(param)) continue; - DConfig.SetDefConParam(cmp->Name, param); + DConfig.SetDefConParam(cmp->name, param); } } - else if (DConfig.DefConModesOn.HasFlag(cm->Name)) + else if (DConfig.DefConModesOn.HasFlag(cm->name)) { - DConfig.DefConModesOn.UnsetFlag(cm->Name); + DConfig.DefConModesOn.UnsetFlag(cm->name); - if (cm->Type == MODE_PARAM) - DConfig.UnsetDefConParam(cm->Name); + if (cm->type == MODE_PARAM) + DConfig.UnsetDefConParam(cm->name); } } } /* We can't mlock +L if +l is not mlocked as well. */ - if ((cm = ModeManager::FindChannelModeByName(CMODE_REDIRECT)) && DConfig.DefConModesOn.HasFlag(cm->Name) && !DConfig.DefConModesOn.HasFlag(CMODE_LIMIT)) + if ((cm = ModeManager::FindChannelModeByName(CMODE_REDIRECT)) && DConfig.DefConModesOn.HasFlag(cm->name) && !DConfig.DefConModesOn.HasFlag(CMODE_LIMIT)) { DConfig.DefConModesOn.UnsetFlag(CMODE_REDIRECT); @@ -356,9 +356,9 @@ class OSDefcon : public Module dconfig.defcons[1] = config.ReadValue("defcon", "level1", 0); dconfig.sessionlimit = config.ReadInteger("defcon", "sessionlimit", 0, 0); dconfig.akillreason = config.ReadValue("defcon", "akillreason", 0); - dconfig.akillexpire = dotime(config.ReadValue("defcon", "akillexpire", 0)); + dconfig.akillexpire = Anope::DoTime(config.ReadValue("defcon", "akillexpire", 0)); dconfig.chanmodes = config.ReadValue("defcon", "chanmodes", 0); - dconfig.timeout = dotime(config.ReadValue("defcon", "timeout", 0)); + dconfig.timeout = Anope::DoTime(config.ReadValue("defcon", "timeout", 0)); dconfig.globalondefcon = config.ReadFlag("defcon", "globalondefcon", 0); dconfig.message = config.ReadValue("defcon", "message", 0); dconfig.offmessage = config.ReadValue("defcon", "offmessage", 0); @@ -414,9 +414,9 @@ class OSDefcon : public Module { if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills) { - Log(findbot(Config->OperServ), "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; + Log(OperServ, "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; XLine *x = new XLine("*@" + u->host, Config->OperServ, Anope::CurTime + DConfig.akillexpire, DConfig.akillreason, XLineManager::GenerateUID()); - x->By = Config->OperServ; + x->by = Config->OperServ; akills->AddXLine(x); } @@ -435,7 +435,7 @@ class OSDefcon : public Module if (DConfig.Check(DEFCON_FORCE_CHAN_MODES) && cm && DConfig.DefConModesOff.HasFlag(Name)) { - c->RemoveMode(findbot(Config->OperServ), Name, param); + c->RemoveMode(OperServ, Name, param); return EVENT_STOP; } @@ -452,9 +452,9 @@ class OSDefcon : public Module Anope::string param; if (DConfig.GetDefConParam(Name, param)) - c->SetMode(findbot(Config->OperServ), Name, param); + c->SetMode(OperServ, Name, param); else - c->SetMode(findbot(Config->OperServ), Name); + c->SetMode(OperServ, Name); return EVENT_STOP; @@ -501,16 +501,16 @@ class OSDefcon : public Module return EVENT_CONTINUE; } - void OnUserConnect(dynamic_reference<User> &u, bool &exempt) anope_override + void OnUserConnect(Reference<User> &u, bool &exempt) anope_override { if (exempt || !u || !u->server->IsSynced() || u->server->IsULined()) return; if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills) { - Log(findbot(Config->OperServ), "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; + Log(OperServ, "operserv/defcon") << "DEFCON: adding akill for *@" << u->host; XLine x("*@" + u->host, Config->OperServ, Anope::CurTime + DConfig.akillexpire, DConfig.akillreason, XLineManager::GenerateUID()); - x.By = Config->OperServ; + x.by = Config->OperServ; akills->Send(NULL, &x); } if (DConfig.Check(DEFCON_NO_NEW_CLIENTS) || DConfig.Check(DEFCON_AKILL_NEW_CLIENTS)) @@ -525,7 +525,7 @@ class OSDefcon : public Module return; } - if (!DConfig.sessionlimit || !session_service) + if (DConfig.sessionlimit <= 0 || !session_service) return; Session *session; @@ -541,19 +541,19 @@ class OSDefcon : public Module if (DConfig.Check(DEFCON_REDUCE_SESSION) && !exception) { - if (session && session->count > DConfig.sessionlimit) + if (session && session->count > static_cast<unsigned>(DConfig.sessionlimit)) { if (!Config->SessionLimitExceeded.empty()) - ircdproto->SendMessage(findbot(Config->OperServ), u->nick, Config->SessionLimitExceeded.c_str(), u->host.c_str()); + IRCD->SendMessage(OperServ, u->nick, Config->SessionLimitExceeded.c_str(), u->host.c_str()); if (!Config->SessionLimitDetailsLoc.empty()) - ircdproto->SendMessage(findbot(Config->OperServ), u->nick, "%s", Config->SessionLimitDetailsLoc.c_str()); + IRCD->SendMessage(OperServ, u->nick, "%s", Config->SessionLimitDetailsLoc.c_str()); ++session->hits; if (akills && Config->MaxSessionKill && session->hits >= Config->MaxSessionKill) { XLine x("*@" + u->host, Config->OperServ, Anope::CurTime + Config->SessionAutoKillExpiry, "Defcon session limit exceeded", XLineManager::GenerateUID()); akills->Send(NULL, &x); - Log(findbot(Config->OperServ), "akill/defcon") << "[DEFCON] Added a temporary AKILL for \2*@" << u->host << "\2 due to excessive connections"; + Log(OperServ, "akill/defcon") << "[DEFCON] Added a temporary AKILL for \2*@" << u->host << "\2 due to excessive connections"; } else { @@ -566,14 +566,14 @@ class OSDefcon : public Module void OnChannelModeAdd(ChannelMode *cm) anope_override { - if (DConfig.chanmodes.find(cm->ModeChar) != Anope::string::npos) + if (DConfig.chanmodes.find(cm->mchar) != Anope::string::npos) this->ParseModeString(); } void OnChannelCreate(Channel *c) anope_override { if (DConfig.Check(DEFCON_FORCE_CHAN_MODES)) - c->SetModes(findbot(Config->OperServ), false, "%s", DConfig.chanmodes.c_str()); + c->SetModes(OperServ, false, "%s", DConfig.chanmodes.c_str()); } }; @@ -612,10 +612,10 @@ void runDefCon() { if (DConfig.chanmodes[0] == '+' || DConfig.chanmodes[0] == '-') { - Log(findbot(Config->OperServ), "operserv/defcon") << "DEFCON: setting " << DConfig.chanmodes << " on all channels"; + Log(OperServ, "operserv/defcon") << "DEFCON: setting " << DConfig.chanmodes << " on all channels"; DefConModesSet = true; for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) - it->second->SetModes(findbot(Config->OperServ), false, "%s", DConfig.chanmodes.c_str()); + it->second->SetModes(OperServ, false, "%s", DConfig.chanmodes.c_str()); } } } @@ -629,9 +629,9 @@ void runDefCon() Anope::string newmodes = defconReverseModes(DConfig.chanmodes); if (!newmodes.empty()) { - Log(findbot(Config->OperServ), "operserv/defcon") << "DEFCON: setting " << newmodes << " on all channels"; + Log(OperServ, "operserv/defcon") << "DEFCON: setting " << newmodes << " on all channels"; for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) - it->second->SetModes(findbot(Config->OperServ), false, "%s", newmodes.c_str()); + it->second->SetModes(OperServ, false, "%s", newmodes.c_str()); } } } diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp index e304050b3..769a42f26 100644 --- a/modules/commands/os_dns.cpp +++ b/modules/commands/os_dns.cpp @@ -44,12 +44,12 @@ class DNSServer : public Serializable void Pool(bool p) { pooled = p; - if (DNSEngine) - DNSEngine->UpdateSerial(); + if (DNS::Engine) + DNS::Engine->UpdateSerial(); } - Serialize::Data serialize() const anope_override + Serialize::Data Serialize() const anope_override { Serialize::Data data; @@ -62,7 +62,7 @@ class DNSServer : public Serializable return data; } - static Serializable* unserialize(Serializable *obj, Serialize::Data &data) + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { DNSServer *req; @@ -104,7 +104,7 @@ class CommandOSDNS : public Command } ListFormatter lf; - lf.addColumn("Server").addColumn("IP").addColumn("Limit").addColumn("State"); + lf.AddColumn("Server").AddColumn("IP").AddColumn("Limit").AddColumn("State"); for (unsigned i = 0; i < dns_servers.size(); ++i) { DNSServer *s = dns_servers[i]; @@ -129,7 +129,7 @@ class CommandOSDNS : public Command else entry["State"] = "Unpooled"; - lf.addEntry(entry); + lf.AddEntry(entry); } std::vector<Anope::string> replies; @@ -221,7 +221,7 @@ class CommandOSDNS : public Command Log(LOG_ADMIN, source, this) << "to add IP " << params[2] << " to " << s->GetName(); if (s->Pooled()) - DNSEngine->UpdateSerial(); + DNS::Engine->UpdateSerial(); } void DelIP(CommandSource &source, const std::vector<Anope::string> ¶ms) @@ -248,7 +248,7 @@ class CommandOSDNS : public Command } if (s->Pooled()) - DNSEngine->UpdateSerial(); + DNS::Engine->UpdateSerial(); return; } @@ -388,7 +388,7 @@ class CommandOSDNS : public Command class ModuleDNS : public Module { - SerializeType dns_type; + Serialize::Type dns_type; CommandOSDNS commandosdns; time_t ttl; @@ -400,7 +400,7 @@ class ModuleDNS : public Module public: ModuleDNS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), - dns_type("DNSServer", DNSServer::unserialize), commandosdns(this) + dns_type("DNSServer", DNSServer::Unserialize), commandosdns(this) { this->SetAuthor("Anope"); @@ -414,10 +414,10 @@ class ModuleDNS : public Module { ConfigReader config; - this->ttl = dotime(config.ReadValue("os_dns", "ttl", 0)); + this->ttl = Anope::DoTime(config.ReadValue("os_dns", "ttl", 0)); this->user_drop_mark = config.ReadInteger("os_dns", "user_drop_mark", 0, false); - this->user_drop_time = dotime(config.ReadValue("os_dns", "user_drop_time", 0, false)); - this->user_drop_readd_time = dotime(config.ReadValue("os_dns", "user_drop_readd_time", 0, false)); + this->user_drop_time = Anope::DoTime(config.ReadValue("os_dns", "user_drop_time", 0, false)); + this->user_drop_readd_time = Anope::DoTime(config.ReadValue("os_dns", "user_drop_readd_time", 0, false)); this->remove_split_servers = config.ReadFlag("os_dns", "remove_split_servers", 0); this->readd_connected_servers = config.ReadFlag("os_dns", "readd_connected_servers", 0); } @@ -427,7 +427,7 @@ class ModuleDNS : public Module if (this->readd_connected_servers) { DNSServer *dns = DNSServer::Find(s->GetName()); - if (dns && !dns->Pooled() && !dns->GetIPs().empty() && dns->GetLimit() < s->Users) + if (dns && !dns->Pooled() && !dns->GetIPs().empty() && dns->GetLimit() < s->users) { dns->Pool(true); Log(this) << "Pooling server " << s->GetName(); @@ -446,15 +446,15 @@ class ModuleDNS : public Module } } - void OnUserConnect(dynamic_reference<User> &u, bool &exempt) anope_override + void OnUserConnect(Reference<User> &u, bool &exempt) anope_override { if (u && u->server) { DNSServer *s = DNSServer::Find(u->server->GetName()); /* Check for user limit reached */ - if (s && s->GetLimit() && s->Pooled() && u->server->Users >= s->GetLimit()) + if (s && s->GetLimit() && s->Pooled() && u->server->users >= s->GetLimit()) { - Log(this) << "Depooling full server " << s->GetName() << ": " << u->server->Users << " users"; + Log(this) << "Depooling full server " << s->GetName() << ": " << u->server->users << " users"; s->Pool(false); } } @@ -469,7 +469,7 @@ class ModuleDNS : public Module return; /* Check for dropping under userlimit */ - if (s->GetLimit() && !s->Pooled() && s->GetLimit() > u->server->Users) + if (s->GetLimit() && !s->Pooled() && s->GetLimit() > u->server->users) { Log(this) << "Pooling server " << s->GetName(); s->Pool(true); @@ -505,13 +505,13 @@ class ModuleDNS : public Module } } - void OnDnsRequest(DNSPacket &req, DNSPacket *packet) anope_override + void OnDnsRequest(DNS::Packet &req, DNS::Packet *packet) anope_override { if (req.questions.empty()) return; /* Currently we reply to any QR for A/AAAA */ - const Question& q = req.questions[0]; - if (q.type != DNS_QUERY_A && q.type != DNS_QUERY_AAAA && q.type != DNS_QUERY_AXFR) + const DNS::Question& q = req.questions[0]; + if (q.type != DNS::QUERY_A && q.type != DNS::QUERY_AAAA && q.type != DNS::QUERY_AXFR) return; for (unsigned i = 0; i < dns_servers.size(); ++i) @@ -522,11 +522,11 @@ class ModuleDNS : public Module for (unsigned j = 0; j < s->GetIPs().size(); ++j) { - QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS_QUERY_AAAA : DNS_QUERY_A; + DNS::QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A; - if (q.type == DNS_QUERY_AXFR || q_type == q.type) + if (q.type == DNS::QUERY_AXFR || q_type == q.type) { - ResourceRecord rr(q.name, q_type); + DNS::ResourceRecord rr(q.name, q_type); rr.ttl = this->ttl; rr.rdata = s->GetIPs()[j]; packet->answers.push_back(rr); @@ -550,11 +550,11 @@ class ModuleDNS : public Module for (unsigned j = 0; j < s->GetIPs().size(); ++j) { - QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS_QUERY_AAAA : DNS_QUERY_A; + DNS::QueryType q_type = s->GetIPs()[j].find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A; - if (q.type == DNS_QUERY_AXFR || q_type == q.type) + if (q.type == DNS::QUERY_AXFR || q_type == q.type) { - ResourceRecord rr(q.name, q_type); + DNS::ResourceRecord rr(q.name, q_type); rr.ttl = this->ttl; rr.rdata = s->GetIPs()[j]; packet->answers.push_back(rr); diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp index 31ca94265..08710b223 100644 --- a/modules/commands/os_forbid.cpp +++ b/modules/commands/os_forbid.cpp @@ -31,7 +31,7 @@ class MyForbidService : public ForbidService std::vector<ForbidData *>::iterator it = std::find(this->forbidData.begin(), this->forbidData.end(), d); if (it != this->forbidData.end()) this->forbidData.erase(it); - d->destroy(); + d->Destroy(); } ForbidData *FindForbid(const Anope::string &mask, ForbidType ftype) anope_override @@ -65,7 +65,7 @@ class MyForbidService : public ForbidService Log(LOG_NORMAL, "expire/forbid") << "Expiring forbid for " << d->mask << " type " << ftype; this->forbidData.erase(this->forbidData.begin() + i - 1); - d->destroy(); + d->Destroy(); } } @@ -75,7 +75,7 @@ class MyForbidService : public ForbidService class CommandOSForbid : public Command { - service_reference<ForbidService> fs; + ServiceReference<ForbidService> fs; public: CommandOSForbid(Module *creator) : Command(creator, "operserv/forbid", 1, 5), fs("ForbidService", "forbid") { @@ -122,12 +122,12 @@ class CommandOSForbid : public Command if (!expiry.empty()) { - expiryt = dotime(expiry); + expiryt = Anope::DoTime(expiry); if (expiryt) expiryt += Anope::CurTime; } - NickAlias *target = findnick(entry); + NickAlias *target = NickAlias::Find(entry); if (target != NULL && Config->NSSecureAdmins && target->nc->IsServicesOper()) { source.Reply(ACCESS_DENIED); @@ -152,7 +152,7 @@ class CommandOSForbid : public Command this->fs->AddForbid(d); Log(LOG_ADMIN, source, this) << "to add a forbid on " << entry << " of type " << subcommand; - source.Reply(_("Added a%s forbid on %s to expire on %s"), ftype == FT_CHAN ? "n" : "", entry.c_str(), d->expires ? do_strftime(d->expires).c_str() : "never"); + source.Reply(_("Added a%s forbid on %s to expire on %s"), ftype == FT_CHAN ? "n" : "", entry.c_str(), d->expires ? Anope::strftime(d->expires).c_str() : "never"); } else if (command.equals_ci("DEL") && params.size() > 2 && ftype != FT_NONE) { @@ -176,7 +176,7 @@ class CommandOSForbid : public Command else { ListFormatter list; - list.addColumn("Mask").addColumn("Type").addColumn("Reason"); + list.AddColumn("Mask").AddColumn("Type").AddColumn("Reason"); for (unsigned i = 0; i < forbids.size(); ++i) { @@ -196,9 +196,9 @@ class CommandOSForbid : public Command entry["Mask"] = d->mask; entry["Type"] = stype; entry["Creator"] = d->creator; - entry["Expires"] = d->expires ? do_strftime(d->expires).c_str() : "never"; + entry["Expires"] = d->expires ? Anope::strftime(d->expires).c_str() : "never"; entry["Reason"] = d->reason; - list.addEntry(entry); + list.AddEntry(entry); } source.Reply(_("Forbid list:")); @@ -234,13 +234,13 @@ class CommandOSForbid : public Command class OSForbid : public Module { - SerializeType forbiddata_type; + Serialize::Type forbiddata_type; MyForbidService forbidService; CommandOSForbid commandosforbid; public: OSForbid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - forbiddata_type("ForbidData", ForbidData::unserialize), forbidService(this), commandosforbid(this) + forbiddata_type("ForbidData", ForbidData::Unserialize), forbidService(this), commandosforbid(this) { this->SetAuthor("Anope"); @@ -248,7 +248,7 @@ class OSForbid : public Module ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnUserConnect(dynamic_reference<User> &u, bool &exempt) anope_override + void OnUserConnect(Reference<User> &u, bool &exempt) anope_override { if (!u || exempt) return; @@ -264,13 +264,12 @@ class OSForbid : public Module ForbidData *d = this->forbidService.FindForbid(u->nick, FT_NICK); if (d != NULL) { - const BotInfo *bi = findbot(Config->OperServ); - if (bi) + if (OperServ) { if (d->reason.empty()) - u->SendMessage(bi, _("This nickname has been forbidden.")); + u->SendMessage(OperServ, _("This nickname has been forbidden.")); else - u->SendMessage(bi, _("This nickname has been forbidden: %s"), d->reason.c_str()); + u->SendMessage(OperServ, _("This nickname has been forbidden: %s"), d->reason.c_str()); } u->Collide(NULL); } @@ -278,17 +277,16 @@ class OSForbid : public Module void OnJoinChannel(User *u, Channel *c) anope_override { - if (u->HasMode(UMODE_OPER)) + if (u->HasMode(UMODE_OPER) || !OperServ) return; - BotInfo *bi = findbot(Config->OperServ); ForbidData *d = this->forbidService.FindForbid(c->name, FT_CHAN); - if (bi != NULL && d != NULL) + if (d != NULL) { - if (ircdproto->CanSQLineChannel) + if (IRCD->CanSQLineChannel) { - XLine x(c->name, bi->nick, Anope::CurTime + Config->CSInhabit, d->reason); - ircdproto->SendSQLine(NULL, &x); + XLine x(c->name, OperServ->nick, Anope::CurTime + Config->CSInhabit, d->reason); + IRCD->SendSQLine(NULL, &x); } else if (!c->HasFlag(CH_INHABIT)) { @@ -303,9 +301,9 @@ class OSForbid : public Module } if (d->reason.empty()) - c->Kick(bi, u, _("This channel has been forbidden.")); + c->Kick(OperServ, u, _("This channel has been forbidden.")); else - c->Kick(bi, u, _("This channel has been forbidden: %s"), d->reason.c_str()); + c->Kick(OperServ, u, _("This channel has been forbidden: %s"), d->reason.c_str()); } } diff --git a/modules/commands/os_forbid.h b/modules/commands/os_forbid.h index f79b63616..1fce928db 100644 --- a/modules/commands/os_forbid.h +++ b/modules/commands/os_forbid.h @@ -19,8 +19,8 @@ struct ForbidData : Serializable ForbidType type; ForbidData() : Serializable("ForbidData") { } - Serialize::Data serialize() const anope_override; - static Serializable* unserialize(Serializable *obj, Serialize::Data &data); + Serialize::Data Serialize() const anope_override; + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; class ForbidService : public Service @@ -37,9 +37,9 @@ class ForbidService : public Service virtual const std::vector<ForbidData *> &GetForbids() = 0; }; -static service_reference<ForbidService> forbid_service("ForbidService", "forbid"); +static ServiceReference<ForbidService> forbid_service("ForbidService", "forbid"); -Serialize::Data ForbidData::serialize() const +Serialize::Data ForbidData::Serialize() const { Serialize::Data data; @@ -53,7 +53,7 @@ Serialize::Data ForbidData::serialize() const return data; } -Serializable* ForbidData::unserialize(Serializable *obj, Serialize::Data &data) +Serializable* ForbidData::Unserialize(Serializable *obj, Serialize::Data &data) { if (!forbid_service) return NULL; diff --git a/modules/commands/os_ignore.cpp b/modules/commands/os_ignore.cpp index 2377c28be..f959e7ebc 100644 --- a/modules/commands/os_ignore.cpp +++ b/modules/commands/os_ignore.cpp @@ -25,7 +25,7 @@ class OSIgnoreService : public IgnoreService Anope::string realmask = mask; size_t user, host; - User *u = finduser(mask); + User *u = User::Find(mask, true); if (u) realmask = "*!*@" + u->host; /* Determine whether we get a nick or a mask. */ @@ -86,7 +86,7 @@ class OSIgnoreService : public IgnoreService IgnoreData *Find(const Anope::string &mask) anope_override { - User *u = finduser(mask); + User *u = User::Find(mask, true); std::list<IgnoreData>::iterator ign = this->ignores.begin(), ign_end = this->ignores.end(); if (u) @@ -162,7 +162,7 @@ class CommandOSIgnore : public Command } else { - time_t t = dotime(time); + time_t t = Anope::DoTime(time); if (t <= -1) { @@ -205,7 +205,7 @@ class CommandOSIgnore : public Command else { ListFormatter list; - list.addColumn("Mask").addColumn("Creator").addColumn("Reason").addColumn("Expires"); + list.AddColumn("Mask").AddColumn("Creator").AddColumn("Reason").AddColumn("Expires"); for (std::list<IgnoreData>::const_iterator ign = ignores.begin(), ign_end = ignores.end(); ign != ign_end; ++ign) { const IgnoreData &ignore = *ign; @@ -214,8 +214,8 @@ class CommandOSIgnore : public Command entry["Mask"] = ignore.mask; entry["Creator"] = ignore.creator; entry["Reason"] = ignore.reason; - entry["Expires"] = do_strftime(ignore.time); - list.addEntry(entry); + entry["Expires"] = Anope::strftime(ignore.time); + list.AddEntry(entry); } source.Reply(_("Services ignore list:")); @@ -309,17 +309,16 @@ class CommandOSIgnore : public Command class OSIgnore : public Module { - SerializeType ignoredata_type; + Serialize::Type ignoredata_type; OSIgnoreService osignoreservice; CommandOSIgnore commandosignore; public: OSIgnore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - ignoredata_type("IgnoreData", IgnoreData::unserialize), osignoreservice(this), commandosignore(this) + ignoredata_type("IgnoreData", IgnoreData::Unserialize), osignoreservice(this), commandosignore(this) { this->SetAuthor("Anope"); - Implementation i[] = { I_OnBotPrivmsg }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } diff --git a/modules/commands/os_ignore.h b/modules/commands/os_ignore.h index 38042a72d..003d88b5b 100644 --- a/modules/commands/os_ignore.h +++ b/modules/commands/os_ignore.h @@ -18,8 +18,8 @@ struct IgnoreData : Serializable time_t time; /* When do we stop ignoring them? */ IgnoreData() : Serializable("IgnoreData") { } - Serialize::Data serialize() const anope_override; - static Serializable* unserialize(Serializable *obj, Serialize::Data &data); + Serialize::Data Serialize() const anope_override; + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; class IgnoreService : public Service @@ -41,9 +41,9 @@ class IgnoreService : public Service inline std::list<IgnoreData> &GetIgnores() { return this->ignores; } }; -static service_reference<IgnoreService> ignore_service("IgnoreService", "ignore"); +static ServiceReference<IgnoreService> ignore_service("IgnoreService", "ignore"); -Serialize::Data IgnoreData::serialize() const +Serialize::Data IgnoreData::Serialize() const { Serialize::Data data; @@ -55,7 +55,7 @@ Serialize::Data IgnoreData::serialize() const return data; } -Serializable* IgnoreData::unserialize(Serializable *obj, Serialize::Data &data) +Serializable* IgnoreData::Unserialize(Serializable *obj, Serialize::Data &data) { if (!ignore_service) return NULL; diff --git a/modules/commands/os_jupe.cpp b/modules/commands/os_jupe.cpp index cfe917c13..49095129c 100644 --- a/modules/commands/os_jupe.cpp +++ b/modules/commands/os_jupe.cpp @@ -28,7 +28,7 @@ class CommandOSJupe : public Command const Anope::string &reason = params.size() > 1 ? params[1] : ""; Server *server = Server::Find(jserver); - if (!IsValidHost(jserver) || jserver.find('.') == Anope::string::npos) + if (!IRCD->IsHostValid(jserver) || jserver.find('.') == Anope::string::npos) source.Reply(_("Please use a valid server name when juping")); else if (server && (server == Me || server == Me->GetLinks().front())) source.Reply(_("You can not jupe your services server or your uplink server.")); @@ -36,9 +36,9 @@ class CommandOSJupe : public Command { Anope::string rbuf = "Juped by " + source.GetNick() + (!reason.empty() ? ": " + reason : ""); if (server) - ircdproto->SendSquit(server, rbuf); - Server *juped_server = new Server(Me, jserver, 1, rbuf, ts6_sid_retrieve(), SERVER_JUPED); - ircdproto->SendServer(juped_server); + IRCD->SendSquit(server, rbuf); + Server *juped_server = new Server(Me, jserver, 1, rbuf, Servers::TS6_SID_Retrieve(), SERVER_JUPED); + IRCD->SendServer(juped_server); Log(LOG_ADMIN, source, this) << "on " << jserver << " (" << rbuf << ")"; } diff --git a/modules/commands/os_kick.cpp b/modules/commands/os_kick.cpp index 0a5165621..5f33a4bbc 100644 --- a/modules/commands/os_kick.cpp +++ b/modules/commands/os_kick.cpp @@ -30,7 +30,7 @@ class CommandOSKick : public Command Channel *c; User *u2; - if (!(c = findchan(chan))) + if (!(c = Channel::Find(chan))) { source.Reply(CHAN_X_NOT_IN_USE, chan.c_str()); return; @@ -40,7 +40,7 @@ class CommandOSKick : public Command source.Reply(_("Services is unable to change modes. Are your servers' U:lines configured correctly?")); return; } - else if (!(u2 = finduser(nick))) + else if (!(u2 = User::Find(nick, true))) { source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); return; diff --git a/modules/commands/os_kill.cpp b/modules/commands/os_kill.cpp index e7f78b1b5..83cd81f58 100644 --- a/modules/commands/os_kill.cpp +++ b/modules/commands/os_kill.cpp @@ -27,7 +27,7 @@ class CommandOSKill : public Command const Anope::string &nick = params[0]; Anope::string reason = params.size() > 1 ? params[1] : ""; - User *u2 = finduser(nick); + User *u2 = User::Find(nick, true); if (u2 == NULL) source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); else if (u2->IsProtected() || u2->server == Me) diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp index 0272742c1..dfb0c00c8 100644 --- a/modules/commands/os_list.cpp +++ b/modules/commands/os_list.cpp @@ -36,9 +36,9 @@ class CommandOSChanList : public Command } ListFormatter list; - list.addColumn("Name").addColumn("Users").addColumn("Modes").addColumn("Topic"); + list.AddColumn("Name").AddColumn("Users").AddColumn("Modes").AddColumn("Topic"); - if (!pattern.empty() && (u2 = finduser(pattern))) + if (!pattern.empty() && (u2 = User::Find(pattern, true))) { source.Reply(_("\002%s\002 channel list:"), u2->nick.c_str()); @@ -56,7 +56,7 @@ class CommandOSChanList : public Command entry["Users"] = stringify(cc->chan->users.size()); entry["Modes"] = cc->chan->GetModes(true, true); entry["Topic"] = cc->chan->topic; - list.addEntry(entry); + list.AddEntry(entry); } } else @@ -79,7 +79,7 @@ class CommandOSChanList : public Command entry["Users"] = stringify(c->users.size()); entry["Modes"] = c->GetModes(true, true); entry["Topic"] = c->topic; - list.addEntry(entry); + list.AddEntry(entry); } } @@ -130,9 +130,9 @@ class CommandOSUserList : public Command Modes.push_back(UMODE_INVIS); ListFormatter list; - list.addColumn("Name").addColumn("Mask"); + list.AddColumn("Name").AddColumn("Mask"); - if (!pattern.empty() && (c = findchan(pattern))) + if (!pattern.empty() && (c = Channel::Find(pattern))) { source.Reply(_("\002%s\002 users list:"), pattern.c_str()); @@ -148,7 +148,7 @@ class CommandOSUserList : public Command ListFormatter::ListEntry entry; entry["Name"] = uc->user->nick; entry["Mask"] = uc->user->GetIdent() + "@" + uc->user->GetDisplayedHost(); - list.addEntry(entry); + list.AddEntry(entry); } } else @@ -178,7 +178,7 @@ class CommandOSUserList : public Command ListFormatter::ListEntry entry; entry["Name"] = u2->nick; entry["Mask"] = u2->GetIdent() + "@" + u2->GetDisplayedHost(); - list.addEntry(entry); + list.AddEntry(entry); } } diff --git a/modules/commands/os_login.cpp b/modules/commands/os_login.cpp index 7b223eb1f..735562819 100644 --- a/modules/commands/os_login.cpp +++ b/modules/commands/os_login.cpp @@ -41,7 +41,7 @@ class CommandOSLogin : public Command else if (o->password != password) { source.Reply(PASSWORD_INCORRECT); - bad_password(u); + u->BadPassword(); } else { diff --git a/modules/commands/os_logsearch.cpp b/modules/commands/os_logsearch.cpp index 12431798c..7ad806330 100644 --- a/modules/commands/os_logsearch.cpp +++ b/modules/commands/os_logsearch.cpp @@ -23,7 +23,7 @@ class CommandOSLogSearch : public Command strftime(timestamp, sizeof(timestamp), "%Y%m%d", tm); - return log_dir + "/" + file + "." + timestamp; + return Anope::LogDir + "/" + file + "." + timestamp; } public: diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp index 419fc8442..676ef7ea5 100644 --- a/modules/commands/os_mode.cpp +++ b/modules/commands/os_mode.cpp @@ -27,7 +27,7 @@ class CommandOSMode : public Command const Anope::string &target = params[0]; const Anope::string &modes = params[1]; - Channel *c = findchan(target); + Channel *c = Channel::Find(target); if (!c) source.Reply(CHAN_X_NOT_IN_USE, target.c_str()); else if (c->bouncy_modes) @@ -62,23 +62,23 @@ class CommandOSMode : public Command continue; Anope::string param, param_log; - if (cm->Type != MODE_REGULAR) + if (cm->type != MODE_REGULAR) { if (!sep.GetToken(param)) continue; param_log = param; - if (cm->Type == MODE_STATUS) + if (cm->type == MODE_STATUS) { - User *targ = finduser(param); + User *targ = User::Find(param, true); if (targ == NULL || c->FindUser(targ) == NULL) continue; param = targ->GetUID(); } } - log_modes += cm->ModeChar; + log_modes += cm->mchar; if (!param.empty()) log_params += " " + param_log; @@ -117,7 +117,7 @@ class CommandOSUMode : public Command const Anope::string &target = params[0]; const Anope::string &modes = params[1]; - User *u2 = finduser(target); + User *u2 = User::Find(target, true); if (!u2) source.Reply(NICK_X_NOT_IN_USE, target.c_str()); else diff --git a/modules/commands/os_modinfo.cpp b/modules/commands/os_modinfo.cpp index 88748a106..15e2d73a2 100644 --- a/modules/commands/os_modinfo.cpp +++ b/modules/commands/os_modinfo.cpp @@ -29,12 +29,12 @@ class CommandOSModInfo : public Command Module *m = ModuleManager::FindModule(file); if (m) { - source.Reply(_("Module: \002%s\002 Version: \002%s\002 Author: \002%s\002 loaded: \002%s\002"), m->name.c_str(), !m->version.empty() ? m->version.c_str() : "?", !m->author.empty() ? m->author.c_str() : "?", do_strftime(m->created).c_str()); + source.Reply(_("Module: \002%s\002 Version: \002%s\002 Author: \002%s\002 loaded: \002%s\002"), m->name.c_str(), !m->version.empty() ? m->version.c_str() : "?", !m->author.empty() ? m->author.c_str() : "?", Anope::strftime(m->created).c_str()); std::vector<Anope::string> servicekeys = Service::GetServiceKeys("Command"); for (unsigned i = 0; i < servicekeys.size(); ++i) { - service_reference<Command> c("Command", servicekeys[i]); + ServiceReference<Command> c("Command", servicekeys[i]); if (!c || c->owner != m) continue; @@ -156,9 +156,11 @@ class CommandOSModList : public Command } } + Module *protocol = ModuleManager::FindFirstOf(PROTOCOL); + source.Reply(_("Current Module list:")); - for (std::list<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; ++it) + for (std::list<Module *>::iterator it = ModuleManager::Modules.begin(), it_end = ModuleManager::Modules.end(); it != it_end; ++it) { Module *m = *it; @@ -179,6 +181,8 @@ class CommandOSModList : public Command } break; case PROTOCOL: + if (m != protocol) + break; if (showProto) { source.Reply(_("Module: \002%s\002 [%s] [%s]"), m->name.c_str(), m->version.c_str(), proto); diff --git a/modules/commands/os_module.cpp b/modules/commands/os_module.cpp index e7e0e2c16..75bc82af6 100644 --- a/modules/commands/os_module.cpp +++ b/modules/commands/os_module.cpp @@ -76,6 +76,13 @@ class CommandOSModReLoad : public Command return; } + Module *protocol = ModuleManager::FindFirstOf(PROTOCOL); + if (m->type == PROTOCOL && m != protocol) + { + source.Reply(_("You may not reload this module directly, instead reload %s."), protocol ? protocol->name.c_str() : "(unknown)"); + return; + } + /* Unrecoverable */ bool fatal = m->type == PROTOCOL; ModuleReturn status = ModuleManager::UnloadModule(m, source.GetUser()); @@ -96,8 +103,8 @@ class CommandOSModReLoad : public Command { if (fatal) { - quitmsg = "Unable to reload module " + mname; - quitting = true; + Anope::QuitReason = "Unable to reload module " + mname; + Anope::Quitting = true; } else source.Reply(_("Unable to load module \002%s\002"), mname.c_str()); diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index ba23c431d..eea480d13 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -72,7 +72,7 @@ class MyNewsService : public NewsService { for (unsigned i = 0; i < 3; ++i) for (unsigned j = 0; j < newsItems[i].size(); ++j) - newsItems[i][j]->destroy(); + newsItems[i][j]->Destroy(); } void AddNewsItem(NewsItem *n) @@ -86,7 +86,7 @@ class MyNewsService : public NewsService std::vector<NewsItem *>::iterator it = std::find(list.begin(), list.end(), n); if (it != list.end()) list.erase(it); - n->destroy(); + n->Destroy(); } std::vector<NewsItem *> &GetNewsList(NewsType t) @@ -106,7 +106,7 @@ static const char **findmsgs(NewsType type) class NewsBase : public Command { - service_reference<NewsService> ns; + ServiceReference<NewsService> ns; protected: void DoList(CommandSource &source, NewsType ntype, const char **msgs) @@ -117,16 +117,16 @@ class NewsBase : public Command else { ListFormatter lflist; - lflist.addColumn("Number").addColumn("Creator").addColumn("Created").addColumn("Text"); + lflist.AddColumn("Number").AddColumn("Creator").AddColumn("Created").AddColumn("Text"); for (unsigned i = 0, end = list.size(); i < end; ++i) { ListFormatter::ListEntry entry; entry["Number"] = stringify(i + 1); entry["Creator"] = list[i]->who; - entry["Created"] = do_strftime(list[i]->time); + entry["Created"] = Anope::strftime(list[i]->time); entry["Text"] = list[i]->text; - lflist.addEntry(entry); + lflist.AddEntry(entry); } source.Reply(msgs[MSG_LIST_HEADER]); @@ -151,7 +151,7 @@ class NewsBase : public Command this->OnSyntaxError(source, "ADD"); else { - if (readonly) + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); NewsItem *news = new NewsItem(); @@ -181,7 +181,7 @@ class NewsBase : public Command source.Reply(msgs[MSG_LIST_NONE]); else { - if (readonly) + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); if (!text.equals_ci("ALL")) { @@ -336,7 +336,7 @@ class CommandOSRandomNews : public NewsBase class OSNews : public Module { - SerializeType newsitem_type; + Serialize::Type newsitem_type; MyNewsService newsservice; CommandOSLogonNews commandoslogonnews; @@ -364,14 +364,14 @@ class OSNews : public Module if (Type == NEWS_RANDOM && i != cur_rand_news) continue; - const BotInfo *gl = findbot(Config->Global); + const BotInfo *gl = Global; if (!gl && !BotListByNick->empty()) gl = BotListByNick->begin()->second; - const BotInfo *os = findbot(Config->OperServ); + const BotInfo *os = OperServ; if (!os) os = gl; if (gl) - u->SendMessage(Type != NEWS_OPER ? gl : os, msg.c_str(), do_strftime(newsList[i]->time).c_str(), newsList[i]->text.c_str()); + u->SendMessage(Type != NEWS_OPER ? gl : os, msg.c_str(), Anope::strftime(newsList[i]->time).c_str(), newsList[i]->text.c_str()); ++displayed; @@ -391,7 +391,7 @@ class OSNews : public Module public: OSNews(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - newsitem_type("NewsItem", NewsItem::unserialize), newsservice(this), commandoslogonnews(this), commandosopernews(this), commandosrandomnews(this) + newsitem_type("NewsItem", NewsItem::Unserialize), newsservice(this), commandoslogonnews(this), commandosopernews(this), commandosrandomnews(this) { this->SetAuthor("Anope"); @@ -405,7 +405,7 @@ class OSNews : public Module DisplayNews(u, NEWS_OPER); } - void OnUserConnect(dynamic_reference<User> &user, bool &) anope_override + void OnUserConnect(Reference<User> &user, bool &) anope_override { if (!user || !user->server->IsSynced()) return; diff --git a/modules/commands/os_news.h b/modules/commands/os_news.h index 426121fb7..44525b963 100644 --- a/modules/commands/os_news.h +++ b/modules/commands/os_news.h @@ -23,8 +23,8 @@ struct NewsItem : Serializable time_t time; NewsItem() : Serializable("NewsItem") { } - Serialize::Data serialize() const anope_override; - static Serializable* unserialize(Serializable *obj, Serialize::Data &data); + Serialize::Data Serialize() const anope_override; + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; class NewsService : public Service @@ -39,9 +39,9 @@ class NewsService : public Service virtual std::vector<NewsItem *> &GetNewsList(NewsType t) = 0; }; -static service_reference<NewsService> news_service("NewsService", "news"); +static ServiceReference<NewsService> news_service("NewsService", "news"); -Serialize::Data NewsItem::serialize() const +Serialize::Data NewsItem::Serialize() const { Serialize::Data data; @@ -53,7 +53,7 @@ Serialize::Data NewsItem::serialize() const return data; } -Serializable* NewsItem::unserialize(Serializable *obj, Serialize::Data &data) +Serializable* NewsItem::Unserialize(Serializable *obj, Serialize::Data &data) { if (!news_service) return NULL; diff --git a/modules/commands/os_noop.cpp b/modules/commands/os_noop.cpp index 826f1313a..fa9361f7b 100644 --- a/modules/commands/os_noop.cpp +++ b/modules/commands/os_noop.cpp @@ -36,7 +36,7 @@ class CommandOSNOOP : public Command else if (cmd.equals_ci("SET")) { /* Remove the O:lines */ - ircdproto->SendSVSNOOP(s, true); + IRCD->SendSVSNOOP(s, true); s->Extend("noop", new ExtensibleItemClass<Anope::string>(source.GetNick())); Log(LOG_ADMIN, source, this) << "SET on " << s->GetName(); @@ -56,7 +56,7 @@ class CommandOSNOOP : public Command else if (cmd.equals_ci("REVOKE")) { s->Shrink("noop"); - ircdproto->SendSVSNOOP(s, false); + IRCD->SendSVSNOOP(s, false); Log(LOG_ADMIN, source, this) << "REVOKE on " << s->GetName(); source.Reply(_("All O:lines of \002%s\002 have been reset."), s->GetName().c_str()); } diff --git a/modules/commands/os_oline.cpp b/modules/commands/os_oline.cpp index 3fe622c1c..7b8be5768 100644 --- a/modules/commands/os_oline.cpp +++ b/modules/commands/os_oline.cpp @@ -29,11 +29,11 @@ class CommandOSOLine : public Command User *u2 = NULL; /* let's check whether the user is online */ - if (!(u2 = finduser(nick))) + if (!(u2 = User::Find(nick, true))) source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); else if (u2 && flag[0] == '+') { - ircdproto->SendSVSO(source.service, nick, flag); + IRCD->SendSVSO(source.service, nick, flag); u2->SetMode(source.service, UMODE_OPER); u2->SendMessage(source.service, _("You are now an IRC Operator.")); source.Reply(_("Operflags \002%s\002 have been added for \002%s\002."), flag.c_str(), nick.c_str()); @@ -41,7 +41,7 @@ class CommandOSOLine : public Command } else if (u2 && flag[0] == '-') { - ircdproto->SendSVSO(source.service, nick, flag); + IRCD->SendSVSO(source.service, nick, flag); source.Reply(_("Operflags \002%s\002 have been added for \002%s\002."), flag.c_str(), nick.c_str()); Log(LOG_ADMIN, source, this) << "for " << nick; } @@ -72,7 +72,7 @@ class OSOLine : public Module { this->SetAuthor("Anope"); - if (!ircdproto || !ircdproto->CanSVSO) + if (!IRCD || !IRCD->CanSVSO) throw ModuleException("Your IRCd does not support OMODE."); } diff --git a/modules/commands/os_oper.cpp b/modules/commands/os_oper.cpp index e2e7b4ab3..882455898 100644 --- a/modules/commands/os_oper.cpp +++ b/modules/commands/os_oper.cpp @@ -17,7 +17,7 @@ struct MyOper : Oper, Serializable { MyOper(const Anope::string &n, OperType *o) : Oper(n, o), Serializable("Oper") { } - Serialize::Data serialize() const anope_override + Serialize::Data Serialize() const anope_override { Serialize::Data data; @@ -27,12 +27,12 @@ struct MyOper : Oper, Serializable return data; } - static Serializable* unserialize(Serializable *obj, Serialize::Data &data) + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { OperType *ot = OperType::Find(data["type"].astr()); if (ot == NULL) return NULL; - NickCore *nc = findcore(data["name"].astr()); + NickCore *nc = NickCore::Find(data["name"].astr()); if (nc == NULL) return NULL; @@ -68,7 +68,7 @@ class CommandOSOper : public Command const Anope::string &oper = params[1]; const Anope::string &otype = params[2]; - const NickAlias *na = findnick(oper); + const NickAlias *na = NickAlias::Find(oper); if (na == NULL) source.Reply(NICK_X_NOT_REGISTERED, oper.c_str()); else if (na->nc->o) @@ -91,7 +91,7 @@ class CommandOSOper : public Command { const Anope::string &oper = params[1]; - const NickAlias *na = findnick(oper); + const NickAlias *na = NickAlias::Find(oper); if (na == NULL) source.Reply(NICK_X_NOT_REGISTERED, oper.c_str()); else if (!na->nc || !na->nc->o) @@ -118,7 +118,7 @@ class CommandOSOper : public Command source.Reply(_("%-8s %s"), nc->o->name.c_str(), nc->o->ot->GetName().c_str()); if (nc->o->config) source.Reply(_(" This oper is configured in the configuration file.")); - for (std::list<User *>::const_iterator uit = nc->Users.begin(); uit != nc->Users.end(); ++uit) + for (std::list<User *>::const_iterator uit = nc->users.begin(); uit != nc->users.end(); ++uit) { User *u = *uit; source.Reply(_(" %s is online using this oper block."), u->nick.c_str()); @@ -202,12 +202,12 @@ class CommandOSOper : public Command class OSOper : public Module { - SerializeType myoper_type; + Serialize::Type myoper_type; CommandOSOper commandosoper; public: OSOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - myoper_type("Oper", MyOper::unserialize), commandosoper(this) + myoper_type("Oper", MyOper::Unserialize), commandosoper(this) { this->SetAuthor("Anope"); } diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index 2311b2ed2..27157d511 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -101,9 +101,9 @@ class ExpireTimer : public Timer if (!e->expires || e->expires > Anope::CurTime) continue; - Log(findbot(Config->OperServ), "expire/exception") << "Session exception for " << e->mask << "has expired."; + Log(OperServ, "expire/exception") << "Session exception for " << e->mask << "has expired."; session_service->DelException(e); - e->destroy(); + e->Destroy(); } } }; @@ -112,30 +112,30 @@ class ExceptionDelCallback : public NumberList { protected: CommandSource &source; - unsigned Deleted; + unsigned deleted; public: - ExceptionDelCallback(CommandSource &_source, const Anope::string &numlist) : NumberList(numlist, true), source(_source), Deleted(0) + ExceptionDelCallback(CommandSource &_source, const Anope::string &numlist) : NumberList(numlist, true), source(_source), deleted(0) { } ~ExceptionDelCallback() { - if (!Deleted) + if (!deleted) source.Reply(_("No matching entries on session-limit exception list.")); - else if (Deleted == 1) + else if (deleted == 1) source.Reply(_("Deleted 1 entry from session-limit exception list.")); else - source.Reply(_("Deleted %d entries from session-limit exception list."), Deleted); + source.Reply(_("Deleted %d entries from session-limit exception list."), deleted); } - virtual void HandleNumber(unsigned Number) anope_override + virtual void HandleNumber(unsigned number) anope_override { - if (!Number || Number > session_service->GetExceptions().size()) + if (!number || number > session_service->GetExceptions().size()) return; - ++Deleted; + ++deleted; - DoDel(source, Number - 1); + DoDel(source, number - 1); } static void DoDel(CommandSource &source, unsigned index) @@ -144,7 +144,7 @@ class ExceptionDelCallback : public NumberList FOREACH_MOD(I_OnExceptionDel, OnExceptionDel(source, e)); session_service->DelException(e); - e->destroy(); + e->Destroy(); } }; @@ -167,7 +167,7 @@ class CommandOSSession : public Command else { ListFormatter list; - list.addColumn("Session").addColumn("Host"); + list.AddColumn("Session").AddColumn("Host"); for (SessionService::SessionMap::iterator it = session_service->GetSessions().begin(), it_end = session_service->GetSessions().end(); it != it_end; ++it) { @@ -178,7 +178,7 @@ class CommandOSSession : public Command ListFormatter::ListEntry entry; entry["Session"] = stringify(session->count); entry["Host"] = session->addr.mask(); - list.addEntry(entry); + list.AddEntry(entry); } } @@ -296,7 +296,7 @@ class CommandOSException : public Command return; } - time_t expires = !expiry.empty() ? dotime(expiry) : Config->ExceptionExpiry; + time_t expires = !expiry.empty() ? Anope::DoTime(expiry) : Config->ExceptionExpiry; if (expires < 0) { source.Reply(BAD_EXPIRY_TIME); @@ -352,12 +352,12 @@ class CommandOSException : public Command EventReturn MOD_RESULT; FOREACH_RESULT(I_OnExceptionAdd, OnExceptionAdd(exception)); if (MOD_RESULT == EVENT_STOP) - exception->destroy(); + exception->Destroy(); else { session_service->AddException(exception); source.Reply(_("Session limit for \002%s\002 set to \002%d\002."), mask.c_str(), limit); - if (readonly) + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); } } @@ -394,7 +394,7 @@ class CommandOSException : public Command source.Reply(_("\002%s\002 not found on session-limit exception list."), mask.c_str()); } - if (readonly) + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); return; @@ -428,7 +428,7 @@ class CommandOSException : public Command source.Reply(_("Exception for \002%s\002 (#%d) moved to position \002%d\002."), session_service->GetExceptions()[n1]->mask.c_str(), n1 + 1, n2 + 1); - if (readonly) + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); } else @@ -468,10 +468,10 @@ class CommandOSException : public Command entry["Number"] = stringify(Number); entry["Mask"] = e->mask; entry["By"] = e->who; - entry["Created"] = do_strftime(e->time); + entry["Created"] = Anope::strftime(e->time); entry["Limit"] = stringify(e->limit); entry["Reason"] = e->reason; - this->list.addEntry(entry); + this->list.AddEntry(entry); } } nl_list(list, mask); @@ -488,15 +488,15 @@ class CommandOSException : public Command entry["Number"] = stringify(i + 1); entry["Mask"] = e->mask; entry["By"] = e->who; - entry["Created"] = do_strftime(e->time); + entry["Created"] = Anope::strftime(e->time); entry["Limit"] = stringify(e->limit); entry["Reason"] = e->reason; - list.addEntry(entry); + list.AddEntry(entry); } } } - if (list.isEmpty()) + if (list.IsEmpty()) source.Reply(_("No matching entries on session-limit exception list.")); else { @@ -513,7 +513,7 @@ class CommandOSException : public Command void DoList(CommandSource &source, const std::vector<Anope::string> ¶ms) { ListFormatter list; - list.addColumn("Number").addColumn("Limit").addColumn("Mask"); + list.AddColumn("Number").AddColumn("Limit").AddColumn("Mask"); this->ProcessList(source, params, list); } @@ -521,7 +521,7 @@ class CommandOSException : public Command void DoView(CommandSource &source, const std::vector<Anope::string> ¶ms) { ListFormatter list; - list.addColumn("Number").addColumn("Mask").addColumn("By").addColumn("Created").addColumn("Limit").addColumn("Reason"); + list.AddColumn("Number").AddColumn("Mask").AddColumn("By").AddColumn("Created").AddColumn("Limit").AddColumn("Reason"); this->ProcessList(source, params, list); } @@ -604,12 +604,12 @@ class CommandOSException : public Command class OSSession : public Module { - SerializeType exception_type; + Serialize::Type exception_type; MySessionService ss; ExpireTimer expiretimer; CommandOSSession commandossession; CommandOSException commandosexception; - service_reference<XLineManager> akills; + ServiceReference<XLineManager> akills; void AddSession(User *u, bool exempt) { @@ -649,13 +649,12 @@ class OSSession : public Module if (kill && !exempt) { - const BotInfo *bi = findbot(Config->OperServ); - if (bi) + if (OperServ) { if (!Config->SessionLimitExceeded.empty()) - u->SendMessage(bi, Config->SessionLimitExceeded.c_str(), u->host.c_str()); + u->SendMessage(OperServ, Config->SessionLimitExceeded.c_str(), u->host.c_str()); if (!Config->SessionLimitDetailsLoc.empty()) - u->SendMessage(bi, "%s", Config->SessionLimitDetailsLoc.c_str()); + u->SendMessage(OperServ, "%s", Config->SessionLimitDetailsLoc.c_str()); } ++session->hits; @@ -665,7 +664,7 @@ class OSSession : public Module XLine *x = new XLine(akillmask, Config->OperServ, Anope::CurTime + Config->SessionAutoKillExpiry, "Session limit exceeded", XLineManager::GenerateUID()); akills->AddXLine(x); akills->Send(NULL, x); - Log(bi, "akill/session") << "Added a temporary AKILL for \2" << akillmask << "\2 due to excessive connections"; + Log(OperServ, "akill/session") << "Added a temporary AKILL for \2" << akillmask << "\2 due to excessive connections"; } else { @@ -694,8 +693,7 @@ class OSSession : public Module } if (!session) { - if (debug) - Log(this) << "Tried to delete non-existant session: " << u->host; + Log(LOG_DEBUG) << "Tried to delete non-existant session: " << u->host; return; } @@ -711,7 +709,7 @@ class OSSession : public Module public: OSSession(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - exception_type("Exception", Exception::unserialize), ss(this), commandossession(this), commandosexception(this), akills("XLineManager", "xlinemanager/sgline") + exception_type("Exception", Exception::Unserialize), ss(this), commandossession(this), commandosexception(this), akills("XLineManager", "xlinemanager/sgline") { this->SetAuthor("Anope"); @@ -720,7 +718,7 @@ class OSSession : public Module ModuleManager::SetPriority(this, PRIORITY_FIRST); } - void OnUserConnect(dynamic_reference<User> &user, bool &exempt) anope_override + void OnUserConnect(Reference<User> &user, bool &exempt) anope_override { if (user && Config->LimitSessions) this->AddSession(user, exempt); diff --git a/modules/commands/os_session.h b/modules/commands/os_session.h index 070975fd2..7304b21ae 100644 --- a/modules/commands/os_session.h +++ b/modules/commands/os_session.h @@ -20,8 +20,8 @@ struct Exception : Serializable time_t expires; /* Time when it expires. 0 == no expiry */ Exception() : Serializable("Exception") { } - Serialize::Data serialize() const anope_override; - static Serializable* unserialize(Serializable *obj, Serialize::Data &data); + Serialize::Data Serialize() const anope_override; + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; class SessionService : public Service @@ -51,9 +51,9 @@ class SessionService : public Service virtual SessionMap &GetSessions() = 0; }; -static service_reference<SessionService> session_service("SessionService", "session"); +static ServiceReference<SessionService> session_service("SessionService", "session"); -Serialize::Data Exception::serialize() const +Serialize::Data Exception::Serialize() const { Serialize::Data data; @@ -67,7 +67,7 @@ Serialize::Data Exception::serialize() const return data; } -Serializable* Exception::unserialize(Serializable *obj, Serialize::Data &data) +Serializable* Exception::Unserialize(Serializable *obj, Serialize::Data &data) { if (!session_service) return NULL; diff --git a/modules/commands/os_set.cpp b/modules/commands/os_set.cpp index a8a7e2e62..1592e7936 100644 --- a/modules/commands/os_set.cpp +++ b/modules/commands/os_set.cpp @@ -22,11 +22,11 @@ class CommandOSSet : public Command Anope::string index; - index = readonly ? _("%s is enabled") : _("%s is disabled"); + index = Anope::ReadOnly ? _("%s is enabled") : _("%s is disabled"); source.Reply(index.c_str(), "READONLY"); - index = debug ? _("%s is enabled") : _("%s is disabled"); + index = Anope::Debug ? _("%s is enabled") : _("%s is disabled"); source.Reply(index.c_str(), "DEBUG"); - index = noexpire ? _("%s is enabled") : _("%s is disabled"); + index = Anope::NoExpire ? _("%s is enabled") : _("%s is disabled"); source.Reply(index.c_str(), "NOEXPIRE"); return; @@ -44,13 +44,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { - readonly = true; + Anope::ReadOnly = true; Log(LOG_ADMIN, source, this) << "READONLY ON"; source.Reply(_("Services are now in \002read-only\002 mode.")); } else if (setting.equals_ci("OFF")) { - readonly = false; + Anope::ReadOnly = false; Log(LOG_ADMIN, source, this) << "READONLY OFF"; source.Reply(_("Services are now in \002read-write\002 mode.")); } @@ -79,21 +79,21 @@ class CommandOSSet : public Command * Rob **/ if (!Config->SuperAdmin) - source.Reply(_("SuperAdmin setting not enabled in services.conf")); + source.Reply(_("Superadmin can not be set because it is not enabled in the configuration")); else if (setting.equals_ci("ON")) { - source.GetUser()->SuperAdmin = true; + source.GetUser()->super_admin = true; source.Reply(_("You are now a SuperAdmin")); Log(LOG_ADMIN, source, this) << "SUPERADMIN ON"; } else if (setting.equals_ci("OFF")) { - source.GetUser()->SuperAdmin = false; + source.GetUser()->super_admin = false; source.Reply(_("You are no longer a SuperAdmin")); Log(LOG_ADMIN, source, this) << "SUPERADMIN OFF"; } else - source.Reply(_("Setting for SuperAdmin must be \002on\002 or \002off\002 (must be enabled in services.conf)")); + source.Reply(_("Setting for SuperAdmin must be \002on\002 or \002off\002.")); return; } @@ -110,23 +110,23 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { - debug = 1; + Anope::Debug = 1; Log(LOG_ADMIN, source, this) << "DEBUG ON"; source.Reply(_("Services are now in debug mode.")); } else if (setting.equals_ci("OFF") || setting == "0") { Log(LOG_ADMIN, source, this) << "DEBUG OFF"; - debug = 0; + Anope::Debug = 0; source.Reply(_("Services are now in non-debug mode.")); } else { try { - debug = convertTo<int>(setting); - Log(LOG_ADMIN, source, this) << "DEBUG " << debug; - source.Reply(_("Services are now in debug mode (level %d)."), debug); + Anope::Debug = convertTo<int>(setting); + Log(LOG_ADMIN, source, this) << "DEBUG " << Anope::Debug; + source.Reply(_("Services are now in debug mode (level %d)."), Anope::Debug); return; } catch (const ConvertException &) { } @@ -149,13 +149,13 @@ class CommandOSSet : public Command if (setting.equals_ci("ON")) { - noexpire = true; + Anope::NoExpire = true; Log(LOG_ADMIN, source, this) << "NOEXPIRE ON"; source.Reply(_("Services are now in \002no expire\002 mode.")); } else if (setting.equals_ci("OFF")) { - noexpire = false; + Anope::NoExpire = false; Log(LOG_ADMIN, source, this) << "NOEXPIRE OFF"; source.Reply(_("Services are now in \002expire\002 mode.")); } diff --git a/modules/commands/os_shutdown.cpp b/modules/commands/os_shutdown.cpp index 6edb3a64d..2f7827be3 100644 --- a/modules/commands/os_shutdown.cpp +++ b/modules/commands/os_shutdown.cpp @@ -24,8 +24,8 @@ class CommandOSQuit : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - quitmsg = source.command + " command received from " + source.GetNick(); - quitting = true; + Anope::QuitReason = source.command + " command received from " + source.GetNick(); + Anope::Quitting = true; return; } @@ -52,9 +52,9 @@ class CommandOSRestart : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - quitmsg = source.command + " command received from " + source.GetNick(); - quitting = restarting = true; - save_databases(); + Anope::QuitReason = source.command + " command received from " + source.GetNick(); + Anope::Quitting = Anope::Restarting = true; + Anope::SaveDatabases(); return; } @@ -78,9 +78,9 @@ class CommandOSShutdown : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - quitmsg = source.command + " command received from " + source.GetNick(); - quitting = true; - save_databases(); + Anope::QuitReason = source.command + " command received from " + source.GetNick(); + Anope::Quitting = true; + Anope::SaveDatabases(); return; } diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index 83f13a90a..bb029eed9 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -18,20 +18,20 @@ struct Stats : Serializable { Stats() : Serializable("Stats") { } - Serialize::Data serialize() const anope_override + Serialize::Data Serialize() const anope_override { Serialize::Data data; - data["maxusercnt"] << maxusercnt; - data["maxusertime"] << maxusertime; + data["maxusercnt"] << MaxUserCount; + data["maxusertime"] << MaxUserTime; return data; } - static Serializable* unserialize(Serializable *obj, Serialize::Data &data) + static Serializable* Unserialize(Serializable *obj, Serialize::Data &data) { - data["maxusercnt"] >> maxusercnt; - data["maxusertime"] >> maxusertime; + data["maxusercnt"] >> MaxUserCount; + data["maxusertime"] >> MaxUserTime; return NULL; } }; @@ -57,7 +57,7 @@ static int stats_count_servers(Server *s) class CommandOSStats : public Command { - service_reference<XLineManager> akills, snlines, sqlines; + ServiceReference<XLineManager> akills, snlines, sqlines; private: void DoStatsAkill(CommandSource &source) { @@ -82,7 +82,7 @@ class CommandOSStats : public Command else source.Reply(_("Default AKILL expiry time: \002No expiration\002")); } - if (ircdproto->CanSNLine && snlines) + if (IRCD->CanSNLine && snlines) { /* SNLINEs */ source.Reply(_("Current number of SNLINEs: \002%d\002"), snlines->GetCount()); @@ -102,7 +102,7 @@ class CommandOSStats : public Command else source.Reply(_("Default SNLINE expiry time: \002No expiration\002")); } - if (ircdproto->CanSQLine && sqlines) + if (IRCD->CanSQLine && sqlines) { /* SQLINEs */ source.Reply(_("Current number of SQLINEs: \002%d\002"), sqlines->GetCount()); @@ -127,17 +127,17 @@ class CommandOSStats : public Command void DoStatsReset(CommandSource &source) { - maxusercnt = usercnt; + MaxUserCount = UserListByNick.size(); source.Reply(_("Statistics reset.")); return; } void DoStatsUptime(CommandSource &source) { - time_t uptime = Anope::CurTime - start_time; - source.Reply(_("Current users: \002%d\002 (\002%d\002 ops)"), usercnt, opcnt); - source.Reply(_("Maximum users: \002%d\002 (%s)"), maxusercnt, do_strftime(maxusertime).c_str()); - source.Reply(_("Services up %s"), duration(uptime).c_str()); + time_t uptime = Anope::CurTime - Anope::StartTime; + source.Reply(_("Current users: \002%d\002 (\002%d\002 ops)"), UserListByNick.size(), OperCount); + source.Reply(_("Maximum users: \002%d\002 (%s)"), MaxUserCount, Anope::strftime(MaxUserTime).c_str()); + source.Reply(_("Services up %s"), Anope::Duration(uptime).c_str()); return; } @@ -145,7 +145,7 @@ class CommandOSStats : public Command void DoStatsUplink(CommandSource &source) { Anope::string buf; - for (std::set<Anope::string>::iterator it = Capab.begin(); it != Capab.end(); ++it) + for (std::set<Anope::string>::iterator it = Servers::Capab.begin(); it != Servers::Capab.end(); ++it) buf += " " + *it; if (!buf.empty()) buf.erase(buf.begin()); @@ -255,12 +255,12 @@ class CommandOSStats : public Command class OSStats : public Module { CommandOSStats commandosstats; - SerializeType stats_type; + Serialize::Type stats_type; Stats stats_saver; public: OSStats(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - commandosstats(this), stats_type("Stats", Stats::unserialize) + commandosstats(this), stats_type("Stats", Stats::Unserialize) { this->SetAuthor("Anope"); diff --git a/modules/commands/os_svsnick.cpp b/modules/commands/os_svsnick.cpp index 4c6329acb..e08d5d3aa 100644 --- a/modules/commands/os_svsnick.cpp +++ b/modules/commands/os_svsnick.cpp @@ -36,28 +36,22 @@ class CommandOSSVSNick : public Command } /* Check for valid characters */ - if (newnick[0] == '-' || isdigit(newnick[0])) + if (!IRCD->IsNickValid(newnick)) { source.Reply(_("Nick \002%s\002 is an illegal nickname and cannot be used."), newnick.c_str()); return; } - for (unsigned i = 0, end = newnick.length(); i < end; ++i) - if (!isvalidnick(newnick[i])) - { - source.Reply(_("Nick \002%s\002 is an illegal nickname and cannot be used."), newnick.c_str()); - return; - } /* Check for a nick in use or a forbidden/suspended nick */ - if (!(u2 = finduser(nick))) + if (!(u2 = User::Find(nick, true))) source.Reply(NICK_X_NOT_IN_USE, nick.c_str()); - else if (!nick.equals_ci(newnick) && finduser(newnick)) + else if (!nick.equals_ci(newnick) && User::Find(newnick)) source.Reply(_("Nick \002%s\002 is currently in use."), newnick.c_str()); else { source.Reply(_("The nick \002%s\002 is now being changed to \002%s\002."), nick.c_str(), newnick.c_str()); Log(LOG_ADMIN, source, this) << "to change " << nick << " to " << newnick; - ircdproto->SendForceNickChange(u2, newnick, Anope::CurTime); + IRCD->SendForceNickChange(u2, newnick, Anope::CurTime); } return; } @@ -81,7 +75,7 @@ class OSSVSNick : public Module { this->SetAuthor("Anope"); - if (!ircdproto || !ircdproto->CanSVSNick) + if (!IRCD || !IRCD->CanSVSNick) throw ModuleException("Your IRCd does not support SVSNICK"); } diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp index 9261bcddd..7f48a2645 100644 --- a/modules/commands/os_sxline.cpp +++ b/modules/commands/os_sxline.cpp @@ -18,33 +18,33 @@ class SXLineDelCallback : public NumberList XLineManager *xlm; Command *command; CommandSource &source; - unsigned Deleted; + unsigned deleted; public: - SXLineDelCallback(XLineManager *x, Command *c, CommandSource &_source, const Anope::string &numlist) : NumberList(numlist, true), xlm(x), command(c), source(_source), Deleted(0) + SXLineDelCallback(XLineManager *x, Command *c, CommandSource &_source, const Anope::string &numlist) : NumberList(numlist, true), xlm(x), command(c), source(_source), deleted(0) { } ~SXLineDelCallback() { - if (!Deleted) + if (!deleted) source.Reply(_("No matching entries on the %s list."), this->command->name.c_str()); - else if (Deleted == 1) + else if (deleted == 1) source.Reply(_("Deleted 1 entry from the %s list."), this->command->name.c_str()); else - source.Reply(_("Deleted %d entries from the %s list."), Deleted, this->command->name.c_str()); + source.Reply(_("Deleted %d entries from the %s list."), deleted, this->command->name.c_str()); } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned number) anope_override { - if (!Number) + if (!number) return; - XLine *x = this->xlm->GetEntry(Number - 1); + XLine *x = this->xlm->GetEntry(number - 1); if (!x) return; - ++Deleted; + ++deleted; DoDel(this->xlm, source, x); } @@ -99,7 +99,7 @@ class CommandOSSXLineBase : public Command source.Reply(_("\002%s\002 deleted from the %s list."), mask.c_str(), source.command.c_str()); } - if (readonly) + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); return; @@ -126,24 +126,24 @@ class CommandOSSXLineBase : public Command { } - void HandleNumber(unsigned Number) anope_override + void HandleNumber(unsigned number) anope_override { - if (!Number) + if (!number) return; - const XLine *x = this->xlm->GetEntry(Number - 1); + const XLine *x = this->xlm->GetEntry(number - 1); if (!x) return; ListFormatter::ListEntry entry; - entry["Number"] = stringify(Number); - entry["Mask"] = x->Mask; - entry["By"] = x->By; - entry["Created"] = do_strftime(x->Created, NULL, true); - entry["Expires"] = expire_left(NULL, x->Expires); - entry["Reason"] = x->Reason; - list.addEntry(entry); + entry["Number"] = stringify(number); + entry["Mask"] = x->mask; + entry["By"] = x->by; + entry["Created"] = Anope::strftime(x->created, NULL, true); + entry["Expires"] = Anope::Expires(x->expires); + entry["Reason"] = x->reason; + list.AddEntry(entry); } } sl_list(this->xlm(), list, mask); @@ -155,21 +155,21 @@ class CommandOSSXLineBase : public Command { const XLine *x = this->xlm()->GetEntry(i); - if (mask.empty() || mask.equals_ci(x->Mask) || mask == x->UID || Anope::Match(x->Mask, mask, false, true)) + if (mask.empty() || mask.equals_ci(x->mask) || mask == x->id || Anope::Match(x->mask, mask, false, true)) { ListFormatter::ListEntry entry; entry["Number"] = stringify(i + 1); - entry["Mask"] = x->Mask; - entry["By"] = x->By; - entry["Created"] = do_strftime(x->Created, NULL, true); - entry["Expires"] = expire_left(source.nc, x->Expires); - entry["Reason"] = x->Reason; - list.addEntry(entry); + entry["Mask"] = x->mask; + entry["By"] = x->by; + entry["Created"] = Anope::strftime(x->created, NULL, true); + entry["Expires"] = Anope::Expires(x->expires, source.nc); + entry["Reason"] = x->reason; + list.AddEntry(entry); } } } - if (list.isEmpty()) + if (list.IsEmpty()) source.Reply(_("No matching entries on the %s list."), source.command.c_str()); else { @@ -186,7 +186,7 @@ class CommandOSSXLineBase : public Command void OnList(CommandSource &source, const std::vector<Anope::string> ¶ms) { ListFormatter list; - list.addColumn("Number").addColumn("Mask").addColumn("Reason"); + list.AddColumn("Number").AddColumn("Mask").AddColumn("Reason"); this->ProcessList(source, params, list); } @@ -194,7 +194,7 @@ class CommandOSSXLineBase : public Command void OnView(CommandSource &source, const std::vector<Anope::string> ¶ms) { ListFormatter list; - list.addColumn("Number").addColumn("Mask").addColumn("By").addColumn("Created").addColumn("Expires").addColumn("Reason"); + list.AddColumn("Number").AddColumn("Mask").AddColumn("By").AddColumn("Created").AddColumn("Expires").AddColumn("Reason"); this->ProcessList(source, params, list); } @@ -250,7 +250,7 @@ class CommandOSSNLine : public CommandOSSXLineBase void OnAdd(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (!this->xlm() || !ircdproto->CanSNLine) + if (!this->xlm() || !IRCD->CanSNLine) { source.Reply(_("Your IRCd does not support SNLINE")); return; @@ -268,7 +268,7 @@ class CommandOSSNLine : public CommandOSSXLineBase last_param = 3; } - expires = !expiry.empty() ? dotime(expiry) : Config->SNLineExpiry; + expires = !expiry.empty() ? Anope::DoTime(expiry) : Config->SNLineExpiry; /* If the expiry given does not contain a final letter, it's in days, * said the doc. Ah well. */ @@ -318,7 +318,7 @@ class CommandOSSNLine : public CommandOSSXLineBase return; } - service_reference<RegexProvider> provider("Regex", Config->RegexEngine); + ServiceReference<RegexProvider> provider("Regex", Config->RegexEngine); if (!provider) { source.Reply(_("Unable to find regex engine %s"), Config->RegexEngine.c_str()); @@ -354,7 +354,7 @@ class CommandOSSNLine : public CommandOSSXLineBase XLine *x = new XLine(mask, source.GetNick(), expires, reason); if (Config->AkillIds) - x->UID = XLineManager::GenerateUID(); + x->id = XLineManager::GenerateUID(); unsigned int affected = 0; for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) @@ -366,7 +366,7 @@ class CommandOSSNLine : public CommandOSSXLineBase { source.Reply(USERHOST_MASK_TOO_WIDE, mask.c_str()); Log(LOG_ADMIN, source, this) << "tried to " << source.command << " " << percent << "% of the network (" << affected << " users)"; - x->destroy(); + x->Destroy(); return; } @@ -374,7 +374,7 @@ class CommandOSSNLine : public CommandOSSXLineBase FOREACH_RESULT(I_OnAddXLine, OnAddXLine(source, x, this->xlm())); if (MOD_RESULT == EVENT_STOP) { - x->destroy(); + x->Destroy(); return; } @@ -391,18 +391,18 @@ class CommandOSSNLine : public CommandOSSXLineBase User *user = it->second; ++it; - if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->realname, x->Mask, false, true)) + if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->realname, x->mask, false, true)) user->Kill(Config->ServerName, rreason); } } source.Reply(_("\002%s\002 added to the %s list."), mask.c_str(), source.command.c_str()); - Log(LOG_ADMIN, source, this) << "on " << mask << " (" << reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; - if (readonly) + Log(LOG_ADMIN, source, this) << "on " << mask << " (" << reason << ") expires in " << (expires ? Anope::Duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); } - service_reference<XLineManager> snlines; + ServiceReference<XLineManager> snlines; public: CommandOSSNLine(Module *creator) : CommandOSSXLineBase(creator, "operserv/snline"), snlines("XLineManager", "xlinemanager/snline") { @@ -471,7 +471,7 @@ class CommandOSSQLine : public CommandOSSXLineBase void OnAdd(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (!this->xlm() || !ircdproto->CanSQLine) + if (!this->xlm() || !IRCD->CanSQLine) { source.Reply(_("Your IRCd does not support SQLINE")); return; @@ -489,7 +489,7 @@ class CommandOSSQLine : public CommandOSSXLineBase last_param = 3; } - expires = !expiry.empty() ? dotime(expiry) : Config->SQLineExpiry; + expires = !expiry.empty() ? Anope::DoTime(expiry) : Config->SQLineExpiry; /* If the expiry given does not contain a final letter, it's in days, * said the doc. Ah well. */ @@ -528,7 +528,7 @@ class CommandOSSQLine : public CommandOSSXLineBase return; } - service_reference<RegexProvider> provider("Regex", Config->RegexEngine); + ServiceReference<RegexProvider> provider("Regex", Config->RegexEngine); if (!provider) { source.Reply(_("Unable to find regex engine %s"), Config->RegexEngine.c_str()); @@ -557,7 +557,7 @@ class CommandOSSQLine : public CommandOSSXLineBase XLine *x = new XLine(mask, source.GetNick(), expires, reason); if (Config->AkillIds) - x->UID = XLineManager::GenerateUID(); + x->id = XLineManager::GenerateUID(); unsigned int affected = 0; for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) @@ -569,7 +569,7 @@ class CommandOSSQLine : public CommandOSSXLineBase { source.Reply(USERHOST_MASK_TOO_WIDE, mask.c_str()); Log(LOG_ADMIN, source, this) << "tried to SQLine " << percent << "% of the network (" << affected << " users)"; - x->destroy(); + x->Destroy(); return; } @@ -577,7 +577,7 @@ class CommandOSSQLine : public CommandOSSXLineBase FOREACH_RESULT(I_OnAddXLine, OnAddXLine(source, x, this->xlm())); if (MOD_RESULT == EVENT_STOP) { - x->destroy(); + x->Destroy(); return; } @@ -616,7 +616,7 @@ class CommandOSSQLine : public CommandOSSXLineBase User *user = it->second; ++it; - if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->nick, x->Mask, false, true)) + if (!user->HasMode(UMODE_OPER) && user->server != Me && Anope::Match(user->nick, x->mask, false, true)) user->Kill(Config->ServerName, rreason); } } @@ -625,13 +625,13 @@ class CommandOSSQLine : public CommandOSSXLineBase } source.Reply(_("\002%s\002 added to the SQLINE list."), mask.c_str()); - Log(LOG_ADMIN, source, this) << "on " << mask << " (" << reason << ") expires in " << (expires ? duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; + Log(LOG_ADMIN, source, this) << "on " << mask << " (" << reason << ") expires in " << (expires ? Anope::Duration(expires - Anope::CurTime) : "never") << " [affects " << affected << " user(s) (" << percent << "%)]"; - if (readonly) + if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); } - service_reference<XLineManager> sqlines; + ServiceReference<XLineManager> sqlines; public: CommandOSSQLine(Module *creator) : CommandOSSXLineBase(creator, "operserv/sqline"), sqlines("XLineManager", "xlinemanager/sqline") { diff --git a/modules/commands/os_update.cpp b/modules/commands/os_update.cpp index b9b43230f..7bea34aaf 100644 --- a/modules/commands/os_update.cpp +++ b/modules/commands/os_update.cpp @@ -25,7 +25,7 @@ class CommandOSUpdate : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override { source.Reply(_("Updating databases.")); - save_databases(); + Anope::SaveDatabases(); return; } diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp index 2b31c8a81..acb287cee 100644 --- a/modules/database/db_flatfile.cpp +++ b/modules/database/db_flatfile.cpp @@ -37,7 +37,7 @@ class DBFlatFile : public Module void BackupDatabase() { /* Do not backup a database that doesn't exist */ - if (!IsFile(DatabaseFile)) + if (!Anope::IsFile(DatabaseFile)) return; time_t now = Anope::CurTime; @@ -58,7 +58,7 @@ class DBFlatFile : public Module Log(this) << "Unable to back up database!"; if (!Config->NoBackupOkay) - quitting = true; + Anope::Quitting = true; return; } @@ -76,8 +76,8 @@ class DBFlatFile : public Module void OnReload() anope_override { ConfigReader config; - DatabaseFile = db_dir + "/" + config.ReadValue("db_flatfile", "database", "anope.db", 0); - BackupFile = db_dir + "/backups/" + config.ReadValue("db_flatfile", "database", "anope.db", 0); + DatabaseFile = Anope::DataDir + "/" + config.ReadValue("db_flatfile", "database", "anope.db", 0); + BackupFile = Anope::DataDir + "/backups/" + config.ReadValue("db_flatfile", "database", "anope.db", 0); } EventReturn OnLoadDatabase() anope_override @@ -92,23 +92,23 @@ class DBFlatFile : public Module return EVENT_CONTINUE; } - const std::vector<Anope::string> type_order = SerializeType::GetTypeOrder(); + const std::vector<Anope::string> type_order = Serialize::Type::GetTypeOrder(); for (unsigned i = 0; i < type_order.size(); ++i) { - SerializeType *stype = SerializeType::Find(type_order[i]); + Serialize::Type *stype = Serialize::Type::Find(type_order[i]); if (stype && !databases.count(stype->GetOwner())) { - Anope::string db_name = db_dir + "/module_" + stype->GetOwner()->name + ".db"; + Anope::string db_name = Anope::DataDir + "/module_" + stype->GetOwner()->name + ".db"; databases[stype->GetOwner()] = new std::fstream(db_name.c_str(), std::ios_base::in); } } - std::multimap<SerializeType *, Serialize::Data> objects; + std::multimap<Serialize::Type *, Serialize::Data> objects; for (std::map<Module *, std::fstream *>::iterator it = databases.begin(), it_end = databases.end(); it != it_end; ++it) { std::fstream *db = it->second; - SerializeType *st = NULL; + Serialize::Type *st = NULL; Serialize::Data data; for (Anope::string buf, token; std::getline(*db, buf.str());) { @@ -119,7 +119,7 @@ class DBFlatFile : public Module if (token == "OBJECT" && sep.GetToken(token)) { - st = SerializeType::Find(token); + st = Serialize::Type::Find(token); data.clear(); } else if (token == "DATA" && st != NULL && sep.GetToken(token)) @@ -136,9 +136,9 @@ class DBFlatFile : public Module for (unsigned i = 0; i < type_order.size(); ++i) { - SerializeType *stype = SerializeType::Find(type_order[i]); + Serialize::Type *stype = Serialize::Type::Find(type_order[i]); - std::multimap<SerializeType *, Serialize::Data>::iterator it = objects.find(stype), it_end = objects.upper_bound(stype); + std::multimap<Serialize::Type *, Serialize::Data>::iterator it = objects.find(stype), it_end = objects.upper_bound(stype); if (it == objects.end()) continue; for (; it != it_end; ++it) @@ -178,16 +178,16 @@ class DBFlatFile : public Module for (std::list<Serializable *>::const_iterator it = items.begin(), it_end = items.end(); it != it_end; ++it) { Serializable *base = *it; - SerializeType *s_type = base->GetSerializableType(); + Serialize::Type *s_type = base->GetSerializableType(); if (!s_type) continue; - Serialize::Data data = base->serialize(); + Serialize::Data data = base->Serialize(); if (!databases.count(s_type->GetOwner())) { - Anope::string db_name = db_dir + "/module_" + s_type->GetOwner()->name + ".db"; + Anope::string db_name = Anope::DataDir + "/module_" + s_type->GetOwner()->name + ".db"; databases[s_type->GetOwner()] = new std::fstream(db_name.c_str(), std::ios_base::out | std::ios_base::trunc); } std::fstream *fd = databases[s_type->GetOwner()]; @@ -203,7 +203,7 @@ class DBFlatFile : public Module Log(this) << "Unable to write database"; databases[NULL]->close(); if (!Config->NoBackupOkay) - quitting = true; + Anope::Quitting = true; if (IsFile(tmp_db)) rename(tmp_db.c_str(), DatabaseFile.c_str()); } diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp index f09fb2aab..ea899edd6 100644 --- a/modules/database/db_old.cpp +++ b/modules/database/db_old.cpp @@ -309,7 +309,7 @@ static dbFILE *open_db_read(const char *service, const char *filename, int versi int myversion; f = new dbFILE; - strscpy(f->filename, (db_dir + "/" + filename).c_str(), sizeof(f->filename)); + strscpy(f->filename, (Anope::DataDir + "/" + filename).c_str(), sizeof(f->filename)); f->mode = 'r'; fp = fopen(f->filename, "rb"); if (!fp) @@ -595,7 +595,7 @@ static void LoadNicks() Anope::string core; READ(read_string(core, f)); - NickCore *nc = findcore(core); + NickCore *nc = NickCore::Find(core); if (nc == NULL) { Log() << "Skipping coreless nick " << nick << " with core " << core; @@ -634,7 +634,7 @@ static void LoadVHosts() READ(read_string(creator, f)); READ(read_int32(&vtime, f)); - NickAlias *na = findnick(nick); + NickAlias *na = NickAlias::Find(nick); if (na == NULL) { Log() << "Removing vhost for nonexistant nick " << nick; @@ -669,7 +669,7 @@ static void LoadBots() READ(read_int32(&created, f)); READ(read_int16(&chancount, f)); - BotInfo *bi = findbot(nick); + BotInfo *bi = BotInfo::Find(nick); if (!bi) bi = new BotInfo(nick, user, host, real); bi->created = created; @@ -698,10 +698,10 @@ static void LoadChannels() ChannelInfo *ci = new ChannelInfo(namebuf); READ(read_string(buffer, f)); - ci->SetFounder(findcore(buffer)); + ci->SetFounder(NickCore::Find(buffer)); READ(read_string(buffer, f)); - ci->successor = findcore(buffer); + ci->successor = NickCore::Find(buffer); char pwbuf[32]; READ(read_buffer(pwbuf, f)); @@ -777,7 +777,7 @@ static void LoadChannels() ci->SetLevel(GetLevelName(j), level); } - service_reference<AccessProvider> provider("AccessProvider", "access/access"); + ServiceReference<AccessProvider> provider("AccessProvider", "access/access"); uint16_t tmpu16; READ(read_uint16(&tmpu16, f)); for (uint16_t j = 0; j < tmpu16; ++j) @@ -793,7 +793,7 @@ static void LoadChannels() int16_t level; READ(read_int16(&level, f)); if (access) - access->Unserialize(stringify(level)); + access->AccessUnserialize(stringify(level)); Anope::string mask; READ(read_string(mask, f)); @@ -858,7 +858,7 @@ static void LoadChannels() READ(read_string(buffer, f)); READ(read_string(buffer, f)); - ci->bi = findbot(buffer); + ci->bi = BotInfo::Find(buffer); READ(read_int32(&tmp32, f)); if (tmp32 & OLD_BS_DONTKICKOPS) @@ -981,7 +981,7 @@ static void LoadOper() continue; XLine *x = new XLine(user + "@" + host, by, expires, reason, XLineManager::GenerateUID()); - x->Created = seton; + x->created = seton; akill->AddXLine(x); } @@ -1001,7 +1001,7 @@ static void LoadOper() continue; XLine *x = new XLine(mask, by, expires, reason, XLineManager::GenerateUID()); - x->Created = seton; + x->created = seton; snline->AddXLine(x); } @@ -1021,7 +1021,7 @@ static void LoadOper() continue; XLine *x = new XLine(mask, by, expires, reason, XLineManager::GenerateUID()); - x->Created = seton; + x->created = seton; sqline->AddXLine(x); } @@ -1041,7 +1041,7 @@ static void LoadOper() continue; XLine *x = new XLine(mask, by, expires, reason, XLineManager::GenerateUID()); - x->Created = seton; + x->created = seton; szline->AddXLine(x); } diff --git a/modules/database/db_plain.cpp b/modules/database/db_plain.cpp index e6d430556..f23cf4e4a 100644 --- a/modules/database/db_plain.cpp +++ b/modules/database/db_plain.cpp @@ -139,9 +139,9 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co else if (key.equals_ci("MEMOMAX")) ci->memos.memomax = params[0].is_pos_number_only() ? convertTo<int16_t>(params[0]) : -1; else if (key.equals_ci("FOUNDER")) - ci->SetFounder(findcore(params[0])); + ci->SetFounder(NickCore::Find(params[0])); else if (key.equals_ci("SUCCESSOR")) - ci->successor = findcore(params[0]); + ci->successor = NickCore::Find(params[0]); else if (key.equals_ci("LEVELS")) { for (unsigned j = 0, end = params.size(); j < end; j += 2) @@ -169,14 +169,14 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co } else if (key.equals_ci("ACCESS")) // Older access system, from Anope 1.9.4. { - service_reference<AccessProvider> provider("AccessProvider", "access/access"); + ServiceReference<AccessProvider> provider("AccessProvider", "access/access"); if (!provider) throw DatabaseException("Old access entry for nonexistant provider"); ChanAccess *access = const_cast<ChanAccess *>(provider->Create()); access->ci = ci; access->mask = params[0]; - access->Unserialize(params[1]); + access->AccessUnserialize(params[1]); access->last_seen = params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0; access->creator = params[3]; access->created = Anope::CurTime; @@ -185,14 +185,14 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co } else if (key.equals_ci("ACCESS2")) { - service_reference<AccessProvider> provider("AccessProvider", params[0]); + ServiceReference<AccessProvider> provider("AccessProvider", params[0]); if (!provider) throw DatabaseException("Access entry for nonexistant provider " + params[0]); ChanAccess *access = const_cast<ChanAccess *>(provider->Create()); access->ci = ci; access->mask = params[1]; - access->Unserialize(params[2]); + access->AccessUnserialize(params[2]); access->last_seen = params[3].is_pos_number_only() ? convertTo<time_t>(params[3]) : 0; access->creator = params[4]; access->created = params.size() > 5 && params[5].is_pos_number_only() ? convertTo<time_t>(params[5]) : Anope::CurTime; @@ -206,7 +206,7 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co NickCore *nc = NULL; if (Nick) { - nc = findcore(params[2]); + nc = NickCore::Find(params[2]); if (!nc) throw DatabaseException("Akick for nonexistant core " + params[2] + " on " + ci->name); } @@ -242,6 +242,7 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co Anope::string setter = params[2]; time_t mcreated = params[3].is_pos_number_only() ? convertTo<time_t>(params[3]) : Anope::CurTime; Anope::string param = params.size() > 4 ? params[4] : ""; + const Anope::string* ChannelModeNameStrings = Flags<ChannelModeName>::GetFlagStrings(); for (size_t i = CMODE_BEGIN + 1; i < CMODE_END; ++i) if (ChannelModeNameStrings[i] == mode_name) { @@ -270,7 +271,7 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co else if (key.equals_ci("BI")) { if (params[0].equals_ci("NAME")) - ci->bi = findbot(params[1]); + ci->bi = BotInfo::Find(params[1]); else if (params[0].equals_ci("FLAGS")) ci->botflags.FromVector(params); else if (params[0].equals_ci("TTB")) @@ -396,22 +397,22 @@ static void ReadDatabase(Module *m = NULL) { if (params[0].equals_ci("NC")) { - nc = findcore(params[1]); + nc = NickCore::Find(params[1]); Type = MD_NC; } else if (params[0].equals_ci("NA")) { - na = findnick(params[2]); + na = NickAlias::Find(params[2]); Type = MD_NA; } else if (params[0].equals_ci("BI")) { - bi = findbot(params[1]); + bi = BotInfo::Find(params[1]); Type = MD_BI; } else if (params[0].equals_ci("CH")) { - ci = cs_findchan(params[1]); + ci = ChannelInfo::Find(params[1]); Type = MD_CH; } else if (params[0].equals_ci("MD")) @@ -484,7 +485,7 @@ static void LoadNickCore(const std::vector<Anope::string> ¶ms) static void LoadNickAlias(const std::vector<Anope::string> ¶ms) { - NickCore *nc = findcore(params[0]); + NickCore *nc = NickCore::Find(params[0]); if (!nc) { Log() << "[db_plain]: Unable to find core " << params[0]; @@ -502,7 +503,7 @@ static void LoadNickAlias(const std::vector<Anope::string> ¶ms) static void LoadBotInfo(const std::vector<Anope::string> ¶ms) { - BotInfo *bi = findbot(params[0]); + BotInfo *bi = BotInfo::Find(params[0]); if (!bi) bi = new BotInfo(params[0], params[1], params[2]); @@ -533,8 +534,8 @@ static void LoadOperInfo(const std::vector<Anope::string> ¶ms) { if (params[0].equals_ci("STATS")) { - maxusercnt = params[1].is_pos_number_only() ? convertTo<uint32_t>(params[1]) : 0; - maxusertime = params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0; + MaxUserCount = params[1].is_pos_number_only() ? convertTo<uint32_t>(params[1]) : 0; + MaxUserTime = params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0; } else if (params[0].equals_ci("SXLINE")) { @@ -551,7 +552,7 @@ static void LoadOperInfo(const std::vector<Anope::string> ¶ms) Anope::string reason = params[7]; XLine *x = new XLine(mask, by, expires, reason, XLineManager::GenerateUID()); - x->Created = seton; + x->created = seton; xl->AddXLine(x); break; } @@ -627,7 +628,7 @@ class DBPlain : public Module Log() << "Unable to back up database!"; if (!Config->NoBackupOkay) - quitting = true; + Anope::Quitting = true; return; } @@ -646,8 +647,8 @@ class DBPlain : public Module void OnReload() anope_override { ConfigReader config; - DatabaseFile = db_dir + "/" + config.ReadValue("db_plain", "database", "anope.db", 0); - BackupFile = db_dir + "/backups/" + config.ReadValue("db_plain", "database", "anope.db", 0); + DatabaseFile = Anope::DataDir + "/" + config.ReadValue("db_plain", "database", "anope.db", 0); + BackupFile = Anope::DataDir + "/backups/" + config.ReadValue("db_plain", "database", "anope.db", 0); } EventReturn OnLoadDatabase() anope_override @@ -777,7 +778,7 @@ class DBPlain : public Module for (unsigned k = 0, end = ci->GetAccessCount(); k < end; ++k) { const ChanAccess *access = ci->GetAccess(k); - db_buffer << "MD ACCESS2 " << access->provider->name << " " << access->mask << " " << access->Serialize() << " " << access->last_seen << " " << access->creator << " " << access->created << endl; + db_buffer << "MD ACCESS2 " << access->provider->name << " " << access->mask << " " << access->AccessSerialize() << " " << access->last_seen << " " << access->creator << " " << access->created << endl; } for (unsigned k = 0, end = ci->GetAkickCount(); k < end; ++k) { @@ -835,7 +836,7 @@ class DBPlain : public Module //FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, ci)); } - db_buffer << "OS STATS " << maxusercnt << " " << maxusertime << endl; + db_buffer << "OS STATS " << MaxUserCount << " " << MaxUserTime << endl; for (std::list<XLineManager *>::iterator it = XLineManager::XLineManagers.begin(), it_end = XLineManager::XLineManagers.end(); it != it_end; ++it) { @@ -843,7 +844,7 @@ class DBPlain : public Module for (unsigned i = 0, end = xl->GetCount(); i < end; ++i) { const XLine *x = xl->GetEntry(i); - db_buffer << "OS SXLINE " << xl->Type() << " " << x->GetUser() << " " << x->GetHost() << " " << x->By << " " << x->Created << " " << x->Expires << " :" << x->Reason << endl; + db_buffer << "OS SXLINE " << xl->Type() << " " << x->GetUser() << " " << x->GetHost() << " " << x->by << " " << x->created << " " << x->expires << " :" << x->reason << endl; } } @@ -861,7 +862,7 @@ class DBPlain : public Module if (!db.is_open()) { - ircdproto->SendGlobops(NULL, "Unable to open %s for writing!", DatabaseFile.c_str()); + IRCD->SendGlobops(NULL, "Unable to open %s for writing!", DatabaseFile.c_str()); return EVENT_CONTINUE; } diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp index 48c813a3c..60db11c0d 100644 --- a/modules/database/db_sql.cpp +++ b/modules/database/db_sql.cpp @@ -33,7 +33,7 @@ class SQLSQLInterface : public SQLInterface class ResultSQLSQLInterface : public SQLSQLInterface { - dynamic_reference<Serializable> obj; + Reference<Serializable> obj; public: ResultSQLSQLInterface(Module *o, Serializable *ob) : SQLSQLInterface(o), obj(ob) { } @@ -55,10 +55,10 @@ public: class DBSQL : public Module, public Pipe { - service_reference<SQLProvider> sql; + ServiceReference<SQLProvider> sql; SQLSQLInterface sqlinterface; Anope::string prefix; - std::set<dynamic_reference<Serializable> > updated_items; + std::set<Reference<Serializable> > updated_items; bool shutting_down; void RunBackground(const SQLQuery &q, SQLInterface *iface = NULL) @@ -72,7 +72,7 @@ class DBSQL : public Module, public Pipe Log(this) << "db_sql: Unable to execute query, is SQL configured correctly?"; } } - else if (!quitting) + else if (!Anope::Quitting) { if (iface == NULL) iface = &this->sqlinterface; @@ -95,9 +95,9 @@ class DBSQL : public Module, public Pipe void OnNotify() anope_override { - for (std::set<dynamic_reference<Serializable> >::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it) + for (std::set<Reference<Serializable> >::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it) { - dynamic_reference<Serializable> obj = *it; + Reference<Serializable> obj = *it; if (obj && this->sql) { @@ -105,11 +105,11 @@ class DBSQL : public Module, public Pipe continue; obj->UpdateCache(); - SerializeType *s_type = obj->GetSerializableType(); + Serialize::Type *s_type = obj->GetSerializableType(); if (!s_type) continue; - Serialize::Data data = obj->serialize(); + Serialize::Data data = obj->Serialize(); std::vector<SQLQuery> create = this->sql->CreateTable(this->prefix + s_type->GetName(), data); for (unsigned i = 0; i < create.size(); ++i) @@ -127,7 +127,7 @@ class DBSQL : public Module, public Pipe { ConfigReader config; Anope::string engine = config.ReadValue("db_sql", "engine", "", 0); - this->sql = service_reference<SQLProvider>("SQLProvider", engine); + this->sql = ServiceReference<SQLProvider>("SQLProvider", engine); this->prefix = config.ReadValue("db_sql", "prefix", "anope_db_", 0); } @@ -150,10 +150,10 @@ class DBSQL : public Module, public Pipe return EVENT_CONTINUE; } - const std::vector<Anope::string> type_order = SerializeType::GetTypeOrder(); + const std::vector<Anope::string> type_order = Serialize::Type::GetTypeOrder(); for (unsigned i = 0; i < type_order.size(); ++i) { - SerializeType *sb = SerializeType::Find(type_order[i]); + Serialize::Type *sb = Serialize::Type::Find(type_order[i]); SQLQuery query("SELECT * FROM `" + this->prefix + sb->GetName() + "`"); SQLResult res = this->sql->RunQuery(query); @@ -192,7 +192,7 @@ class DBSQL : public Module, public Pipe void OnSerializableDestruct(Serializable *obj) anope_override { - SerializeType *s_type = obj->GetSerializableType(); + Serialize::Type *s_type = obj->GetSerializableType(); if (s_type) this->RunBackground("DELETE FROM `" + this->prefix + s_type->GetName() + "` WHERE `id` = " + stringify(obj->id)); } diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp index 3473fc1a9..00561592f 100644 --- a/modules/database/db_sql_live.cpp +++ b/modules/database/db_sql_live.cpp @@ -7,22 +7,20 @@ class DBMySQL : public Module, public Pipe private: Anope::string engine; Anope::string prefix; - service_reference<SQLProvider> SQL; + ServiceReference<SQLProvider> SQL; time_t lastwarn; bool ro; bool init; - std::set<dynamic_reference<Serializable> > updated_items; + std::set<Reference<Serializable> > updated_items; bool CheckSQL() { if (SQL) { - if (readonly && this->ro) + if (Anope::ReadOnly && this->ro) { - readonly = this->ro = false; - const BotInfo *bi = findbot(Config->OperServ); - if (bi) - ircdproto->SendGlobops(bi, "Found SQL again, going out of readonly mode..."); + Anope::ReadOnly = this->ro = false; + Log() << "Found SQL again, going out of readonly mode..."; } return true; @@ -31,10 +29,8 @@ class DBMySQL : public Module, public Pipe { if (Anope::CurTime - Config->UpdateTimeout > lastwarn) { - const BotInfo *bi = findbot(Config->OperServ); - if (bi) - ircdproto->SendGlobops(bi, "Unable to locate SQL reference, going to readonly..."); - readonly = this->ro = true; + Log() << "Unable to locate SQL reference, going to readonly..."; + Anope::ReadOnly = this->ro = true; this->lastwarn = Anope::CurTime; } @@ -85,9 +81,9 @@ class DBMySQL : public Module, public Pipe if (!this->CheckInit()) return; - for (std::set<dynamic_reference<Serializable> >::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it) + for (std::set<Reference<Serializable> >::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it) { - dynamic_reference<Serializable> obj = *it; + Reference<Serializable> obj = *it; if (obj && this->SQL) { @@ -95,11 +91,11 @@ class DBMySQL : public Module, public Pipe continue; obj->UpdateCache(); - SerializeType *s_type = obj->GetSerializableType(); + Serialize::Type *s_type = obj->GetSerializableType(); if (!s_type) continue; - Serialize::Data data = obj->serialize(); + Serialize::Data data = obj->Serialize(); std::vector<SQLQuery> create = this->SQL->CreateTable(this->prefix + s_type->GetName(), data); for (unsigned i = 0; i < create.size(); ++i) @@ -133,7 +129,7 @@ class DBMySQL : public Module, public Pipe { ConfigReader config; this->engine = config.ReadValue("db_sql", "engine", "", 0); - this->SQL = service_reference<SQLProvider>("SQLProvider", this->engine); + this->SQL = ServiceReference<SQLProvider>("SQLProvider", this->engine); this->prefix = config.ReadValue("db_sql", "prefix", "anope_db_", 0); } @@ -149,14 +145,14 @@ class DBMySQL : public Module, public Pipe { if (!this->CheckInit()) return; - SerializeType *s_type = obj->GetSerializableType(); + Serialize::Type *s_type = obj->GetSerializableType(); if (!s_type) return; this->RunQuery("DELETE FROM `" + this->prefix + s_type->GetName() + "` WHERE `id` = " + stringify(obj->id)); s_type->objects.erase(obj->id); } - void OnSerializeCheck(SerializeType *obj) anope_override + void OnSerializeCheck(Serialize::Type *obj) anope_override { if (!this->CheckInit() || obj->GetTimestamp() == Anope::CurTime) return; @@ -189,7 +185,7 @@ class DBMySQL : public Module, public Pipe std::map<unsigned int, Serializable *>::iterator it = obj->objects.find(id); if (it != obj->objects.end()) { - it->second->destroy(); + it->second->Destroy(); obj->objects.erase(it); } } @@ -217,7 +213,7 @@ class DBMySQL : public Module, public Pipe } } else - s->destroy(); + s->Destroy(); } } diff --git a/modules/encryption/enc_md5.cpp b/modules/encryption/enc_md5.cpp index bcbe4aeed..45c7f3df5 100644 --- a/modules/encryption/enc_md5.cpp +++ b/modules/encryption/enc_md5.cpp @@ -341,7 +341,7 @@ class EMD5 : public Module void OnCheckAuthentication(User *, IdentifyRequest *req) anope_override { - const NickAlias *na = findnick(req->GetAccount()); + const NickAlias *na = NickAlias::Find(req->GetAccount()); if (na == NULL) return; NickCore *nc = na->nc; @@ -361,7 +361,7 @@ class EMD5 : public Module * we want to re-encrypt the pass with the new encryption */ if (ModuleManager::FindFirstOf(ENCRYPTION) != this) - enc_encrypt(req->GetPassword(), nc->pass); + Anope::Encrypt(req->GetPassword(), nc->pass); req->Success(this); } } diff --git a/modules/encryption/enc_none.cpp b/modules/encryption/enc_none.cpp index 9496939fd..4854e5eb0 100644 --- a/modules/encryption/enc_none.cpp +++ b/modules/encryption/enc_none.cpp @@ -43,7 +43,7 @@ class ENone : public Module void OnCheckAuthentication(User *, IdentifyRequest *req) anope_override { - const NickAlias *na = findnick(req->GetAccount()); + const NickAlias *na = NickAlias::Find(req->GetAccount()); if (na == NULL) return; NickCore *nc = na->nc; @@ -63,7 +63,7 @@ class ENone : public Module * we want to re-encrypt the pass with the new encryption */ if (ModuleManager::FindFirstOf(ENCRYPTION) != this) - enc_encrypt(req->GetPassword(), nc->pass); + Anope::Encrypt(req->GetPassword(), nc->pass); req->Success(this); } } diff --git a/modules/encryption/enc_old.cpp b/modules/encryption/enc_old.cpp index b5ce86540..f7c83515d 100644 --- a/modules/encryption/enc_old.cpp +++ b/modules/encryption/enc_old.cpp @@ -351,7 +351,7 @@ class EOld : public Module void OnCheckAuthentication(User *, IdentifyRequest *req) anope_override { - const NickAlias *na = findnick(req->GetAccount()); + const NickAlias *na = NickAlias::Find(req->GetAccount()); if (na == NULL) return; NickCore *nc = na->nc; @@ -371,7 +371,7 @@ class EOld : public Module * we want to re-encrypt the pass with the new encryption */ if (ModuleManager::FindFirstOf(ENCRYPTION) != this) - enc_encrypt(req->GetPassword(), nc->pass); + Anope::Encrypt(req->GetPassword(), nc->pass); req->Success(this); } } diff --git a/modules/encryption/enc_sha1.cpp b/modules/encryption/enc_sha1.cpp index 28d216972..88571d776 100644 --- a/modules/encryption/enc_sha1.cpp +++ b/modules/encryption/enc_sha1.cpp @@ -194,7 +194,7 @@ class ESHA1 : public Module void OnCheckAuthentication(User *, IdentifyRequest *req) anope_override { - const NickAlias *na = findnick(req->GetAccount()); + const NickAlias *na = NickAlias::Find(req->GetAccount()); if (na == NULL) return; NickCore *nc = na->nc; @@ -211,7 +211,7 @@ class ESHA1 : public Module if (nc->pass.equals_cs(buf)) { if (ModuleManager::FindFirstOf(ENCRYPTION) != this) - enc_encrypt(req->GetPassword(), nc->pass); + Anope::Encrypt(req->GetPassword(), nc->pass); req->Success(this); } } diff --git a/modules/encryption/enc_sha256.cpp b/modules/encryption/enc_sha256.cpp index 36eaa98fc..396f975ed 100644 --- a/modules/encryption/enc_sha256.cpp +++ b/modules/encryption/enc_sha256.cpp @@ -280,7 +280,7 @@ class ESHA256 : public Module void OnCheckAuthentication(User *, IdentifyRequest *req) anope_override { - const NickAlias *na = findnick(req->GetAccount()); + const NickAlias *na = NickAlias::Find(req->GetAccount()); if (na == NULL) return; NickCore *nc = na->nc; @@ -303,7 +303,7 @@ class ESHA256 : public Module * we want to re-encrypt the pass with the new encryption */ if (ModuleManager::FindFirstOf(ENCRYPTION) != this) - enc_encrypt(req->GetPassword(), nc->pass); + Anope::Encrypt(req->GetPassword(), nc->pass); req->Success(this); } } diff --git a/modules/extra/bs_autoassign.cpp b/modules/extra/bs_autoassign.cpp index f290a3856..c84e18964 100644 --- a/modules/extra/bs_autoassign.cpp +++ b/modules/extra/bs_autoassign.cpp @@ -31,7 +31,7 @@ class BSAutoAssign : public Module if (this->bot.empty()) return; - BotInfo *bi = findbot(this->bot); + BotInfo *bi = BotInfo::Find(this->bot); if (bi == NULL) { Log(this) << "bs_autoassign is configured to assign bot " << this->bot << ", but it does not exist?"; diff --git a/modules/extra/httpd.h b/modules/extra/httpd.h index 490bf72bb..bf6a9838d 100644 --- a/modules/extra/httpd.h +++ b/modules/extra/httpd.h @@ -130,7 +130,7 @@ class HTTPClient : public ClientSocket, public BufferedSocket, public BinarySock bool ProcessWrite() anope_override { - return !BinarySocket::ProcessWrite() || BinarySocket::WriteBuffer.empty() ? false : true; + return !BinarySocket::ProcessWrite() || BinarySocket::write_buffer.empty() ? false : true; } void Write(const char *buffer, size_t l) anope_override diff --git a/modules/extra/m_chanstats.cpp b/modules/extra/m_chanstats.cpp index 1c37aa8ec..b50592b0f 100644 --- a/modules/extra/m_chanstats.cpp +++ b/modules/extra/m_chanstats.cpp @@ -21,7 +21,7 @@ class MySQLInterface : public SQLInterface class MChanstats : public Module { - service_reference<SQLProvider> sql; + ServiceReference<SQLProvider> sql; MySQLInterface sqlinterface; SQLQuery query; Anope::string SmileysHappy, SmileysSad, SmileysOther, prefix; @@ -359,7 +359,7 @@ class MChanstats : public Module SmileysOther = config.ReadValue("chanstats", "SmileysOther", ":/", 0); Anope::string engine = config.ReadValue("chanstats", "engine", "", 0); - this->sql = service_reference<SQLProvider>("SQLProvider", engine); + this->sql = ServiceReference<SQLProvider>("SQLProvider", engine); if (sql) this->CheckTables(); else @@ -367,7 +367,7 @@ class MChanstats : public Module } void OnTopicUpdated(Channel *c, const Anope::string &user, const Anope::string &topic) anope_override { - User *u = finduser(user); + User *u = User::Find(user); if (!u || !u->Account() || !c->ci || !c->ci->HasFlag(CI_STATS)) return; query = "CALL " + prefix + "chanstats_proc_update(@channel@, @nick@, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);"; diff --git a/modules/extra/m_dnsbl.cpp b/modules/extra/m_dnsbl.cpp index b860bd64c..54c802cd4 100644 --- a/modules/extra/m_dnsbl.cpp +++ b/modules/extra/m_dnsbl.cpp @@ -7,7 +7,7 @@ #include "module.h" -static service_reference<XLineManager> akills("XLineManager", "xlinemanager/sgline"); +static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sgline"); struct Blacklist { @@ -19,21 +19,21 @@ struct Blacklist Blacklist(const Anope::string &n, time_t b, const Anope::string &r, const std::map<int, Anope::string> &re) : name(n), bantime(b), reason(r), replies(re) { } }; -class DNSBLResolver : public DNSRequest +class DNSBLResolver : public DNS::Request { - dynamic_reference<User> user; + Reference<User> user; Blacklist blacklist; bool add_to_akill; public: - DNSBLResolver(Module *c, User *u, const Blacklist &b, const Anope::string &host, bool add_akill) : DNSRequest(host, DNS_QUERY_A, true, c), user(u), blacklist(b), add_to_akill(add_akill) { } + DNSBLResolver(Module *c, User *u, const Blacklist &b, const Anope::string &host, bool add_akill) : DNS::Request(host, DNS::QUERY_A, true, c), user(u), blacklist(b), add_to_akill(add_akill) { } - void OnLookupComplete(const DNSQuery *record) anope_override + void OnLookupComplete(const DNS::Query *record) anope_override { if (!user || user->HasExt("m_dnsbl_akilled")) return; - const ResourceRecord &ans_record = record->answers[0]; + const DNS::ResourceRecord &ans_record = record->answers[0]; // Replies should be in 127.0.0.0/24 if (ans_record.rdata.find("127.0.0.") != 0) return; @@ -61,8 +61,7 @@ class DNSBLResolver : public DNSRequest reason = reason.replace_all_cs("%r", record_reason); reason = reason.replace_all_cs("%N", Config->NetworkName); - const BotInfo *operserv = findbot(Config->OperServ); - Log(operserv) << "DNSBL: " << user->GetMask() << " (" << user->ip << ") appears in " << this->blacklist.name; + Log(OperServ) << "DNSBL: " << user->GetMask() << " (" << user->ip << ") appears in " << this->blacklist.name; XLine *x = new XLine("*@" + user->ip, Config->OperServ, Anope::CurTime + this->blacklist.bantime, reason, XLineManager::GenerateUID()); if (this->add_to_akill && akills) { @@ -71,8 +70,8 @@ class DNSBLResolver : public DNSRequest } else { - ircdproto->SendAkill(NULL, x); - x->destroy(); + IRCD->SendAkill(NULL, x); + x->Destroy(); } } }; @@ -110,7 +109,7 @@ class ModuleDNSBL : public Module if (bname.empty()) continue; Anope::string sbantime = config.ReadValue("blacklist", "time", "4h", i); - time_t bantime = dotime(sbantime); + time_t bantime = Anope::DoTime(sbantime); if (bantime < 0) bantime = 9000; Anope::string reason = config.ReadValue("blacklist", "reason", "", i); @@ -126,7 +125,7 @@ class ModuleDNSBL : public Module } } - void OnUserConnect(dynamic_reference<User> &user, bool &exempt) anope_override + void OnUserConnect(Reference<User> &user, bool &exempt) anope_override { if (exempt || !user || (!this->check_on_connect && !Me->IsSynced())) return; diff --git a/modules/extra/m_helpchan.cpp b/modules/extra/m_helpchan.cpp index 08f90b644..6b450e581 100644 --- a/modules/extra/m_helpchan.cpp +++ b/modules/extra/m_helpchan.cpp @@ -26,10 +26,10 @@ class HelpChannel : public Module { if (Name == CMODE_OP && c && c->ci && c->name.equals_ci(this->HelpChan)) { - User *u = finduser(param); + User *u = User::Find(param); if (u && c->ci->AccessFor(u).HasPriv("OPDEOPME")) - u->SetMode(findbot(Config->OperServ), UMODE_HELPOP); + u->SetMode(OperServ, UMODE_HELPOP); } return EVENT_CONTINUE; diff --git a/modules/extra/m_httpd.cpp b/modules/extra/m_httpd.cpp index f2704d77c..0176b955a 100644 --- a/modules/extra/m_httpd.cpp +++ b/modules/extra/m_httpd.cpp @@ -42,7 +42,7 @@ class MyHTTPClient : public HTTPClient HTTPMessage header; bool header_done, served; Anope::string page_name; - dynamic_reference<HTTPPage> page; + Reference<HTTPPage> page; Anope::string ip; enum @@ -114,7 +114,8 @@ class MyHTTPClient : public HTTPClient { if (this->action == ACTION_NONE) { - std::vector<Anope::string> params = BuildStringVector(buf); + std::vector<Anope::string> params; + spacesepstream(buf).GetTokens(params); if (params.empty() || (params[0] != "GET" && params[0] != "POST")) { @@ -189,11 +190,11 @@ class MyHTTPClient : public HTTPClient } catch (const ConvertException &) { } - if (this->extrabuf.length() == content_length) + if (this->extra_buf.length() == content_length) { - Log(LOG_DEBUG_2) << "HTTP POST from " << this->clientaddr.addr() << ": " << this->extrabuf; + Log(LOG_DEBUG_2) << "HTTP POST from " << this->clientaddr.addr() << ": " << this->extra_buf; - sepstream sep(this->extrabuf, '&'); + sepstream sep(this->extra_buf, '&'); Anope::string token; while (sep.GetToken(token)) @@ -204,7 +205,7 @@ class MyHTTPClient : public HTTPClient this->header.post_data[token.substr(0, sz)] = HTTPUtils::URLDecode(token.substr(sz + 1)); } - this->header.content = this->extrabuf; + this->header.content = this->extra_buf; this->Serve(); } } @@ -281,7 +282,7 @@ class MyHTTPProvider : public HTTPProvider, public CallBack { int timeout; std::map<Anope::string, HTTPPage *> pages; - std::list<dynamic_reference<MyHTTPClient> > clients; + std::list<Reference<MyHTTPClient> > clients; public: MyHTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p, const int t) : Socket(-1, i.find(':') != Anope::string::npos), HTTPProvider(c, n, i, p), CallBack(c, 10, Anope::CurTime, true), timeout(t) { } @@ -290,7 +291,7 @@ class MyHTTPProvider : public HTTPProvider, public CallBack { while (!this->clients.empty()) { - dynamic_reference<MyHTTPClient>& c = this->clients.front(); + Reference<MyHTTPClient>& c = this->clients.front(); if (c && c->created + this->timeout >= Anope::CurTime) break; @@ -326,7 +327,7 @@ class MyHTTPProvider : public HTTPProvider, public CallBack class HTTPD : public Module { - service_reference<SSLService> sslref; + ServiceReference<SSLService> sslref; std::map<Anope::string, HTTPProvider *> providers; public: HTTPD(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED), sslref("SSLService", "ssl") @@ -432,7 +433,7 @@ class HTTPD : public Module p->ext_ip = ext_ip; - p->ext_headers = BuildStringVector(ext_header); + spacesepstream(ext_header).GetTokens(p->ext_headers); } for (std::map<Anope::string, HTTPProvider *>::iterator it = this->providers.begin(), it_end = this->providers.end(); it != it_end;) diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp index f2140eb71..233a43dde 100644 --- a/modules/extra/m_ldap_authentication.cpp +++ b/modules/extra/m_ldap_authentication.cpp @@ -12,13 +12,13 @@ static Anope::string username_attribute; struct IdentifyInfo { - dynamic_reference<User> user; + Reference<User> user; IdentifyRequest *req; - service_reference<LDAPProvider> lprov; + ServiceReference<LDAPProvider> lprov; bool admin_bind; Anope::string dn; - IdentifyInfo(User *u, IdentifyRequest *r, service_reference<LDAPProvider> &lp) : user(u), req(r), lprov(lp), admin_bind(true) + IdentifyInfo(User *u, IdentifyRequest *r, ServiceReference<LDAPProvider> &lp) : user(u), req(r), lprov(lp), admin_bind(true) { req->Hold(me); } @@ -100,18 +100,17 @@ class IdentifyInterface : public LDAPInterface } else { - NickAlias *na = findnick(ii->req->GetAccount()); + NickAlias *na = NickAlias::Find(ii->req->GetAccount()); if (na == NULL) { na = new NickAlias(ii->req->GetAccount(), new NickCore(ii->req->GetAccount())); if (ii->user) { if (Config->NSAddAccessOnReg) - na->nc->AddAccess(create_mask(ii->user)); + na->nc->AddAccess(ii->user->Mask()); - const BotInfo *bi = findbot(Config->NickServ); - if (bi) - ii->user->SendMessage(bi, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); + if (NickServ) + ii->user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); } } na->nc->Extend("m_ldap_authentication_dn", new ExtensibleItemClass<Anope::string>(ii->dn)); @@ -155,7 +154,7 @@ class OnIdentifyInterface : public LDAPInterface std::map<LDAPQuery, Anope::string>::iterator it = this->requests.find(r.id); if (it == this->requests.end()) return; - User *u = finduser(it->second); + User *u = User::Find(it->second); this->requests.erase(it); if (!u || !u->Account() || r.empty()) @@ -169,9 +168,8 @@ class OnIdentifyInterface : public LDAPInterface if (!email.equals_ci(u->Account()->email)) { u->Account()->email = email; - BotInfo *bi = findbot(Config->NickServ); - if (bi) - u->SendMessage(bi, _("Your email has been updated to \002%s\002"), email.c_str()); + if (NickServ) + u->SendMessage(NickServ, _("Your email has been updated to \002%s\002"), email.c_str()); Log(this->owner) << "m_ldap_authentication: Updated email address for " << u->nick << " (" << u->Account()->display << ") to " << email; } } @@ -206,7 +204,7 @@ class OnRegisterInterface : public LDAPInterface class NSIdentifyLDAP : public Module { - service_reference<LDAPProvider> ldap; + ServiceReference<LDAPProvider> ldap; IdentifyInterface iinterface; OnIdentifyInterface oninterface; OnRegisterInterface orinterface; diff --git a/modules/extra/m_ldap_oper.cpp b/modules/extra/m_ldap_oper.cpp index 53b3d4d43..ed2f5900a 100644 --- a/modules/extra/m_ldap_oper.cpp +++ b/modules/extra/m_ldap_oper.cpp @@ -23,7 +23,7 @@ class IdentifyInterface : public LDAPInterface std::map<LDAPQuery, Anope::string>::iterator it = this->requests.find(r.id); if (it == this->requests.end()) return; - User *u = finduser(it->second); + User *u = User::Find(it->second); this->requests.erase(it); @@ -77,7 +77,7 @@ class IdentifyInterface : public LDAPInterface class LDAPOper : public Module { - service_reference<LDAPProvider> ldap; + ServiceReference<LDAPProvider> ldap; IdentifyInterface iinterface; Anope::string binddn; diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp index 7f1f965cd..47f6f41de 100644 --- a/modules/extra/m_mysql.cpp +++ b/modules/extra/m_mysql.cpp @@ -376,10 +376,10 @@ std::vector<SQLQuery> MySQLService::CreateTable(const Anope::string &table, cons known_cols.insert(it->first); query_text += ", `" + it->first + "` "; - if (it->second.getType() == Serialize::DT_INT) + if (it->second.GetType() == Serialize::DT_INT) query_text += "int(11)"; - else if (it->second.getMax() > 0) - query_text += "varchar(" + stringify(it->second.getMax()) + ")"; + else if (it->second.GetMax() > 0) + query_text += "varchar(" + stringify(it->second.GetMax()) + ")"; else query_text += "text"; } @@ -395,10 +395,10 @@ std::vector<SQLQuery> MySQLService::CreateTable(const Anope::string &table, cons known_cols.insert(it->first); Anope::string query_text = "ALTER TABLE `" + table + "` ADD `" + it->first + "` "; - if (it->second.getType() == Serialize::DT_INT) + if (it->second.GetType() == Serialize::DT_INT) query_text += "int(11)"; - else if (it->second.getMax() > 0) - query_text += "varchar(" + stringify(it->second.getMax()) + ")"; + else if (it->second.GetMax() > 0) + query_text += "varchar(" + stringify(it->second.GetMax()) + ")"; else query_text += "text"; diff --git a/modules/extra/m_proxyscan.cpp b/modules/extra/m_proxyscan.cpp index 00519c57f..6d2a6b7b0 100644 --- a/modules/extra/m_proxyscan.cpp +++ b/modules/extra/m_proxyscan.cpp @@ -36,7 +36,7 @@ class ProxyCallbackListener : public ListenSocket bool ProcessWrite() anope_override { - return !BufferedSocket::ProcessWrite() || this->WriteBuffer.empty() ? false : true; + return !BufferedSocket::ProcessWrite() || this->write_buffer.empty() ? false : true; } }; @@ -53,7 +53,7 @@ class ProxyCallbackListener : public ListenSocket class ProxyConnect : public ConnectionSocket { - static service_reference<XLineManager> akills; + static ServiceReference<XLineManager> akills; public: static std::set<ProxyConnect *> proxies; @@ -85,7 +85,7 @@ class ProxyConnect : public ConnectionSocket reason = reason.replace_all_cs("%i", this->conaddr.addr()); reason = reason.replace_all_cs("%p", stringify(this->conaddr.port())); - Log(findbot(Config->OperServ)) << "PROXYSCAN: Open " << this->GetType() << " proxy found on " << this->conaddr.addr() << ":" << this->conaddr.port() << " (" << reason << ")"; + Log(OperServ) << "PROXYSCAN: Open " << this->GetType() << " proxy found on " << this->conaddr.addr() << ":" << this->conaddr.port() << " (" << reason << ")"; XLine *x = new XLine("*@" + this->conaddr.addr(), Config->OperServ, Anope::CurTime + this->proxy.duration, reason, XLineManager::GenerateUID()); if (add_to_akill && akills) { @@ -94,15 +94,15 @@ class ProxyConnect : public ConnectionSocket } else { - if (ircdproto->CanSZLine) - ircdproto->SendSZLine(NULL, x); + if (IRCD->CanSZLine) + IRCD->SendSZLine(NULL, x); else - ircdproto->SendAkill(NULL, x); - x->destroy(); + IRCD->SendAkill(NULL, x); + x->Destroy(); } } }; -service_reference<XLineManager> ProxyConnect::akills("XLineManager", "xlinemanager/sgline"); +ServiceReference<XLineManager> ProxyConnect::akills("XLineManager", "xlinemanager/sgline"); std::set<ProxyConnect *> ProxyConnect::proxies; class HTTPProxyConnect : public ProxyConnect, public BufferedSocket @@ -255,7 +255,7 @@ class ModuleProxyScan : public Module ++it; ClientSocket *cs = dynamic_cast<ClientSocket *>(s); - if (cs != NULL && cs->LS == this->listener) + if (cs != NULL && cs->ls == this->listener) delete s; } @@ -332,7 +332,7 @@ class ModuleProxyScan : public Module if (p.ports.empty()) continue; - p.duration = dotime(config.ReadValue("proxyscan", "time", "4h", i)); + p.duration = Anope::DoTime(config.ReadValue("proxyscan", "time", "4h", i)); p.reason = config.ReadValue("proxyscan", "reason", "", i); if (p.reason.empty()) continue; @@ -341,7 +341,7 @@ class ModuleProxyScan : public Module } } - void OnUserConnect(dynamic_reference<User> &user, bool &exempt) anope_override + void OnUserConnect(Reference<User> &user, bool &exempt) anope_override { if (exempt || !user || !Me->IsSynced() || !user->server->IsSynced()) return; @@ -360,7 +360,7 @@ class ModuleProxyScan : public Module if (!this->con_notice.empty() && !this->con_source.empty()) { - const BotInfo *bi = findbot(this->con_source); + const BotInfo *bi = BotInfo::Find(this->con_source); if (bi) user->SendMessage(bi, this->con_notice); } diff --git a/modules/extra/m_rewrite.cpp b/modules/extra/m_rewrite.cpp index 6d8690960..70710bd8a 100644 --- a/modules/extra/m_rewrite.cpp +++ b/modules/extra/m_rewrite.cpp @@ -13,7 +13,8 @@ struct Rewrite bool Matches(const std::vector<Anope::string> &message) { - std::vector<Anope::string> sm = BuildStringVector(this->source_message); + std::vector<Anope::string> sm; + spacesepstream(this->source_message).GetTokens(sm); for (unsigned i = 0; i < sm.size(); ++i) if (sm[i] != "$" && !sm[i].equals_ci(message[i])) @@ -106,7 +107,8 @@ class ModuleRewrite : public Module EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) anope_override { - std::vector<Anope::string> tokens = BuildStringVector(message); + std::vector<Anope::string> tokens; + spacesepstream(message).GetTokens(tokens); for (unsigned i = 0; i < this->rewrites.size(); ++i) { Rewrite &rw = this->rewrites[i]; diff --git a/modules/extra/m_sql_authentication.cpp b/modules/extra/m_sql_authentication.cpp index 9412edc50..ce7a275b3 100644 --- a/modules/extra/m_sql_authentication.cpp +++ b/modules/extra/m_sql_authentication.cpp @@ -5,7 +5,7 @@ static Module *me; class SQLAuthenticationResult : public SQLInterface { - dynamic_reference<User> user; + Reference<User> user; IdentifyRequest *req; public: @@ -37,26 +37,25 @@ class SQLAuthenticationResult : public SQLInterface } catch (const SQLException &) { } - const BotInfo *bi = findbot(Config->NickServ); - NickAlias *na = findnick(req->GetAccount()); + NickAlias *na = NickAlias::Find(req->GetAccount()); if (na == NULL) { na = new NickAlias(req->GetAccount(), new NickCore(req->GetAccount())); if (user) { if (Config->NSAddAccessOnReg) - na->nc->AddAccess(create_mask(user)); + na->nc->AddAccess(user->Mask()); - if (bi) - user->SendMessage(bi, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); + if (NickServ) + user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); } } if (!email.empty() && email != na->nc->email) { na->nc->email = email; - if (user && bi) - user->SendMessage(bi, _("Your email has been updated to \002%s\002."), email.c_str()); + if (user && NickServ) + user->SendMessage(NickServ, _("Your email has been updated to \002%s\002."), email.c_str()); } req->Success(me); @@ -77,7 +76,7 @@ class ModuleSQLAuthentication : public Module bool disable_register; Anope::string disable_reason; - service_reference<SQLProvider> SQL; + ServiceReference<SQLProvider> SQL; public: ModuleSQLAuthentication(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) @@ -101,7 +100,7 @@ class ModuleSQLAuthentication : public Module this->disable_register = config.ReadFlag("m_sql_authentication", "disable_ns_register", "false", 0); this->disable_reason = config.ReadValue("m_sql_authentication", "disable_reason", "", 0); - this->SQL = service_reference<SQLProvider>("SQLProvider", this->engine); + this->SQL = ServiceReference<SQLProvider>("SQLProvider", this->engine); } EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) anope_override diff --git a/modules/extra/m_sql_oper.cpp b/modules/extra/m_sql_oper.cpp index 22218a646..523272a49 100644 --- a/modules/extra/m_sql_oper.cpp +++ b/modules/extra/m_sql_oper.cpp @@ -3,7 +3,7 @@ class SQLOperResult : public SQLInterface { - dynamic_reference<User> user; + Reference<User> user; struct SQLOperResultDeleter { @@ -51,7 +51,7 @@ class SQLOperResult : public SQLInterface delete user->Account()->o; user->Account()->o = NULL; Log(this->owner) << "m_sql_oper: Removed services operator from " << user->nick << " (" << user->Account()->display << ")"; - user->RemoveMode(findbot(Config->OperServ), UMODE_OPER); // Probably not set, just incase + user->RemoveMode(OperServ, UMODE_OPER); // Probably not set, just incase } return; } @@ -72,10 +72,10 @@ class SQLOperResult : public SQLInterface if (!user->HasMode(UMODE_OPER)) { - ircdproto->SendOper(user); + IRCD->SendOper(user); if (!modes.empty()) - user->SetModes(findbot(Config->OperServ), "%s", modes.c_str()); + user->SetModes(OperServ, "%s", modes.c_str()); } } @@ -91,7 +91,7 @@ class ModuleSQLOper : public Module Anope::string engine; Anope::string query; - service_reference<SQLProvider> SQL; + ServiceReference<SQLProvider> SQL; public: ModuleSQLOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, SUPPORTED) @@ -111,7 +111,7 @@ class ModuleSQLOper : public Module this->engine = config.ReadValue("m_sql_oper", "engine", "", 0); this->query = config.ReadValue("m_sql_oper", "query", "", 0); - this->SQL = service_reference<SQLProvider>("SQLProvider", this->engine); + this->SQL = ServiceReference<SQLProvider>("SQLProvider", this->engine); } void OnNickIdentify(User *u) anope_override diff --git a/modules/extra/m_sqlite.cpp b/modules/extra/m_sqlite.cpp index f0db04c66..971345475 100644 --- a/modules/extra/m_sqlite.cpp +++ b/modules/extra/m_sqlite.cpp @@ -107,7 +107,7 @@ class ModuleSQLite : public Module if (this->SQLiteServices.find(connname) == this->SQLiteServices.end()) { - Anope::string database = db_dir + "/" + config.ReadValue("sqlite", "database", "anope", i); + Anope::string database = Anope::DataDir + "/" + config.ReadValue("sqlite", "database", "anope", i); try { @@ -214,7 +214,7 @@ std::vector<SQLQuery> SQLiteService::CreateTable(const Anope::string &table, con known_cols.insert(it->first); query_text += ", `" + it->first + "` "; - if (it->second.getType() == Serialize::DT_INT) + if (it->second.GetType() == Serialize::DT_INT) query_text += "int(11)"; else query_text += "text"; @@ -242,7 +242,7 @@ std::vector<SQLQuery> SQLiteService::CreateTable(const Anope::string &table, con known_cols.insert(it->first); Anope::string query_text = "ALTER TABLE `" + table + "` ADD `" + it->first + "` "; - if (it->second.getType() == Serialize::DT_INT) + if (it->second.GetType() == Serialize::DT_INT) query_text += "int(11)"; else query_text += "text"; diff --git a/modules/extra/m_ssl.cpp b/modules/extra/m_ssl.cpp index 2f72744c7..fdde28919 100644 --- a/modules/extra/m_ssl.cpp +++ b/modules/extra/m_ssl.cpp @@ -110,7 +110,7 @@ class SSLModule : public Module this->OnReload(); - if (IsFile(this->certfile.c_str())) + if (Anope::IsFile(this->certfile.c_str())) { if (!SSL_CTX_use_certificate_file(client_ctx, this->certfile.c_str(), SSL_FILETYPE_PEM) || !SSL_CTX_use_certificate_file(server_ctx, this->certfile.c_str(), SSL_FILETYPE_PEM)) { @@ -124,7 +124,7 @@ class SSLModule : public Module else Log() << "Unable to open certificate " << this->certfile; - if (IsFile(this->keyfile.c_str())) + if (Anope::IsFile(this->keyfile.c_str())) { if (!SSL_CTX_use_PrivateKey_file(client_ctx, this->keyfile.c_str(), SSL_FILETYPE_PEM) || !SSL_CTX_use_PrivateKey_file(server_ctx, this->keyfile.c_str(), SSL_FILETYPE_PEM)) { @@ -137,7 +137,7 @@ class SSLModule : public Module } else { - if (IsFile(this->certfile.c_str())) + if (Anope::IsFile(this->certfile.c_str())) { SSL_CTX_free(client_ctx); SSL_CTX_free(server_ctx); @@ -168,7 +168,7 @@ class SSLModule : public Module Socket *s = it->second; ++it; - if (dynamic_cast<SSLSocketIO *>(s->IO)) + if (dynamic_cast<SSLSocketIO *>(s->io)) delete s; } @@ -188,7 +188,7 @@ class SSLModule : public Module { ConfigReader config; - if (config.ReadFlag("uplink", "ssl", "no", CurrentUplink)) + if (config.ReadFlag("uplink", "ssl", "no", Anope::CurrentUplink)) { this->service.Init(UplinkSock); } @@ -201,10 +201,10 @@ MySSLService::MySSLService(Module *o, const Anope::string &n) : SSLService(o, n) void MySSLService::Init(Socket *s) { - if (s->IO != &normalSocketIO) + if (s->io != &NormalSocketIO) throw CoreException("Socket initializing SSL twice"); - s->IO = new SSLSocketIO(); + s->io = new SSLSocketIO(); } SSLSocketIO::SSLSocketIO() @@ -228,7 +228,7 @@ int SSLSocketIO::Send(Socket *s, const char *buf, size_t sz) ClientSocket *SSLSocketIO::Accept(ListenSocket *s) { - if (s->IO == &normalSocketIO) + if (s->io == &NormalSocketIO) throw SocketException("Attempting to accept on uninitialized socket with SSL"); sockaddrs conaddr; @@ -245,15 +245,15 @@ ClientSocket *SSLSocketIO::Accept(ListenSocket *s) ClientSocket *newsocket = s->OnAccept(newsock, conaddr); me->service.Init(newsocket); - SSLSocketIO *IO = anope_dynamic_static_cast<SSLSocketIO *>(newsocket->IO); + SSLSocketIO *io = anope_dynamic_static_cast<SSLSocketIO *>(newsocket->io); - IO->sslsock = SSL_new(server_ctx); - if (!IO->sslsock) + io->sslsock = SSL_new(server_ctx); + if (!io->sslsock) throw SocketException("Unable to initialize SSL socket"); - SSL_set_accept_state(IO->sslsock); + SSL_set_accept_state(io->sslsock); - if (!SSL_set_fd(IO->sslsock, newsocket->GetFD())) + if (!SSL_set_fd(io->sslsock, newsocket->GetFD())) throw SocketException("Unable to set SSL fd"); newsocket->SetFlag(SF_ACCEPTING); @@ -264,19 +264,19 @@ ClientSocket *SSLSocketIO::Accept(ListenSocket *s) SocketFlag SSLSocketIO::FinishAccept(ClientSocket *cs) { - if (cs->IO == &normalSocketIO) + if (cs->io == &NormalSocketIO) throw SocketException("Attempting to finish connect uninitialized socket with SSL"); else if (cs->HasFlag(SF_ACCEPTED)) return SF_ACCEPTED; else if (!cs->HasFlag(SF_ACCEPTING)) throw SocketException("SSLSocketIO::FinishAccept called for a socket not accepted nor accepting?"); - SSLSocketIO *IO = anope_dynamic_static_cast<SSLSocketIO *>(cs->IO); + SSLSocketIO *io = anope_dynamic_static_cast<SSLSocketIO *>(cs->io); - int ret = SSL_accept(IO->sslsock); + int ret = SSL_accept(io->sslsock); if (ret <= 0) { - int error = SSL_get_error(IO->sslsock, ret); + int error = SSL_get_error(io->sslsock, ret); if (ret == -1 && (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE)) { SocketEngine::Change(cs, error == SSL_ERROR_WANT_WRITE, SF_WRITABLE); @@ -304,7 +304,7 @@ SocketFlag SSLSocketIO::FinishAccept(ClientSocket *cs) void SSLSocketIO::Connect(ConnectionSocket *s, const Anope::string &target, int port) { - if (s->IO == &normalSocketIO) + if (s->io == &NormalSocketIO) throw SocketException("Attempting to connect uninitialized socket with SSL"); s->UnsetFlag(SF_CONNECTING); @@ -336,29 +336,29 @@ void SSLSocketIO::Connect(ConnectionSocket *s, const Anope::string &target, int SocketFlag SSLSocketIO::FinishConnect(ConnectionSocket *s) { - if (s->IO == &normalSocketIO) + if (s->io == &NormalSocketIO) throw SocketException("Attempting to finish connect uninitialized socket with SSL"); else if (s->HasFlag(SF_CONNECTED)) return SF_CONNECTED; else if (!s->HasFlag(SF_CONNECTING)) throw SocketException("SSLSocketIO::FinishConnect called for a socket not connected nor connecting?"); - SSLSocketIO *IO = anope_dynamic_static_cast<SSLSocketIO *>(s->IO); + SSLSocketIO *io = anope_dynamic_static_cast<SSLSocketIO *>(s->io); - if (IO->sslsock == NULL) + if (io->sslsock == NULL) { - IO->sslsock = SSL_new(client_ctx); - if (!IO->sslsock) + io->sslsock = SSL_new(client_ctx); + if (!io->sslsock) throw SocketException("Unable to initialize SSL socket"); - if (!SSL_set_fd(IO->sslsock, s->GetFD())) + if (!SSL_set_fd(io->sslsock, s->GetFD())) throw SocketException("Unable to set SSL fd"); } - int ret = SSL_connect(IO->sslsock); + int ret = SSL_connect(io->sslsock); if (ret <= 0) { - int error = SSL_get_error(IO->sslsock, ret); + int error = SSL_get_error(io->sslsock, ret); if (ret == -1 && (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE)) { SocketEngine::Change(s, error == SSL_ERROR_WANT_WRITE, SF_WRITABLE); diff --git a/modules/extra/m_statusupdate.cpp b/modules/extra/m_statusupdate.cpp index 7cbd9c7be..41ea8833e 100644 --- a/modules/extra/m_statusupdate.cpp +++ b/modules/extra/m_statusupdate.cpp @@ -43,7 +43,7 @@ class StatusUpdate : public Module for (int i = 0; !modeInfo[i].priv.empty(); ++i) if (!access->HasPriv(modeInfo[i].priv)) ci->c->RemoveMode(NULL, modeInfo[i].name, user->nick); - chan_set_correct_modes(user, ci->c, 1, false); + ci->c->SetCorrectModes(user, true, false); } } } diff --git a/modules/extra/m_xmlrpc.cpp b/modules/extra/m_xmlrpc.cpp index 2ff648812..a3b999a5e 100644 --- a/modules/extra/m_xmlrpc.cpp +++ b/modules/extra/m_xmlrpc.cpp @@ -157,7 +157,7 @@ class MyXMLRPCServiceInterface : public XMLRPCServiceInterface, public HTTPPage class ModuleXMLRPC : public Module { - service_reference<HTTPProvider> httpref; + ServiceReference<HTTPProvider> httpref; public: MyXMLRPCServiceInterface xmlrpcinterface; @@ -183,7 +183,7 @@ class ModuleXMLRPC : public Module void OnReload() anope_override { ConfigReader config; - httpref = service_reference<HTTPProvider>("HTTPProvider", "httpd/main"); + httpref = ServiceReference<HTTPProvider>("HTTPProvider", "httpd/main"); } }; diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp index 4bd9c0ec6..672ef5524 100644 --- a/modules/extra/m_xmlrpc_main.cpp +++ b/modules/extra/m_xmlrpc_main.cpp @@ -8,8 +8,8 @@ class XMLRPCIdentifyRequest : public IdentifyRequest XMLRPCRequest request; HTTPReply repl; /* Request holds a reference to the HTTPReply, because we might exist long enough to invalidate it we'll copy it here then reset the reference before we use it */ - dynamic_reference<HTTPClient> client; - dynamic_reference<XMLRPCServiceInterface> xinterface; + Reference<HTTPClient> client; + Reference<XMLRPCServiceInterface> xinterface; public: XMLRPCIdentifyRequest(Module *m, XMLRPCRequest& req, HTTPClient *c, XMLRPCServiceInterface* iface, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(m, acc, pass), request(req), repl(request.r), client(c), xinterface(iface) { } @@ -74,14 +74,14 @@ class MyXMLRPCEvent : public XMLRPCEvent request.reply("error", "Invalid parameters"); else { - BotInfo *bi = findbot(service); + BotInfo *bi = BotInfo::Find(service); if (!bi) request.reply("error", "Invalid service"); else { request.reply("result", "Success"); - NickAlias *na = findnick(user); + NickAlias *na = NickAlias::Find(user); Anope::string out; @@ -127,18 +127,18 @@ class MyXMLRPCEvent : public XMLRPCEvent void DoStats(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) { - request.reply("uptime", stringify(Anope::CurTime - start_time)); + request.reply("uptime", stringify(Anope::CurTime - Anope::StartTime)); request.reply("uplinkname", Me->GetLinks().front()->GetName()); { Anope::string buf; - for (std::set<Anope::string>::iterator it = Capab.begin(); it != Capab.end(); ++it) + for (std::set<Anope::string>::iterator it = Servers::Capab.begin(); it != Servers::Capab.end(); ++it) buf += " " + *it; if (!buf.empty()) buf.erase(buf.begin()); request.reply("uplinkcapab", buf); } - request.reply("usercount", stringify(usercnt)); - request.reply("maxusercount", stringify(maxusercnt)); + request.reply("usercount", stringify(UserListByNick.size())); + request.reply("maxusercount", stringify(MaxUserCount)); request.reply("channelcount", stringify(ChannelList.size())); } @@ -147,7 +147,7 @@ class MyXMLRPCEvent : public XMLRPCEvent if (request.data.empty()) return; - Channel *c = findchan(request.data[0]); + Channel *c = Channel::Find(request.data[0]); request.reply("name", iface->Sanitize(c ? c->name : request.data[0])); @@ -175,7 +175,7 @@ class MyXMLRPCEvent : public XMLRPCEvent for (CUserList::const_iterator it = c->users.begin(); it != c->users.end(); ++it) { UserContainer *uc = *it; - users += uc->Status->BuildModePrefixList() + uc->user->nick + " "; + users += uc->status->BuildModePrefixList() + uc->user->nick + " "; } if (!users.empty()) { @@ -199,7 +199,7 @@ class MyXMLRPCEvent : public XMLRPCEvent if (request.data.empty()) return; - User *u = finduser(request.data[0]); + User *u = User::Find(request.data[0]); request.reply("nick", iface->Sanitize(u ? u->nick : request.data[0])); @@ -227,7 +227,7 @@ class MyXMLRPCEvent : public XMLRPCEvent for (UChannelList::const_iterator it = u->chans.begin(); it != u->chans.end(); ++it) { ChannelContainer *cc = *it; - channels += cc->Status->BuildModePrefixList() + cc->chan->name + " "; + channels += cc->status->BuildModePrefixList() + cc->chan->name + " "; } if (!channels.empty()) { @@ -253,7 +253,7 @@ class MyXMLRPCEvent : public XMLRPCEvent class ModuleXMLRPCMain : public Module { - service_reference<XMLRPCServiceInterface> xmlrpc; + ServiceReference<XMLRPCServiceInterface> xmlrpc; MyXMLRPCEvent stats; diff --git a/modules/extra/webcpanel/pages/chanserv/access.cpp b/modules/extra/webcpanel/pages/chanserv/access.cpp index a1b8be97f..d21546c3a 100644 --- a/modules/extra/webcpanel/pages/chanserv/access.cpp +++ b/modules/extra/webcpanel/pages/chanserv/access.cpp @@ -22,7 +22,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s return true; } - ChannelInfo *ci = cs_findchan(chname); + ChannelInfo *ci = ChannelInfo::Find(chname); if (!ci) return true; @@ -64,7 +64,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s if (acc->mask == message.post_data["mask"]) { - if ((!highest || *acc >= *highest) && !u_access.Founder && !has_priv) + if ((!highest || *acc >= *highest) && !u_access.founder && !has_priv) { replacements["MESSAGES"] = "Access denied"; denied = true; @@ -85,7 +85,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s new_acc->creator = na->nc->display; try { - new_acc->Unserialize(message.post_data["access"]); + new_acc->AccessUnserialize(message.post_data["access"]); } catch (...) { @@ -98,7 +98,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s new_acc->last_seen = 0; new_acc->created = Anope::CurTime; - if ((!highest || *highest <= *new_acc) && !u_access.Founder && !has_priv) + if ((!highest || *highest <= *new_acc) && !u_access.founder && !has_priv) delete new_acc; else if (new_acc->Serialize().empty()) { @@ -108,7 +108,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s else { ci->AddAccess(new_acc); - replacements["MESSAGES"] = "Access for " + new_acc->mask + " set to " + new_acc->Serialize(); + replacements["MESSAGES"] = "Access for " + new_acc->mask + " set to " + new_acc->AccessSerialize(); } } } @@ -123,7 +123,7 @@ bool WebCPanel::ChanServ::Access::OnRequest(HTTPProvider *server, const Anope::s ChanAccess *access = ci->GetAccess(i); replacements["MASKS"] = HTTPUtils::Escape(access->mask); - replacements["ACCESSES"] = HTTPUtils::Escape(access->Serialize()); + replacements["ACCESSES"] = HTTPUtils::Escape(access->AccessSerialize()); replacements["CREATORS"] = HTTPUtils::Escape(access->creator); replacements["ACCESS_CHANGES"] = ci->AccessFor(na->nc).HasPriv("ACCESS_CHANGE") ? "YES" : "NO"; } diff --git a/modules/extra/webcpanel/pages/chanserv/akick.cpp b/modules/extra/webcpanel/pages/chanserv/akick.cpp index d5351bfd9..bb678b715 100644 --- a/modules/extra/webcpanel/pages/chanserv/akick.cpp +++ b/modules/extra/webcpanel/pages/chanserv/akick.cpp @@ -22,7 +22,7 @@ bool WebCPanel::ChanServ::Akick::OnRequest(HTTPProvider *server, const Anope::st return true; } - ChannelInfo *ci = cs_findchan(chname); + ChannelInfo *ci = ChannelInfo::Find(chname); if (!ci) return true; diff --git a/modules/extra/webcpanel/pages/chanserv/set.cpp b/modules/extra/webcpanel/pages/chanserv/set.cpp index 4ad551e6a..4a61b37db 100644 --- a/modules/extra/webcpanel/pages/chanserv/set.cpp +++ b/modules/extra/webcpanel/pages/chanserv/set.cpp @@ -22,7 +22,7 @@ bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::stri return true; } - ChannelInfo *ci = cs_findchan(chname); + ChannelInfo *ci = ChannelInfo::Find(chname); if (!ci || !ci->AccessFor(na->nc).HasPriv("SET")) return true; @@ -93,8 +93,8 @@ bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::stri replacements["FOUNDER"] = ci->GetFounder()->display; if (ci->successor) replacements["SUCCESSOR"] = ci->successor->display; - replacements["TIME_REGISTERED"] = do_strftime(ci->time_registered, na->nc); - replacements["LAST_USED"] = do_strftime(ci->last_used, na->nc); + replacements["TIME_REGISTERED"] = Anope::strftime(ci->time_registered, na->nc); + replacements["LAST_USED"] = Anope::strftime(ci->last_used, na->nc); if (!ci->last_topic.empty()) { diff --git a/modules/extra/webcpanel/pages/index.cpp b/modules/extra/webcpanel/pages/index.cpp index c97737c21..6178dab29 100644 --- a/modules/extra/webcpanel/pages/index.cpp +++ b/modules/extra/webcpanel/pages/index.cpp @@ -11,9 +11,9 @@ class WebpanelRequest : public IdentifyRequest { HTTPReply reply; HTTPMessage message; - dynamic_reference<HTTPProvider> server; + Reference<HTTPProvider> server; Anope::string page_name; - dynamic_reference<HTTPClient> client; + Reference<HTTPClient> client; TemplateFileServer::Replacements replacements; public: @@ -23,7 +23,7 @@ class WebpanelRequest : public IdentifyRequest { if (!client) return; - NickAlias *na = findnick(this->GetAccount()); + NickAlias *na = NickAlias::Find(this->GetAccount()); if (!na) { this->OnFail(); diff --git a/modules/extra/webcpanel/pages/memoserv/memos.cpp b/modules/extra/webcpanel/pages/memoserv/memos.cpp index 00b913ef0..54c7a1227 100644 --- a/modules/extra/webcpanel/pages/memoserv/memos.cpp +++ b/modules/extra/webcpanel/pages/memoserv/memos.cpp @@ -36,7 +36,7 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st } else { - ci = cs_findchan(chname); + ci = ChannelInfo::Find(chname); if (ci) { replacements["MESSAGES"] = "Displaying the memos for " + chname + "."; @@ -107,7 +107,7 @@ bool WebCPanel::MemoServ::Memos::OnRequest(HTTPProvider *server, const Anope::st m = mi->GetMemo(i); replacements["NUMBER"] = stringify(i+1); replacements["SENDER"] = m->sender; - replacements["TIME"] = do_strftime(m->time); + replacements["TIME"] = Anope::strftime(m->time); replacements["TEXT"] = m->text; if (m->HasFlag(MF_UNREAD)) replacements["UNREAD"] = "YES"; diff --git a/modules/extra/webcpanel/pages/nickserv/alist.cpp b/modules/extra/webcpanel/pages/nickserv/alist.cpp index 2fd184dbb..3b5b8dab0 100644 --- a/modules/extra/webcpanel/pages/nickserv/alist.cpp +++ b/modules/extra/webcpanel/pages/nickserv/alist.cpp @@ -39,7 +39,7 @@ bool WebCPanel::NickServ::Alist::OnRequest(HTTPProvider *server, const Anope::st replacements["CHANNELS"] = (ci->HasFlag(CI_NO_EXPIRE) ? "!" : "") + ci->name; Anope::string access_str; for (unsigned i = 0; i < access.size(); ++i) - access_str += ", " + access[i]->Serialize(); + access_str += ", " + access[i]->AccessSerialize(); replacements["ACCESSES"] = access_str.substr(2); } diff --git a/modules/extra/webcpanel/pages/nickserv/info.cpp b/modules/extra/webcpanel/pages/nickserv/info.cpp index 3ec61b03f..cdd80b7cd 100644 --- a/modules/extra/webcpanel/pages/nickserv/info.cpp +++ b/modules/extra/webcpanel/pages/nickserv/info.cpp @@ -19,7 +19,7 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str { if (message.post_data["email"] != na->nc->email) { - if (!message.post_data["email"].empty() && !MailValidate(message.post_data["email"])) + if (!message.post_data["email"].empty() && !Mail::Validate(message.post_data["email"])) replacements["ERRORS"] = "Invalid email"; else { @@ -83,7 +83,7 @@ bool WebCPanel::NickServ::Info::OnRequest(HTTPProvider *server, const Anope::str replacements["DISPLAY"] = HTTPUtils::Escape(na->nc->display); if (na->nc->email.empty() == false) replacements["EMAIL"] = HTTPUtils::Escape(na->nc->email); - replacements["TIME_REGISTERED"] = do_strftime(na->time_registered, na->nc); + replacements["TIME_REGISTERED"] = Anope::strftime(na->time_registered, na->nc); if (na->HasVhost()) { if (na->GetVhostIdent().empty() == false) diff --git a/modules/extra/webcpanel/pages/operserv/akill.cpp b/modules/extra/webcpanel/pages/operserv/akill.cpp index 3d66b5c6a..112949d9e 100644 --- a/modules/extra/webcpanel/pages/operserv/akill.cpp +++ b/modules/extra/webcpanel/pages/operserv/akill.cpp @@ -14,7 +14,7 @@ WebCPanel::OperServ::Akill::Akill(const Anope::string &cat, const Anope::string bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) { - static service_reference<XLineManager> akills("XLineManager","xlinemanager/sgline"); + static ServiceReference<XLineManager> akills("XLineManager","xlinemanager/sgline"); if (!na->nc->IsServicesOper() && !(na->nc->o && na->nc->o->ot && na->nc->o->ot->HasPriv("operserv/akill"))) { @@ -28,7 +28,7 @@ bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::st if (message.post_data.count("mask") > 0 && message.post_data.count("expiry") > 0 && message.post_data.count("reason") > 0) { std::vector<Anope::string> params; - stringstream cmdstr; + std::stringstream cmdstr; params.push_back("ADD"); cmdstr << "+" << HTTPUtils::URLDecode(message.post_data["expiry"]); cmdstr << " " << HTTPUtils::URLDecode(message.post_data["mask"]); @@ -49,11 +49,11 @@ bool WebCPanel::OperServ::Akill::OnRequest(HTTPProvider *server, const Anope::st { const XLine *x = akills->GetEntry(i); replacements["NUMBER"] = stringify(i + 1); - replacements["HOST"] = x->Mask; - replacements["SETTER"] = x->By; - replacements["TIME"] = do_strftime(x->Created, NULL, true); - replacements["EXPIRE"] = expire_left(na->nc, x->Expires); - replacements["REASON"] = x->Reason; + replacements["HOST"] = x->mask; + replacements["SETTER"] = x->by; + replacements["TIME"] = Anope::strftime(x->created, NULL, true); + replacements["EXPIRE"] = Anope::Expires(x->expires, na->nc); + replacements["REASON"] = x->reason; } } diff --git a/modules/extra/webcpanel/template_fileserver.cpp b/modules/extra/webcpanel/template_fileserver.cpp index b1881b811..cf7094e39 100644 --- a/modules/extra/webcpanel/template_fileserver.cpp +++ b/modules/extra/webcpanel/template_fileserver.cpp @@ -126,7 +126,8 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n if (content.find("IF ") == 0) { - std::vector<Anope::string> tokens = BuildStringVector(content); + std::vector<Anope::string> tokens; + spacesepstream(content).GetTokens(tokens); if (tokens.size() == 4 && tokens[1] == "EQ") { @@ -163,13 +164,17 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n } else if (content.find("FOR ") == 0) { - std::vector<Anope::string> tokens = BuildStringVector(content); + std::vector<Anope::string> tokens; + spacesepstream(content).GetTokens(tokens); + if (tokens.size() != 4 || tokens[2] != "IN") Log() << "Invalid FOR in web template " << this->file_name; else { - std::vector<Anope::string> temp_variables = BuildStringVector(tokens[1], ','), - real_variables = BuildStringVector(tokens[3], ','); + std::vector<Anope::string> temp_variables, real_variables; + commasepstream(tokens[1]).GetTokens(temp_variables); + commasepstream(tokens[3]).GetTokens(real_variables); + if (temp_variables.size() != real_variables.size()) Log() << "Invalid FOR in web template " << this->file_name << " variable mismatch"; else @@ -200,7 +205,9 @@ void TemplateFileServer::Serve(HTTPProvider *server, const Anope::string &page_n } else if (content.find("INCLUDE ") == 0) { - std::vector<Anope::string> tokens = BuildStringVector(content); + std::vector<Anope::string> tokens; + spacesepstream(content).GetTokens(tokens); + if (tokens.size() != 2) Log() << "Invalid INCLUDE in web template " << this->file_name; else diff --git a/modules/extra/webcpanel/webcpanel.cpp b/modules/extra/webcpanel/webcpanel.cpp index 77cf606aa..164c4b903 100644 --- a/modules/extra/webcpanel/webcpanel.cpp +++ b/modules/extra/webcpanel/webcpanel.cpp @@ -52,11 +52,11 @@ class ModuleWebCPanel : public Module ConfigReader reader; provider_name = reader.ReadValue("webcpanel", "server", "httpd/main", 0); template_name = reader.ReadValue("webcpanel", "template", "template", 0); - template_base = db_dir + "/modules/webcpanel/templates/" + template_name; + template_base = Anope::DataDir + "/modules/webcpanel/templates/" + template_name; page_title = reader.ReadValue("webcpanel", "title", "Anope IRC Services", 0); use_ssl = reader.ReadFlag("webcpanel", "ssl", "no", 0); // This is dumb, is there a better way to do this? - service_reference<HTTPProvider> provider("HTTPProvider", provider_name); + ServiceReference<HTTPProvider> provider("HTTPProvider", provider_name); if (!provider) throw ModuleException("Unable to find HTTPD provider. Is m_httpd loaded?"); @@ -80,7 +80,7 @@ class ModuleWebCPanel : public Module s.subsections.push_back(ss); provider->RegisterPage(&this->nickserv_info); - if (ircdproto && ircdproto->CanCertFP) + if (IRCD && IRCD->CanCertFP) { ss.name = "SSL Certificates"; ss.url = "/nickserv/cert"; @@ -160,7 +160,7 @@ class ModuleWebCPanel : public Module ~ModuleWebCPanel() { - service_reference<HTTPProvider> provider("HTTPProvider", provider_name); + ServiceReference<HTTPProvider> provider("HTTPProvider", provider_name); if (provider) { provider->UnregisterPage(&this->style_css); @@ -191,14 +191,14 @@ namespace WebPanel { void RunCommand(const Anope::string &user, NickCore *nc, const Anope::string &service, const Anope::string &c, const std::vector<Anope::string> ¶ms, TemplateFileServer::Replacements &r) { - service_reference<Command> cmd("Command", c); + ServiceReference<Command> cmd("Command", c); if (!cmd) { r["MESSAGES"] = "Unable to find command " + c; return; } - BotInfo *bi = findbot(service); + BotInfo *bi = BotInfo::Find(service); if (!bi) { if (BotListByNick->empty()) diff --git a/modules/extra/webcpanel/webcpanel.h b/modules/extra/webcpanel/webcpanel.h index 99cb2ec3a..27b8ce67a 100644 --- a/modules/extra/webcpanel/webcpanel.h +++ b/modules/extra/webcpanel/webcpanel.h @@ -46,7 +46,7 @@ class Panel : public Section, public Service if (acc.empty() || id.empty()) return NULL; - NickAlias *na = findnick(acc); + NickAlias *na = NickAlias::Find(acc); if (na == NULL) return NULL; @@ -83,7 +83,7 @@ class WebPanelProtectedPage : public WebPanelPage bool OnRequest(HTTPProvider *provider, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply) anope_override anope_final { - service_reference<Panel> panel("Panel", "webcpanel"); + ServiceReference<Panel> panel("Panel", "webcpanel"); NickAlias *na; if (!panel || !(na = panel->GetNickFromSession(client, message))) diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index e39226dd8..839876d90 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -49,7 +49,7 @@ class BahamutIRCdProto : public IRCDProto void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override { - if (Capab.count("TSMODE") > 0) + if (Servers::Capab.count("TSMODE") > 0) { if (source) UplinkSocket::Message(source) << "MODE " << dest->name << " " << dest->creation_time << " " << buf; @@ -93,13 +93,13 @@ class BahamutIRCdProto : public IRCDProto /* SQLINE */ void SendSQLine(User *, const XLine *x) anope_override { - UplinkSocket::Message() << "SQLINE " << x->Mask << " :" << x->GetReason(); + UplinkSocket::Message() << "SQLINE " << x->mask << " :" << x->GetReason(); } /* UNSLINE */ void SendSGLineDel(const XLine *x) anope_override { - UplinkSocket::Message() << "UNSGLINE 0 :" << x->Mask; + UplinkSocket::Message() << "UNSGLINE 0 :" << x->mask; } /* UNSZLINE */ @@ -115,13 +115,13 @@ class BahamutIRCdProto : public IRCDProto void SendSZLine(User *, const XLine *x) anope_override { // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) + time_t timeleft = x->expires - Anope::CurTime; + if (timeleft > 172800 || !x->expires) timeleft = 172800; /* this will likely fail so its only here for legacy */ UplinkSocket::Message() << "SZLINE " << x->GetHost() << " :" << x->GetReason(); /* this is how we are supposed to deal with it */ - UplinkSocket::Message() << "AKILL " << x->GetHost() << " * " << timeleft << " " << x->By << " " << Anope::CurTime << " :" << x->GetReason(); + UplinkSocket::Message() << "AKILL " << x->GetHost() << " * " << timeleft << " " << x->by << " " << Anope::CurTime << " :" << x->GetReason(); } /* SVSNOOP */ @@ -133,7 +133,7 @@ class BahamutIRCdProto : public IRCDProto /* SGLINE */ void SendSGLine(User *, const XLine *x) anope_override { - UplinkSocket::Message() << "SGLINE " << x->Mask.length() << " :" << x->Mask << ":" << x->GetReason(); + UplinkSocket::Message() << "SGLINE " << x->mask.length() << " :" << x->mask << ":" << x->GetReason(); } /* RAKILL */ @@ -148,7 +148,7 @@ class BahamutIRCdProto : public IRCDProto if (x->GetUser() == "*") { sockaddrs(x->GetHost()); - ircdproto->SendSZLineDel(x); + IRCD->SendSZLineDel(x); return; } } @@ -166,7 +166,7 @@ class BahamutIRCdProto : public IRCDProto /* UNSQLINE */ void SendSQLineDel(const XLine *x) anope_override { - UplinkSocket::Message() << "UNSQLINE " << x->Mask; + UplinkSocket::Message() << "UNSQLINE " << x->mask; } /* JOIN - SJOIN */ @@ -182,11 +182,11 @@ class BahamutIRCdProto : public IRCDProto */ UserContainer *uc = c->FindUser(user); if (uc != NULL) - uc->Status->ClearFlags(); + uc->status->ClearFlags(); - BotInfo *setter = findbot(user->nick); + BotInfo *setter = BotInfo::Find(user->nick); for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) - if (cs.HasFlag(ModeManager::ChannelModes[i]->Name)) + if (cs.HasFlag(ModeManager::ChannelModes[i]->name)) c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); } } @@ -210,10 +210,10 @@ class BahamutIRCdProto : public IRCDProto return; /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - x = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID); + x = new XLine("*@" + u->host, old->by, old->expires, old->reason, old->id); old->manager->AddXLine(x); - Log(findbot(Config->OperServ), "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->Mask; + Log(OperServ, "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask; } /* ZLine if we can instead */ @@ -222,17 +222,17 @@ class BahamutIRCdProto : public IRCDProto if (x->GetUser() == "*") { sockaddrs(x->GetHost()); - ircdproto->SendSZLine(u, x); + IRCD->SendSZLine(u, x); return; } } catch (const SocketException &) { } // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; + time_t timeleft = x->expires - Anope::CurTime; if (timeleft > 172800) timeleft = 172800; - UplinkSocket::Message() << "AKILL " << x->GetHost() << " " << x->GetUser() << " " << timeleft << " " << x->By << " " << Anope::CurTime << " :" << x->GetReason(); + UplinkSocket::Message() << "AKILL " << x->GetHost() << " " << x->GetUser() << " " << timeleft << " " << x->by << " " << Anope::CurTime << " :" << x->GetReason(); } /* @@ -270,7 +270,7 @@ class BahamutIRCdProto : public IRCDProto void SendConnect() anope_override { - UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " :TS"; + UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink]->password << " :TS"; UplinkSocket::Message() << "CAPAB SSJOIN NOQUIT BURST UNCONNECT NICKIP TSMODE TS3"; SendServer(Me); /* @@ -295,20 +295,18 @@ class BahamutIRCdProto : public IRCDProto void SendLogin(User *u) anope_override { - const BotInfo *ns = findbot(Config->NickServ); - ircdproto->SendMode(ns, u, "+d %d", u->timestamp); + IRCD->SendMode(NickServ, u, "+d %d", u->timestamp); } void SendLogout(User *u) anope_override { - const BotInfo *ns = findbot(Config->NickServ); - ircdproto->SendMode(ns, u, "+d 1"); + IRCD->SendMode(NickServ, u, "+d 1"); } }; struct IRCDMessageBurst : IRCDMessage { - IRCDMessageBurst() : IRCDMessage("BURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageBurst(Module *creator) : IRCDMessage(creator, "BURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -327,14 +325,15 @@ struct IRCDMessageBurst : IRCDMessage struct IRCDMessageMode : IRCDMessage { - IRCDMessageMode(const Anope::string &n) : IRCDMessage(n, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageMode(Module *creator, const Anope::string &sname) : IRCDMessage(creator, sname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (params.size() > 2 && ircdproto->IsChannelValid(params[0])) + if (params.size() > 2 && IRCD->IsChannelValid(params[0])) { - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); time_t ts = 0; + try { ts = convertTo<time_t>(params[1]); @@ -346,7 +345,7 @@ struct IRCDMessageMode : IRCDMessage } else { - User *u = finduser(params[0]); + User *u = User::Find(params[0]); if (u) u->SetModesInternal("%s", params[1].c_str()); } @@ -375,7 +374,7 @@ struct IRCDMessageMode : IRCDMessage */ struct IRCDMessageNick : IRCDMessage { - IRCDMessageNick() : IRCDMessage("NICK", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -389,18 +388,18 @@ struct IRCDMessageNick : IRCDMessage } User *user = new User(params[0], params[4], params[5], "", params[8], s, params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[3]); - if (user && nickserv) + if (user && NickServService) { const NickAlias *na; - if (user->timestamp == convertTo<time_t>(params[7]) && (na = findnick(user->nick))) + if (user->timestamp == convertTo<time_t>(params[7]) && (na = NickAlias::Find(user->nick))) { NickCore *nc = na->nc; user->Login(nc); if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false) - user->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); + user->SetMode(NickServ, UMODE_REGISTERED); } else - nickserv->Validate(user); + NickServService->Validate(user); } } else @@ -412,7 +411,7 @@ struct IRCDMessageNick : IRCDMessage struct IRCDMessageServer : IRCDMessage { - IRCDMessageServer() : IRCDMessage("SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -424,77 +423,39 @@ struct IRCDMessageServer : IRCDMessage struct IRCDMessageSJoin : IRCDMessage { - IRCDMessageSJoin() : IRCDMessage("SJOIN", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageSJoin(Module *creator) : IRCDMessage(creator, "SJOIN", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Channel *c = findchan(params[1]); - time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0; - bool keep_their_modes = true; - - if (!c) - { - c = new Channel(params[1], ts); - c->SetFlag(CH_SYNCING); - } - /* Our creation time is newer than what the server gave us */ - else if (c->creation_time > ts) - { - c->creation_time = ts; - c->Reset(); - } - /* Their TS is newer than ours, our modes > theirs, unset their modes if need be */ - else if (ts > c->creation_time) - keep_their_modes = false; - - /* If we need to keep their modes, and this SJOIN string contains modes */ - if (keep_their_modes && params.size() >= 4) - { - /* Set the modes internally */ - Anope::string modes; + Anope::string modes; + if (params.size() >= 4) for (unsigned i = 2; i < params.size(); ++i) modes += " " + params[i]; - if (!modes.empty()) - modes.erase(modes.begin()); - c->SetModesInternal(source, modes); - } + if (!modes.empty()) + modes.erase(modes.begin()); + + std::list<Message::Join::SJoinUser> users; /* For some reason, bahamut will send a SJOIN from the user joining a channel * if the channel already existed */ - if (!c->HasFlag(CH_SYNCING) && params.size() == 2) + if (source.GetUser()) { - User *u = source.GetUser(); - - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); - - /* Add the user to the channel */ - c->JoinUser(u); - - /* Now set whatever modes this user is allowed to have on the channel */ - chan_set_correct_modes(u, c, 1, true); - - /* Check to see if modules want the user to join, if they do - * check to see if they are allowed to join (CheckKick will kick/ban them) - * Don't trigger OnJoinChannel event then as the user will be destroyed - */ - if (MOD_RESULT == EVENT_STOP && (!c->ci || !c->ci->CheckKick(u))) - { - FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); - } + Message::Join::SJoinUser sju; + sju.second = source.GetUser(); + users.push_back(sju); } else { spacesepstream sep(params[params.size() - 1]); Anope::string buf; + while (sep.GetToken(buf)) { - std::list<ChannelMode *> Status; - char ch; + Message::Join::SJoinUser sju; /* Get prefixes from the nick */ - while ((ch = ModeManager::GetStatusChar(buf[0]))) + for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) { buf.erase(buf.begin()); ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); @@ -504,50 +465,22 @@ struct IRCDMessageSJoin : IRCDMessage continue; } - if (keep_their_modes) - Status.push_back(cm); + sju.first.SetFlag(cm->name); } - User *u = finduser(buf); - if (!u) + sju.second = User::Find(buf); + if (!sju.second) { - Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; + Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << params[1]; continue; } - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); - - /* Add the user to the channel */ - c->JoinUser(u); - - /* Update their status internally on the channel - * This will enforce secureops etc on the user - */ - for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it) - c->SetModeInternal(source, *it, buf); - - /* Now set whatever modes this user is allowed to have on the channel */ - chan_set_correct_modes(u, c, 1, true); - - /* Check to see if modules want the user to join, if they do - * check to see if they are allowed to join (CheckKick will kick/ban them) - * Don't trigger OnJoinChannel event then as the user will be destroyed - */ - if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u)) - continue; - - FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); + users.push_back(sju); } } - /* Channel is done syncing */ - if (c->HasFlag(CH_SYNCING)) - { - /* Unset the syncing flag */ - c->UnsetFlag(CH_SYNCING); - c->Sync(); - } + time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : Anope::CurTime; + Message::Join::SJoin(source, params[1], ts, modes, users); return true; } @@ -555,11 +488,11 @@ struct IRCDMessageSJoin : IRCDMessage struct IRCDMessageTopic : IRCDMessage { - IRCDMessageTopic() : IRCDMessage("TOPIC", 4) { } + IRCDMessageTopic(Module *creator) : IRCDMessage(creator, "TOPIC", 4) { } bool Run(MessageSource &, const std::vector<Anope::string> ¶ms) anope_override { - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); if (c) c->ChangeTopicInternal(params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime); return true; @@ -571,23 +504,22 @@ class ProtoBahamut : public Module BahamutIRCdProto ircd_proto; /* Core message handlers */ - CoreIRCDMessageAway core_message_away; - CoreIRCDMessageCapab core_message_capab; - CoreIRCDMessageError core_message_error; - CoreIRCDMessageJoin core_message_join; - CoreIRCDMessageKick core_message_kick; - CoreIRCDMessageKill core_message_kill; - CoreIRCDMessageMOTD core_message_motd; - CoreIRCDMessagePart core_message_part; - CoreIRCDMessagePing core_message_ping; - CoreIRCDMessagePrivmsg core_message_privmsg; - CoreIRCDMessageQuit core_message_quit; - CoreIRCDMessageSQuit core_message_squit; - CoreIRCDMessageStats core_message_stats; - CoreIRCDMessageTime core_message_time; - CoreIRCDMessageTopic core_message_topic; - CoreIRCDMessageVersion core_message_version; - CoreIRCDMessageWhois core_message_whois; + Message::Away message_away; + Message::Capab message_capab; + Message::Error message_error; + Message::Join message_join; + Message::Kick message_kick; + Message::Kill message_kill; + Message::MOTD message_motd; + Message::Part message_part; + Message::Ping message_ping; + Message::Privmsg message_privmsg; + Message::Quit message_quit; + Message::SQuit message_squit; + Message::Stats message_stats; + Message::Time message_time; + Message::Version message_version; + Message::Whois message_whois; /* Our message handlers */ IRCDMessageBurst message_burst; @@ -636,7 +568,13 @@ class ProtoBahamut : public Module public: ProtoBahamut(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL), - message_mode("MODE"), message_svsmode("SVSMODE") + message_away(this), message_capab(this), message_error(this), message_join(this), + message_kick(this), message_kill(this), message_motd(this), message_part(this), + message_ping(this), message_privmsg(this), message_quit(this), message_squit(this), + message_stats(this), message_time(this), message_version(this), message_whois(this), + + message_burst(this), message_mode(this, "MODE"), message_svsmode(this, "SVSMODE"), + message_nick(this), message_server(this), message_sjoin(this), message_topic(this) { this->SetAuthor("Anope"); @@ -645,10 +583,15 @@ class ProtoBahamut : public Module ModuleManager::Attach(I_OnUserNickChange, this); } + IRCDProto *GetIRCDProto() anope_override + { + return &ircd_proto; + } + void OnUserNickChange(User *u, const Anope::string &) anope_override { u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED)); - ircdproto->SendLogout(u); + IRCD->SendLogout(u); } }; diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index d3d67d84e..1161db3fa 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -37,44 +37,40 @@ class HybridProto : public IRCDProto UplinkSocket::Message(bi) << "PRIVMSG $$" << dest->GetName() << " :" << msg; } - void SendSQLine(User *, const XLine *x) anope_override + void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override { - const BotInfo *bi = findbot(Config->OperServ); + UplinkSocket::Message(source) << "OPERWALL :" << buf; + } - UplinkSocket::Message(bi) << "RESV * " << x->Mask << " :" << x->GetReason(); + void SendSQLine(User *, const XLine *x) anope_override + { + UplinkSocket::Message(OperServ) << "RESV * " << x->mask << " :" << x->GetReason(); } void SendSGLineDel(const XLine *x) anope_override { - const BotInfo *bi = findbot(Config->OperServ); - - UplinkSocket::Message(bi) << "UNXLINE * " << x->Mask; + UplinkSocket::Message(OperServ) << "UNXLINE * " << x->mask; } void SendSGLine(User *, const XLine *x) anope_override { - const BotInfo *bi = findbot(Config->OperServ); - - UplinkSocket::Message(bi) << "XLINE * " << x->Mask << " 0 :" << x->GetReason(); + UplinkSocket::Message(OperServ) << "XLINE * " << x->mask << " 0 :" << x->GetReason(); } void SendSZLineDel(const XLine *x) anope_override { - const BotInfo *bi = findbot(Config->OperServ); - - UplinkSocket::Message(bi) << "UNDLINE * " << x->GetHost(); + UplinkSocket::Message(OperServ) << "UNDLINE * " << x->GetHost(); } void SendSZLine(User *, const XLine *x) anope_override { - const BotInfo *bi = findbot(Config->OperServ); /* Calculate the time left before this would expire, capping it at 2 days */ - time_t timeleft = x->Expires - Anope::CurTime; + time_t timeleft = x->expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) + if (timeleft > 172800 || !x->expires) timeleft = 172800; - UplinkSocket::Message(bi) << "DLINE * " << timeleft << " " << x->GetHost() << " :" << x->GetReason(); + UplinkSocket::Message(OperServ) << "DLINE * " << timeleft << " " << x->GetHost() << " :" << x->GetReason(); } void SendAkillDel(const XLine *x) anope_override @@ -82,16 +78,12 @@ class HybridProto : public IRCDProto if (x->IsRegex() || x->HasNickOrReal()) return; - const BotInfo *bi = findbot(Config->OperServ); - - UplinkSocket::Message(bi) << "UNKLINE * " << x->GetUser() << " " << x->GetHost(); + UplinkSocket::Message(OperServ) << "UNKLINE * " << x->GetUser() << " " << x->GetHost(); } void SendSQLineDel(const XLine *x) anope_override { - const BotInfo *bi = findbot(Config->OperServ); - - UplinkSocket::Message(bi) << "UNRESV * " << x->Mask; + UplinkSocket::Message(OperServ) << "UNRESV * " << x->mask; } void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override @@ -111,14 +103,12 @@ class HybridProto : public IRCDProto UserContainer *uc = c->FindUser(user); if (uc != NULL) - *uc->Status = *status; + *uc->status = *status; } } void SendAkill(User *u, XLine *x) anope_override { - const BotInfo *bi = findbot(Config->OperServ); - if (x->IsRegex() || x->HasNickOrReal()) { if (!u) @@ -140,32 +130,35 @@ class HybridProto : public IRCDProto return; /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - XLine *xline = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID); + XLine *xline = new XLine("*@" + u->host, old->by, old->expires, old->reason, old->id); old->manager->AddXLine(xline); x = xline; - Log(bi, "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" - << u->realname << " matches " << old->Mask; + Log(OperServ, "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" + << u->realname << " matches " << old->mask; } /* Calculate the time left before this would expire, capping it at 2 days */ - time_t timeleft = x->Expires - Anope::CurTime; + time_t timeleft = x->expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) + if (timeleft > 172800 || !x->expires) timeleft = 172800; - UplinkSocket::Message(bi) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason(); + UplinkSocket::Message(OperServ) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason(); } void SendServer(const Server *server) anope_override { - UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription(); + if (server == Me) + UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription(); + else + UplinkSocket::Message(Me) << "SID " << server->GetName() << " " << server->GetHops() << " " << server->GetSID() << " :" << server->GetDescription(); } void SendConnect() anope_override { - UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " TS 6 :" << Me->GetSID(); + UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink]->password << " TS 6 :" << Me->GetSID(); /* * As of October 13, 2012, ircd-hybrid-8 does support the following capabilities @@ -213,16 +206,12 @@ class HybridProto : public IRCDProto void SendLogin(User *u) anope_override { - const BotInfo *ns = findbot(Config->NickServ); - - ircdproto->SendMode(ns, u, "+d %s", u->Account()->display.c_str()); + IRCD->SendMode(NickServ, u, "+d %s", u->Account()->display.c_str()); } void SendLogout(User *u) anope_override { - const BotInfo *ns = findbot(Config->NickServ); - - ircdproto->SendMode(ns, u, "+d 0"); + IRCD->SendMode(NickServ, u, "+d 0"); } void SendChannel(Channel *c) anope_override @@ -256,13 +245,13 @@ class HybridProto : public IRCDProto struct IRCDMessageBMask : IRCDMessage { - IRCDMessageBMask() : IRCDMessage("BMASK", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageBMask(Module *creator) : IRCDMessage(creator, "BMASK", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } /* 0 1 2 3 */ /* :0MC BMASK 1350157102 #channel b :*!*@*.test.com */ bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Channel *c = findchan(params[1]); + Channel *c = Channel::Find(params[1]); if (c) { @@ -270,20 +259,16 @@ struct IRCDMessageBMask : IRCDMessage *except = ModeManager::FindChannelModeByName(CMODE_EXCEPT), *invex = ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE); - Anope::string bans = params[3]; - - int count = myNumToken(bans, ' '), i; - - for (i = 0; i < count; ++i) + spacesepstream bans(params[3]); + Anope::string token; + while (bans.GetToken(token)) { - Anope::string b = myStrGetToken(bans, ' ', i); - if (ban && params[2].equals_cs("b")) - c->SetModeInternal(source, ban, b); + c->SetModeInternal(source, ban, token); else if (except && params[2].equals_cs("e")) - c->SetModeInternal(source, except, b); + c->SetModeInternal(source, except, token); else if (invex && params[2].equals_cs("I")) - c->SetModeInternal(source, invex, b); + c->SetModeInternal(source, invex, token); } } @@ -291,57 +276,36 @@ struct IRCDMessageBMask : IRCDMessage } }; -struct IRCDMessageJoin : CoreIRCDMessageJoin +struct IRCDMessageEOB : IRCDMessage { - IRCDMessageJoin() : CoreIRCDMessageJoin("JOIN") { } + IRCDMessageEOB(Module *craetor) : IRCDMessage(craetor, "EOB", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (params.size() < 2) - return true; - - std::vector<Anope::string> p = params; - p.erase(p.begin()); - - return CoreIRCDMessageJoin::Run(source, p); + source.GetServer()->Sync(true); + return true; } }; -struct IRCDMessageMode : IRCDMessage +struct IRCDMessageJoin : Message::Join { - IRCDMessageMode(const Anope::string &n) : IRCDMessage(n, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageJoin(Module *creator) : Message::Join(creator, "JOIN") { } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (params.size() > 2 && ircdproto->IsChannelValid(params[0])) - { - Channel *c = findchan(params[0]); - time_t ts = 0; - - try - { - ts = convertTo<time_t>(params[1]); - } - catch (const ConvertException &) { } - - if (c) - c->SetModesInternal(source, params[2], ts); - } - else - { - User *u = finduser(params[0]); + if (params.size() < 2) + return true; - if (u) - u->SetModesInternal("%s", params[1].c_str()); - } + std::vector<Anope::string> p = params; + p.erase(p.begin()); - return true; + return Message::Join::Run(source, p); } }; struct IRCDMessageNick : IRCDMessage { - IRCDMessageNick() : IRCDMessage("NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } /* 0 1 */ /* :0MCAAAAAB NICK newnick 1350157102 */ @@ -354,7 +318,7 @@ struct IRCDMessageNick : IRCDMessage struct IRCDMessagePass : IRCDMessage { - IRCDMessagePass() : IRCDMessage("PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessagePass(Module *creator) : IRCDMessage(creator, "PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } /* 0 1 2 3 */ /* PASS password TS 6 0MC */ @@ -367,7 +331,7 @@ struct IRCDMessagePass : IRCDMessage struct IRCDMessagePong : IRCDMessage { - IRCDMessagePong() : IRCDMessage("PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessagePong(Module *creator) : IRCDMessage(creator, "PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -378,7 +342,7 @@ struct IRCDMessagePong : IRCDMessage struct IRCDMessageServer : IRCDMessage { - IRCDMessageServer() : IRCDMessage("SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } /* 0 1 2 */ /* SERVER hades.arpa 1 :ircd-hybrid test server */ @@ -390,14 +354,14 @@ struct IRCDMessageServer : IRCDMessage new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); - ircdproto->SendPing(Config->ServerName, params[0]); + IRCD->SendPing(Config->ServerName, params[0]); return true; } }; struct IRCDMessageSID : IRCDMessage { - IRCDMessageSID() : IRCDMessage("SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageSID(Module *creator) : IRCDMessage(creator, "SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } /* 0 1 2 3 */ /* :0MC SID hades.arpa 2 4XY :ircd-hybrid test server */ @@ -406,64 +370,37 @@ struct IRCDMessageSID : IRCDMessage unsigned int hops = params[1].is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0; new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[3], params[2]); - ircdproto->SendPing(Config->ServerName, params[0]); + IRCD->SendPing(Config->ServerName, params[0]); return true; } }; -struct IRCDMessageSjoin : IRCDMessage +struct IRCDMessageSJoin : IRCDMessage { - IRCDMessageSjoin() : IRCDMessage("SJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageSJoin(Module *creator) : IRCDMessage(creator, "SJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Channel *c = findchan(params[1]); - time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0; - bool keep_their_modes = true; - - if (!c) - { - c = new Channel(params[1], ts); - c->SetFlag(CH_SYNCING); - } - /* Our creation time is newer than what the server gave us */ - else if (c->creation_time > ts) - { - c->creation_time = ts; - c->Reset(); - } - /* Their TS is newer than ours, our modes > theirs, unset their modes if need be */ - else if (ts > c->creation_time) - keep_their_modes = false; - - /* If we need to keep their modes, and this SJOIN string contains modes */ - if (keep_their_modes && params.size() >= 3) - { - Anope::string modes; - + Anope::string modes; + if (params.size() >= 3) for (unsigned i = 2; i < params.size() - 1; ++i) modes += " " + params[i]; + if (!modes.empty()) + modes.erase(modes.begin()); - if (!modes.empty()) - modes.erase(modes.begin()); - - /* Set the modes internally */ - c->SetModesInternal(source, modes); - } + std::list<Message::Join::SJoinUser> users; spacesepstream sep(params[params.size() - 1]); Anope::string buf; while (sep.GetToken(buf)) { - std::list<ChannelMode *> Status; - char ch; + Message::Join::SJoinUser sju; /* Get prefixes from the nick */ - while ((ch = ModeManager::GetStatusChar(buf[0]))) + for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) { buf.erase(buf.begin()); - ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); if (!cm) @@ -472,66 +409,60 @@ struct IRCDMessageSjoin : IRCDMessage continue; } - if (keep_their_modes) - Status.push_back(cm); + sju.first.SetFlag(cm->name); } - User *u = finduser(buf); - - if (!u) + sju.second = User::Find(buf); + if (!sju.second) { - Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; + Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << params[1]; continue; } - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); - - /* Add the user to the channel */ - c->JoinUser(u); - - /* - * Update their status internally on the channel - * This will enforce secureops etc on the user - */ - for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it) - c->SetModeInternal(source, *it, buf); + users.push_back(sju); + } - /* Now set whatever modes this user is allowed to have on the channel */ - chan_set_correct_modes(u, c, 1, true); + time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : Anope::CurTime; + Message::Join::SJoin(source, params[1], ts, modes, users); - /* - * Check to see if modules want the user to join, if they do - * check to see if they are allowed to join (CheckKick will kick/ban them) - * Don't trigger OnJoinChannel event then as the user will be destroyed - */ - if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u)) - continue; + return true; + } +}; - FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); - } +struct IRCDMessageSVSMode : IRCDMessage +{ + IRCDMessageSVSMode(Module *creator) : IRCDMessage(creator, "SVSMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + /* + * parv[0] = nickname + * parv[1] = TS + * parv[2] = mode + * parv[3] = optional argument (services id) + */ + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + User *u = User::Find(params[0]); + if (!u) + return true; - /* Channel is done syncing */ - if (c->HasFlag(CH_SYNCING)) - { - /* Unset the syncing flag */ - c->UnsetFlag(CH_SYNCING); - c->Sync(); - } + if (!params[1].is_pos_number_only() || convertTo<time_t>(params[1]) != u->timestamp) + return true; + u->SetModesInternal("%s", params[2].c_str()); return true; } }; struct IRCDMessageTBurst : IRCDMessage { - IRCDMessageTBurst() : IRCDMessage("TBURST", 5) { } + IRCDMessageTBurst(Module *creator) : IRCDMessage(creator, "TBURST", 5) { } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Anope::string setter = myStrGetToken(params[3], '!', 0); + Anope::string setter; + sepstream(params[3], '!').GetToken(setter, 0); time_t topic_time = Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime; - Channel *c = findchan(params[1]); + Channel *c = Channel::Find(params[1]); if (c) c->ChangeTopicInternal(setter, params[4], topic_time); @@ -542,7 +473,7 @@ struct IRCDMessageTBurst : IRCDMessage struct IRCDMessageTMode : IRCDMessage { - IRCDMessageTMode() : IRCDMessage("TMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageTMode(Module *creator) : IRCDMessage(creator, "TMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -554,7 +485,7 @@ struct IRCDMessageTMode : IRCDMessage } catch (const ConvertException &) { } - Channel *c = findchan(params[1]); + Channel *c = Channel::Find(params[1]); Anope::string modes = params[2]; for (unsigned i = 3; i < params.size(); ++i) @@ -569,7 +500,7 @@ struct IRCDMessageTMode : IRCDMessage struct IRCDMessageUID : IRCDMessage { - IRCDMessageUID() : IRCDMessage("UID", 10) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 10) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } /* 0 1 2 3 4 5 6 7 8 9 */ /* :0MC UID Steve 1 1350157102 +oi ~steve resolved.host 10.0.0.1 0MCAAAAAB 1350157108 :Mining all the time */ @@ -586,22 +517,22 @@ struct IRCDMessageUID : IRCDMessage params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[3], params[7]); - if (user && nickserv) + if (user && NickServService) { const NickAlias *na = NULL; if (params[8] != "0") - na = findnick(params[8]); + na = NickAlias::Find(params[8]); if (na) { user->Login(na->nc); if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false) - user->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); + user->SetMode(NickServ, UMODE_REGISTERED); } else - nickserv->Validate(user); + NickServService->Validate(user); } return true; @@ -613,33 +544,35 @@ class ProtoHybrid : public Module HybridProto ircd_proto; /* Core message handlers */ - CoreIRCDMessageAway core_message_away; - CoreIRCDMessageCapab core_message_capab; - CoreIRCDMessageError core_message_error; - CoreIRCDMessageKick core_message_kick; - CoreIRCDMessageKill core_message_kill; - CoreIRCDMessageMOTD core_message_motd; - CoreIRCDMessagePart core_message_part; - CoreIRCDMessagePing core_message_ping; - CoreIRCDMessagePrivmsg core_message_privmsg; - CoreIRCDMessageQuit core_message_quit; - CoreIRCDMessageSQuit core_message_squit; - CoreIRCDMessageStats core_message_stats; - CoreIRCDMessageTime core_message_time; - CoreIRCDMessageTopic core_message_topic; - CoreIRCDMessageVersion core_message_version; - CoreIRCDMessageWhois core_message_whois; + Message::Away message_away; + Message::Capab message_capab; + Message::Error message_error; + Message::Kick message_kick; + Message::Kill message_kill; + Message::Mode message_mode; + Message::MOTD message_motd; + Message::Part message_part; + Message::Ping message_ping; + Message::Privmsg message_privmsg; + Message::Quit message_quit; + Message::SQuit message_squit; + Message::Stats message_stats; + Message::Time message_time; + Message::Topic message_topic; + Message::Version message_version; + Message::Whois message_whois; /* Our message handlers */ IRCDMessageBMask message_bmask; + IRCDMessageEOB message_eob; IRCDMessageJoin message_join; - IRCDMessageMode message_mode, message_svsmode; IRCDMessageNick message_nick; IRCDMessagePass message_pass; IRCDMessagePong message_pong; IRCDMessageServer message_server; IRCDMessageSID message_sid; - IRCDMessageSjoin message_sjoin; + IRCDMessageSJoin message_sjoin; + IRCDMessageSVSMode message_svsmode; IRCDMessageTBurst message_tburst; IRCDMessageTMode message_tmode; IRCDMessageUID message_uid; @@ -663,12 +596,15 @@ class ProtoHybrid : public Module /* v/h/o/a/q */ ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, 'v', '+', 0)); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, 'o', '@', 1)); + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_HALFOP, 'h', '%', 1)); + ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, 'o', '@', 2)); + + /* l/k */ + ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, 'l')); + ModeManager::AddChannelMode(new ChannelModeKey('k')); /* Add channel modes */ ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, 'i')); - ModeManager::AddChannelMode(new ChannelModeKey('k')); - ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, 'l')); ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, 'm')); ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, 'n')); ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, 'p')); @@ -681,8 +617,15 @@ class ProtoHybrid : public Module } public: - ProtoHybrid(const Anope::string &modname, const Anope::string &creator) : - Module(modname, creator, PROTOCOL), message_mode("MODE"), message_svsmode("SVSMODE") + ProtoHybrid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL), + message_away(this), message_capab(this), message_error(this), message_kick(this), message_kill(this), + message_mode(this), message_motd(this), message_part(this), message_ping(this), message_privmsg(this), + message_quit(this), message_squit(this), message_stats(this), message_time(this), message_topic(this), + message_version(this), message_whois(this), + + message_bmask(this), message_eob(this), message_join(this), + message_nick(this), message_pass(this), message_pong(this), message_server(this), message_sid(this), + message_sjoin(this), message_svsmode(this), message_tburst(this), message_tmode(this), message_uid(this) { this->SetAuthor("Anope"); this->AddModes(); @@ -691,7 +634,7 @@ public: if (Config->Numeric.empty()) { - Anope::string numeric = ts6_sid_retrieve(); + Anope::string numeric = Servers::TS6_SID_Retrieve(); Me->SetSID(numeric); Config->Numeric = numeric; } @@ -700,10 +643,14 @@ public: it->second->GenerateUID(); } + IRCDProto *GetIRCDProto() anope_override + { + return &ircd_proto; + } + void OnUserNickChange(User *u, const Anope::string &) anope_override { u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED)); - ircdproto->SendLogout(u); } }; diff --git a/modules/protocol/inspircd-ts6.h b/modules/protocol/inspircd-ts6.h deleted file mode 100644 index 7e0fe971d..000000000 --- a/modules/protocol/inspircd-ts6.h +++ /dev/null @@ -1,817 +0,0 @@ -/* Inspircd 1.2+ generic TS6 functions - * - * (C) 2003-2012 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. - */ - -class ChannelModeFlood : public ChannelModeParam -{ - public: - ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam(CMODE_FLOOD, modeChar, minusNoArg) { } - - bool IsValid(const Anope::string &value) const anope_override - { - try - { - Anope::string rest; - if (!value.empty() && value[0] != ':' && convertTo<int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<int>(rest.substr(1), rest, false) > 0 && rest.empty()) - return true; - } - catch (const ConvertException &) { } - - return false; - } -}; - -class InspIRCdTS6Proto : public IRCDProto -{ - private: - void SendChgIdentInternal(const Anope::string &nick, const Anope::string &vIdent) - { - if (!has_chgidentmod) - Log() << "CHGIDENT not loaded!"; - else - UplinkSocket::Message(findbot(Config->HostServ)) << "CHGIDENT " << nick << " " << vIdent; - } - - void SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost) - { - if (!has_chghostmod) - Log() << "CHGHOST not loaded!"; - else - UplinkSocket::Message(Me) << "CHGHOST " << nick << " " << vhost; - } - - void SendAddLine(const Anope::string &type, const Anope::string &mask, time_t duration, const Anope::string &addedby, const Anope::string &reason) - { - UplinkSocket::Message(Me) << "ADDLINE " << type << " " << mask << " " << addedby << " " << Anope::CurTime << " " << duration << " :" << reason; - } - - void SendDelLine(const Anope::string &type, const Anope::string &mask) - { - UplinkSocket::Message(Me) << "DELLINE " << type << " " << mask; - } - - protected: - InspIRCdTS6Proto(const Anope::string &name) : IRCDProto(name) - { - DefaultPseudoclientModes = "+I"; - CanSVSNick = true; - CanSetVHost = true; - CanSetVIdent = true; - CanSQLine = true; - CanSZLine = true; - CanSVSHold = true; - CanCertFP = true; - RequiresID = true; - MaxModes = 20; - } - - void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override - { - UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg; - } - - void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override - { - UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg; - } - - void SendAkillDel(const XLine *x) anope_override - { - /* InspIRCd may support regex bans */ - if (x->IsRegex() && has_rlinemod) - { - Anope::string mask = x->Mask; - size_t h = x->Mask.find('#'); - if (h != Anope::string::npos) - mask = mask.replace(h, 1, ' '); - SendDelLine("R", mask); - return; - } - else if (x->IsRegex() || x->HasNickOrReal()) - return; - - SendDelLine("G", x->Mask); - } - - void SendTopic(BotInfo *whosets, Channel *c) anope_override - { - if (has_svstopic_topiclock) - { - UplinkSocket::Message(c->ci->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic; - } - else - { - /* If the last time a topic was set is after the TS we want for this topic we must bump this topic's timestamp to now */ - time_t ts = c->topic_ts; - if (c->topic_time > ts) - ts = Anope::CurTime; - /* But don't modify c->topic_ts, it should remain set to the real TS we want as ci->last_topic_time pulls from it */ - UplinkSocket::Message(whosets) << "FTOPIC " << c->name << " " << ts << " " << c->topic_setter << " :" << c->topic; - } - } - - void SendVhostDel(User *u) anope_override - { - if (u->HasMode(UMODE_CLOAK)) - this->SendChgHostInternal(u->nick, u->chost); - else - this->SendChgHostInternal(u->nick, u->host); - - if (has_chgidentmod && u->GetIdent() != u->GetVIdent()) - this->SendChgIdentInternal(u->nick, u->GetIdent()); - } - - void SendAkill(User *u, XLine *x) anope_override - { - // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) - timeleft = 172800; - - const BotInfo *bi = findbot(Config->OperServ); - /* InspIRCd may support regex bans, if they do we can send this and forget about it */ - if (x->IsRegex() && has_rlinemod) - { - Anope::string mask = x->Mask; - size_t h = x->Mask.find('#'); - if (h != Anope::string::npos) - mask = mask.replace(h, 1, ' '); - SendAddLine("R", mask, timeleft, x->By, x->GetReason()); - return; - } - else if (x->IsRegex() || x->HasNickOrReal()) - { - if (!u) - { - /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */ - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - if (x->manager->Check(it->second, x)) - this->SendAkill(it->second, x); - return; - } - - const XLine *old = x; - - if (old->manager->HasEntry("*@" + u->host)) - return; - - /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - x = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID); - old->manager->AddXLine(x); - - Log(bi, "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->Mask; - } - - /* ZLine if we can instead */ - try - { - if (x->GetUser() == "*") - { - sockaddrs(x->GetHost()); - ircdproto->SendSZLine(u, x); - return; - } - } - catch (const SocketException &) { } - SendAddLine("G", x->GetUser() + "@" + x->GetHost(), timeleft, x->By, x->GetReason()); - } - - void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) anope_override - { - UplinkSocket::Message() << "PUSH " << dest << " ::" << Me->GetName() << " " << numeric << " " << dest << " " << buf; - } - - void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override - { - UplinkSocket::Message(source) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf; - } - - void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override - { - UplinkSocket::Message(bi) << "MODE " << u->GetUID() << " " << buf; - } - - void SendClientIntroduction(const User *u) anope_override - { - Anope::string modes = "+" + u->GetModes(); - UplinkSocket::Message(Me) << "UID " << u->GetUID() << " " << u->timestamp << " " << u->nick << " " << u->host << " " << u->host << " " << u->GetIdent() << " 0.0.0.0 " << u->timestamp << " " << modes << " :" << u->realname; - } - - /* SERVER services-dev.chatspike.net password 0 :Description here */ - void SendServer(const Server *server) anope_override - { - UplinkSocket::Message() << "SERVER " << server->GetName() << " " << Config->Uplinks[CurrentUplink]->password << " " << server->GetHops() << " " << server->GetSID() << " :" << server->GetDescription(); - } - - /* JOIN */ - void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override - { - UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :," << user->GetUID(); - /* Note that we can send this with the FJOIN but choose not to - * because the mode stacker will handle this and probably will - * merge these modes with +nrt and other mlocked modes - */ - if (status) - { - /* First save the channel status incase uc->Status == status */ - ChannelStatus cs = *status; - /* If the user is internally on the channel with flags, kill them so that - * the stacker will allow this. - */ - UserContainer *uc = c->FindUser(user); - if (uc != NULL) - uc->Status->ClearFlags(); - - BotInfo *setter = findbot(user->nick); - for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) - if (cs.HasFlag(ModeManager::ChannelModes[i]->Name)) - c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); - } - } - - /* UNSQLINE */ - void SendSQLineDel(const XLine *x) anope_override - { - SendDelLine("Q", x->Mask); - } - - /* SQLINE */ - void SendSQLine(User *, const XLine *x) anope_override - { - // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) - timeleft = 172800; - SendAddLine("Q", x->Mask, timeleft, x->By, x->GetReason()); - } - - /* Functions that use serval cmd functions */ - - void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) anope_override - { - if (!vIdent.empty()) - this->SendChgIdentInternal(u->nick, vIdent); - if (!vhost.empty()) - this->SendChgHostInternal(u->nick, vhost); - } - - void SendConnect() anope_override - { - SendServer(Me); - UplinkSocket::Message(Me) << "BURST"; - Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); - UplinkSocket::Message(Me) << "VERSION :Anope-" << Anope::Version() << " " << Config->ServerName << " :" << ircdproto->GetProtocolName() << " - (" << (enc ? enc->name : "unknown") << ") -- " << Anope::VersionBuildString(); - } - - /* SVSHOLD - set */ - void SendSVSHold(const Anope::string &nick) anope_override - { - const BotInfo *bi = findbot(Config->NickServ); - if (bi) - UplinkSocket::Message(bi) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << " :Being held for registered user"; - } - - /* SVSHOLD - release */ - void SendSVSHoldDel(const Anope::string &nick) anope_override - { - const BotInfo *bi = findbot(Config->NickServ); - if (bi) - UplinkSocket::Message(bi) << "SVSHOLD " << nick; - } - - /* UNSZLINE */ - void SendSZLineDel(const XLine *x) anope_override - { - SendDelLine("Z", x->GetHost()); - } - - /* SZLINE */ - void SendSZLine(User *, const XLine *x) anope_override - { - // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) - timeleft = 172800; - SendAddLine("Z", x->GetHost(), timeleft, x->By, x->GetReason()); - } - - void SendSVSJoin(const BotInfo *source, const Anope::string &nick, const Anope::string &chan, const Anope::string &) anope_override - { - User *u = finduser(nick); - UplinkSocket::Message(source) << "SVSJOIN " << u->GetUID() << " " << chan; - } - - void SendSWhois(const BotInfo *, const Anope::string &who, const Anope::string &mask) anope_override - { - User *u = finduser(who); - - UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " swhois :" << mask; - } - - void SendBOB() anope_override - { - UplinkSocket::Message(Me) << "BURST " << Anope::CurTime; - } - - void SendEOB() anope_override - { - UplinkSocket::Message(Me) << "ENDBURST"; - } - - void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) - { - if (has_globopsmod) - UplinkSocket::Message(source) << "SNONOTICE g :" << buf; - else - UplinkSocket::Message(source) << "SNONOTICE A :" << buf; - } - - void SendLogin(User *u) anope_override - { - if (!u->Account() || u->Account()->HasFlag(NI_UNCONFIRMED)) - return; - - UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :" << u->Account()->display; - } - - void SendLogout(User *u) anope_override - { - UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :"; - } - - void SendChannel(Channel *c) anope_override - { - UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :"; - } - - bool IsNickValid(const Anope::string &nick) anope_override - { - /* InspIRCd, like TS6, uses UIDs on collision, so... */ - if (isdigit(nick[0])) - return false; - - return true; - } - - void SendOper(User *u) anope_override - { - } -}; - -struct IRCDMessageEndburst : IRCDMessage -{ - IRCDMessageEndburst() : IRCDMessage("ENDBURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - Server *s = source.GetServer(); - - Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName(); - - s->Sync(true); - return true; - } -}; - -struct IRCDMessageFHost : IRCDMessage -{ - IRCDMessageFHost(const Anope::string &n) : IRCDMessage(n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - source.GetUser()->SetDisplayedHost(params[0]); - return true; - } -}; - -struct IRCDMessageFJoin : IRCDMessage -{ - IRCDMessageFJoin() : IRCDMessage("FJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - Channel *c = findchan(params[0]); - time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0; - bool keep_their_modes = true; - - if (!c) - { - c = new Channel(params[0], ts); - c->SetFlag(CH_SYNCING); - } - /* Our creation time is newer than what the server gave us */ - else if (c->creation_time > ts) - { - c->creation_time = ts; - c->Reset(); - } - /* Their TS is newer than ours, our modes > theirs, unset their modes if need be */ - else if (ts > c->creation_time) - keep_their_modes = false; - - /* If we need to keep their modes, and this FJOIN string contains modes */ - if (keep_their_modes && params.size() >= 3) - { - Anope::string modes; - for (unsigned i = 2; i < params.size() - 1; ++i) - modes += " " + params[i]; - if (!modes.empty()) - modes.erase(modes.begin()); - /* Set the modes internally */ - c->SetModesInternal(source, modes); - } - - spacesepstream sep(params[params.size() - 1]); - Anope::string buf; - while (sep.GetToken(buf)) - { - std::list<ChannelMode *> Status; - - /* Loop through prefixes and find modes for them */ - while (buf[0] != ',') - { - ChannelMode *cm = ModeManager::FindChannelModeByChar(buf[0]); - if (!cm) - { - Log() << "Received unknown mode prefix " << buf[0] << " in FJOIN string"; - buf.erase(buf.begin()); - continue; - } - - buf.erase(buf.begin()); - if (keep_their_modes) - Status.push_back(cm); - } - buf.erase(buf.begin()); - - User *u = finduser(buf); - if (!u) - { - Log(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << c->name; - continue; - } - - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); - - /* Add the user to the channel */ - c->JoinUser(u); - - /* Update their status internally on the channel - * This will enforce secureops etc on the user - */ - for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it) - c->SetModeInternal(source, *it, buf); - - /* Now set whatever modes this user is allowed to have on the channel */ - chan_set_correct_modes(u, c, 1, true); - - /* Check to see if modules want the user to join, if they do - * check to see if they are allowed to join (CheckKick will kick/ban them) - * Don't trigger OnJoinChannel event then as the user will be destroyed - */ - if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u)) - continue; - - FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); - } - - /* Channel is done syncing */ - if (c->HasFlag(CH_SYNCING)) - { - /* Unset the syncing flag */ - c->UnsetFlag(CH_SYNCING); - c->Sync(); - } - - return true; - } -}; - -struct IRCDMessageFMode : IRCDMessage -{ - IRCDMessageFMode() : IRCDMessage("FMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - /* :source FMODE #test 12345678 +nto foo */ - - Anope::string modes = params[2]; - for (unsigned n = 3; n < params.size(); ++n) - modes += " " + params[n]; - - Channel *c = findchan(params[0]); - time_t ts; - - try - { - ts = convertTo<time_t>(params[1]); - } - catch (const ConvertException &) - { - ts = 0; - } - - if (c) - c->SetModesInternal(source, modes, ts); - - return true; - } -}; - -struct IRCDMessageFTopic : IRCDMessage -{ - IRCDMessageFTopic() : IRCDMessage("FTOPIC", 4) { } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - /* :source FTOPIC channel topicts setby :topic */ - - Channel *c = findchan(params[0]); - if (c) - c->ChangeTopicInternal(params[2], params[3], Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime); - - return true; - } -}; - -struct IRCDMessageIdle : IRCDMessage -{ - IRCDMessageIdle() : IRCDMessage("IDLE", 1) { } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - const BotInfo *bi = findbot(params[0]); - if (bi) - UplinkSocket::Message(bi) << "IDLE " << source.GetSource() << " " << start_time << " " << (Anope::CurTime - bi->lastmsg); - return true; - } -}; - -/* - * source = numeric of the sending server - * params[0] = uuid - * params[1] = metadata name - * params[2] = data - */ -struct IRCDMessageMetadata : IRCDMessage -{ - IRCDMessageMetadata() : IRCDMessage("METADATA", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - if (isdigit(params[0][0])) - { - if (params[1].equals_cs("accountname")) - { - User *u = finduser(params[0]); - NickCore *nc = findcore(params[2]); - if (u && nc) - { - u->Login(nc); - - const BotInfo *bi = findbot(Config->NickServ); - const NickAlias *user_na = findnick(u->nick); - if (!Config->NoNicknameOwnership && nickserv && user_na && user_na->nc == nc && user_na->nc->HasFlag(NI_UNCONFIRMED) == false) - u->SetMode(bi, UMODE_REGISTERED); - - /* Sometimes a user connects, we send them the usual "this nickname is registered" mess (if - * their server isn't syncing) and then we receive this.. so tell them about it. - */ - if (u->server->IsSynced() && bi) - u->SendMessage(bi, _("You have been logged in as \2%s\2."), nc->display.c_str()); - } - } - - /* - * possible incoming ssl_cert messages: - * Received: :409 METADATA 409AAAAAA ssl_cert :vTrSe c38070ce96e41cc144ed6590a68d45a6 <...> <...> - * Received: :409 METADATA 409AAAAAC ssl_cert :vTrSE Could not get peer certificate: error:00000000:lib(0):func(0):reason(0) - */ - else if (params[1].equals_cs("ssl_cert")) - { - User *u = finduser(params[0]); - if (!u) - return true; - std::string data = params[2].c_str(); - size_t pos1 = data.find(' ') + 1; - size_t pos2 = data.find(' ', pos1); - if ((pos2 - pos1) >= 32) // inspircd supports md5 and sha1 fingerprint hashes -> size 32 or 40 bytes. - { - u->fingerprint = data.substr(pos1, pos2 - pos1); - FOREACH_MOD(I_OnFingerprint, OnFingerprint(u)); - } - } - } - else if (params[0][0] == '#') - { - } - else if (params[0] == "*") - { - // Wed Oct 3 15:40:27 2012: S[14] O :20D METADATA * modules :-m_svstopic.so - - if (params[1].equals_cs("modules") && !params[2].empty()) - { - // only interested when it comes from our uplink - Server* server = source.GetServer(); - if (!server || server->GetUplink() != Me) - return true; - - bool plus = (params[2][0] == '+'); - if (!plus && params[2][0] != '-') - return true; - - bool required = false; - Anope::string module = params[2].substr(1); - - if (module.equals_cs("m_services_account.so")) - required = true; - else if (module.equals_cs("m_hidechans.so")) - required = true; - else if (module.equals_cs("m_chghost.so")) - has_chghostmod = plus; - else if (module.equals_cs("m_chgident.so")) - has_chgidentmod = plus; - else if (module.equals_cs("m_svshold.so")) - ircdproto->CanSVSHold = plus; - else if (module.equals_cs("m_rline.so")) - has_rlinemod = plus; - else if (module.equals_cs("m_topiclock.so")) - has_svstopic_topiclock = plus; - else - return true; - - if (required) - { - if (!plus) - Log() << "Warning: InspIRCd unloaded module " << module << ", Anope won't function correctly without it"; - } - else - { - Log() << "InspIRCd " << (plus ? "loaded" : "unloaded") << " module " << module << ", adjusted functionality"; - } - - } - } - - return true; - } -}; - -struct IRCDMessageMode : IRCDMessage -{ - IRCDMessageMode() : IRCDMessage("MODE", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - if (ircdproto->IsChannelValid(params[0])) - { - Channel *c = findchan(params[0]); - - Anope::string modes = params[1]; - for (unsigned n = 2; n < params.size(); ++n) - modes += " " + params[n]; - - if (c) - c->SetModesInternal(source, modes); - } - else - { - /* InspIRCd lets opers change another - users modes, we have to kludge this - as it slightly breaks RFC1459 - */ - User *u = source.GetUser(); - // This can happen with server-origin modes. - if (!u) - u = finduser(params[0]); - // if it's still null, drop it like fire. - // most likely situation was that server introduced a nick which we subsequently akilled - if (u) - u->SetModesInternal("%s", params[1].c_str()); - } - - return true; - } -}; - -struct IRCDMessageNick : IRCDMessage -{ - IRCDMessageNick() : IRCDMessage("NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - source.GetUser()->ChangeNick(params[0]); - return true; - } -}; - -struct IRCDMessageOperType : IRCDMessage -{ - IRCDMessageOperType() : IRCDMessage("OPERTYPE", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - /* opertype is equivalent to mode +o because servers - dont do this directly */ - User *u = source.GetUser(); - if (!u->HasMode(UMODE_OPER)) - u->SetModesInternal("+o"); - - return true; - } -}; - -struct IRCDMessageRSQuit : IRCDMessage -{ - IRCDMessageRSQuit() : IRCDMessage("RSQUIT", 1) { } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - Server *s = Server::Find(params[0]); - if (!s) - return true; - - /* On InspIRCd we must send a SQUIT when we recieve RSQUIT for a server we have juped */ - if (s->HasFlag(SERVER_JUPED)) - UplinkSocket::Message(Me) << "SQUIT " << s->GetSID() << " :" << (params.size() > 1 ? params[1].c_str() : ""); - - FOREACH_MOD(I_OnServerQuit, OnServerQuit(s)); - - s->Delete(s->GetName() + " " + s->GetUplink()->GetName()); - - return true; - } -}; - -struct IRCDMessageServer : IRCDMessage -{ - IRCDMessageServer() : IRCDMessage("SERVER", 5) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - - /* - * [Nov 04 00:08:46.308435 2009] debug: Received: SERVER irc.inspircd.com pass 0 964 :Testnet Central! - * 0: name - * 1: pass - * 2: hops - * 3: numeric - * 4: desc - */ - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - unsigned int hops = Anope::string(params[2]).is_pos_number_only() ? convertTo<unsigned>(params[2]) : 0; - new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[4], params[3]); - return true; - } -}; - -struct IRCDMessageTime : IRCDMessage -{ - IRCDMessageTime() : IRCDMessage("TIME", 2) { } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - UplinkSocket::Message(Me) << "TIME " << source.GetSource() << " " << params[1] << " " << Anope::CurTime; - return true; - } -}; - -struct IRCDMessageUID : IRCDMessage -{ - IRCDMessageUID() : IRCDMessage("UID", 8) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - - /* - * [Nov 03 22:09:58.176252 2009] debug: Received: :964 UID 964AAAAAC 1225746297 w00t2 localhost testnet.user w00t 127.0.0.1 1225746302 +iosw +ACGJKLNOQcdfgjklnoqtx :Robin Burchell <w00t@inspircd.org> - * 0: uid - * 1: ts - * 2: nick - * 3: host - * 4: dhost - * 5: ident - * 6: ip - * 7: signon - * 8+: modes and params -- IMPORTANT, some modes (e.g. +s) may have parameters. So don't assume a fixed position of realname! - * last: realname - */ - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - time_t ts = convertTo<time_t>(params[1]); - - Anope::string modes = params[8]; - for (unsigned i = 9; i < params.size() - 1; ++i) - modes += " " + params[i]; - - User *u = new User(params[2], params[5], params[3], params[4], params[6], source.GetServer(), params[params.size() - 1], ts, modes, params[0]); - if (u->server->IsSynced() && nickserv) - nickserv->Validate(u); - - return true; - } -}; - diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp index 1ac97ddcc..aaaec9fef 100644 --- a/modules/protocol/inspircd11.cpp +++ b/modules/protocol/inspircd11.cpp @@ -45,7 +45,7 @@ class InspIRCdProto : public IRCDProto { if (nick.empty() || vIdent.empty()) return; - UplinkSocket::Message(findbot(Config->OperServ)) << "CHGIDENT " << nick << " " << vIdent; + UplinkSocket::Message(OperServ) << "CHGIDENT " << nick << " " << vIdent; } else Log() << "CHGIDENT not loaded!"; @@ -57,7 +57,7 @@ class InspIRCdProto : public IRCDProto { if (nick.empty() || vhost.empty()) return; - UplinkSocket::Message(findbot(Config->OperServ)) << "CHGHOST " << nick << " " << vhost; + UplinkSocket::Message(OperServ) << "CHGHOST " << nick << " " << vhost; } else Log() << "CHGHOST not loaded!"; @@ -84,13 +84,13 @@ class InspIRCdProto : public IRCDProto if (x->GetUser() == "*") { sockaddrs(x->GetHost()); - ircdproto->SendSZLineDel(x); + IRCD->SendSZLineDel(x); return; } } catch (const SocketException &) { } - UplinkSocket::Message(findbot(Config->OperServ)) << "GLINE " << x->Mask; + UplinkSocket::Message(OperServ) << "GLINE " << x->mask; } void SendTopic(BotInfo *whosets, Channel *c) anope_override @@ -128,10 +128,10 @@ class InspIRCdProto : public IRCDProto return; /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - x = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID); + x = new XLine("*@" + u->host, old->by, old->expires, old->reason, old->id); old->manager->AddXLine(x); - Log(findbot(Config->OperServ), "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->Mask; + Log(OperServ, "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask; } /* ZLine if we can instead */ @@ -140,17 +140,17 @@ class InspIRCdProto : public IRCDProto if (x->GetUser() == "*") { sockaddrs(x->GetHost()); - ircdproto->SendSZLine(u, x); + IRCD->SendSZLine(u, x); return; } } catch (const SocketException &) { } // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) + time_t timeleft = x->expires - Anope::CurTime; + if (timeleft > 172800 || !x->expires) timeleft = 172800; - UplinkSocket::Message(Me) << "ADDLINE G " << x->Mask << " " << x->By << " " << Anope::CurTime << " " << timeleft << " :" << x->GetReason(); + UplinkSocket::Message(Me) << "ADDLINE G " << x->mask << " " << x->by << " " << Anope::CurTime << " " << timeleft << " :" << x->GetReason(); } void SendSVSKillInternal(const BotInfo *source, User *user, const Anope::string &buf) anope_override @@ -214,11 +214,11 @@ class InspIRCdProto : public IRCDProto */ UserContainer *uc = c->FindUser(user); if (uc != NULL) - uc->Status->ClearFlags(); + uc->status->ClearFlags(); - BotInfo *setter = findbot(user->nick); + BotInfo *setter = BotInfo::Find(user->nick); for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) - if (cs.HasFlag(ModeManager::ChannelModes[i]->Name)) + if (cs.HasFlag(ModeManager::ChannelModes[i]->name)) c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); } } @@ -226,17 +226,17 @@ class InspIRCdProto : public IRCDProto /* UNSQLINE */ void SendSQLineDel(const XLine *x) anope_override { - UplinkSocket::Message(findbot(Config->OperServ)) << "QLINE " << x->Mask; + UplinkSocket::Message(OperServ) << "QLINE " << x->mask; } /* SQLINE */ void SendSQLine(User *, const XLine *x) anope_override { // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) + time_t timeleft = x->expires - Anope::CurTime; + if (timeleft > 172800 || !x->expires) timeleft = 172800; - UplinkSocket::Message(Me) << "ADDLINE Q " << x->Mask << " " << x->By << " " << Anope::CurTime << " " << timeleft << " :" << x->GetReason(); + UplinkSocket::Message(Me) << "ADDLINE Q " << x->mask << " " << x->by << " " << Anope::CurTime << " " << timeleft << " :" << x->GetReason(); } /* Functions that use serval cmd functions */ @@ -251,7 +251,7 @@ class InspIRCdProto : public IRCDProto void SendConnect() anope_override { - current_pass = Config->Uplinks[CurrentUplink]->password; + current_pass = Config->Uplinks[Anope::CurrentUplink]->password; SendServer(Me); UplinkSocket::Message() << "BURST"; Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); @@ -261,29 +261,29 @@ class InspIRCdProto : public IRCDProto /* SVSHOLD - set */ void SendSVSHold(const Anope::string &nick) anope_override { - UplinkSocket::Message(findbot(Config->OperServ)) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << "s :Being held for registered user"; + UplinkSocket::Message(OperServ) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << "s :Being held for registered user"; } /* SVSHOLD - release */ void SendSVSHoldDel(const Anope::string &nick) anope_override { - UplinkSocket::Message(findbot(Config->OperServ)) << "SVSHOLD " << nick; + UplinkSocket::Message(OperServ) << "SVSHOLD " << nick; } /* UNSZLINE */ void SendSZLineDel(const XLine *x) anope_override { - UplinkSocket::Message(findbot(Config->OperServ)) << "ZLINE " << x->GetHost(); + UplinkSocket::Message(OperServ) << "ZLINE " << x->GetHost(); } /* SZLINE */ void SendSZLine(User *, const XLine *x) anope_override { // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) + time_t timeleft = x->expires - Anope::CurTime; + if (timeleft > 172800 || !x->expires) timeleft = 172800; - UplinkSocket::Message(Me) << "ADDLINE Z " << x->GetHost() << " " << x->By << " " << Anope::CurTime << " " << timeleft << " :" << x->GetReason(); + UplinkSocket::Message(Me) << "ADDLINE Z " << x->GetHost() << " " << x->by << " " << Anope::CurTime << " " << timeleft << " :" << x->GetReason(); } void SendSVSJoin(const BotInfo *source, const Anope::string &nick, const Anope::string &chan, const Anope::string &) anope_override @@ -334,11 +334,11 @@ class ChannelModeFlood : public ChannelModeParam } }; -struct IRCDMessageCapab : IRCDMessage +struct IRCDMessageCapab : Message::Capab { - IRCDMessageCapab() : IRCDMessage("CAPAB", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageCapab(Module *creator) : Message::Capab(creator, "CAPAB") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - bool Run(MessageSource &, const std::vector<Anope::string> ¶ms) anope_override + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { if (params[0].equals_cs("START")) { @@ -348,7 +348,7 @@ struct IRCDMessageCapab : IRCDMessage has_chghostmod = false; has_chgidentmod = false; has_hidechansmod = false; - ircdproto->CanSVSHold = false; + IRCD->CanSVSHold = false; } else if (params[0].equals_cs("MODULES") && params.size() > 1) { @@ -357,7 +357,7 @@ struct IRCDMessageCapab : IRCDMessage if (params[1].find("m_services.so") != Anope::string::npos) has_servicesmod = true; if (params[1].find("m_svshold.so") != Anope::string::npos) - ircdproto->CanSVSHold = true; + IRCD->CanSVSHold = true; if (params[1].find("m_chghost.so") != Anope::string::npos) has_chghostmod = true; if (params[1].find("m_chgident.so") != Anope::string::npos) @@ -531,7 +531,7 @@ struct IRCDMessageCapab : IRCDMessage else if (capab.find("MAXMODES=") != Anope::string::npos) { Anope::string maxmodes(capab.begin() + 9, capab.end()); - ircdproto->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3; + IRCD->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3; } } } @@ -540,25 +540,25 @@ struct IRCDMessageCapab : IRCDMessage if (!has_globopsmod) { UplinkSocket::Message() << "ERROR :m_globops is not loaded. This is required by Anope"; - quitmsg = "ERROR: Remote server does not have the m_globops module loaded, and this is required."; - quitting = true; + Anope::QuitReason = "ERROR: Remote server does not have the m_globops module loaded, and this is required."; + Anope::Quitting = true; return false; } if (!has_servicesmod) { UplinkSocket::Message() << "ERROR :m_services is not loaded. This is required by Anope"; - quitmsg = "ERROR: Remote server does not have the m_services module loaded, and this is required."; - quitting = true; + Anope::QuitReason = "ERROR: Remote server does not have the m_services module loaded, and this is required."; + Anope::Quitting = true; return false; } if (!has_hidechansmod) { UplinkSocket::Message() << "ERROR :m_hidechans.so is not loaded. This is required by Anope"; - quitmsg = "ERROR: Remote server deos not have the m_hidechans module loaded, and this is required."; - quitting = true; + Anope::QuitReason = "ERROR: Remote server deos not have the m_hidechans module loaded, and this is required."; + Anope::Quitting = true; return false; } - if (!ircdproto->CanSVSHold) + if (!IRCD->CanSVSHold) Log() << "SVSHOLD missing, Usage disabled until module is loaded."; if (!has_chghostmod) Log() << "CHGHOST missing, Usage disabled until module is loaded."; @@ -566,17 +566,17 @@ struct IRCDMessageCapab : IRCDMessage Log() << "CHGIDENT missing, Usage disabled until module is loaded."; } - return true; + return Message::Capab::Run(source, params); } }; struct IRCDMessageChgIdent : IRCDMessage { - IRCDMessageChgIdent(const Anope::string &n) : IRCDMessage(n, 2) { } + IRCDMessageChgIdent(Module *creator, const Anope::string &n) : IRCDMessage(creator, n, 2) { } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = finduser(params[0]); + User *u = User::Find(params[0]); if (!u) { Log(LOG_DEBUG) << "CHGIDENT for nonexistent user " << params[0]; @@ -590,7 +590,7 @@ struct IRCDMessageChgIdent : IRCDMessage struct IRCDMessageChgName : IRCDMessage { - IRCDMessageChgName(const Anope::string &n) : IRCDMessage(n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + IRCDMessageChgName(Module *creator, const Anope::string &n) : IRCDMessage(creator, n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -601,7 +601,7 @@ struct IRCDMessageChgName : IRCDMessage struct IRCDMessageEndBurst : IRCDMessage { - IRCDMessageEndBurst() : IRCDMessage("ENDBURST", 0) { } + IRCDMessageEndBurst(Module *creator) : IRCDMessage(creator, "ENDBURST", 0) { } bool Run(MessageSource &, const std::vector<Anope::string> ¶ms) anope_override { @@ -612,7 +612,7 @@ struct IRCDMessageEndBurst : IRCDMessage struct IRCDMessageFHost : IRCDMessage { - IRCDMessageFHost(const Anope::string &n) : IRCDMessage(n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + IRCDMessageFHost(Module *creator, const Anope::string &n) : IRCDMessage(creator, n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -623,94 +623,47 @@ struct IRCDMessageFHost : IRCDMessage struct IRCDMessageFJoin : IRCDMessage { - IRCDMessageFJoin() : IRCDMessage("FJOIN", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageFJoin(Module *creator) : IRCDMessage(creator, "FJOIN", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Channel *c = findchan(params[0]); - time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0; - bool keep_their_modes = true; - - if (!c) - { - c = new Channel(params[0], ts); - c->SetFlag(CH_SYNCING); - } - /* Our creation time is newer than what the server gave us */ - else if (c->creation_time > ts) - { - c->creation_time = ts; - c->Reset(); - } - /* Their TS is newer than ours, our modes > theirs, unset their modes if need be */ - else if (ts > c->creation_time) - keep_their_modes = false; + std::list<Message::Join::SJoinUser> users; spacesepstream sep(params[params.size() - 1]); Anope::string buf; + while (sep.GetToken(buf)) { - std::list<ChannelMode *> Status; - char ch; + Message::Join::SJoinUser sju; /* Loop through prefixes */ - while ((ch = ModeManager::GetStatusChar(buf[0]))) + for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) { ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); + buf.erase(buf.begin()); if (!cm) { - Log() << "Received unknown mode prefix " << buf[0] << " in FJOIN string"; - buf.erase(buf.begin()); + Log() << "Received unknown mode prefix " << ch << " in FJOIN string"; continue; } - buf.erase(buf.begin()); - if (keep_their_modes) - Status.push_back(cm); + sju.first.SetFlag(cm->name); } /* Erase the , */ buf.erase(buf.begin()); - User *u = finduser(buf); - if (!u) + sju.second = User::Find(buf); + if (!sju.second) { - Log(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << c->name; + Log(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << params[0]; continue; } - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); - - /* Add the user to the channel */ - c->JoinUser(u); - - /* Update their status internally on the channel - * This will enforce secureops etc on the user - */ - for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it) - c->SetModeInternal(source, *it, buf); - - /* Now set whatever modes this user is allowed to have on the channel */ - chan_set_correct_modes(u, c, 1, true); - - /* Check to see if modules want the user to join, if they do - * check to see if they are allowed to join (CheckKick will kick/ban them) - * Don't trigger OnJoinChannel event then as the user will be destroyed - */ - if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u)) - continue; - - FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); } - /* Channel is done syncing */ - if (c->HasFlag(CH_SYNCING)) - { - /* Unset the syncing flag */ - c->UnsetFlag(CH_SYNCING); - c->Sync(); - } + time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime; + Message::Join::SJoin(source, params[0], ts, "", users); return true; } @@ -718,13 +671,13 @@ struct IRCDMessageFJoin : IRCDMessage struct IRCDMessageFMode : IRCDMessage { - IRCDMessageFMode() : IRCDMessage("FMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageFMode(Module *creator) : IRCDMessage(creator, "FMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { /* :source FMODE #test 12345678 +nto foo */ - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); if (!c) return true; time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0; @@ -742,11 +695,11 @@ struct IRCDMessageFMode : IRCDMessage struct IRCDMessageFTopic : IRCDMessage { - IRCDMessageFTopic() : IRCDMessage("FTOPIC", 4) { } + IRCDMessageFTopic(Module *creator) : IRCDMessage(creator, "FTOPIC", 4) { } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); if (c) c->ChangeTopicInternal(params[2], params[3], Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime); @@ -756,25 +709,25 @@ struct IRCDMessageFTopic : IRCDMessage struct IRCDMessageIdle : IRCDMessage { - IRCDMessageIdle() : IRCDMessage("IDLE", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + IRCDMessageIdle(Module *creator) : IRCDMessage(creator, "IDLE", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - const BotInfo *bi = findbot(params[0]); - UplinkSocket::Message(bi) << "IDLE " << source.GetSource() << " " << start_time << " " << (bi ? Anope::CurTime - bi->lastmsg : 0); + const BotInfo *bi = BotInfo::Find(params[0]); + UplinkSocket::Message(bi) << "IDLE " << source.GetSource() << " " << Anope::StartTime << " " << (bi ? Anope::CurTime - bi->lastmsg : 0); return true; } }; struct IRCDMessageMode : IRCDMessage { - IRCDMessageMode() : IRCDMessage("MODE", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageMode(Module *creator) : IRCDMessage(creator, "MODE", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (ircdproto->IsChannelValid(params[0])) + if (IRCD->IsChannelValid(params[0])) { - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); time_t ts; try @@ -791,7 +744,7 @@ struct IRCDMessageMode : IRCDMessage } else { - User *u = finduser(params[0]); + User *u = User::Find(params[0]); if (u) u->SetModesInternal("%s", params[1].c_str()); } @@ -802,7 +755,7 @@ struct IRCDMessageMode : IRCDMessage struct IRCDMessageNick : IRCDMessage { - IRCDMessageNick() : IRCDMessage("NICK", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -811,19 +764,19 @@ struct IRCDMessageNick : IRCDMessage time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : Anope::CurTime; User *user = new User(params[1], params[4], params[2], params[3], params[6], source.GetServer(), params[7], ts, params[5]); - if (nickserv) + if (NickServService) { - NickAlias *na = findnick(user->nick); + NickAlias *na = NickAlias::Find(user->nick); Anope::string *svidbuf = na ? na->nc->GetExt<ExtensibleItemClass<Anope::string> *>("authenticationtoken") : NULL; if (na && svidbuf && *svidbuf == params[0]) { NickCore *nc = na->nc; user->Login(nc); if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false) - user->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); + user->SetMode(NickServ, UMODE_REGISTERED); } - else if (nickserv) - nickserv->Validate(user); + else + NickServService->Validate(user); } } else if (params.size() == 1 && source.GetUser()) @@ -835,7 +788,7 @@ struct IRCDMessageNick : IRCDMessage struct IRCDMessageOperType : IRCDMessage { - IRCDMessageOperType() : IRCDMessage("OPERTYPE", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); } + IRCDMessageOperType(Module *creator) : IRCDMessage(creator, "OPERTYPE", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -851,7 +804,7 @@ struct IRCDMessageOperType : IRCDMessage struct IRCDMessageRSQuit : IRCDMessage { - IRCDMessageRSQuit() : IRCDMessage("RSQUIT", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageRSQuit(Module *creator) : IRCDMessage(creator, "RSQUIT", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -873,7 +826,7 @@ struct IRCDMessageRSQuit : IRCDMessage struct IRCDMessageServer : IRCDMessage { - IRCDMessageServer() : IRCDMessage("SERVER", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -888,22 +841,21 @@ class ProtoInspIRCd : public Module InspIRCdProto ircd_proto; /* Core message handlers */ - CoreIRCDMessageAway core_message_away; - CoreIRCDMessageCapab core_message_capab; - CoreIRCDMessageError core_message_error; - CoreIRCDMessageJoin core_message_join; - CoreIRCDMessageKick core_message_kick; - CoreIRCDMessageKill core_message_kill; - CoreIRCDMessageMOTD core_message_motd; - CoreIRCDMessagePart core_message_part; - CoreIRCDMessagePing core_message_ping; - CoreIRCDMessagePrivmsg core_message_privmsg; - CoreIRCDMessageQuit core_message_quit; - CoreIRCDMessageSQuit core_message_squit; - CoreIRCDMessageStats core_message_stats; - CoreIRCDMessageTime core_message_time; - CoreIRCDMessageTopic core_message_topic; - CoreIRCDMessageVersion core_message_version; + Message::Away message_away; + Message::Error message_error; + Message::Join message_join; + Message::Kick message_kick; + Message::Kill message_kill; + Message::MOTD message_motd; + Message::Part message_part; + Message::Ping message_ping; + Message::Privmsg message_privmsg; + Message::Quit message_quit; + Message::SQuit message_squit; + Message::Stats message_stats; + Message::Time message_time; + Message::Topic message_topic; + Message::Version message_version; /* Our message handlers */ IRCDMessageCapab message_capab; @@ -934,19 +886,30 @@ class ProtoInspIRCd : public Module public: ProtoInspIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL), - message_chgident("CHGIDENT"), message_setident("SETIDENT"), - message_chgname("CHGNAME"), message_setname("SETNAME"), - message_fhost("FHOST"), message_sethost("SETHOST") + message_away(this), message_error(this), message_join(this), message_kick(this), message_kill(this), + message_motd(this), message_part(this), message_ping(this), message_privmsg(this), message_quit(this), + message_squit(this), message_stats(this), message_time(this), message_topic(this), message_version(this), + + message_capab(this), message_chgident(this, "CHGIDENT"), message_setident(this, "SETIDENT"), + message_chgname(this, "CHGNAME"), message_setname(this, "SETNAME"), message_endburst(this), + message_fhost(this, "FHOST"), message_sethost(this, "SETHOST"), message_fjoin(this), + message_fmode(this), message_ftopic(this), message_idle(this), message_mode(this), + message_nick(this), message_opertype(this), message_rsquit(this), message_server(this) { this->SetAuthor("Anope"); - Capab.insert("NOQUIT"); + Servers::Capab.insert("NOQUIT"); this->AddModes(); ModuleManager::Attach(I_OnUserNickChange, this); } + IRCDProto *GetIRCDProto() anope_override + { + return &ircd_proto; + } + void OnUserNickChange(User *u, const Anope::string &) anope_override { u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED)); diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp index 3d925bd4a..09ba57f00 100644 --- a/modules/protocol/inspircd12.cpp +++ b/modules/protocol/inspircd12.cpp @@ -13,22 +13,354 @@ #include "module.h" -/* inspircd-ts6.h uses these */ static bool has_globopsmod = false; static bool has_chghostmod = false; static bool has_chgidentmod = false; static bool has_rlinemod = false; static bool has_svstopic_topiclock = false; -//static unsigned int spanningtree_proto_ver = 1201; -#include "inspircd-ts6.h" - static bool has_servicesmod = false; static bool has_hidechansmod = false; -class InspIRCd12Proto : public InspIRCdTS6Proto +class ChannelModeFlood : public ChannelModeParam +{ + public: + ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam(CMODE_FLOOD, modeChar, minusNoArg) { } + + bool IsValid(const Anope::string &value) const anope_override + { + try + { + Anope::string rest; + if (!value.empty() && value[0] != ':' && convertTo<int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<int>(rest.substr(1), rest, false) > 0 && rest.empty()) + return true; + } + catch (const ConvertException &) { } + + return false; + } +}; + +class InspIRCd12Proto : public IRCDProto { + private: + void SendChgIdentInternal(const Anope::string &nick, const Anope::string &vIdent) + { + if (!has_chgidentmod) + Log() << "CHGIDENT not loaded!"; + else + UplinkSocket::Message(HostServ) << "CHGIDENT " << nick << " " << vIdent; + } + + void SendChgHostInternal(const Anope::string &nick, const Anope::string &vhost) + { + if (!has_chghostmod) + Log() << "CHGHOST not loaded!"; + else + UplinkSocket::Message(Me) << "CHGHOST " << nick << " " << vhost; + } + + void SendAddLine(const Anope::string &type, const Anope::string &mask, time_t duration, const Anope::string &addedby, const Anope::string &reason) + { + UplinkSocket::Message(Me) << "ADDLINE " << type << " " << mask << " " << addedby << " " << Anope::CurTime << " " << duration << " :" << reason; + } + + void SendDelLine(const Anope::string &type, const Anope::string &mask) + { + UplinkSocket::Message(Me) << "DELLINE " << type << " " << mask; + } + public: - InspIRCd12Proto() : InspIRCdTS6Proto("InspIRCd 1.2") { } + InspIRCd12Proto() : IRCDProto("InspIRCd 1.2") + { + DefaultPseudoclientModes = "+I"; + CanSVSNick = true; + CanSetVHost = true; + CanSetVIdent = true; + CanSQLine = true; + CanSZLine = true; + CanSVSHold = true; + CanCertFP = true; + RequiresID = true; + MaxModes = 20; + } + + void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + { + UplinkSocket::Message(bi) << "NOTICE $" << dest->GetName() << " :" << msg; + } + + void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override + { + UplinkSocket::Message(bi) << "PRIVMSG $" << dest->GetName() << " :" << msg; + } + + void SendAkillDel(const XLine *x) anope_override + { + /* InspIRCd may support regex bans */ + if (x->IsRegex() && has_rlinemod) + { + Anope::string mask = x->mask; + size_t h = x->mask.find('#'); + if (h != Anope::string::npos) + mask = mask.replace(h, 1, ' '); + SendDelLine("R", mask); + return; + } + else if (x->IsRegex() || x->HasNickOrReal()) + return; + + SendDelLine("G", x->mask); + } + + void SendTopic(BotInfo *whosets, Channel *c) anope_override + { + if (has_svstopic_topiclock) + { + UplinkSocket::Message(c->ci->WhoSends()) << "SVSTOPIC " << c->name << " " << c->topic_ts << " " << c->topic_setter << " :" << c->topic; + } + else + { + /* If the last time a topic was set is after the TS we want for this topic we must bump this topic's timestamp to now */ + time_t ts = c->topic_ts; + if (c->topic_time > ts) + ts = Anope::CurTime; + /* But don't modify c->topic_ts, it should remain set to the real TS we want as ci->last_topic_time pulls from it */ + UplinkSocket::Message(whosets) << "FTOPIC " << c->name << " " << ts << " " << c->topic_setter << " :" << c->topic; + } + } + + void SendVhostDel(User *u) anope_override + { + if (u->HasMode(UMODE_CLOAK)) + this->SendChgHostInternal(u->nick, u->chost); + else + this->SendChgHostInternal(u->nick, u->host); + + if (has_chgidentmod && u->GetIdent() != u->GetVIdent()) + this->SendChgIdentInternal(u->nick, u->GetIdent()); + } + + void SendAkill(User *u, XLine *x) anope_override + { + // Calculate the time left before this would expire, capping it at 2 days + time_t timeleft = x->expires - Anope::CurTime; + if (timeleft > 172800 || !x->expires) + timeleft = 172800; + + /* InspIRCd may support regex bans, if they do we can send this and forget about it */ + if (x->IsRegex() && has_rlinemod) + { + Anope::string mask = x->mask; + size_t h = x->mask.find('#'); + if (h != Anope::string::npos) + mask = mask.replace(h, 1, ' '); + SendAddLine("R", mask, timeleft, x->by, x->GetReason()); + return; + } + else if (x->IsRegex() || x->HasNickOrReal()) + { + if (!u) + { + /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */ + for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) + if (x->manager->Check(it->second, x)) + this->SendAkill(it->second, x); + return; + } + + const XLine *old = x; + + if (old->manager->HasEntry("*@" + u->host)) + return; + + /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ + x = new XLine("*@" + u->host, old->by, old->expires, old->reason, old->id); + old->manager->AddXLine(x); + + Log(OperServ, "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask; + } + + /* ZLine if we can instead */ + try + { + if (x->GetUser() == "*") + { + sockaddrs(x->GetHost()); + IRCD->SendSZLine(u, x); + return; + } + } + catch (const SocketException &) { } + SendAddLine("G", x->GetUser() + "@" + x->GetHost(), timeleft, x->by, x->GetReason()); + } + + void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) anope_override + { + UplinkSocket::Message() << "PUSH " << dest << " ::" << Me->GetName() << " " << numeric << " " << dest << " " << buf; + } + + void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override + { + UplinkSocket::Message(source) << "FMODE " << dest->name << " " << dest->creation_time << " " << buf; + } + + void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override + { + UplinkSocket::Message(bi) << "MODE " << u->GetUID() << " " << buf; + } + + void SendClientIntroduction(const User *u) anope_override + { + Anope::string modes = "+" + u->GetModes(); + UplinkSocket::Message(Me) << "UID " << u->GetUID() << " " << u->timestamp << " " << u->nick << " " << u->host << " " << u->host << " " << u->GetIdent() << " 0.0.0.0 " << u->timestamp << " " << modes << " :" << u->realname; + } + + /* SERVER services-dev.chatspike.net password 0 :Description here */ + void SendServer(const Server *server) anope_override + { + UplinkSocket::Message() << "SERVER " << server->GetName() << " " << Config->Uplinks[Anope::CurrentUplink]->password << " " << server->GetHops() << " " << server->GetSID() << " :" << server->GetDescription(); + } + + /* JOIN */ + void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override + { + UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :," << user->GetUID(); + /* Note that we can send this with the FJOIN but choose not to + * because the mode stacker will handle this and probably will + * merge these modes with +nrt and other mlocked modes + */ + if (status) + { + /* First save the channel status incase uc->Status == status */ + ChannelStatus cs = *status; + /* If the user is internally on the channel with flags, kill them so that + * the stacker will allow this. + */ + UserContainer *uc = c->FindUser(user); + if (uc != NULL) + uc->status->ClearFlags(); + + BotInfo *setter = BotInfo::Find(user->nick); + for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) + if (cs.HasFlag(ModeManager::ChannelModes[i]->name)) + c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); + } + } + + /* UNSQLINE */ + void SendSQLineDel(const XLine *x) anope_override + { + SendDelLine("Q", x->mask); + } + + /* SQLINE */ + void SendSQLine(User *, const XLine *x) anope_override + { + // Calculate the time left before this would expire, capping it at 2 days + time_t timeleft = x->expires - Anope::CurTime; + if (timeleft > 172800 || !x->expires) + timeleft = 172800; + SendAddLine("Q", x->mask, timeleft, x->by, x->GetReason()); + } + + /* Functions that use serval cmd functions */ + + void SendVhost(User *u, const Anope::string &vIdent, const Anope::string &vhost) anope_override + { + if (!vIdent.empty()) + this->SendChgIdentInternal(u->nick, vIdent); + if (!vhost.empty()) + this->SendChgHostInternal(u->nick, vhost); + } + + void SendConnect() anope_override + { + SendServer(Me); + UplinkSocket::Message(Me) << "BURST"; + Module *enc = ModuleManager::FindFirstOf(ENCRYPTION); + UplinkSocket::Message(Me) << "VERSION :Anope-" << Anope::Version() << " " << Config->ServerName << " :" << IRCD->GetProtocolName() << " - (" << (enc ? enc->name : "unknown") << ") -- " << Anope::VersionBuildString(); + } + + /* SVSHOLD - set */ + void SendSVSHold(const Anope::string &nick) anope_override + { + UplinkSocket::Message(NickServ) << "SVSHOLD " << nick << " " << Config->NSReleaseTimeout << " :Being held for registered user"; + } + + /* SVSHOLD - release */ + void SendSVSHoldDel(const Anope::string &nick) anope_override + { + UplinkSocket::Message(NickServ) << "SVSHOLD " << nick; + } + + /* UNSZLINE */ + void SendSZLineDel(const XLine *x) anope_override + { + SendDelLine("Z", x->GetHost()); + } + + /* SZLINE */ + void SendSZLine(User *, const XLine *x) anope_override + { + // Calculate the time left before this would expire, capping it at 2 days + time_t timeleft = x->expires - Anope::CurTime; + if (timeleft > 172800 || !x->expires) + timeleft = 172800; + SendAddLine("Z", x->GetHost(), timeleft, x->by, x->GetReason()); + } + + void SendSVSJoin(const BotInfo *source, const Anope::string &nick, const Anope::string &chan, const Anope::string &) anope_override + { + User *u = User::Find(nick); + UplinkSocket::Message(source) << "SVSJOIN " << u->GetUID() << " " << chan; + } + + void SendSWhois(const BotInfo *, const Anope::string &who, const Anope::string &mask) anope_override + { + User *u = User::Find(who); + + UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " swhois :" << mask; + } + + void SendBOB() anope_override + { + UplinkSocket::Message(Me) << "BURST " << Anope::CurTime; + } + + void SendEOB() anope_override + { + UplinkSocket::Message(Me) << "ENDBURST"; + } + + void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) + { + if (has_globopsmod) + UplinkSocket::Message(source) << "SNONOTICE g :" << buf; + else + UplinkSocket::Message(source) << "SNONOTICE A :" << buf; + } + + void SendLogin(User *u) anope_override + { + if (!u->Account() || u->Account()->HasFlag(NI_UNCONFIRMED)) + return; + + UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :" << u->Account()->display; + } + + void SendLogout(User *u) anope_override + { + UplinkSocket::Message(Me) << "METADATA " << u->GetUID() << " accountname :"; + } + + void SendChannel(Channel *c) anope_override + { + UplinkSocket::Message(Me) << "FJOIN " << c->name << " " << c->creation_time << " +" << c->GetModes(true, true) << " :"; + } + + void SendOper(User *u) anope_override + { + } }; class InspIRCdExtBan : public ChannelModeList @@ -44,7 +376,7 @@ class InspIRCdExtBan : public ChannelModeList { Anope::string real_mask = mask.substr(2); - Entry en(this->Name, real_mask); + Entry en(this->name, real_mask); if (en.Matches(u)) return true; } @@ -52,7 +384,7 @@ class InspIRCdExtBan : public ChannelModeList { Anope::string real_mask = mask.substr(2); - Channel *c = findchan(real_mask); + Channel *c = Channel::Find(real_mask); if (c != NULL && c->FindUser(u) != NULL) return true; } @@ -82,9 +414,9 @@ class InspIRCdExtBan : public ChannelModeList } }; -struct IRCDMessageCapab : IRCDMessage +struct IRCDMessageCapab : Message::Capab { - IRCDMessageCapab() : IRCDMessage("CAPAB", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageCapab(Module *creator) : Message::Capab(creator, "CAPAB") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -96,7 +428,7 @@ struct IRCDMessageCapab : IRCDMessage has_chghostmod = false; has_chgidentmod = false; has_hidechansmod = false; - ircdproto->CanSVSHold = false; + IRCD->CanSVSHold = false; } else if (params[0].equals_cs("MODULES") && params.size() > 1) { @@ -105,7 +437,7 @@ struct IRCDMessageCapab : IRCDMessage if (params[1].find("m_services_account.so") != Anope::string::npos) has_servicesmod = true; if (params[1].find("m_svshold.so") != Anope::string::npos) - ircdproto->CanSVSHold = true; + IRCD->CanSVSHold = true; if (params[1].find("m_chghost.so") != Anope::string::npos) has_chghostmod = true; if (params[1].find("m_chgident.so") != Anope::string::npos) @@ -113,7 +445,7 @@ struct IRCDMessageCapab : IRCDMessage if (params[1].find("m_hidechans.so") != Anope::string::npos) has_hidechansmod = true; if (params[1].find("m_servprotect.so") != Anope::string::npos) - ircdproto->DefaultPseudoclientModes = "+Ik"; + IRCD->DefaultPseudoclientModes = "+Ik"; if (params[1].find("m_rline.so") != Anope::string::npos) has_rlinemod = true; } @@ -383,7 +715,7 @@ struct IRCDMessageCapab : IRCDMessage else if (capab.find("MAXMODES=") != Anope::string::npos) { Anope::string maxmodes(capab.begin() + 9, capab.end()); - ircdproto->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3; + IRCD->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3; } } } @@ -392,25 +724,25 @@ struct IRCDMessageCapab : IRCDMessage if (!has_globopsmod) { UplinkSocket::Message() << "ERROR :m_globops is not loaded. This is required by Anope"; - quitmsg = "Remote server does not have the m_globops module loaded, and this is required."; - quitting = true; + Anope::QuitReason = "Remote server does not have the m_globops module loaded, and this is required."; + Anope::Quitting = true; return false; } if (!has_servicesmod) { UplinkSocket::Message() << "ERROR :m_services_account.so is not loaded. This is required by Anope"; - quitmsg = "ERROR: Remote server does not have the m_services_account module loaded, and this is required."; - quitting = true; + Anope::QuitReason = "ERROR: Remote server does not have the m_services_account module loaded, and this is required."; + Anope::Quitting = true; return false; } if (!has_hidechansmod) { UplinkSocket::Message() << "ERROR :m_hidechans.so is not loaded. This is required by Anope"; - quitmsg = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required."; - quitting = true; + Anope::QuitReason = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required."; + Anope::Quitting = true; return false; } - if (!ircdproto->CanSVSHold) + if (!IRCD->CanSVSHold) Log() << "SVSHOLD missing, Usage disabled until module is loaded."; if (!has_chghostmod) Log() << "CHGHOST missing, Usage disabled until module is loaded."; @@ -418,17 +750,19 @@ struct IRCDMessageCapab : IRCDMessage Log() << "CHGIDENT missing, Usage disabled until module is loaded."; } - return true; + Servers::Capab.insert("NOQUIT"); + + return Message::Capab::Run(source, params); } }; struct IRCDMessageChgIdent : IRCDMessage { - IRCDMessageChgIdent() : IRCDMessage("CHGIDENT", 2) { } + IRCDMessageChgIdent(Module *creator) : IRCDMessage(creator, "CHGIDENT", 2) { } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = finduser(params[0]); + User *u = User::Find(params[0]); if (u) u->SetIdent(params[1]); return true; @@ -437,7 +771,7 @@ struct IRCDMessageChgIdent : IRCDMessage struct IRCDMessageChgName : IRCDMessage { - IRCDMessageChgName(const Anope::string &n) : IRCDMessage(n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + IRCDMessageChgName(Module *creator, const Anope::string &n) : IRCDMessage(creator, n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -446,9 +780,345 @@ struct IRCDMessageChgName : IRCDMessage } }; +struct IRCDMessageEndburst : IRCDMessage +{ + IRCDMessageEndburst(Module *creator) : IRCDMessage(creator, "ENDBURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + Server *s = source.GetServer(); + + Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName(); + + s->Sync(true); + return true; + } +}; + +struct IRCDMessageFHost : IRCDMessage +{ + IRCDMessageFHost(Module *creator, const Anope::string &n) : IRCDMessage(creator, n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + source.GetUser()->SetDisplayedHost(params[0]); + return true; + } +}; + +struct IRCDMessageFJoin : IRCDMessage +{ + IRCDMessageFJoin(Module *creator) : IRCDMessage(creator, "FJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + Anope::string modes; + if (params.size() >= 3) + { + for (unsigned i = 2; i < params.size() - 1; ++i) + modes += " " + params[i]; + if (!modes.empty()) + modes.erase(modes.begin()); + } + + std::list<Message::Join::SJoinUser> users; + + spacesepstream sep(params[params.size() - 1]); + Anope::string buf; + while (sep.GetToken(buf)) + { + Message::Join::SJoinUser sju; + + /* Loop through prefixes and find modes for them */ + for (char c; (c = buf[0]) != ',';) + { + ChannelMode *cm = ModeManager::FindChannelModeByChar(c); + if (!cm) + { + Log() << "Received unknown mode prefix " << c << " in FJOIN string"; + continue; + } + + sju.first.SetFlag(cm->name); + } + /* Erase the , */ + buf.erase(buf.begin()); + + sju.second = User::Find(buf); + if (!sju.second) + { + Log(LOG_DEBUG) << "FJOIN for nonexistant user " << buf << " on " << params[0]; + continue; + } + + users.push_back(sju); + } + + time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime; + Message::Join::SJoin(source, params[0], ts, "", users); + + return true; + } +}; + +struct IRCDMessageFMode : IRCDMessage +{ + IRCDMessageFMode(Module *creator) : IRCDMessage(creator, "FMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + /* :source FMODE #test 12345678 +nto foo */ + + Anope::string modes = params[2]; + for (unsigned n = 3; n < params.size(); ++n) + modes += " " + params[n]; + + Channel *c = Channel::Find(params[0]); + time_t ts; + + try + { + ts = convertTo<time_t>(params[1]); + } + catch (const ConvertException &) + { + ts = 0; + } + + if (c) + c->SetModesInternal(source, modes, ts); + + return true; + } +}; + +struct IRCDMessageFTopic : IRCDMessage +{ + IRCDMessageFTopic(Module *creator) : IRCDMessage(creator, "FTOPIC", 4) { } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + /* :source FTOPIC channel topicts setby :topic */ + + Channel *c = Channel::Find(params[0]); + if (c) + c->ChangeTopicInternal(params[2], params[3], Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime); + + return true; + } +}; + +struct IRCDMessageIdle : IRCDMessage +{ + IRCDMessageIdle(Module *creator) : IRCDMessage(creator, "IDLE", 1) { } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + const BotInfo *bi = BotInfo::Find(params[0]); + if (bi) + UplinkSocket::Message(bi) << "IDLE " << source.GetSource() << " " << Anope::StartTime << " " << (Anope::CurTime - bi->lastmsg); + return true; + } +}; + +/* + * source = numeric of the sending server + * params[0] = uuid + * params[1] = metadata name + * params[2] = data + */ +struct IRCDMessageMetadata : IRCDMessage +{ + IRCDMessageMetadata(Module *creator) : IRCDMessage(creator, "METADATA", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + if (isdigit(params[0][0])) + { + if (params[1].equals_cs("accountname")) + { + User *u = User::Find(params[0]); + NickCore *nc = NickCore::Find(params[2]); + if (u && nc) + { + u->Login(nc); + + const NickAlias *user_na = NickAlias::Find(u->nick); + if (!Config->NoNicknameOwnership && user_na && user_na->nc == nc && user_na->nc->HasFlag(NI_UNCONFIRMED) == false) + u->SetMode(NickServ, UMODE_REGISTERED); + + /* Sometimes a user connects, we send them the usual "this nickname is registered" mess (if + * their server isn't syncing) and then we receive this.. so tell them about it. + */ + if (u->server->IsSynced() && NickServ) + u->SendMessage(NickServ, _("You have been logged in as \2%s\2."), nc->display.c_str()); + } + } + + /* + * possible incoming ssl_cert messages: + * Received: :409 METADATA 409AAAAAA ssl_cert :vTrSe c38070ce96e41cc144ed6590a68d45a6 <...> <...> + * Received: :409 METADATA 409AAAAAC ssl_cert :vTrSE Could not get peer certificate: error:00000000:lib(0):func(0):reason(0) + */ + else if (params[1].equals_cs("ssl_cert")) + { + User *u = User::Find(params[0]); + if (!u) + return true; + std::string data = params[2].c_str(); + size_t pos1 = data.find(' ') + 1; + size_t pos2 = data.find(' ', pos1); + if ((pos2 - pos1) >= 32) // inspircd supports md5 and sha1 fingerprint hashes -> size 32 or 40 bytes. + { + u->fingerprint = data.substr(pos1, pos2 - pos1); + FOREACH_MOD(I_OnFingerprint, OnFingerprint(u)); + } + } + } + else if (params[0][0] == '#') + { + } + else if (params[0] == "*") + { + // Wed Oct 3 15:40:27 2012: S[14] O :20D METADATA * modules :-m_svstopic.so + + if (params[1].equals_cs("modules") && !params[2].empty()) + { + // only interested when it comes from our uplink + Server* server = source.GetServer(); + if (!server || server->GetUplink() != Me) + return true; + + bool plus = (params[2][0] == '+'); + if (!plus && params[2][0] != '-') + return true; + + bool required = false; + Anope::string module = params[2].substr(1); + + if (module.equals_cs("m_services_account.so")) + required = true; + else if (module.equals_cs("m_hidechans.so")) + required = true; + else if (module.equals_cs("m_chghost.so")) + has_chghostmod = plus; + else if (module.equals_cs("m_chgident.so")) + has_chgidentmod = plus; + else if (module.equals_cs("m_svshold.so")) + IRCD->CanSVSHold = plus; + else if (module.equals_cs("m_rline.so")) + has_rlinemod = plus; + else if (module.equals_cs("m_topiclock.so")) + has_svstopic_topiclock = plus; + else + return true; + + if (required) + { + if (!plus) + Log() << "Warning: InspIRCd unloaded module " << module << ", Anope won't function correctly without it"; + } + else + { + Log() << "InspIRCd " << (plus ? "loaded" : "unloaded") << " module " << module << ", adjusted functionality"; + } + + } + } + + return true; + } +}; + +struct IRCDMessageMode : IRCDMessage +{ + IRCDMessageMode(Module *creator) : IRCDMessage(creator, "MODE", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + if (IRCD->IsChannelValid(params[0])) + { + Channel *c = Channel::Find(params[0]); + + Anope::string modes = params[1]; + for (unsigned n = 2; n < params.size(); ++n) + modes += " " + params[n]; + + if (c) + c->SetModesInternal(source, modes); + } + else + { + /* InspIRCd lets opers change another + users modes, we have to kludge this + as it slightly breaks RFC1459 + */ + User *u = source.GetUser(); + // This can happen with server-origin modes. + if (!u) + u = User::Find(params[0]); + // if it's still null, drop it like fire. + // most likely situation was that server introduced a nick which we subsequently akilled + if (u) + u->SetModesInternal("%s", params[1].c_str()); + } + + return true; + } +}; + +struct IRCDMessageNick : IRCDMessage +{ + IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + source.GetUser()->ChangeNick(params[0]); + return true; + } +}; + +struct IRCDMessageOperType : IRCDMessage +{ + IRCDMessageOperType(Module *creator) : IRCDMessage(creator, "OPERTYPE", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + /* opertype is equivalent to mode +o because servers + dont do this directly */ + User *u = source.GetUser(); + if (!u->HasMode(UMODE_OPER)) + u->SetModesInternal("+o"); + + return true; + } +} +; +struct IRCDMessageRSQuit : IRCDMessage +{ + IRCDMessageRSQuit(Module *creator) : IRCDMessage(creator, "RSQUIT", 1) { } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + Server *s = Server::Find(params[0]); + if (!s) + return true; + + /* On InspIRCd we must send a SQUIT when we recieve RSQUIT for a server we have juped */ + if (s->HasFlag(SERVER_JUPED)) + UplinkSocket::Message(Me) << "SQUIT " << s->GetSID() << " :" << (params.size() > 1 ? params[1].c_str() : ""); + + FOREACH_MOD(I_OnServerQuit, OnServerQuit(s)); + + s->Delete(s->GetName() + " " + s->GetUplink()->GetName()); + + return true; + } +}; + struct IRCDMessageSetIdent : IRCDMessage { - IRCDMessageSetIdent() : IRCDMessage("SETIDENT", 0) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + IRCDMessageSetIdent(Module *creator) : IRCDMessage(creator, "SETIDENT", 0) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -457,28 +1127,94 @@ struct IRCDMessageSetIdent : IRCDMessage } }; +struct IRCDMessageServer : IRCDMessage +{ + IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 5) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + + /* + * [Nov 04 00:08:46.308435 2009] debug: Received: SERVER irc.inspircd.com pass 0 964 :Testnet Central! + * 0: name + * 1: pass + * 2: hops + * 3: numeric + * 4: desc + */ + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + unsigned int hops = Anope::string(params[2]).is_pos_number_only() ? convertTo<unsigned>(params[2]) : 0; + new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[4], params[3]); + return true; + } +}; + +struct IRCDMessageTime : IRCDMessage +{ + IRCDMessageTime(Module *creator) : IRCDMessage(creator, "TIME", 2) { } + + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + UplinkSocket::Message(Me) << "TIME " << source.GetSource() << " " << params[1] << " " << Anope::CurTime; + return true; + } +}; + +struct IRCDMessageUID : IRCDMessage +{ + IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 8) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + + /* + * [Nov 03 22:09:58.176252 2009] debug: Received: :964 UID 964AAAAAC 1225746297 w00t2 localhost testnet.user w00t 127.0.0.1 1225746302 +iosw +ACGJKLNOQcdfgjklnoqtx :Robin Burchell <w00t@inspircd.org> + * 0: uid + * 1: ts + * 2: nick + * 3: host + * 4: dhost + * 5: ident + * 6: ip + * 7: signon + * 8+: modes and params -- IMPORTANT, some modes (e.g. +s) may have parameters. So don't assume a fixed position of realname! + * last: realname + */ + bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override + { + time_t ts = convertTo<time_t>(params[1]); + + Anope::string modes = params[8]; + for (unsigned i = 9; i < params.size() - 1; ++i) + modes += " " + params[i]; + + User *u = new User(params[2], params[5], params[3], params[4], params[6], source.GetServer(), params[params.size() - 1], ts, modes, params[0]); + if (u->server->IsSynced() && NickServService) + NickServService->Validate(u); + + return true; + } +}; + class ProtoInspIRCd : public Module { InspIRCd12Proto ircd_proto; /* Core message handlers */ - CoreIRCDMessageAway core_message_away; - CoreIRCDMessageCapab core_message_capab; - CoreIRCDMessageError core_message_error; - CoreIRCDMessageJoin core_message_join; - CoreIRCDMessageKick core_message_kick; - CoreIRCDMessageKill core_message_kill; - CoreIRCDMessageMOTD core_message_motd; - CoreIRCDMessagePart core_message_part; - CoreIRCDMessagePing core_message_ping; - CoreIRCDMessagePrivmsg core_message_privmsg; - CoreIRCDMessageQuit core_message_quit; - CoreIRCDMessageSQuit core_message_squit; - CoreIRCDMessageStats core_message_stats; - CoreIRCDMessageTopic core_message_topic; - CoreIRCDMessageVersion core_message_version; - - /* inspircd-ts6.h message handlers */ + Message::Away message_away; + Message::Error message_error; + Message::Join message_join; + Message::Kick message_kick; + Message::Kill message_kill; + Message::MOTD message_motd; + Message::Part message_part; + Message::Ping message_ping; + Message::Privmsg message_privmsg; + Message::Quit message_quit; + Message::SQuit message_squit; + Message::Stats message_stats; + Message::Topic message_topic; + Message::Version message_version; + + /* Our message handlers */ + IRCDMessageChgIdent message_chgident; + IRCDMessageChgName message_setname, message_chgname; + IRCDMessageCapab message_capab; IRCDMessageEndburst message_endburst; IRCDMessageFHost message_fhost, message_sethost; IRCDMessageFJoin message_sjoin; @@ -490,31 +1226,30 @@ class ProtoInspIRCd : public Module IRCDMessageNick message_nick; IRCDMessageOperType message_opertype; IRCDMessageRSQuit message_rsquit; + IRCDMessageSetIdent message_setident; IRCDMessageServer message_server; IRCDMessageTime message_time; IRCDMessageUID message_uid; - /* Our message handlers */ - IRCDMessageChgIdent message_chgident; - IRCDMessageChgName message_setname, message_chgname; - IRCDMessageCapab message_capab; - IRCDMessageSetIdent message_setident; - public: ProtoInspIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL), - message_fhost("FHOST"), message_sethost("SETHOST"), - message_setname("SETNAME"), message_chgname("FNAME") + message_away(this), message_error(this), message_join(this), message_kick(this), message_kill(this), + message_motd(this), message_part(this), message_ping(this), message_privmsg(this), message_quit(this), + message_squit(this), message_stats(this), message_topic(this), message_version(this), + + message_chgident(this), message_setname(this, "SETNAME"), message_chgname(this, "FNAME"), message_capab(this), message_endburst(this), + message_fhost(this, "FHOST"), message_sethost(this, "SETHOST"), message_sjoin(this), message_fmode(this), message_ftopic(this), + message_idle(this), message_metadata(this), message_mode(this), message_nick(this), message_opertype(this), message_rsquit(this), + message_setident(this), message_server(this), message_time(this), message_uid(this) { this->SetAuthor("Anope"); - Capab.insert("NOQUIT"); - Implementation i[] = { I_OnUserNickChange, I_OnServerSync }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); if (Config->Numeric.empty()) { - Anope::string numeric = ts6_sid_retrieve(); + Anope::string numeric = Servers::TS6_SID_Retrieve(); Me->SetSID(numeric); Config->Numeric = numeric; } @@ -523,22 +1258,27 @@ class ProtoInspIRCd : public Module it->second->GenerateUID(); } + IRCDProto *GetIRCDProto() anope_override + { + return &ircd_proto; + } + void OnUserNickChange(User *u, const Anope::string &) anope_override { /* InspIRCd 1.2 doesn't set -r on nick change, remove -r here. Note that if we have to set +r later * this will cancel out this -r, resulting in no mode changes. */ - u->RemoveMode(findbot(Config->NickServ), UMODE_REGISTERED); + u->RemoveMode(NickServ, UMODE_REGISTERED); } void OnServerSync(Server *s) anope_override { - if (nickserv) + if (NickServService) for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { User *u = it->second; if (u->server == s && !u->IsIdentified()) - nickserv->Validate(u); + NickServService->Validate(u); } } }; diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 9bb3d9e1a..85cfd9088 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -13,29 +13,67 @@ #include "module.h" -/* inspircd-ts6.h uses these */ static bool has_chghostmod = false; static bool has_chgidentmod = false; -static bool has_globopsmod = true; // Not a typo static bool has_rlinemod = false; static bool has_svstopic_topiclock = false; static unsigned int spanningtree_proto_ver = 0; -#include "inspircd-ts6.h" - static bool has_servicesmod = false; -class InspIRCd20Proto : public InspIRCdTS6Proto +static IRCDProto *insp12; + +class InspIRCd20Proto : public IRCDProto { public: - InspIRCd20Proto() : InspIRCdTS6Proto("InspIRCd 2.0") { } + InspIRCd20Proto() : IRCDProto("InspIRCd 2.0") + { + DefaultPseudoclientModes = "+I"; + CanSVSNick = true; + CanSetVHost = true; + CanSetVIdent = true; + CanSQLine = true; + CanSZLine = true; + CanSVSHold = true; + CanCertFP = true; + RequiresID = true; + MaxModes = 20; + } void SendConnect() anope_override { UplinkSocket::Message() << "CAPAB START 1202"; UplinkSocket::Message() << "CAPAB CAPABILITIES :PROTOCOL=1202"; UplinkSocket::Message() << "CAPAB END"; - InspIRCdTS6Proto::SendConnect(); + insp12->SendConnect(); } + + void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { insp12->SendGlobalNotice(bi, dest, msg); } + void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { insp12->SendGlobalPrivmsg(bi, dest, msg); } + void SendAkillDel(const XLine *x) anope_override { insp12->SendAkillDel(x); } + void SendTopic(BotInfo *whosets, Channel *c) anope_override { insp12->SendTopic(whosets, c); }; + void SendVhostDel(User *u) anope_override { insp12->SendVhostDel(u); } + void SendAkill(User *u, XLine *x) anope_override { insp12->SendAkill(u, x); } + void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) anope_override { insp12->SendNumericInternal(numeric, dest, buf); } + void SendModeInternal(const BotInfo *source, const Channel *dest, const Anope::string &buf) anope_override { insp12->SendModeInternal(source, dest, buf); } + void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override { insp12->SendModeInternal(bi, u, buf); } + void SendClientIntroduction(const User *u) anope_override { insp12->SendClientIntroduction(u); } + void SendServer(const Server *server) anope_override { insp12->SendServer(server); } + void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override { insp12->SendJoin(user, c, status); } + void SendSQLineDel(const XLine *x) anope_override { insp12->SendSQLineDel(x); } + void SendSQLine(User *u, const XLine *x) anope_override { insp12->SendSQLine(u, x); } + void SendVhost(User *u, const Anope::string &vident, const Anope::string &vhost) anope_override { insp12->SendVhost(u, vident, vhost); } + void SendSVSHold(const Anope::string &nick) anope_override { insp12->SendSVSHold(nick); } + void SendSVSHoldDel(const Anope::string &nick) anope_override { insp12->SendSVSHoldDel(nick); } + void SendSZLineDel(const XLine *x) anope_override { insp12->SendSZLineDel(x); } + void SendSZLine(User *u, const XLine *x) anope_override { insp12->SendSZLine(u, x); } + void SendSVSJoin(const BotInfo *source, const Anope::string &nick, const Anope::string &chan, const Anope::string &other) anope_override { insp12->SendSVSJoin(source, nick, chan, other); } + void SendSWhois(const BotInfo *bi, const Anope::string &who, const Anope::string &mask) anope_override { insp12->SendSWhois(bi, who, mask); } + void SendBOB() anope_override { insp12->SendBOB(); } + void SendEOB() anope_override { insp12->SendEOB(); } + void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) { insp12->SendGlobopsInternal(source, buf); } + void SendLogin(User *u) anope_override { insp12->SendLogin(u); } + void SendLogout(User *u) anope_override { insp12->SendLogout(u); } + void SendChannel(Channel *c) anope_override { insp12->SendChannel(c); } }; class InspIRCdExtBan : public ChannelModeList @@ -51,7 +89,7 @@ class InspIRCdExtBan : public ChannelModeList { Anope::string real_mask = mask.substr(3); - Entry en(this->Name, real_mask); + Entry en(this->name, real_mask); if (en.Matches(u)) return true; } @@ -65,16 +103,16 @@ class InspIRCdExtBan : public ChannelModeList char modeChar = ModeManager::GetStatusChar(channel[0]); channel.erase(channel.begin()); cm = ModeManager::FindChannelModeByChar(modeChar); - if (cm != NULL && cm->Type != MODE_STATUS) + if (cm != NULL && cm->type != MODE_STATUS) cm = NULL; } - Channel *c = findchan(channel); + Channel *c = Channel::Find(channel); if (c != NULL) { UserContainer *uc = c->FindUser(u); if (uc != NULL) - if (cm == NULL || uc->Status->HasFlag(cm->Name)) + if (cm == NULL || uc->status->HasFlag(cm->name)) return true; } } @@ -111,9 +149,28 @@ class InspIRCdExtBan : public ChannelModeList } }; -struct IRCDMessageCapab : IRCDMessage +class ChannelModeFlood : public ChannelModeParam { - IRCDMessageCapab() : IRCDMessage("CAPAB", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + public: + ChannelModeFlood(char modeChar, bool minusNoArg) : ChannelModeParam(CMODE_FLOOD, modeChar, minusNoArg) { } + + bool IsValid(const Anope::string &value) const anope_override + { + try + { + Anope::string rest; + if (!value.empty() && value[0] != ':' && convertTo<int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<int>(rest.substr(1), rest, false) > 0 && rest.empty()) + return true; + } + catch (const ConvertException &) { } + + return false; + } +}; + +struct IRCDMessageCapab : Message::Capab +{ + IRCDMessageCapab(Module *creator) : Message::Capab(creator, "CAPAB") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -125,8 +182,8 @@ struct IRCDMessageCapab : IRCDMessage if (spanningtree_proto_ver < 1202) { UplinkSocket::Message() << "ERROR :Protocol mismatch, no or invalid protocol version given in CAPAB START"; - quitmsg = "Protocol mismatch, no or invalid protocol version given in CAPAB START"; - quitting = true; + Anope::QuitReason = "Protocol mismatch, no or invalid protocol version given in CAPAB START"; + Anope::Quitting = true; return false; } @@ -135,7 +192,7 @@ struct IRCDMessageCapab : IRCDMessage has_chghostmod = false; has_chgidentmod = false; has_svstopic_topiclock = false; - ircdproto->CanSVSHold = false; + IRCD->CanSVSHold = false; } else if (params[0].equals_cs("CHANMODES") && params.size() > 1) { @@ -275,7 +332,7 @@ struct IRCDMessageCapab : IRCDMessage else if (modename.equals_cs("servprotect")) { um = new UserMode(UMODE_PROTECTED, modechar[0]); - ircdproto->DefaultPseudoclientModes += "k"; + IRCD->DefaultPseudoclientModes += "k"; } else if (modename.equals_cs("showwhois")) um = new UserMode(UMODE_WHOIS, modechar[0]); @@ -302,7 +359,7 @@ struct IRCDMessageCapab : IRCDMessage while (ssep.GetToken(module)) { if (module.equals_cs("m_svshold.so")) - ircdproto->CanSVSHold = true; + IRCD->CanSVSHold = true; else if (module.find("m_rline.so") == 0) { has_rlinemod = true; @@ -392,7 +449,7 @@ struct IRCDMessageCapab : IRCDMessage else if (capab.find("MAXMODES=") != Anope::string::npos) { Anope::string maxmodes(capab.begin() + 9, capab.end()); - ircdproto->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3; + IRCD->MaxModes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3; } else if (capab.find("PREFIX=") != Anope::string::npos) { @@ -403,7 +460,7 @@ struct IRCDMessageCapab : IRCDMessage for (size_t t = 0, end = modes.length(); t < end; ++t) { ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[t]); - if (cm == NULL || cm->Type != MODE_STATUS) + if (cm == NULL || cm->type != MODE_STATUS) { Log() << "CAPAB PREFIX gave unknown channel status mode " << modes[t]; continue; @@ -420,18 +477,18 @@ struct IRCDMessageCapab : IRCDMessage if (!has_servicesmod) { UplinkSocket::Message() << "ERROR :m_services_account.so is not loaded. This is required by Anope"; - quitmsg = "ERROR: Remote server does not have the m_services_account module loaded, and this is required."; - quitting = true; + Anope::QuitReason = "ERROR: Remote server does not have the m_services_account module loaded, and this is required."; + Anope::Quitting = true; return false; } if (!ModeManager::FindUserModeByName(UMODE_PRIV)) { UplinkSocket::Message() << "ERROR :m_hidechans.so is not loaded. This is required by Anope"; - quitmsg = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required."; - quitting = true; + Anope::QuitReason = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required."; + Anope::Quitting = true; return false; } - if (!ircdproto->CanSVSHold) + if (!IRCD->CanSVSHold) Log() << "SVSHOLD missing, Usage disabled until module is loaded."; if (!has_chghostmod) Log() << "CHGHOST missing, Usage disabled until module is loaded."; @@ -441,15 +498,15 @@ struct IRCDMessageCapab : IRCDMessage Log() << "m_topiclock missing, server side topic locking disabled until module is loaded."; } - return true; + Servers::Capab.insert("NOQUIT"); + + return Message::Capab::Run(source, params); } }; struct IRCDMessageEncap : IRCDMessage { - Module *me; - - IRCDMessageEncap(Module *m) : IRCDMessage("ENCAP", 4), me(m) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 4) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -458,7 +515,7 @@ struct IRCDMessageEncap : IRCDMessage if (params[1] == "CHGIDENT") { - User *u = finduser(params[2]); + User *u = User::Find(params[2]); if (!u || u->server != Me) return true; @@ -467,7 +524,7 @@ struct IRCDMessageEncap : IRCDMessage } else if (params[1] == "CHGHOST") { - User *u = finduser(params[2]); + User *u = User::Find(params[2]); if (!u || u->server != Me) return true; @@ -476,7 +533,7 @@ struct IRCDMessageEncap : IRCDMessage } else if (params[1] == "CHGNAME") { - User *u = finduser(params[2]); + User *u = User::Find(params[2]); if (!u || u->server != Me) return true; @@ -502,7 +559,7 @@ struct IRCDMessageEncap : IRCDMessage { UplinkSocket::Message(Me) << "ENCAP " << this->uid.substr(0, 3) << " SASL " << Me->GetSID() << " " << this->uid << " " << " D F"; - Log(findbot(Config->NickServ)) << "A user failed to identify for account " << this->GetAccount() << " using SASL"; + Log(NickServ) << "A user failed to identify for account " << this->GetAccount() << " using SASL"; } }; @@ -534,7 +591,7 @@ struct IRCDMessageEncap : IRCDMessage if (acc.empty() || pass.empty()) return true; - IdentifyRequest *req = new InspIRCDSASLIdentifyRequest(me, params[2], acc, pass); + IdentifyRequest *req = new InspIRCDSASLIdentifyRequest(this->owner, params[2], acc, pass); FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(NULL, req)); req->Dispatch(); } @@ -546,7 +603,7 @@ struct IRCDMessageEncap : IRCDMessage struct IRCDMessageFIdent : IRCDMessage { - IRCDMessageFIdent() : IRCDMessage("FIDENT", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + IRCDMessageFIdent(Module *creator) : IRCDMessage(creator, "FIDENT", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -557,40 +614,31 @@ struct IRCDMessageFIdent : IRCDMessage class ProtoInspIRCd : public Module { + Module *m_insp12; + InspIRCd20Proto ircd_proto; /* Core message handlers */ - CoreIRCDMessageAway core_message_away; - CoreIRCDMessageCapab core_message_capab; - CoreIRCDMessageError core_message_error; - CoreIRCDMessageJoin core_message_join; - CoreIRCDMessageKick core_message_kick; - CoreIRCDMessageKill core_message_kill; - CoreIRCDMessageMOTD core_message_motd; - CoreIRCDMessagePart core_message_part; - CoreIRCDMessagePing core_message_ping; - CoreIRCDMessagePrivmsg core_message_privmsg; - CoreIRCDMessageQuit core_message_quit; - CoreIRCDMessageSQuit core_message_squit; - CoreIRCDMessageStats core_message_stats; - CoreIRCDMessageTopic core_message_topic; - CoreIRCDMessageVersion core_message_version; - - /* inspircd-ts6.h message handlers */ - IRCDMessageEndburst message_endburst; - IRCDMessageFHost message_fhost; - IRCDMessageFJoin message_sjoin; - IRCDMessageFMode message_fmode; - IRCDMessageFTopic message_ftopic; - IRCDMessageIdle message_idle; - IRCDMessageMetadata message_metadata; - IRCDMessageMode message_mode; - IRCDMessageNick message_nick; - IRCDMessageOperType message_opertype; - IRCDMessageRSQuit message_rsquit; - IRCDMessageServer message_server; - IRCDMessageTime message_time; - IRCDMessageUID message_uid; + Message::Away message_away; + Message::Error message_error; + Message::Join message_join; + Message::Kick message_kick; + Message::Kill message_kill; + Message::MOTD message_motd; + Message::Part message_part; + Message::Ping message_ping; + Message::Privmsg message_privmsg; + Message::Quit message_quit; + Message::SQuit message_squit; + Message::Stats message_stats; + Message::Topic message_topic; + Message::Version message_version; + + /* InspIRCd 1.2 message handlers */ + ServiceAlias message_endburst, message_fhost, message_sjoin, message_fmode, + message_ftopic, message_idle, message_metadata, message_mode, + message_nick, message_opertype, message_rsquit, message_server, + message_time, message_uid; /* Our message handlers */ IRCDMessageCapab message_capab; @@ -604,24 +652,51 @@ class ProtoInspIRCd : public Module public: ProtoInspIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL), - message_fhost("FHOST"), message_encap(this) + message_away(this), message_error(this), message_join(this), message_kick(this), message_kill(this), + message_motd(this), message_part(this), message_ping(this), message_privmsg(this), message_quit(this), + message_squit(this), message_stats(this), message_topic(this), message_version(this), + + message_endburst("IRCDMessage", "inspircd20/endburst", "inspircd12/endburst"), + message_fhost("IRCDMessage", "inspircd20/fhost", "inspircd12/fhost"), + message_sjoin("IRCDMessage", "inspircd20/sjoin", "inspircd12/sjoin"), + message_fmode("IRCDMessage", "inspircd20/mode", "inspircd12/fmode"), + message_ftopic("IRCDMessage", "inspircd20/ftopic", "inspircd12/ftopic"), + message_idle("IRCDMessage", "inspircd20/idle", "inspircd12/idle"), + message_metadata("IRCDMessage", "inspircd20/metadata", "inspircd12/metadata"), + message_mode("IRCDMessage", "inspircd20/mode", "inspircd12/mode"), + message_nick("IRCDMessage", "inspircd20/nick", "inspircd12/nick"), + message_opertype("IRCDMessage", "inspircd20/opertype", "inspircd12/opertype"), + message_rsquit("IRCDMessage", "inspircd20/rsquit", "inspircd12/rsquit"), + message_server("IRCDMessage", "inspircd20/server", "inspircd12/server"), + message_time("IRCDMessage", "inspircd20/time", "inspircd12/time"), + message_uid("IRCDMessage", "inspircd20/uid", "inspircd12/uid"), + + message_capab(this), message_encap(this), message_fident(this) { this->SetAuthor("Anope"); - Capab.insert("NOQUIT"); + if (ModuleManager::LoadModule("inspircd12", User::Find(creator)) != MOD_ERR_OK) + throw ModuleException("Unable to load inspircd12"); + m_insp12 = ModuleManager::FindModule("inspircd12"); + if (!m_insp12) + throw ModuleException("Unable to find inspircd12"); + insp12 = m_insp12->GetIRCDProto(); + if (!insp12) + throw ModuleException("No protocol interface for insp12"); + ModuleManager::DetachAll(m_insp12); Implementation i[] = { I_OnUserNickChange, I_OnServerSync, I_OnChannelCreate, I_OnChanRegistered, I_OnDelChan, I_OnMLock, I_OnUnMLock, I_OnSetChannelOption }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); + } - if (Config->Numeric.empty()) - { - Anope::string numeric = ts6_sid_retrieve(); - Me->SetSID(numeric); - Config->Numeric = numeric; - } + ~ProtoInspIRCd() + { + ModuleManager::UnloadModule(m_insp12, NULL); + } - for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) - it->second->GenerateUID(); + IRCDProto *GetIRCDProto() anope_override + { + return &ircd_proto; } void OnUserNickChange(User *u, const Anope::string &) anope_override @@ -631,13 +706,7 @@ class ProtoInspIRCd : public Module void OnServerSync(Server *s) anope_override { - if (nickserv) - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - { - User *u = it->second; - if (u->server == s && !u->IsIdentified()) - nickserv->Validate(u); - } + m_insp12->OnServerSync(s); } void OnChannelCreate(Channel *c) anope_override @@ -673,9 +742,9 @@ class ProtoInspIRCd : public Module EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override { ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name); - if (cm && ci->c && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM) && Config->UseServerSideMLock) + if (cm && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Config->UseServerSideMLock) { - Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->ModeChar; + Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->mchar; SendChannelMetadata(ci->c, "mlock", modes); } @@ -685,9 +754,9 @@ class ProtoInspIRCd : public Module EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override { ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name); - if (cm && ci->c && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM) && Config->UseServerSideMLock) + if (cm && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Config->UseServerSideMLock) { - Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->ModeChar, ""); + Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->mchar, ""); SendChannelMetadata(ci->c, "mlock", modes); } diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index f822922fa..28d534d2a 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -28,15 +28,15 @@ class ngIRCdProto : public IRCDProto void SendAkill(User *u, XLine *x) anope_override { // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) + time_t timeleft = x->expires - Anope::CurTime; + if (timeleft > 172800 || !x->expires) timeleft = 172800; - UplinkSocket::Message(Me) << "GLINE " << x->Mask << " " << timeleft << " :" << x->GetReason() << " (" << x->By << ")"; + UplinkSocket::Message(Me) << "GLINE " << x->mask << " " << timeleft << " :" << x->GetReason() << " (" << x->by << ")"; } void SendAkillDel(const XLine *x) anope_override { - UplinkSocket::Message(Me) << "GLINE " << x->Mask; + UplinkSocket::Message(Me) << "GLINE " << x->mask; } void SendChannel(Channel *c) anope_override @@ -53,7 +53,7 @@ class ngIRCdProto : public IRCDProto void SendConnect() anope_override { - UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " 0210-IRC+ Anope|" << Anope::VersionShort() << ":CLHMSo P"; + UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink]->password << " 0210-IRC+ Anope|" << Anope::VersionShort() << ":CLHMSo P"; /* Make myself known to myself in the serverlist */ SendServer(Me); /* finish the enhanced server handshake and register the connection */ @@ -95,11 +95,11 @@ class ngIRCdProto : public IRCDProto */ UserContainer *uc = c->FindUser(user); if (uc != NULL) - uc->Status->ClearFlags(); + uc->status->ClearFlags(); - BotInfo *setter = findbot(user->nick); + BotInfo *setter = BotInfo::Find(user->nick); for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) - if (cs.HasFlag(ModeManager::ChannelModes[i]->Name)) + if (cs.HasFlag(ModeManager::ChannelModes[i]->name)) c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); } } @@ -176,7 +176,7 @@ class ngIRCdProto : public IRCDProto struct IRCDMessage005 : IRCDMessage { - IRCDMessage005() : IRCDMessage("005", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessage005(Module *creator) : IRCDMessage(creator, "005", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } // Please see <http://www.irc.org/tech_docs/005.html> for details. bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override @@ -193,7 +193,7 @@ struct IRCDMessage005 : IRCDMessage if (parameter == "MODES") { unsigned maxmodes = convertTo<unsigned>(data); - ircdproto->MaxModes = maxmodes; + IRCD->MaxModes = maxmodes; } else if (parameter == "NICKLEN") { @@ -212,7 +212,7 @@ struct IRCDMessage005 : IRCDMessage struct IRCDMessage376 : IRCDMessage { - IRCDMessage376() : IRCDMessage("376", 2) { } + IRCDMessage376(Module *creator) : IRCDMessage(creator, "376", 2) { } /* * :ngircd.dev.anope.de 376 services.anope.de :End of MOTD command @@ -230,7 +230,7 @@ struct IRCDMessage376 : IRCDMessage struct IRCDMessageChaninfo : IRCDMessage { - IRCDMessageChaninfo() : IRCDMessage("CHANINFO", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageChaninfo(Module *creator) : IRCDMessage(creator, "CHANINFO", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } /* * CHANINFO is used by servers to inform each other about a channel: its @@ -252,7 +252,7 @@ struct IRCDMessageChaninfo : IRCDMessage bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); if (!c) c = new Channel(params[0]); @@ -284,9 +284,9 @@ struct IRCDMessageChaninfo : IRCDMessage } }; -struct IRCDMessageJoin : IRCDMessage +struct IRCDMessageJoin : Message::Join { - IRCDMessageJoin() : IRCDMessage("JOIN", 1) { } + IRCDMessageJoin(Module *creator) : Message::Join(creator, "JOIN") { } /* * <@po||ux> DukeP: RFC 2813, 4.2.1: the JOIN command on server-server links @@ -296,7 +296,6 @@ struct IRCDMessageJoin : IRCDMessage */ bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Channel *chan; User *user = source.GetUser(); size_t pos = params[0].find('\7'); Anope::string channel, modes; @@ -311,41 +310,16 @@ struct IRCDMessageJoin : IRCDMessage channel = params[0]; } - chan = findchan(channel); - /* Channel doesn't exist, create it */ - if (!chan) - { - chan = new Channel(channel, Anope::CurTime); - chan->SetFlag(CH_SYNCING); - } - - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(user, chan)); + std::vector<Anope::string> new_params; + new_params.push_back(channel); - /* Join the user to the channel */ - chan->JoinUser(user); + Message::Join::Run(source, new_params); if (!modes.empty()) - chan->SetModesInternal(source, modes); - - /* Set the proper modes on the user */ - chan_set_correct_modes(user, chan, 1, true); - - /* Modules may want to allow this user in the channel, check. - * If not, CheckKick will kick/ban them, don't call OnJoinChannel after this as the user will have - * been destroyed - */ - if (MOD_RESULT != EVENT_STOP && (!chan->ci || !chan->ci->CheckKick(user))) - { - FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(user, chan)); - } - - /* Channel is done syncing */ - if (chan->HasFlag(CH_SYNCING)) { - /* Unset the syncing flag */ - chan->UnsetFlag(CH_SYNCING); - chan->Sync(); + Channel *c = Channel::Find(channel); + if (c) + c->SetModesInternal(source, modes); } return true; @@ -395,7 +369,7 @@ struct IRCDMessageMetadata : IRCDMessage struct IRCDMessageMode : IRCDMessage { - IRCDMessageMode() : IRCDMessage("MODE", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageMode(Module *creator) : IRCDMessage(creator, "MODE", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } /* * Received: :DukeP MODE #anope +b *!*@*.aol.com @@ -412,16 +386,16 @@ struct IRCDMessageMode : IRCDMessage for (size_t i = 2; i < params.size(); ++i) modes += " " + params[i]; - if (ircdproto->IsChannelValid(params[0])) + if (IRCD->IsChannelValid(params[0])) { - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); if (c) c->SetModesInternal(source, modes); } else { - User *u = finduser(params[0]); + User *u = User::Find(params[0]); if (u) u->SetModesInternal("%s", params[1].c_str()); @@ -432,7 +406,7 @@ struct IRCDMessageMode : IRCDMessage struct IRCDMessageNick : IRCDMessage { - IRCDMessageNick() : IRCDMessage("NICK", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 1) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } /* * NICK - NEW @@ -464,8 +438,8 @@ struct IRCDMessageNick : IRCDMessage { // a new user is connecting to the network User *user = new User(params[0], params[2], params[3], "", "", source.GetServer(), params[6], Anope::CurTime, params[5], ""); - if (user && nickserv) - nickserv->Validate(user); + if (user && NickServService) + NickServService->Validate(user); } else { @@ -477,7 +451,7 @@ struct IRCDMessageNick : IRCDMessage struct IRCDMessageNJoin : IRCDMessage { - IRCDMessageNJoin() : IRCDMessage("NJOIN",2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }; + IRCDMessageNJoin(Module *creator) : IRCDMessage(creator, "NJOIN",2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }; /* * RFC 2813, 4.2.2: Njoin Message: @@ -492,76 +466,46 @@ struct IRCDMessageNJoin : IRCDMessage */ bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Channel *c = findchan(params[0]); + std::list<Message::Join::SJoinUser> users; + commasepstream sep(params[1]); Anope::string buf; - - if (!c) - { - c = new Channel(params[0], Anope::CurTime); - c->SetFlag(CH_SYNCING); - } - while (sep.GetToken(buf)) { - std::list<ChannelMode *> Status; - char ch; + + Message::Join::SJoinUser sju; /* Get prefixes from the nick */ - while ((ch = ModeManager::GetStatusChar(buf[0]))) + for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) { - buf.erase(buf.begin()); ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); + buf.erase(buf.begin()); if (!cm) { Log(LOG_DEBUG) << "Received unknown mode prefix " << ch << " in NJOIN string."; continue; } - Status.push_back(cm); + + sju.first.SetFlag(cm->name); } - User *u = finduser(buf); - if (!u) + + sju.second = User::Find(buf); + if (!sju.second) { - Log(LOG_DEBUG) << "NJOIN for nonexistant user " << buf << " on " << c->name; + Log(LOG_DEBUG) << "NJOIN for nonexistant user " << buf << " on " << params[0]; continue; } + } - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); + Message::Join::SJoin(source, params[0], 0, "", users); - /* Add the user to the Channel */ - c->JoinUser(u); - - /* Update their status internally on the channel - * This will enforce secureops etc on the user - */ - for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it) - c->SetModeInternal(source, *it, buf); - /* Now set whatever modes this user is allowed to have on the channel */ - chan_set_correct_modes(u, c, 1, true); - - /* Check to see if modules want the user to join, if they do - * check to see if they are allowed to join (CheckKick will kick/ban them) - * Don't trigger OnJoinChannel event then as the user will be destroyed - */ - if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u)) - continue; - - FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); - } /* while */ - - if (c->HasFlag(CH_SYNCING)) - { - c->UnsetFlag(CH_SYNCING); - c->Sync(); - } return true; } }; struct IRCDMessagePong : IRCDMessage { - IRCDMessagePong() : IRCDMessage("PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessagePong(Module *creator) : IRCDMessage(creator, "PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } /* * ngIRCd does not send an EOB, so we send a PING immediately @@ -578,7 +522,7 @@ struct IRCDMessagePong : IRCDMessage struct IRCDMessageServer : IRCDMessage { - IRCDMessageServer() : IRCDMessage("SERVER", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } /* * SERVER tolsun.oulu.fi 1 :Experimental server @@ -624,19 +568,19 @@ struct IRCDMessageServer : IRCDMessage * when receiving a new server and then finish sync once we * get a pong back from that server. */ - ircdproto->SendPing(Config->ServerName, params[0]); + IRCD->SendPing(Config->ServerName, params[0]); return true; } }; struct IRCDMessageTopic : IRCDMessage { - IRCDMessageTopic() : IRCDMessage("TOPIC", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageTopic(Module *creator) : IRCDMessage(creator, "TOPIC", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } // Received: :DukeP TOPIC #anope :test bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); if (!c) { Log(LOG_DEBUG) << "TOPIC for nonexistant channel " << params[0]; @@ -654,19 +598,19 @@ class ProtongIRCd : public Module ngIRCdProto ircd_proto; /* Core message handlers */ - CoreIRCDMessageCapab core_message_capab; - CoreIRCDMessageError core_message_error; - CoreIRCDMessageKick core_message_kick; - CoreIRCDMessageKill core_message_kill; - CoreIRCDMessageMOTD core_message_motd; - CoreIRCDMessagePart core_message_part; - CoreIRCDMessagePing core_message_ping; - CoreIRCDMessagePrivmsg core_message_privmsg, core_message_squery; - CoreIRCDMessageQuit core_message_quit; - CoreIRCDMessageSQuit core_message_squit; - CoreIRCDMessageStats core_message_stats; - CoreIRCDMessageTime core_message_time; - CoreIRCDMessageVersion core_message_version; + Message::Capab message_capab; + Message::Error message_error; + Message::Kick message_kick; + Message::Kill message_kill; + Message::MOTD message_motd; + Message::Part message_part; + Message::Ping message_ping; + Message::Privmsg message_privmsg, message_squery; + Message::Quit message_quit; + Message::SQuit message_squit; + Message::Stats message_stats; + Message::Time message_time; + Message::Version message_version; /* Our message handlers */ IRCDMessage005 message_005; @@ -728,11 +672,17 @@ class ProtongIRCd : public Module public: ProtongIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL), - core_message_squery("SQUERY") + message_capab(this), message_error(this), message_kick(this), message_kill(this), message_motd(this), + message_part(this), message_ping(this), message_privmsg(this), message_squery(this, "SQUERY"), + message_quit(this), message_squit(this), message_stats(this), message_time(this), message_version(this), + + message_005(this), message_376(this), message_chaninfo(this), message_join(this), message_mode(this), + message_nick(this), message_njoin(this), message_pong(this), message_server(this), message_topic(this) + { this->SetAuthor("Anope"); - Capab.insert("QS"); + Servers::Capab.insert("QS"); this->AddModes(); @@ -740,6 +690,11 @@ class ProtongIRCd : public Module ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } + IRCDProto *GetIRCDProto() anope_override + { + return &ircd_proto; + } + void OnUserNickChange(User *u, const Anope::string &) anope_override { u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED)); diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index 432cc3c02..53efdbd88 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -12,6 +12,7 @@ #include "module.h" static Anope::string UplinkSID; +static IRCDProto *hybrid; class PlexusProto : public IRCDProto { @@ -31,51 +32,17 @@ class PlexusProto : public IRCDProto MaxModes = 4; } - void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override - { - UplinkSocket::Message(bi) << "NOTICE $$" << dest->GetName() << " :" << msg; - } - - void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override - { - UplinkSocket::Message(bi) << "PRIVMSG $$" << dest->GetName() << " :" << msg; - } - - void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override - { - UplinkSocket::Message(source) << "OPERWALL :" << buf; - } - - void SendSQLine(User *, const XLine *x) anope_override - { - UplinkSocket::Message(Me) << "RESV * " << x->Mask << " :" << x->GetReason(); - } - - void SendSGLineDel(const XLine *x) anope_override - { - const BotInfo *bi = findbot(Config->OperServ); - UplinkSocket::Message(bi) << "UNXLINE * " << x->Mask; - } - - void SendSGLine(User *, const XLine *x) anope_override - { - const BotInfo *bi = findbot(Config->OperServ); - UplinkSocket::Message(bi) << "XLINE * " << x->Mask << " 0 :" << x->GetReason(); - } - - void SendAkillDel(const XLine *x) anope_override - { - if (x->IsRegex() || x->HasNickOrReal()) - return; - - const BotInfo *bi = findbot(Config->OperServ); - UplinkSocket::Message(bi) << "UNKLINE * " << x->GetUser() << " " << x->GetHost(); - } - - void SendSQLineDel(const XLine *x) anope_override - { - UplinkSocket::Message(Me) << "UNRESV * " << x->Mask; - } + void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalNotice(bi, dest, msg); } + void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } + void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override { hybrid->SendGlobopsInternal(source, buf); } + void SendSQLine(User *u, const XLine *x) anope_override { hybrid->SendSQLine(u, x); } + void SendSQLineDel(const XLine *x) anope_override { hybrid->SendSQLineDel(x); } + void SendSGLineDel(const XLine *x) anope_override { hybrid->SendSGLineDel(x); } + void SendSGLine(User *u, const XLine *x) anope_override { hybrid->SendSGLine(u, x); } + void SendAkillDel(const XLine *x) anope_override { hybrid->SendAkillDel(x); } + void SendAkill(User *u, XLine *x) anope_override { hybrid->SendAkill(u, x); } + void SendServer(const Server *server) anope_override { hybrid->SendServer(server); } + void SendChannel(Channel *c) anope_override { hybrid->SendChannel(c); } void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override { @@ -89,82 +56,38 @@ class PlexusProto : public IRCDProto */ UserContainer *uc = c->FindUser(user); if (uc != NULL) - uc->Status->ClearFlags(); + uc->status->ClearFlags(); - BotInfo *setter = findbot(user->nick); + BotInfo *setter = BotInfo::Find(user->nick); for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) - if (cs.HasFlag(ModeManager::ChannelModes[i]->Name)) + if (cs.HasFlag(ModeManager::ChannelModes[i]->name)) c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); } } - void SendAkill(User *u, XLine *x) anope_override - { - const BotInfo *bi = findbot(Config->OperServ); - - if (x->IsRegex() || x->HasNickOrReal()) - { - if (!u) - { - /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */ - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - if (x->manager->Check(it->second, x)) - this->SendAkill(it->second, x); - return; - } - - const XLine *old = x; - - if (old->manager->HasEntry("*@" + u->host)) - return; - - /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - XLine *xline = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID); - old->manager->AddXLine(xline); - x = xline; - - Log(bi, "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->Mask; - } - - // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) - timeleft = 172800; - UplinkSocket::Message(bi) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason(); - } - - void SendServer(const Server *server) anope_override + void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when) anope_override { - if (server == Me) - UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription(); - else - UplinkSocket::Message(Me) << "SID " << server->GetName() << " " << server->GetHops() << " " << server->GetSID() << " :" << server->GetDescription(); + UplinkSocket::Message(Me) << "ENCAP " << u->server->GetName() << " SVSNICK " << u->GetUID() << " " << u->timestamp << " " << newnick << " " << when; } - void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when) anope_override + void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) anope_override { - UplinkSocket::Message(Me) << "ENCAP " << u->server->GetName() << " SVSNICK " << u->GetUID() << " " << u->timestamp << " " << newnick << " " << when; + if (!ident.empty()) + UplinkSocket::Message(Me) << "ENCAP * CHGIDENT " << u->GetUID() << " " << ident; + UplinkSocket::Message(Me) << "ENCAP * CHGHOST " << u->GetUID() << " " << host; } void SendVhostDel(User *u) anope_override { - const BotInfo *bi = findbot(Config->HostServ); if (u->HasMode(UMODE_CLOAK)) - u->RemoveMode(bi, UMODE_CLOAK); + u->RemoveMode(HostServ, UMODE_CLOAK); else this->SendVhost(u, u->GetIdent(), u->chost); } - void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) anope_override - { - if (!ident.empty()) - UplinkSocket::Message(Me) << "ENCAP * CHGIDENT " << u->GetUID() << " " << ident; - UplinkSocket::Message(Me) << "ENCAP * CHGHOST " << u->GetUID() << " " << host; - } - void SendConnect() anope_override { - UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " TS 6 :" << Me->GetSID(); + UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink]->password << " TS 6 :" << Me->GetSID(); /* CAPAB * QS - Can handle quit storm removal * EX - Can do channel +e exemptions @@ -227,53 +150,11 @@ class PlexusProto : public IRCDProto { UplinkSocket::Message(bi) << "ENCAP * TOPIC " << c->name << " " << c->topic_setter << " " << c->topic_ts << " :" << c->topic; } - - void SendChannel(Channel *c) anope_override - { - Anope::string modes = c->GetModes(true, true); - if (modes.empty()) - modes = "+"; - UplinkSocket::Message(Me) << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :"; - } -}; - -struct IRCDMessageBMask : IRCDMessage -{ - IRCDMessageBMask() : IRCDMessage("BMASK", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - /* :42X BMASK 1106409026 #ircops b :*!*@*.aol.com */ - /* 0 1 2 3 */ - Channel *c = findchan(params[1]); - - if (c) - { - ChannelMode *ban = ModeManager::FindChannelModeByName(CMODE_BAN), - *except = ModeManager::FindChannelModeByName(CMODE_EXCEPT), - *invex = ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE); - - Anope::string bans = params[3]; - int count = myNumToken(bans, ' '), i; - for (i = 0; i < count; ++i) - { - Anope::string b = myStrGetToken(bans, ' ', i); - if (ban && params[2].equals_cs("b")) - c->SetModeInternal(source, ban, b); - else if (except && params[2].equals_cs("e")) - c->SetModeInternal(source, except, b); - if (invex && params[2].equals_cs("I")) - c->SetModeInternal(source, invex, b); - } - } - - return true; - } }; struct IRCDMessageEncap : IRCDMessage { - IRCDMessageEncap() : IRCDMessage("ENCAP", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -286,14 +167,14 @@ struct IRCDMessageEncap : IRCDMessage */ if (params[1].equals_cs("SU")) { - User *u = finduser(params[2]); - const NickAlias *user_na = findnick(params[2]); - NickCore *nc = findcore(params[3]); + User *u = User::Find(params[2]); + const NickAlias *user_na = NickAlias::Find(params[2]); + NickCore *nc = NickCore::Find(params[3]); if (u && nc) { u->Login(nc); if (!Config->NoNicknameOwnership && user_na && user_na->nc == nc && user_na->nc->HasFlag(NI_UNCONFIRMED) == false) - u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); + u->SetMode(NickServ, UMODE_REGISTERED); } } @@ -306,7 +187,7 @@ struct IRCDMessageEncap : IRCDMessage */ else if (params[1].equals_cs("CERTFP")) { - User *u = finduser(params[2]); + User *u = User::Find(params[2]); if (u) { u->fingerprint = params[3]; @@ -317,82 +198,9 @@ struct IRCDMessageEncap : IRCDMessage } }; -struct IRCDMessageEOB : IRCDMessage -{ - IRCDMessageEOB() : IRCDMessage("EOB", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - source.GetServer()->Sync(true); - return true; - } -}; - -struct IRCDMessageJoin : CoreIRCDMessageJoin -{ - IRCDMessageJoin() : CoreIRCDMessageJoin("JOIN") { } - - /* - * params[0] = ts - * params[1] = channel - */ - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - if (params.size() < 2) - return true; - - std::vector<Anope::string> p = params; - p.erase(p.begin()); - - return CoreIRCDMessageJoin::Run(source, p); - } -}; - -struct IRCDMessageMode : IRCDMessage -{ - IRCDMessageMode() : IRCDMessage("MODE", 3) { } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - if (ircdproto->IsChannelValid(params[0])) - { - // 0 = channel, 1 = ts, 2 = modes - Channel *c = findchan(params[0]); - time_t ts = 0; - try - { - ts = convertTo<time_t>(params[1]); - } - catch (const ConvertException &) { } - - if (c) - c->SetModesInternal(source, params[2], ts); - } - else - { - User *u = finduser(params[0]); - if (u) - u->SetModesInternal("%s", params[1].c_str()); - } - - return true; - } -}; - -struct IRCDMessageNick : IRCDMessage -{ - IRCDMessageNick() : IRCDMessage("NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - source.GetUser()->ChangeNick(params[0]); - return true; - } -}; - struct IRCDMessagePass : IRCDMessage { - IRCDMessagePass() : IRCDMessage("PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessagePass(Module *creator) : IRCDMessage(creator, "PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -403,206 +211,25 @@ struct IRCDMessagePass : IRCDMessage struct IRCDMessageServer : IRCDMessage { - IRCDMessageServer() : IRCDMessage("SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + /* 0 1 2 */ + /* SERVER hades.arpa 1 :ircd-hybrid test server */ bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - // Servers other then our immediate uplink are introduced via SID + /* Servers other than our immediate uplink are introduced via SID */ if (params[1] != "1") return true; - new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); - return true; - } -}; - -struct IRCDMessageSID : IRCDMessage -{ - IRCDMessageSID() : IRCDMessage("SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - - /* :42X SID trystan.nomadirc.net 2 43X :ircd-plexus test server */ - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - unsigned int hops = params[1].is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0; - new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[3], params[2]); - return true; - } -}; - -struct IRCDMessageSJoin : IRCDMessage -{ - IRCDMessageSJoin() : IRCDMessage("SJOIN", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - Channel *c = findchan(params[1]); - time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0; - bool keep_their_modes = true; - - if (!c) - { - c = new Channel(params[1], ts); - c->SetFlag(CH_SYNCING); - } - /* Our creation time is newer than what the server gave us */ - else if (c->creation_time > ts) - { - c->creation_time = ts; - c->Reset(); - } - /* Their TS is newer than ours, our modes > theirs, unset their modes if need be */ - else if (ts > c->creation_time) - keep_their_modes = false; - - /* If we need to keep their modes, and this SJOIN string contains modes */ - if (keep_their_modes && params.size() >= 3) - { - Anope::string modes; - for (unsigned i = 2; i < params.size() - 1; ++i) - modes += " " + params[i]; - if (!modes.empty()) - modes.erase(modes.begin()); - /* Set the modes internally */ - c->SetModesInternal(source, modes); - } - - spacesepstream sep(params[params.size() - 1]); - Anope::string buf; - while (sep.GetToken(buf)) - { - std::list<ChannelMode *> Status; - char ch; - - /* Get prefixes from the nick */ - while ((ch = ModeManager::GetStatusChar(buf[0]))) - { - buf.erase(buf.begin()); - ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); - if (!cm) - { - Log() << "Received unknown mode prefix " << ch << " in SJOIN string"; - continue; - } - - if (keep_their_modes) - Status.push_back(cm); - } - - User *u = finduser(buf); - if (!u) - { - Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; - continue; - } - - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); - - /* Add the user to the channel */ - c->JoinUser(u); - - /* Update their status internally on the channel - * This will enforce secureops etc on the user - */ - for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it) - c->SetModeInternal(source, *it, buf); - - /* Now set whatever modes this user is allowed to have on the channel */ - chan_set_correct_modes(u, c, 1, true); - - /* Check to see if modules want the user to join, if they do - * check to see if they are allowed to join (CheckKick will kick/ban them) - * Don't trigger OnJoinChannel event then as the user will be destroyed - */ - if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u)) - continue; - - FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); - } - - /* Channel is done syncing */ - if (c->HasFlag(CH_SYNCING)) - { - /* Unset the syncing flag */ - c->UnsetFlag(CH_SYNCING); - c->Sync(); - } - return true; - } -}; - -struct IRCDMessageTBurst : IRCDMessage -{ - IRCDMessageTBurst() : IRCDMessage("TBURST", 5) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - // 0 1 2 3 4 - // :rizon.server TBURST 1298674830 #lol 1298674833 Adam!Adam@i.has.a.spoof :lol - // chan ts topic ts - - Channel *c = findchan(params[1]); - - try - { - if (!c || c->creation_time < convertTo<time_t>(params[0])) - return true; - } - catch (const ConvertException &) - { - return true; - } - - Anope::string setter = myStrGetToken(params[3], '!', 0); - time_t topic_time = Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime; - c->ChangeTopicInternal(setter, params.size() > 4 ? params[4] : "", topic_time); - - return true; - } -}; - -struct IRCDMessageTMode : IRCDMessage -{ - IRCDMessageTMode() : IRCDMessage("TMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - time_t ts = 0; - try - { - ts = convertTo<time_t>(params[0]); - } - catch (const ConvertException &) { } - Channel *c = findchan(params[1]); - Anope::string modes = params[2]; - for (unsigned i = 3; i < params.size(); ++i) - modes += " " + params[i]; - - if (c) - c->SetModesInternal(source, modes, ts); - - return true; - } -}; - -struct IRCDMessageTopic : IRCDMessage -{ - IRCDMessageTopic() : IRCDMessage("TOPIC", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - Channel *c = findchan(params[0]); - if (!c) - return true; + new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); - c->ChangeTopicInternal(params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime); return true; } }; struct IRCDMessageUID : IRCDMessage { - IRCDMessageUID() : IRCDMessage("UID", 11) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 11) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } /* params[0] = nick @@ -628,12 +255,12 @@ struct IRCDMessageUID : IRCDMessage User *user = new User(params[0], params[4], params[9], params[5], ip, source.GetServer(), params[10], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[3], params[7]); if (params[8] != "0" && params[8].is_pos_number_only() && convertTo<time_t>(params[8]) == user->timestamp) { - NickAlias *na = findnick(user->nick); + NickAlias *na = NickAlias::Find(user->nick); if (na) user->Login(na->nc); } - else if (user && user->server->IsSynced() && nickserv) - nickserv->Validate(user); + else if (user && user->server->IsSynced() && NickServService) + NickServService->Validate(user); return true; } @@ -641,127 +268,117 @@ struct IRCDMessageUID : IRCDMessage class ProtoPlexus : public Module { + Module *m_hybrid; + PlexusProto ircd_proto; /* Core message handlers */ - CoreIRCDMessageAway core_message_away; - CoreIRCDMessageCapab core_message_capab; - CoreIRCDMessageError core_message_error; - CoreIRCDMessageKick core_message_kick; - CoreIRCDMessageKill core_message_kill; - CoreIRCDMessageMOTD core_message_motd; - CoreIRCDMessagePart core_message_part; - CoreIRCDMessagePing core_message_ping; - CoreIRCDMessagePrivmsg core_message_privmsg; - CoreIRCDMessageQuit core_message_quit; - CoreIRCDMessageSQuit core_message_squit; - CoreIRCDMessageStats core_message_stats; - CoreIRCDMessageTime core_message_time; - CoreIRCDMessageTopic core_message_topic; - CoreIRCDMessageVersion core_message_version; - CoreIRCDMessageWhois core_message_whois; + Message::Away message_away; + Message::Capab message_capab; + Message::Error message_error; + Message::Kick message_kick; + Message::Kill message_kill; + Message::Mode message_mode; + Message::MOTD message_motd; + Message::Part message_part; + Message::Ping message_ping; + Message::Privmsg message_privmsg; + Message::Quit message_quit; + Message::SQuit message_squit; + Message::Stats message_stats; + Message::Time message_time; + Message::Topic message_topic; + Message::Version message_version; + Message::Whois message_whois; + + /* Hybrid message handlers */ + ServiceAlias message_bmask, message_eob, message_join, message_nick, message_sid, message_sjoin, + message_tburst, message_tmode; /* Our message handlers */ - IRCDMessageBMask message_bmask; IRCDMessageEncap message_encap; - IRCDMessageEOB message_eob; - IRCDMessageJoin message_join; - IRCDMessageMode message_mode; - IRCDMessageNick message_nick; IRCDMessagePass message_pass; IRCDMessageServer message_server; - IRCDMessageSID message_sid; - IRCDMessageSJoin message_sjoin; - IRCDMessageTBurst message_tburst; - IRCDMessageTMode message_tmode; - IRCDMessageTopic message_topic; IRCDMessageUID message_uid; void AddModes() { /* Add user modes */ - ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, 'a')); - ModeManager::AddUserMode(new UserMode(UMODE_INVIS, 'i')); - ModeManager::AddUserMode(new UserMode(UMODE_OPER, 'o')); - ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, 's')); - ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, 'w')); + ModeManager::RemoveUserMode(ModeManager::FindUserModeByName(UMODE_HIDEOPER)); ModeManager::AddUserMode(new UserMode(UMODE_NOCTCP, 'C')); ModeManager::AddUserMode(new UserMode(UMODE_DEAF, 'D')); ModeManager::AddUserMode(new UserMode(UMODE_SOFTCALLERID, 'G')); ModeManager::AddUserMode(new UserMode(UMODE_NETADMIN, 'N')); - ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, 'R')); ModeManager::AddUserMode(new UserMode(UMODE_SSL, 'S')); ModeManager::AddUserMode(new UserMode(UMODE_WEBIRC, 'W')); ModeManager::AddUserMode(new UserMode(UMODE_CALLERID, 'g')); ModeManager::AddUserMode(new UserMode(UMODE_PRIV, 'p')); - ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, 'r')); ModeManager::AddUserMode(new UserMode(UMODE_CLOAK, 'x')); ModeManager::AddUserMode(new UserMode(UMODE_PROTECTED, 'U')); - /* b/e/I */ - ModeManager::AddChannelMode(new ChannelModeList(CMODE_BAN, 'b')); - ModeManager::AddChannelMode(new ChannelModeList(CMODE_EXCEPT, 'e')); - ModeManager::AddChannelMode(new ChannelModeList(CMODE_INVITEOVERRIDE, 'I')); - - /* l/k */ - ModeManager::AddChannelMode(new ChannelModeKey('k')); - ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, 'l')); - /* v/h/o/a/q */ - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, 'v', '+', 0)); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_HALFOP, 'h', '%', 1)); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, 'o', '@', 2)); ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_PROTECT, 'a', '&', 3)); ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OWNER, 'q', '~', 4)); /* Add channel modes */ + ModeManager::RemoveChannelMode(ModeManager::FindChannelModeByName(CMODE_REGISTERED)); ModeManager::AddChannelMode(new ChannelMode(CMODE_BANDWIDTH, 'B')); ModeManager::AddChannelMode(new ChannelMode(CMODE_NOCTCP, 'C')); ModeManager::AddChannelMode(new ChannelMode(CMODE_REGMODERATED, 'M')); ModeManager::AddChannelMode(new ChannelMode(CMODE_NONOTICE, 'N')); - ModeManager::AddChannelMode(new ChannelModeOper('O')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_REGISTEREDONLY, 'R')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_SSL, 'S')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_BLOCKCOLOR, 'c')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, 'i')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, 'm')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, 'n')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, 'p')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, 's')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, 't')); ModeManager::AddChannelMode(new ChannelMode(CMODE_PERM, 'z')); } public: - ProtoPlexus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL) + ProtoPlexus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL), + message_away(this), message_capab(this), message_error(this), message_kick(this), message_kill(this), + message_mode(this), message_motd(this), message_part(this), message_ping(this), message_privmsg(this), message_quit(this), + message_squit(this), message_stats(this), message_time(this), message_topic(this), message_version(this), message_whois(this), + + message_bmask("IRCDMessage", "plexus/bmask", "hybrid/bmask"), message_eob("IRCDMessage", "plexus/eob", "hybrid/eob"), + message_join("IRCDMessage", "plexus/join", "hybrid/join"), message_nick("IRCDMessage", "plexus/nick", "hybrid/nick"), + message_sid("IRCDMessage", "plexus/sid", "hybrid/sid"), + message_sjoin("IRCDMessage", "plexus/sjoin", "hybrid/sjoin"), message_tburst("IRCDMessage", "plexus/tburst", "hybrid/tburst"), + message_tmode("IRCDMessage", "plexus/tmode", "hybrid/tmode"), + + message_encap(this), message_pass(this), message_server(this), message_uid(this) { this->SetAuthor("Anope"); + if (ModuleManager::LoadModule("hybrid", User::Find(creator)) != MOD_ERR_OK) + throw ModuleException("Unable to load hybrid"); + m_hybrid = ModuleManager::FindModule("hybrid"); + if (!m_hybrid) + throw ModuleException("Unable to find hybrid"); + hybrid = m_hybrid->GetIRCDProto(); + if (!hybrid) + throw ModuleException("No protocol interface for hybrid"); + this->AddModes(); Implementation i[] = { I_OnServerSync }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); + } - if (Config->Numeric.empty()) - { - Anope::string numeric = ts6_sid_retrieve(); - Me->SetSID(numeric); - Config->Numeric = numeric; - } + ~ProtoPlexus() + { + ModuleManager::UnloadModule(m_hybrid, NULL); + } - for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) - it->second->GenerateUID(); + IRCDProto *GetIRCDProto() anope_override + { + return &ircd_proto; } void OnServerSync(Server *s) anope_override { - if (nickserv) + if (NickServService) for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { User *u = it->second; if (u->server == s && !u->IsIdentified()) - nickserv->Validate(u); + NickServService->Validate(u); } } }; diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index 3ae4b6e17..32226fae7 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -12,6 +12,7 @@ #include "module.h" static Anope::string UplinkSID; +static IRCDProto *hybrid; class RatboxProto : public IRCDProto { @@ -26,112 +27,24 @@ class RatboxProto : public IRCDProto MaxModes = 4; } - void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override - { - UplinkSocket::Message(bi) << "NOTICE $$" << dest->GetName() << " :" << msg; - } - - void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override - { - UplinkSocket::Message(bi) << "PRIVMSG $$" << dest->GetName() << " :" << msg; - } - - void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override - { - UplinkSocket::Message(source) << "OPERWALL :" << buf; - } - - void SendSQLine(User *, const XLine *x) anope_override - { - UplinkSocket::Message(Me) << "RESV * " << x->Mask << " :" << x->GetReason(); - } - - void SendSGLineDel(const XLine *x) anope_override - { - const BotInfo *bi = findbot(Config->OperServ); - UplinkSocket::Message(bi) << "UNXLINE * " << x->Mask; - } - - void SendSGLine(User *, const XLine *x) anope_override - { - const BotInfo *bi = findbot(Config->OperServ); - UplinkSocket::Message(bi) << "XLINE * " << x->Mask << " 0 :" << x->GetReason(); - } - - void SendAkillDel(const XLine *x) anope_override - { - if (x->IsRegex() || x->HasNickOrReal()) - return; - - const BotInfo *bi = findbot(Config->OperServ); - UplinkSocket::Message(bi) << "UNKLINE * " << x->GetUser() << " " << x->GetHost(); - } - - void SendSQLineDel(const XLine *x) anope_override - { - UplinkSocket::Message(Me) << "UNRESV * " << x->Mask; - } - - void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override - { - /* Note that we must send our modes with the SJOIN and - * can not add them to the mode stacker because ratbox - * does not allow *any* client to op itself - */ - UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " +" << c->GetModes(true, true) << " :" << (status != NULL ? status->BuildModePrefixList() : "") << user->GetUID(); - /* And update our internal status for this user since this is not going through our mode handling system */ - if (status != NULL) - { - UserContainer *uc = c->FindUser(user); - if (uc != NULL) - *uc->Status = *status; - } - } - - void SendAkill(User *u, XLine *x) anope_override - { - const BotInfo *bi = findbot(Config->OperServ); - - if (x->IsRegex() || x->HasNickOrReal()) - { - if (!u) - { - /* No user (this akill was just added), and contains nick and/or realname. Find users that match and ban them */ - for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - if (x->manager->Check(it->second, x)) - this->SendAkill(it->second, x); - return; - } - - const XLine *old = x; - - if (old->manager->HasEntry("*@" + u->host)) - return; - - /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - XLine *xline = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID); - old->manager->AddXLine(xline); - x = xline; - - Log(bi, "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->Mask; - } - - // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) - timeleft = 172800; - UplinkSocket::Message(bi) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason(); - } - - /* SERVER name hop descript */ - void SendServer(const Server *server) anope_override - { - UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription(); - } + void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalNotice(bi, dest, msg); } + void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { hybrid->SendGlobalPrivmsg(bi, dest, msg); } + void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override { hybrid->SendGlobopsInternal(source, buf); } + void SendSQLine(User *u, const XLine *x) anope_override { hybrid->SendSQLine(u, x); } + void SendSGLine(User *u, const XLine *x) anope_override { hybrid->SendSGLine(u, x); } + void SendSGLineDel(const XLine *x) anope_override { hybrid->SendSGLineDel(x); } + void SendAkill(User *u, XLine *x) anope_override { hybrid->SendAkill(u, x); } + void SendAkillDel(const XLine *x) anope_override { hybrid->SendAkillDel(x); } + void SendSQLineDel(const XLine *x) anope_override { hybrid->SendSQLineDel(x); } + void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override { hybrid->SendJoin(user, c, status); } + void SendServer(const Server *server) anope_override { hybrid->SendServer(server); } + void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override { hybrid->SendModeInternal(bi, u, buf); } + void SendChannel(Channel *c) anope_override { hybrid->SendChannel(c); } + void SendTopic(BotInfo *bi, Channel *c) anope_override { hybrid->SendTopic(bi, c); } void SendConnect() anope_override { - UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " TS 6 :" << Me->GetSID(); + UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink]->password << " TS 6 :" << Me->GetSID(); /* QS - Can handle quit storm removal EX - Can do channel +e exemptions @@ -162,11 +75,6 @@ class RatboxProto : public IRCDProto UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " :" << u->realname; } - void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override - { - UplinkSocket::Message(bi) << "SVSMODE " << u->nick << " " << buf; - } - void SendLogin(User *u) anope_override { if (!u->Account()) @@ -179,157 +87,36 @@ class RatboxProto : public IRCDProto { UplinkSocket::Message(Me) << "ENCAP * SU " << u->GetUID(); } - - void SendChannel(Channel *c) anope_override - { - Anope::string modes = c->GetModes(true, true); - if (modes.empty()) - modes = "+"; - UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :"; - } - - bool IsNickValid(const Anope::string &nick) anope_override - { - /* TS6 Save extension -Certus */ - if (isdigit(nick[0])) - return false; - - return true; - } - - void SendTopic(BotInfo *bi, Channel *c) anope_override - { - bool needjoin = c->FindUser(bi) == NULL; - if (needjoin) - { - ChannelStatus status; - status.SetFlag(CMODE_OP); - bi->Join(c, &status); - } - IRCDProto::SendTopic(bi, c); - if (needjoin) - bi->Part(c); - } -}; - -struct IRCDMessageBMask : IRCDMessage -{ - IRCDMessageBMask() : IRCDMessage("BMASK", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - /* :42X BMASK 1106409026 #ircops b :*!*@*.aol.com */ - /* 0 1 2 3 */ - Channel *c = findchan(params[1]); - - if (c) - { - ChannelMode *ban = ModeManager::FindChannelModeByName(CMODE_BAN), - *except = ModeManager::FindChannelModeByName(CMODE_EXCEPT), - *invex = ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE); - - Anope::string bans = params[3]; - int count = myNumToken(bans, ' '), i; - for (i = 0; i < count; ++i) - { - Anope::string b = myStrGetToken(bans, ' ', i); - if (ban && params[2].equals_cs("b")) - c->SetModeInternal(source, ban, b); - else if (except && params[2].equals_cs("e")) - c->SetModeInternal(source, except, b); - if (invex && params[2].equals_cs("I")) - c->SetModeInternal(source, invex, b); - } - } - - return true; - } }; struct IRCDMessageEncap : IRCDMessage { - IRCDMessageEncap() : IRCDMessage("ENCAP", 3) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 3) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } // Debug: Received: :00BAAAAAB ENCAP * LOGIN Adam bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - if (params[1] == "LOGIN") + if (params[1] == "LOGIN" || params[1] == "SU") { User *u = source.GetUser(); - NickCore *nc = findcore(params[2]); + NickCore *nc = NickCore::Find(params[2]); if (!nc) return true; u->Login(nc); - const NickAlias *user_na = findnick(u->nick); + const NickAlias *user_na = NickAlias::Find(u->nick); if (!Config->NoNicknameOwnership && user_na && user_na->nc == nc && user_na->nc->HasFlag(NI_UNCONFIRMED) == false) - u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); - } - - return true; - } -}; - -struct IRCDMessageJoin : CoreIRCDMessageJoin -{ - IRCDMessageJoin() : CoreIRCDMessageJoin("JOIN") { } - - /* - * params[0] = ts - * params[1] = channel - * params[2] = modes - */ - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - if (params.size() < 2) - return true; - - std::vector<Anope::string> p = params; - p.erase(p.begin()); - - return CoreIRCDMessageJoin::Run(source, p); - } -}; - -struct IRCDMessageMode : IRCDMessage -{ - IRCDMessageMode() : IRCDMessage("MODE", 2) { } - - // Received: :42CAAAIHS MODE 42CAAAIHS :+ao - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - if (ircdproto->IsChannelValid(params[0])) - { - Channel *c = findchan(params[0]); - if (c) - c->SetModesInternal(source, params[1]); - } - else - { - User *u = finduser(params[0]); - if (u) - u->SetModesInternal("%s", params[1].c_str()); + u->SetMode(NickServ, UMODE_REGISTERED); } return true; } }; -struct IRCDMessageNick : IRCDMessage -{ - IRCDMessageNick() : IRCDMessage("NICK", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - source.GetUser()->ChangeNick(params[0]); - return true; - } -}; - struct IRCDMessagePass : IRCDMessage { - IRCDMessagePass() : IRCDMessage("PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessagePass(Module *creator) : IRCDMessage(creator, "PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -338,20 +125,9 @@ struct IRCDMessagePass : IRCDMessage } }; -struct IRCDMessagePong : IRCDMessage -{ - IRCDMessagePong() : IRCDMessage("PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - source.GetServer()->Sync(false); - return true; - } -}; - struct IRCDMessageServer : IRCDMessage { - IRCDMessageServer() : IRCDMessage("SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } // SERVER hades.arpa 1 :ircd-ratbox test server bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override @@ -360,166 +136,33 @@ struct IRCDMessageServer : IRCDMessage if (params[1] != "1") return true; new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID); - ircdproto->SendPing(Config->ServerName, params[0]); - return true; - } -}; - -struct IRCDMessageSID : IRCDMessage -{ - IRCDMessageSID() : IRCDMessage("SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - /* :42X SID trystan.nomadirc.net 2 43X :ircd-ratbox test server */ - unsigned int hops = params[1].is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0; - new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[3], params[2]); - ircdproto->SendPing(Config->ServerName, params[0]); - return true; - } -}; - -struct IRCDMessageSjoin : IRCDMessage -{ - IRCDMessageSjoin() : IRCDMessage("SJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - Channel *c = findchan(params[1]); - time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0; - bool keep_their_modes = true; - - if (!c) - { - c = new Channel(params[1], ts); - c->SetFlag(CH_SYNCING); - } - /* Our creation time is newer than what the server gave us */ - else if (c->creation_time > ts) - { - c->creation_time = ts; - c->Reset(); - } - /* Their TS is newer than ours, our modes > theirs, unset their modes if need be */ - else if (ts > c->creation_time) - keep_their_modes = false; - - /* If we need to keep their modes, and this SJOIN string contains modes */ - if (keep_their_modes && params.size() >= 3) - { - Anope::string modes; - for (unsigned i = 2; i < params.size() - 1; ++i) - modes += " " + params[i]; - if (!modes.empty()) - modes.erase(modes.begin()); - /* Set the modes internally */ - c->SetModesInternal(source, modes); - } - - spacesepstream sep(params[params.size() - 1]); - Anope::string buf; - while (sep.GetToken(buf)) - { - std::list<ChannelMode *> Status; - char ch; - - /* Get prefixes from the nick */ - while ((ch = ModeManager::GetStatusChar(buf[0]))) - { - buf.erase(buf.begin()); - ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); - if (!cm) - { - Log() << "Received unknown mode prefix " << ch << " in SJOIN string"; - continue; - } - - if (keep_their_modes) - Status.push_back(cm); - } - - User *u = finduser(buf); - if (!u) - { - Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; - continue; - } - - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); - - /* Add the user to the channel */ - c->JoinUser(u); - - /* Update their status internally on the channel - * This will enforce secureops etc on the user - */ - for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it) - c->SetModeInternal(source, *it, buf); - - /* Now set whatever modes this user is allowed to have on the channel */ - chan_set_correct_modes(u, c, 1, true); - - /* Check to see if modules want the user to join, if they do - * check to see if they are allowed to join (CheckKick will kick/ban them) - * Don't trigger OnJoinChannel event then as the user will be destroyed - */ - if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u)) - continue; - - FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); - } - - /* Channel is done syncing */ - if (c->HasFlag(CH_SYNCING)) - { - /* Unset the syncing flag */ - c->UnsetFlag(CH_SYNCING); - c->Sync(); - } - + IRCD->SendPing(Config->ServerName, params[0]); return true; } }; struct IRCDMessageTBurst : IRCDMessage { - IRCDMessageTBurst() : IRCDMessage("TBURST", 4) { } + IRCDMessageTBurst(Module *creator) : IRCDMessage(creator, "TB", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + /* + * params[0] = channel + * params[1] = ts + * params[2] = topic OR who set the topic + * params[3] = topic if params[2] isnt the topic + */ bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Anope::string setter = myStrGetToken(params[2], '!', 0); time_t topic_time = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime; - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); if (!c) return true; - c->ChangeTopicInternal(setter, params[3], topic_time); - - return true; - } -}; - -struct IRCDMessageTMode : IRCDMessage -{ - IRCDMessageTMode() : IRCDMessage("TMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } - - bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override - { - time_t ts = 0; - try - { - ts = convertTo<time_t>(params[0]); - } - catch (const ConvertException &) { } - Channel *c = findchan(params[1]); - Anope::string modes = params[2]; - for (unsigned i = 3; i < params.size(); ++i) - modes += " " + params[i]; + const Anope::string &setter = params.size() == 4 ? params[2] : "", + topic = params.size() == 4 ? params[3] : params[2]; - if (c) - c->SetModesInternal(source, modes, ts); + c->ChangeTopicInternal(setter, topic, topic_time); return true; } @@ -527,15 +170,15 @@ struct IRCDMessageTMode : IRCDMessage struct IRCDMessageUID : IRCDMessage { - IRCDMessageUID() : IRCDMessage("UID", 9) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageUID(Module *creator) : IRCDMessage(creator, "UID", 9) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } // :42X UID Adam 1 1348535644 +aow Adam 192.168.0.5 192.168.0.5 42XAAAAAB :Adam bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { /* Source is always the server */ User *user = new User(params[0], params[4], params[5], "", params[6], source.GetServer(), params[8], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[3], params[7]); - if (user && user->server->IsSynced() && nickserv) - nickserv->Validate(user); + if (user && user->server->IsSynced() && NickServService) + NickServService->Validate(user); return true; } @@ -543,99 +186,105 @@ struct IRCDMessageUID : IRCDMessage class ProtoRatbox : public Module { + Module *m_hybrid; + RatboxProto ircd_proto; /* Core message handlers */ - CoreIRCDMessageAway core_message_away; - CoreIRCDMessageCapab core_message_capab; - CoreIRCDMessageError core_message_error; - CoreIRCDMessageKick core_message_kick; - CoreIRCDMessageKill core_message_kill; - CoreIRCDMessageMOTD core_message_motd; - CoreIRCDMessagePart core_message_part; - CoreIRCDMessagePing core_message_ping; - CoreIRCDMessagePrivmsg core_message_privmsg; - CoreIRCDMessageQuit core_message_quit; - CoreIRCDMessageSQuit core_message_squit; - CoreIRCDMessageStats core_message_stats; - CoreIRCDMessageTime core_message_time; - CoreIRCDMessageTopic core_message_topic; - CoreIRCDMessageVersion core_message_version; - CoreIRCDMessageWhois core_message_whois; + Message::Away message_away; + Message::Capab message_capab; + Message::Error message_error; + Message::Kick message_kick; + Message::Kill message_kill; + Message::Mode message_mode; + Message::MOTD message_motd; + Message::Part message_part; + Message::Ping message_ping; + Message::Privmsg message_privmsg; + Message::Quit message_quit; + Message::SQuit message_squit; + Message::Stats message_stats; + Message::Time message_time; + Message::Topic message_topic; + Message::Version message_version; + Message::Whois message_whois; + + /* Hybrid message handlers */ + ServiceAlias message_bmask, message_join, message_nick, message_pong, message_sid, + message_sjoin, message_tmode; /* Our message handlers */ - IRCDMessageBMask message_bmask; IRCDMessageEncap message_encap; - IRCDMessageJoin message_join; - IRCDMessageMode message_mode; - IRCDMessageNick message_nick; IRCDMessagePass message_pass; - IRCDMessagePong message_pong; IRCDMessageServer message_server; - IRCDMessageSID message_sid; - IRCDMessageSjoin message_sjoin; IRCDMessageTBurst message_tburst; - IRCDMessageTMode message_tmode; IRCDMessageUID message_uid; void AddModes() { - /* Add user modes */ - ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, 'a')); - ModeManager::AddUserMode(new UserMode(UMODE_INVIS, 'i')); - ModeManager::AddUserMode(new UserMode(UMODE_OPER, 'o')); - ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, 's')); - ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, 'w')); - - /* b/e/I */ - ModeManager::AddChannelMode(new ChannelModeList(CMODE_BAN, 'b')); - ModeManager::AddChannelMode(new ChannelModeList(CMODE_EXCEPT, 'e')); - ModeManager::AddChannelMode(new ChannelModeList(CMODE_INVITEOVERRIDE, 'I')); + /* user modes */ + ModeManager::RemoveUserMode(ModeManager::FindUserModeByName(UMODE_HIDEOPER)); + ModeManager::RemoveUserMode(ModeManager::FindUserModeByName(UMODE_REGPRIV)); /* v/h/o/a/q */ - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, 'v', '+', 0)); - ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, 'o', '@', 1)); - - /* Add channel modes */ - ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, 'i')); - ModeManager::AddChannelMode(new ChannelModeKey('k')); - ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, 'l')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, 'm')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, 'n')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, 'p')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, 's')); - ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, 't')); + ModeManager::RemoveChannelMode(ModeManager::FindChannelModeByName(CMODE_HALFOP)); + + /* channel modes */ + ModeManager::RemoveChannelMode(ModeManager::FindChannelModeByName(CMODE_REGISTERED)); + ModeManager::RemoveChannelMode(ModeManager::FindChannelModeByName(CMODE_OPERONLY)); + ModeManager::RemoveChannelMode(ModeManager::FindChannelModeByName(CMODE_REGISTEREDONLY)); + ModeManager::RemoveChannelMode(ModeManager::FindChannelModeByName(CMODE_SSL)); } public: - ProtoRatbox(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL) + ProtoRatbox(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL), + message_away(this), message_capab(this), message_error(this), message_kick(this), message_kill(this), + message_mode(this), message_motd(this), message_part(this), message_ping(this), message_privmsg(this), + message_quit(this), message_squit(this), message_stats(this), message_time(this), message_topic(this), + message_version(this), message_whois(this), + + message_bmask("IRCDMessage", "ratbox/bmask", "hybrid/bmask"), message_join("IRCDMessage", "ratbox/join", "hybrid/join"), + message_nick("IRCDMessage", "ratbox/nick", "hybrid/nick"), message_pong("IRCDMessage", "ratbox/pong", "hybrid/pong"), + message_sid("IRCDMessage", "ratbox/sid", "hybrid/sid"), message_sjoin("IRCDMessage", "ratbox/sjoin", "hybrid/sjoin"), + message_tmode("IRCDMessage", "ratbox/tmode", "hybrid/tmode"), + + message_encap(this), message_pass(this), message_server(this), message_tburst(this), message_uid(this) { this->SetAuthor("Anope"); + if (ModuleManager::LoadModule("hybrid", User::Find(creator)) != MOD_ERR_OK) + throw ModuleException("Unable to load hybrid"); + m_hybrid = ModuleManager::FindModule("hybrid"); + if (!m_hybrid) + throw ModuleException("Unable to find hybrid"); + hybrid = m_hybrid->GetIRCDProto(); + if (!hybrid) + throw ModuleException("No protocol interface for hybrid"); + this->AddModes(); Implementation i[] = { I_OnServerSync }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); + } - if (Config->Numeric.empty()) - { - Anope::string numeric = ts6_sid_retrieve(); - Me->SetSID(numeric); - Config->Numeric = numeric; - } + ~ProtoRatbox() + { + ModuleManager::UnloadModule(m_hybrid, NULL); + } - for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) - it->second->GenerateUID(); + IRCDProto *GetIRCDProto() anope_override + { + return &ircd_proto; } void OnServerSync(Server *s) anope_override { - if (nickserv) + if (NickServService) for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { User *u = it->second; if (u->server == s && !u->IsIdentified()) - nickserv->Validate(u); + NickServService->Validate(u); } } }; diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index d07c5eaec..5e7a9f194 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -48,7 +48,7 @@ class UnrealIRCdProto : public IRCDProto if (x->GetUser() == "*") { sockaddrs(x->GetHost()); - ircdproto->SendSZLineDel(x); + IRCD->SendSZLineDel(x); return; } } @@ -74,11 +74,10 @@ class UnrealIRCdProto : public IRCDProto void SendVhostDel(User *u) anope_override { - const BotInfo *bi = findbot(Config->HostServ); - u->RemoveMode(bi, UMODE_CLOAK); - u->RemoveMode(bi, UMODE_VHOST); + u->RemoveMode(HostServ, UMODE_CLOAK); + u->RemoveMode(HostServ, UMODE_VHOST); ModeManager::ProcessModes(); - u->SetMode(bi, UMODE_CLOAK); + u->SetMode(HostServ, UMODE_CLOAK); } void SendAkill(User *u, XLine *x) anope_override @@ -100,11 +99,11 @@ class UnrealIRCdProto : public IRCDProto return; /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */ - XLine *xline = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID); + XLine *xline = new XLine("*@" + u->host, old->by, old->expires, old->reason, old->id); old->manager->AddXLine(xline); x = xline; - Log(findbot(Config->OperServ), "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->Mask; + Log(OperServ, "akill") << "AKILL: Added an akill for " << x->mask << " because " << u->GetMask() << "#" << u->realname << " matches " << old->mask; } /* ZLine if we can instead */ @@ -113,17 +112,17 @@ class UnrealIRCdProto : public IRCDProto if (x->GetUser() == "*") { sockaddrs(x->GetHost()); - ircdproto->SendSZLine(u, x); + IRCD->SendSZLine(u, x); return; } } catch (const SocketException &) { } // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) + time_t timeleft = x->expires - Anope::CurTime; + if (timeleft > 172800 || !x->expires) timeleft = 172800; - UplinkSocket::Message() << "BD + G " << x->GetUser() << " " << x->GetHost() << " " << x->By << " " << Anope::CurTime + timeleft << " " << x->Created << " :" << x->GetReason(); + UplinkSocket::Message() << "BD + G " << x->GetUser() << " " << x->GetHost() << " " << x->by << " " << Anope::CurTime + timeleft << " " << x->created << " :" << x->GetReason(); } void SendSVSKillInternal(const BotInfo *source, User *user, const Anope::string &buf) anope_override @@ -165,11 +164,11 @@ class UnrealIRCdProto : public IRCDProto */ UserContainer *uc = c->FindUser(user); if (uc != NULL) - uc->Status->ClearFlags(); + uc->status->ClearFlags(); - BotInfo *setter = findbot(user->nick); + BotInfo *setter = BotInfo::Find(user->nick); for (unsigned i = 0; i < ModeManager::ChannelModes.size(); ++i) - if (cs.HasFlag(ModeManager::ChannelModes[i]->Name)) + if (cs.HasFlag(ModeManager::ChannelModes[i]->name)) c->SetMode(setter, ModeManager::ChannelModes[i], user->GetUID(), false); } } @@ -178,7 +177,7 @@ class UnrealIRCdProto : public IRCDProto */ void SendSQLineDel(const XLine *x) anope_override { - UplinkSocket::Message() << "d " << x->Mask; + UplinkSocket::Message() << "d " << x->mask; } /* SQLINE */ @@ -188,7 +187,7 @@ class UnrealIRCdProto : public IRCDProto */ void SendSQLine(User *, const XLine *x) anope_override { - UplinkSocket::Message() << "c " << x->Mask << " :" << x->GetReason(); + UplinkSocket::Message() << "c " << x->mask << " :" << x->GetReason(); } /* @@ -239,7 +238,7 @@ class UnrealIRCdProto : public IRCDProto UplinkSocket::Message() << "PROTOCTL NICKv2 VHP UMODE2 NICKIP SJOIN SJOIN2 SJ3 NOQUIT TKLEXT ESVID MLOCK VL"; else UplinkSocket::Message() << "PROTOCTL NICKv2 VHP UMODE2 NICKIP SJOIN SJOIN2 SJ3 NOQUIT TKLEXT ESVID MLOCK"; - UplinkSocket::Message() << "PASS :" << Config->Uplinks[CurrentUplink]->password; + UplinkSocket::Message() << "PASS :" << Config->Uplinks[Anope::CurrentUplink]->password; SendServer(Me); } @@ -261,7 +260,7 @@ class UnrealIRCdProto : public IRCDProto */ void SendSGLineDel(const XLine *x) anope_override { - UplinkSocket::Message() << "BR - :" << x->Mask; + UplinkSocket::Message() << "BR - :" << x->mask; } /* UNSZLINE */ @@ -274,10 +273,10 @@ class UnrealIRCdProto : public IRCDProto void SendSZLine(User *, const XLine *x) anope_override { // Calculate the time left before this would expire, capping it at 2 days - time_t timeleft = x->Expires - Anope::CurTime; - if (timeleft > 172800 || !x->Expires) + time_t timeleft = x->expires - Anope::CurTime; + if (timeleft > 172800 || !x->expires) timeleft = 172800; - UplinkSocket::Message() << "BD + Z * " << x->GetHost() << " " << x->By << " " << Anope::CurTime + timeleft << " " << x->Created << " :" << x->GetReason(); + UplinkSocket::Message() << "BD + Z * " << x->GetHost() << " " << x->by << " " << Anope::CurTime + timeleft << " " << x->created << " :" << x->GetReason(); } /* SGLINE */ @@ -288,7 +287,7 @@ class UnrealIRCdProto : public IRCDProto { Anope::string edited_reason = x->GetReason(); edited_reason = edited_reason.replace_all_cs(" ", "_"); - UplinkSocket::Message() << "BR + " << edited_reason << " :" << x->Mask; + UplinkSocket::Message() << "BR + " << edited_reason << " :" << x->mask; } /* svsjoin @@ -323,7 +322,7 @@ class UnrealIRCdProto : public IRCDProto if (nick.equals_ci("ircd") || nick.equals_ci("irc")) return false; - return true; + return IRCDProto::IsNickValid(nick); } bool IsChannelValid(const Anope::string &chan) anope_override @@ -339,17 +338,15 @@ class UnrealIRCdProto : public IRCDProto if (!u->Account()) return; - const BotInfo *ns = findbot(Config->NickServ); - if (Capab.count("ESVID") > 0) - ircdproto->SendMode(ns, u, "+d %s", u->Account()->display.c_str()); + if (Servers::Capab.count("ESVID") > 0) + IRCD->SendMode(NickServ, u, "+d %s", u->Account()->display.c_str()); else - ircdproto->SendMode(ns, u, "+d %d", u->timestamp); + IRCD->SendMode(NickServ, u, "+d %d", u->timestamp); } void SendLogout(User *u) anope_override { - const BotInfo *ns = findbot(Config->NickServ); - ircdproto->SendMode(ns, u, "+d 0"); + IRCD->SendMode(NickServ, u, "+d 0"); } void SendChannel(Channel *c) anope_override @@ -392,16 +389,16 @@ class UnrealExtBan : public ChannelModeList char modeChar = ModeManager::GetStatusChar(channel[0]); channel.erase(channel.begin()); cm = ModeManager::FindChannelModeByChar(modeChar); - if (cm != NULL && cm->Type != MODE_STATUS) + if (cm != NULL && cm->type != MODE_STATUS) cm = NULL; } - Channel *c = findchan(channel); + Channel *c = Channel::Find(channel); if (c != NULL) { UserContainer *uc = c->FindUser(u); if (uc != NULL) - if (cm == NULL || uc->Status->HasFlag(cm->Name)) + if (cm == NULL || uc->status->HasFlag(cm->name)) return true; } } @@ -409,7 +406,7 @@ class UnrealExtBan : public ChannelModeList { Anope::string real_mask = mask.substr(3); - Entry en(this->Name, real_mask); + Entry en(this->name, real_mask); if (en.Matches(u)) return true; } @@ -494,9 +491,9 @@ class ChannelModeUnrealSSL : public ChannelMode } }; -struct IRCDMessageCapab : CoreIRCDMessageCapab +struct IRCDMessageCapab : Message::Capab { - IRCDMessageCapab() : CoreIRCDMessageCapab("PROTOCTL") { } + IRCDMessageCapab(Module *creator) : Message::Capab(creator, "PROTOCTL") { } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -645,17 +642,17 @@ struct IRCDMessageCapab : CoreIRCDMessageCapab } } - return CoreIRCDMessageCapab::Run(source, params); + return Message::Capab::Run(source, params); } }; struct IRCDMessageChgHost : IRCDMessage { - IRCDMessageChgHost() : IRCDMessage("CHGHOST", 2) { } + IRCDMessageChgHost(Module *creator) : IRCDMessage(creator, "CHGHOST", 2) { } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = finduser(params[0]); + User *u = User::Find(params[0]); if (u) u->SetDisplayedHost(params[1]); return true; @@ -664,11 +661,11 @@ struct IRCDMessageChgHost : IRCDMessage struct IRCDMessageChgIdent : IRCDMessage { - IRCDMessageChgIdent() : IRCDMessage("CHGIDENT", 2) { } + IRCDMessageChgIdent(Module *creator) : IRCDMessage(creator, "CHGIDENT", 2) { } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = finduser(params[0]); + User *u = User::Find(params[0]); if (u) u->SetVIdent(params[1]); return true; @@ -677,11 +674,11 @@ struct IRCDMessageChgIdent : IRCDMessage struct IRCDMessageChgName : IRCDMessage { - IRCDMessageChgName() : IRCDMessage("CHGNAME", 2) { } + IRCDMessageChgName(Module *creator) : IRCDMessage(creator, "CHGNAME", 2) { } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = finduser(params[0]); + User *u = User::Find(params[0]); if (u) u->SetRealname(params[1]); return true; @@ -690,7 +687,7 @@ struct IRCDMessageChgName : IRCDMessage struct IRCDMessageMode : IRCDMessage { - IRCDMessageMode(const Anope::string &mname) : IRCDMessage(mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageMode(Module *creator, const Anope::string &mname) : IRCDMessage(creator, mname, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -699,10 +696,11 @@ struct IRCDMessageMode : IRCDMessage for (unsigned i = 2; i < params.size() - (server_source ? 1 : 0); ++i) modes += " " + params[i]; - if (ircdproto->IsChannelValid(params[0])) + if (IRCD->IsChannelValid(params[0])) { - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); time_t ts = 0; + try { if (server_source) @@ -715,7 +713,7 @@ struct IRCDMessageMode : IRCDMessage } else { - User *u = finduser(params[0]); + User *u = User::Find(params[0]); if (u) u->SetModesInternal("%s", params[1].c_str()); } @@ -736,18 +734,18 @@ struct IRCDMessageMode : IRCDMessage */ struct IRCDMessageNetInfo : IRCDMessage { - IRCDMessageNetInfo() : IRCDMessage("NETINFO", 8) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageNetInfo(Module *creator) : IRCDMessage(creator, "NETINFO", 8) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - UplinkSocket::Message() << "AO " << maxusercnt << " " << Anope::CurTime << " " << convertTo<int>(params[2]) << " " << params[3] << " 0 0 0 :" << params[7]; + UplinkSocket::Message() << "AO " << MaxUserCount << " " << Anope::CurTime << " " << convertTo<int>(params[2]) << " " << params[3] << " 0 0 0 :" << params[7]; return true; } }; struct IRCDMessageNick : IRCDMessage { - IRCDMessageNick() : IRCDMessage("NICK", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); } /* ** NICK - new @@ -807,21 +805,21 @@ struct IRCDMessageNick : IRCDMessage else if (params[6].is_pos_number_only()) { if (convertTo<time_t>(params[6]) == user->timestamp) - na = findnick(user->nick); + na = NickAlias::Find(user->nick); } else { - na = findnick(params[6]); + na = NickAlias::Find(params[6]); } if (na) { user->Login(na->nc); - if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false && nickserv) - user->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); + if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false) + user->SetMode(NickServ, UMODE_REGISTERED); } - else if (nickserv) - nickserv->Validate(user); + else if (NickServService) + NickServService->Validate(user); } else source.GetUser()->ChangeNick(params[0]); @@ -841,7 +839,7 @@ struct IRCDMessageNick : IRCDMessage */ struct IRCDMessagePong : IRCDMessage { - IRCDMessagePong() : IRCDMessage("PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessagePong(Module *creator) : IRCDMessage(creator, "PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -878,13 +876,11 @@ struct IRCDMessageSASL : IRCDMessage UplinkSocket::Message() << "SASL " << this->uid.substr(0, p) << " " << this->uid << " D F"; - Log(findbot(Config->NickServ)) << "A user failed to identify for account " << this->GetAccount() << " using SASL"; + Log(NickServ) << "A user failed to identify for account " << this->GetAccount() << " using SASL"; } }; - Module *me; - - IRCDMessageSASL(Module *m) : IRCDMessage("SASL", 4), me(m) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageSASL(Module *creator) : IRCDMessage(creator, "SASL", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } /* Received: :irc.foonet.com SASL services.localhost.net irc.foonet.com!1.57290 S PLAIN * uid @@ -920,7 +916,7 @@ struct IRCDMessageSASL : IRCDMessage if (acc.empty() || pass.empty()) return true; - IdentifyRequest *req = new UnrealSASLIdentifyRequest(me, params[1], acc, pass); + IdentifyRequest *req = new UnrealSASLIdentifyRequest(this->owner, params[1], acc, pass); FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(NULL, req)); req->Dispatch(); } @@ -931,7 +927,7 @@ struct IRCDMessageSASL : IRCDMessage struct IRCDMessageSDesc : IRCDMessage { - IRCDMessageSDesc() : IRCDMessage("SDESC", 1) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageSDesc(Module *creator) : IRCDMessage(creator, "SDESC", 1) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -942,7 +938,7 @@ struct IRCDMessageSDesc : IRCDMessage struct IRCDMessageSetHost : IRCDMessage { - IRCDMessageSetHost() : IRCDMessage("SETHOST", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + IRCDMessageSetHost(Module *creator) : IRCDMessage(creator, "SETHOST", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -960,7 +956,7 @@ struct IRCDMessageSetHost : IRCDMessage struct IRCDMessageSetIdent : IRCDMessage { - IRCDMessageSetIdent() : IRCDMessage("SETIDENT", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + IRCDMessageSetIdent(Module *creator) : IRCDMessage(creator, "SETIDENT", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -972,11 +968,11 @@ struct IRCDMessageSetIdent : IRCDMessage struct IRCDMessageSetName : IRCDMessage { - IRCDMessageSetName() : IRCDMessage("SETNAME", 1) { } + IRCDMessageSetName(Module *creator) : IRCDMessage(creator, "SETNAME", 1) { } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - User *u = finduser(params[0]); + User *u = User::Find(params[0]); if (u) u->SetRealname(params[1]); return true; @@ -985,7 +981,7 @@ struct IRCDMessageSetName : IRCDMessage struct IRCDMessageServer : IRCDMessage { - IRCDMessageServer() : IRCDMessage("SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } + IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -993,16 +989,15 @@ struct IRCDMessageServer : IRCDMessage if (params[1].equals_cs("1")) { - Anope::string vl = myStrGetToken(params[2], ' ', 0); - Anope::string upnumeric = myStrGetToken(vl, '-', 2); - Anope::string desc = myStrGetTokenRemainder(params[2], ' ', 1); + Anope::string desc; + spacesepstream(params[2]).GetTokenRemainder(desc, 1); new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, desc); } else new Server(source.GetServer(), params[0], hops, params[2]); - ircdproto->SendPing(Config->ServerName, params[0]); + IRCD->SendPing(Config->ServerName, params[0]); return true; } @@ -1010,44 +1005,20 @@ struct IRCDMessageServer : IRCDMessage struct IRCDMessageSJoin : IRCDMessage { - IRCDMessageSJoin() : IRCDMessage("SJOIN", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } + IRCDMessageSJoin(Module *creator) : IRCDMessage(creator, "SJOIN", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Channel *c = findchan(params[1]); - time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0; - bool keep_their_modes = true; - - if (!c) - { - c = new Channel(params[1], ts); - c->SetFlag(CH_SYNCING); - } - /* Our creation time is newer than what the server gave us */ - else if (c->creation_time > ts) - { - c->creation_time = ts; - c->Reset(); - } - /* Their TS is newer than ours, our modes > theirs, unset their modes if need be */ - else if (ts > c->creation_time) - keep_their_modes = false; - - /* If we need to keep their modes, and this SJOIN string contains modes */ - if (keep_their_modes && params.size() >= 4) - { - Anope::string modes; + Anope::string modes; + if (params.size() >= 4) for (unsigned i = 2; i < params.size() - 1; ++i) modes += " " + params[i]; - if (!modes.empty()) - modes.erase(modes.begin()); - /* Set the modes internally */ - c->SetModesInternal(source, modes); - } + if (!modes.empty()) + modes.erase(modes.begin()); + + std::list<Anope::string> bans, excepts, invites; + std::list<Message::Join::SJoinUser> users; - ChannelMode *ban = ModeManager::FindChannelModeByName(CMODE_BAN), - *except = ModeManager::FindChannelModeByName(CMODE_EXCEPT), - *invex = ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE); spacesepstream sep(params[params.size() - 1]); Anope::string buf; while (sep.GetToken(buf)) @@ -1056,82 +1027,72 @@ struct IRCDMessageSJoin : IRCDMessage if (buf[0] == '&') { buf.erase(buf.begin()); - if (keep_their_modes && ban) - c->SetModeInternal(source, ban, buf); + bans.push_back(buf); } /* Except */ else if (buf[0] == '"') { buf.erase(buf.begin()); - if (keep_their_modes && except) - c->SetModeInternal(source, except, buf); + excepts.push_back(buf); } /* Invex */ else if (buf[0] == '\'') { buf.erase(buf.begin()); - if (keep_their_modes && invex) - c->SetModeInternal(source, invex, buf); + invites.push_back(buf); } else { - std::list<ChannelMode *> Status; - char ch; + Message::Join::SJoinUser sju; /* Get prefixes from the nick */ - while ((ch = ModeManager::GetStatusChar(buf[0]))) + for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));) { buf.erase(buf.begin()); ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); if (!cm) { - Log() << "Received unknown mode prefix " << ch << " in SJOIN string"; + Log(LOG_DEBUG) << "Received unknown mode prefix " << ch << " in SJOIN string"; continue; } - if (keep_their_modes) - Status.push_back(cm); + sju.first.SetFlag(cm->name); } - User *u = finduser(buf); - if (!u) + sju.second = User::Find(buf); + if (!sju.second) { - Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; + Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << params[1]; continue; } - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); - - /* Add the user to the channel */ - c->JoinUser(u); - - /* Update their status internally on the channel - * This will enforce secureops etc on the user - */ - for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it) - c->SetModeInternal(source, *it, buf); - - /* Now set whatever modes this user is allowed to have on the channel */ - chan_set_correct_modes(u, c, 1, true); - - /* Check to see if modules want the user to join, if they do - * check to see if they are allowed to join (CheckKick will kick/ban them) - * Don't trigger OnJoinChannel event then as the user will be destroyed - */ - if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u)) - continue; - - FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); + users.push_back(sju); } } + + time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : Anope::CurTime; + Message::Join::SJoin(source, params[1], ts, modes, users); - /* Channel is done syncing */ - if (c->HasFlag(CH_SYNCING)) + if (!bans.empty() || !excepts.empty() || !invites.empty()) { - /* Unset the syncing flag */ - c->UnsetFlag(CH_SYNCING); - c->Sync(); + Channel *c = Channel::Find(params[1]); + + if (!c || c->creation_time != ts) + return true; + + ChannelMode *ban = ModeManager::FindChannelModeByName(CMODE_BAN), + *except = ModeManager::FindChannelModeByName(CMODE_EXCEPT), + *invex = ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE); + + if (ban) + for (std::list<Anope::string>::iterator it = bans.begin(), it_end = bans.end(); it != it_end; ++it) + c->SetModeInternal(source, ban, *it); + if (except) + for (std::list<Anope::string>::iterator it = excepts.begin(), it_end = excepts.end(); it != it_end; ++it) + c->SetModeInternal(source, except, *it); + if (invex) + for (std::list<Anope::string>::iterator it = invites.begin(), it_end = invites.end(); it != it_end; ++it) + c->SetModeInternal(source, invex, *it); } return true; @@ -1140,7 +1101,7 @@ struct IRCDMessageSJoin : IRCDMessage struct IRCDMessageTopic : IRCDMessage { - IRCDMessageTopic() : IRCDMessage("TOPIC", 4) { } + IRCDMessageTopic(Module *creator) : IRCDMessage(creator, "TOPIC", 4) { } /* ** source = sender prefix @@ -1151,7 +1112,7 @@ struct IRCDMessageTopic : IRCDMessage */ bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { - Channel *c = findchan(params[0]); + Channel *c = Channel::Find(params[0]); if (c) c->ChangeTopicInternal(params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime); @@ -1162,7 +1123,7 @@ struct IRCDMessageTopic : IRCDMessage struct IRCDMessageUmode2 : IRCDMessage { - IRCDMessageUmode2() : IRCDMessage("UMODE2", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } + IRCDMessageUmode2(Module *creator) : IRCDMessage(creator, "UMODE2", 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); } bool Run(MessageSource &source, const std::vector<Anope::string> ¶ms) anope_override { @@ -1176,22 +1137,21 @@ class ProtoUnreal : public Module UnrealIRCdProto ircd_proto; /* Core message handlers */ - CoreIRCDMessageAway core_message_away; - CoreIRCDMessageError core_message_error; - CoreIRCDMessageJoin core_message_join; - CoreIRCDMessageKick core_message_kick; - CoreIRCDMessageKill core_message_kill; - CoreIRCDMessageMOTD core_message_motd; - CoreIRCDMessagePart core_message_part; - CoreIRCDMessagePing core_message_ping; - CoreIRCDMessagePrivmsg core_message_privmsg; - CoreIRCDMessageQuit core_message_quit; - CoreIRCDMessageSQuit core_message_squit; - CoreIRCDMessageStats core_message_stats; - CoreIRCDMessageTime core_message_time; - CoreIRCDMessageTopic core_message_topic; - CoreIRCDMessageVersion core_message_version; - CoreIRCDMessageWhois core_message_whois; + Message::Away message_away; + Message::Error message_error; + Message::Join message_join; + Message::Kick message_kick; + Message::Kill message_kill; + Message::MOTD message_motd; + Message::Part message_part; + Message::Ping message_ping; + Message::Privmsg message_privmsg; + Message::Quit message_quit; + Message::SQuit message_squit; + Message::Stats message_stats; + Message::Time message_time; + Message::Version message_version; + Message::Whois message_whois; /* Our message handlers */ IRCDMessageCapab message_capab; @@ -1252,7 +1212,15 @@ class ProtoUnreal : public Module public: ProtoUnreal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL), - message_mode("MODE"), message_svsmode("SVSMODE"), message_svs2mode("SVS2MODE"), message_sasl(this) + message_away(this), message_error(this), message_join(this), message_kick(this), message_kill(this), + message_motd(this), message_part(this), message_ping(this), message_privmsg(this), message_quit(this), + message_squit(this), message_stats(this), message_time(this), message_version(this), + message_whois(this), + + message_capab(this), message_chghost(this), message_chgident(this), message_chgname(this), message_mode(this, "MODE"), + message_svsmode(this, "SVSMODE"), message_svs2mode(this, "SVS2MODE"), message_netinfo(this), message_nick(this), message_pong(this), + message_sasl(this), message_sdesc(this), message_sethost(this), message_setident(this), message_setname(this), message_server(this), + message_sjoin(this), message_topic(this), message_umode2(this) { this->SetAuthor("Anope"); @@ -1263,15 +1231,21 @@ class ProtoUnreal : public Module ModuleManager::SetPriority(this, PRIORITY_FIRST); } + IRCDProto *GetIRCDProto() anope_override + { + return &ircd_proto; + } + void OnUserNickChange(User *u, const Anope::string &) anope_override { u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED)); - ircdproto->SendLogout(u); + if (Servers::Capab.count("ESVID") == 0) + IRCD->SendLogout(u); } void OnChannelCreate(Channel *c) anope_override { - if (Config->UseServerSideMLock && Capab.count("MLOCK") > 0 && c->ci) + if (Config->UseServerSideMLock && Servers::Capab.count("MLOCK") > 0 && c->ci) { Anope::string modes = c->ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", ""); UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(c->creation_time) << " " << c->ci->name << " " << modes; @@ -1296,9 +1270,9 @@ class ProtoUnreal : public Module EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override { ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name); - if (cm && ci->c && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM) && Capab.count("MLOCK") > 0 && Config->UseServerSideMLock) + if (cm && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0 && Config->UseServerSideMLock) { - Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->ModeChar; + Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->mchar; UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes; } @@ -1308,9 +1282,9 @@ class ProtoUnreal : public Module EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override { ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name); - if (cm && ci->c && (cm->Type == MODE_REGULAR || cm->Type == MODE_PARAM) && Capab.count("MLOCK") > 0 && Config->UseServerSideMLock) + if (cm && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0 && Config->UseServerSideMLock) { - Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->ModeChar, ""); + Anope::string modes = ci->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->mchar, ""); UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes; } diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp index e653e7d3e..f78d0a6de 100644 --- a/modules/pseudoclients/botserv.cpp +++ b/modules/pseudoclients/botserv.cpp @@ -20,8 +20,8 @@ class BotServCore : public Module { this->SetAuthor("Anope"); - const BotInfo *BotServ = findbot(Config->BotServ); - if (BotServ == NULL) + BotServ = BotInfo::Find(Config->BotServ); + if (!BotServ) throw ModuleException("No bot named " + Config->BotServ); Implementation i[] = { I_OnPrivmsg, I_OnJoinChannel, I_OnLeaveChannel, @@ -41,7 +41,7 @@ class BotServCore : public Module Anope::string ctcp = msg; ctcp.erase(ctcp.begin()); ctcp.erase(ctcp.length() - 1); - ircdproto->SendCTCP(c->ci->bi, u->nick, "%s", ctcp.c_str()); + IRCD->SendCTCP(c->ci->bi, u->nick, "%s", ctcp.c_str()); } Anope::string realbuf = msg; @@ -56,7 +56,8 @@ class BotServCore : public Module if (realbuf.empty() || !c->ci->botflags.HasFlag(BS_FANTASY)) return; - std::vector<Anope::string> params = BuildStringVector(realbuf); + std::vector<Anope::string> params; + spacesepstream(realbuf).GetTokens(params); if (!realbuf.find(c->ci->bi->nick)) params.erase(params.begin()); @@ -87,7 +88,7 @@ class BotServCore : public Module return; const CommandInfo &info = it->second; - service_reference<Command> cmd("Command", info.name); + ServiceReference<Command> cmd("Command", info.name); if (!cmd) { Log(LOG_DEBUG) << "Fantasy command " << it->first << " exists for nonexistant service " << info.name << "!"; @@ -97,10 +98,10 @@ class BotServCore : public Module for (unsigned i = 0, j = params.size() - (count - 1); i < j; ++i) params.erase(params.begin()); - while (cmd->MaxParams > 0 && params.size() > cmd->MaxParams) + while (cmd->max_params > 0 && params.size() > cmd->max_params) { - params[cmd->MaxParams - 1] += " " + params[cmd->MaxParams]; - params.erase(params.begin() + cmd->MaxParams); + params[cmd->max_params - 1] += " " + params[cmd->max_params]; + params.erase(params.begin() + cmd->max_params); } /* All ChanServ commands take the channel as a first parameter */ @@ -111,7 +112,7 @@ class BotServCore : public Module if (!cmd->HasFlag(CFLAG_ALLOW_UNREGISTERED) && !u->Account()) return; - if (params.size() < cmd->MinParams) + if (params.size() < cmd->min_params) return; CommandSource source(u->nick, u, u->Account(), u, c->ci->bi); @@ -139,8 +140,8 @@ class BotServCore : public Module if (MOD_RESULT == EVENT_STOP) return; - dynamic_reference<User> user_reference(u); - dynamic_reference<NickCore> nc_reference(u->Account()); + Reference<User> user_reference(u); + Reference<NickCore> nc_reference(u->Account()); cmd->Execute(source, params); if (user_reference && nc_reference) @@ -160,14 +161,14 @@ class BotServCore : public Module * legit users - Rob **/ if (c->users.size() >= Config->BSMinUsers && !c->FindUser(c->ci->bi)) - c->ci->bi->Join(c, &Config->BotModeList); + c->ci->bi->Join(c, &ModeManager::DefaultBotModes); /* Only display the greet if the main uplink we're connected * to has synced, or we'll get greet-floods when the net * recovers from a netsplit. -GD */ if (c->FindUser(c->ci->bi) && c->ci->botflags.HasFlag(BS_GREET) && user->Account() && !user->Account()->greet.empty() && c->ci->AccessFor(user).HasPriv("GREET") && user->server->IsSynced()) { - ircdproto->SendPrivmsg(c->ci->bi, c->name, "[%s] %s", user->Account()->display.c_str(), user->Account()->greet.c_str()); + IRCD->SendPrivmsg(c->ci->bi, c->name, "[%s] %s", user->Account()->display.c_str(), user->Account()->greet.c_str()); c->ci->bi->lastmsg = Anope::CurTime; } } diff --git a/modules/pseudoclients/botserv.h b/modules/pseudoclients/botserv.h new file mode 100644 index 000000000..9757e5d4e --- /dev/null +++ b/modules/pseudoclients/botserv.h @@ -0,0 +1,6 @@ +#ifndef BOTSERV_H +#define BOTSERV_H + +static Reference<BotInfo> BotServ; + +#endif // BOTSERV_H diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp index c3a6e6479..7a5b482bb 100644 --- a/modules/pseudoclients/chanserv.cpp +++ b/modules/pseudoclients/chanserv.cpp @@ -20,7 +20,7 @@ class ExpireCallback : public CallBack void Tick(time_t) anope_override { - if (!Config->CSExpire || noexpire || readonly) + if (!Config->CSExpire || Anope::NoExpire || Anope::ReadOnly) return; for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ) @@ -30,7 +30,7 @@ class ExpireCallback : public CallBack bool expire = false; - if (!ci->c && Config->CSExpire && Anope::CurTime - ci->last_used >= Config->CSExpire) + if (!ci->c && Anope::CurTime - ci->last_used >= Config->CSExpire) expire = true; if (ci->HasFlag(CI_NO_EXPIRE)) @@ -46,7 +46,7 @@ class ExpireCallback : public CallBack Log(LOG_NORMAL, "chanserv/expire") << "Expiring " << extra << "channel " << ci->name << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << ")"; FOREACH_MOD(I_OnChanExpire, OnChanExpire(ci)); - ci->destroy(); + ci->Destroy(); } } } @@ -61,8 +61,8 @@ class ChanServCore : public Module { this->SetAuthor("Anope"); - const BotInfo *ChanServ = findbot(Config->ChanServ); - if (ChanServ == NULL) + ChanServ = BotInfo::Find(Config->ChanServ); + if (!ChanServ) throw ModuleException("No bot named " + Config->ChanServ); Implementation i[] = { I_OnBotPrivmsg, I_OnDelCore, I_OnPreHelp, I_OnPostHelp, I_OnCheckModes }; @@ -99,7 +99,7 @@ class ChanServCore : public Module for (unsigned j = 0; j < ci->GetAccessCount(); ++j) { const ChanAccess *ca = ci->GetAccess(j); - const NickCore *anc = findcore(ca->mask); + const NickCore *anc = NickCore::Find(ca->mask); if (!anc || (!anc->IsServicesOper() && Config->CSMaxReg && anc->channelcount >= Config->CSMaxReg) || (anc == nc)) continue; @@ -107,7 +107,7 @@ class ChanServCore : public Module highest = ca; } if (highest) - newowner = findcore(highest->mask); + newowner = NickCore::Find(highest->mask); } if (newowner) @@ -120,7 +120,7 @@ class ChanServCore : public Module { Log(LOG_NORMAL, "chanserv/expire") << "Deleting channel " << ci->name << " owned by deleted nick " << nc->display; - ci->destroy(); + ci->Destroy(); continue; } } @@ -131,7 +131,7 @@ class ChanServCore : public Module for (unsigned j = 0; j < ci->GetAccessCount(); ++j) { const ChanAccess *ca = ci->GetAccess(j); - const NickCore *anc = findcore(ca->mask); + const NickCore *anc = NickCore::Find(ca->mask); if (anc && anc == nc) { diff --git a/modules/pseudoclients/chanserv.h b/modules/pseudoclients/chanserv.h new file mode 100644 index 000000000..6c9ccd6c6 --- /dev/null +++ b/modules/pseudoclients/chanserv.h @@ -0,0 +1,6 @@ +#ifndef CHANSERV_H +#define CHANSERV_H + +static Reference<BotInfo> ChanServ; + +#endif // CHANSERV_H diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp index 13e7570ce..a5e1eb573 100644 --- a/modules/pseudoclients/global.cpp +++ b/modules/pseudoclients/global.cpp @@ -53,8 +53,8 @@ class GlobalCore : public Module { this->SetAuthor("Anope"); - const BotInfo *Global = findbot(Config->Global); - if (Global == NULL) + Global = BotInfo::Find(Config->Global); + if (!Global) throw ModuleException("No bot named " + Config->Global); Implementation i[] = { I_OnRestart, I_OnShutdown, I_OnNewServer, I_OnPreHelp }; @@ -64,19 +64,19 @@ class GlobalCore : public Module void OnRestart() anope_override { if (Config->GlobalOnCycle) - global->SendGlobal(findbot(Config->Global), "", Config->GlobalOnCycleMessage); + GlobalService->SendGlobal(Global, "", Config->GlobalOnCycleMessage); } void OnShutdown() anope_override { if (Config->GlobalOnCycle) - global->SendGlobal(findbot(Config->Global), "", Config->GlobalOnCycleMessage); + GlobalService->SendGlobal(Global, "", Config->GlobalOnCycleMessage); } void OnNewServer(Server *s) anope_override { if (Config->GlobalOnCycle && !Config->GlobalOnCycleUP.empty()) - s->Notice(findbot(Config->Global), Config->GlobalOnCycleUP); + s->Notice(Global, Config->GlobalOnCycleUP); } EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override diff --git a/modules/pseudoclients/global.h b/modules/pseudoclients/global.h index 75d783399..46bccef6d 100644 --- a/modules/pseudoclients/global.h +++ b/modules/pseudoclients/global.h @@ -14,7 +14,8 @@ class GlobalService : public Service virtual void SendGlobal(const BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0; }; -static service_reference<GlobalService> global("GlobalService", "Global"); +static ServiceReference<GlobalService> GlobalService("GlobalService", "Global"); +static Reference<BotInfo> Global; #endif // GLOBAL_H diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp index d0d078a79..47c4250c0 100644 --- a/modules/pseudoclients/hostserv.cpp +++ b/modules/pseudoclients/hostserv.cpp @@ -20,11 +20,11 @@ class HostServCore : public Module { this->SetAuthor("Anope"); - if (!ircdproto || !ircdproto->CanSetVHost) + if (!IRCD || !IRCD->CanSetVHost) throw ModuleException("Your IRCd does not support vhosts"); - const BotInfo *HostServ = findbot(Config->HostServ); - if (HostServ == NULL) + HostServ = BotInfo::Find(Config->HostServ); + if (!HostServ) throw ModuleException("No bot named " + Config->HostServ); Implementation i[] = { I_OnNickIdentify, I_OnNickUpdate, I_OnPreHelp }; @@ -33,29 +33,28 @@ class HostServCore : public Module void OnNickIdentify(User *u) anope_override { - const NickAlias *na = findnick(u->nick); + const NickAlias *na = NickAlias::Find(u->nick); if (!na || !na->HasVhost()) - na = findnick(u->Account()->display); - if (!ircdproto->CanSetVHost || !na || !na->HasVhost()) + na = NickAlias::Find(u->Account()->display); + if (!IRCD->CanSetVHost || !na || !na->HasVhost()) return; if (u->vhost.empty() || !u->vhost.equals_cs(na->GetVhostHost()) || (!na->GetVhostIdent().empty() && !u->GetVIdent().equals_cs(na->GetVhostIdent()))) { - ircdproto->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost()); + IRCD->SendVhost(u, na->GetVhostIdent(), na->GetVhostHost()); u->vhost = na->GetVhostHost(); u->UpdateHost(); - if (ircdproto->CanSetVIdent && !na->GetVhostIdent().empty()) + if (IRCD->CanSetVIdent && !na->GetVhostIdent().empty()) u->SetVIdent(na->GetVhostIdent()); - const BotInfo *bi = findbot(Config->HostServ); - if (bi) + if (HostServ) { if (!na->GetVhostIdent().empty()) - u->SendMessage(bi, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); + u->SendMessage(HostServ, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->GetVhostIdent().c_str(), na->GetVhostHost().c_str()); else - u->SendMessage(bi, _("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str()); + u->SendMessage(HostServ, _("Your vhost of \002%s\002 is now activated."), na->GetVhostHost().c_str()); } } } diff --git a/modules/pseudoclients/hostserv.h b/modules/pseudoclients/hostserv.h new file mode 100644 index 000000000..039e711c3 --- /dev/null +++ b/modules/pseudoclients/hostserv.h @@ -0,0 +1,6 @@ +#ifndef HOSTSERV_H +#define HOSTSERV_H + +static Reference<BotInfo> HostServ; + +#endif // HOSTSERV_H diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp index 9cfca1af3..ee9c127f9 100644 --- a/modules/pseudoclients/memoserv.cpp +++ b/modules/pseudoclients/memoserv.cpp @@ -16,8 +16,8 @@ static bool SendMemoMail(NickCore *nc, MemoInfo *mi, Memo *m) { - Anope::string subject = translate(nc, Config->MailMemoSubject.c_str()); - Anope::string message = translate(nc, Config->MailMemoMessage.c_str()); + Anope::string subject = Language::Translate(nc, Config->MailMemoSubject.c_str()); + Anope::string message = Language::Translate(nc, Config->MailMemoMessage.c_str()); subject = subject.replace_all_cs("%n", nc->display); subject = subject.replace_all_cs("%s", m->sender); @@ -29,7 +29,7 @@ static bool SendMemoMail(NickCore *nc, MemoInfo *mi, Memo *m) message = message.replace_all_cs("%d", mi->GetIndex(m)); message = message.replace_all_cs("%t", m->text); - return Mail(nc, subject, message); + return Mail::Send(nc, subject, message); } class MyMemoServService : public MemoServService @@ -42,14 +42,14 @@ class MyMemoServService : public MemoServService if (!target.empty() && target[0] == '#') { ischan = true; - ChannelInfo *ci = cs_findchan(target); + ChannelInfo *ci = ChannelInfo::Find(target); if (ci != NULL) return &ci->memos; } else { ischan = false; - NickAlias *na = findnick(target); + NickAlias *na = NickAlias::Find(target); if (na != NULL) return &na->nc->memos; } @@ -65,7 +65,7 @@ class MyMemoServService : public MemoServService if (mi == NULL) return MEMO_INVALID_TARGET; - User *sender = finduser(source); + User *sender = User::Find(source); if (sender != NULL && !sender->HasPriv("memoserv/no-limit") && !force) { if (Config->MSSendDelay > 0 && sender->lastmemosend + Config->MSSendDelay > Anope::CurTime) @@ -93,7 +93,7 @@ class MyMemoServService : public MemoServService if (ischan) { - ChannelInfo *ci = cs_findchan(target); + ChannelInfo *ci = ChannelInfo::Find(target); if (ci->c) { @@ -104,25 +104,25 @@ class MyMemoServService : public MemoServService if (ci->AccessFor(cu->user).HasPriv("MEMO")) { if (cu->user->Account() && cu->user->Account()->HasFlag(NI_MEMO_RECEIVE)) - cu->user->SendMessage(findbot(Config->MemoServ), MEMO_NEW_X_MEMO_ARRIVED, ci->name.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), ci->name.c_str(), mi->memos->size()); + cu->user->SendMessage(MemoServ, MEMO_NEW_X_MEMO_ARRIVED, ci->name.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), ci->name.c_str(), mi->memos->size()); } } } } else { - NickCore *nc = findnick(target)->nc; + NickCore *nc = NickAlias::Find(target)->nc; if (nc->HasFlag(NI_MEMO_RECEIVE)) { - for (std::list<serialize_obj<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;) + for (std::list<Serialize::Reference<NickAlias> >::const_iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end;) { const NickAlias *na = *it++; if (!na) continue; - User *user = finduser(na->nick); + User *user = User::Find(na->nick); if (user && user->IsIdentified()) - user->SendMessage(findbot(Config->MemoServ), MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), mi->memos->size()); + user->SendMessage(MemoServ, MEMO_NEW_MEMO_ARRIVED, source.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->MemoServ.c_str(), mi->memos->size()); } } @@ -139,20 +139,19 @@ class MyMemoServService : public MemoServService const NickCore *nc = u->Account(); if (!nc) return; - const BotInfo *ms = findbot(Config->MemoServ); unsigned i = 0, end = nc->memos.memos->size(), newcnt = 0; for (; i < end; ++i) if (nc->memos.GetMemo(i)->HasFlag(MF_UNREAD)) ++newcnt; if (newcnt > 0) - u->SendMessage(ms, newcnt == 1 ? _("You have 1 new memo.") : _("You have %d new memos."), newcnt); + u->SendMessage(MemoServ, newcnt == 1 ? _("You have 1 new memo.") : _("You have %d new memos."), newcnt); if (nc->memos.memomax > 0 && nc->memos.memos->size() >= static_cast<unsigned>(nc->memos.memomax)) { if (nc->memos.memos->size() > static_cast<unsigned>(nc->memos.memomax)) - u->SendMessage(ms, _("You are over your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax); + u->SendMessage(MemoServ, _("You are over your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax); else - u->SendMessage(ms, _("You have reached your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax); + u->SendMessage(MemoServ, _("You have reached your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax); } } }; @@ -166,7 +165,8 @@ class MemoServCore : public Module { this->SetAuthor("Anope"); - if (!findbot(Config->MemoServ)) + MemoServ = BotInfo::Find(Config->MemoServ); + if (!MemoServ) throw ModuleException("No bot named " + Config->MemoServ); Implementation i[] = { I_OnNickIdentify, I_OnJoinChannel, I_OnUserAway, I_OnNickUpdate, I_OnPreHelp, I_OnPostHelp }; @@ -183,9 +183,9 @@ class MemoServCore : public Module if (c->ci && c->ci->AccessFor(u).HasPriv("MEMO") && c->ci->memos.memos->size() > 0) { if (c->ci->memos.memos->size() == 1) - u->SendMessage(findbot(Config->MemoServ), _("There is \002%d\002 memo on channel %s."), c->ci->memos.memos->size(), c->ci->name.c_str()); + u->SendMessage(MemoServ, _("There is \002%d\002 memo on channel %s."), c->ci->memos.memos->size(), c->ci->name.c_str()); else - u->SendMessage(findbot(Config->MemoServ), _("There are \002%d\002 memos on channel %s."), c->ci->memos.memos->size(), c->ci->name.c_str()); + u->SendMessage(MemoServ, _("There are \002%d\002 memos on channel %s."), c->ci->memos.memos->size(), c->ci->name.c_str()); } } diff --git a/modules/pseudoclients/memoserv.h b/modules/pseudoclients/memoserv.h index aae7d26b5..25d453ab0 100644 --- a/modules/pseudoclients/memoserv.h +++ b/modules/pseudoclients/memoserv.h @@ -35,7 +35,8 @@ class MemoServService : public Service virtual void Check(User *u) = 0; }; -static service_reference<MemoServService> memoserv("MemoServService", "MemoServ"); +static ServiceReference<MemoServService> MemoServService("MemoServService", "MemoServ"); +static Reference<BotInfo> MemoServ; #endif // MEMOSERV_H diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index 637003682..95044f610 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -15,23 +15,20 @@ #include "nickserv.h" class NickServCollide; -class NickServRelease; typedef std::map<Anope::string, NickServCollide *> nickservcollides_map; -typedef std::map<Anope::string, NickServRelease *> nickservreleases_map; static nickservcollides_map NickServCollides; -static nickservreleases_map NickServReleases; /** Timer for colliding nicks to force people off of nicknames */ class NickServCollide : public Timer { - dynamic_reference<User> u; + Reference<User> u; Anope::string nick; public: - /** Default constructor + /** Constructor * @param nick The nick we're colliding * @param delay How long to delay before kicking the user off the nick */ @@ -45,8 +42,6 @@ class NickServCollide : public Timer NickServCollides.insert(std::make_pair(nick, this)); } - /** Default destructor - */ virtual ~NickServCollide() { NickServCollides.erase(this->nick); @@ -60,7 +55,7 @@ class NickServCollide : public Timer if (!u) return; /* If they identified or don't exist anymore, don't kill them. */ - NickAlias *na = findnick(u->nick); + NickAlias *na = NickAlias::Find(u->nick); if (!na || u->Account() == na->nc || u->timestamp > this->GetSetTime()) return; @@ -75,10 +70,9 @@ class MyNickServService : public NickServService void Validate(User *u) anope_override { - NickAlias *na = findnick(u->nick); + NickAlias *na = NickAlias::Find(u->nick); if (!na) return; - const BotInfo *NickServ = findbot(Config->NickServ); if (na->nc->HasFlag(NI_SUSPENDED)) { @@ -124,12 +118,12 @@ class MyNickServService : public NickServService } else if (na->nc->HasFlag(NI_KILL_QUICK)) { - u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), duration(Config->NSKillQuick, u->Account()).c_str()); + u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(Config->NSKillQuick, u->Account()).c_str()); new NickServCollide(u, Config->NSKillQuick); } else { - u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), duration(Config->NSKill, u->Account()).c_str()); + u->SendMessage(NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(Config->NSKill, u->Account()).c_str()); new NickServCollide(u, Config->NSKill); } } @@ -144,7 +138,7 @@ class ExpireCallback : public CallBack void Tick(time_t) anope_override { - if (noexpire || readonly) + if (Anope::NoExpire || Anope::ReadOnly) return; for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ) @@ -152,7 +146,7 @@ class ExpireCallback : public CallBack NickAlias *na = it->second; ++it; - User *u = finduser(na->nick); + User *u = User::Find(na->nick); if (u && (na->nc->HasFlag(NI_SECURE) ? u->IsIdentified(true) : u->IsRecognized())) na->last_seen = Anope::CurTime; @@ -175,7 +169,7 @@ class ExpireCallback : public CallBack extra = "suspended "; Log(LOG_NORMAL, "expire") << "Expiring " << extra << "nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " << (na->nc->email.empty() ? "none" : na->nc->email) << ")"; FOREACH_MOD(I_OnNickExpire, OnNickExpire(na)); - na->destroy(); + na->Destroy(); } } } @@ -191,7 +185,8 @@ class NickServCore : public Module { this->SetAuthor("Anope"); - if (!findbot(Config->NickServ)) + NickServ = BotInfo::Find(Config->NickServ); + if (!NickServ) throw ModuleException("No bot named " + Config->NickServ); Implementation i[] = { I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickIdentify, I_OnNickGroup, @@ -201,45 +196,41 @@ class NickServCore : public Module void OnDelNick(NickAlias *na) anope_override { - User *u = finduser(na->nick); + User *u = User::Find(na->nick); if (u && u->Account() == na->nc) { - ircdproto->SendLogout(u); - u->RemoveMode(findbot(Config->NickServ), UMODE_REGISTERED); + IRCD->SendLogout(u); + u->RemoveMode(NickServ, UMODE_REGISTERED); u->Logout(); } } void OnDelCore(NickCore *nc) anope_override { - Log(findbot(Config->NickServ), "nick") << "deleting nickname group " << nc->display; + Log(NickServ, "nick") << "deleting nickname group " << nc->display; - /* Clean up this nick core from any users online using it - * (ones that /nick but remain unidentified) - */ - for (std::list<User *>::iterator it = nc->Users.begin(); it != nc->Users.end();) + /* Clean up this nick core from any users online */ + for (std::list<User *>::iterator it = nc->users.begin(); it != nc->users.end();) { User *user = *it++; - ircdproto->SendLogout(user); - user->RemoveMode(findbot(Config->NickServ), UMODE_REGISTERED); + IRCD->SendLogout(user); + user->RemoveMode(NickServ, UMODE_REGISTERED); user->Logout(); FOREACH_MOD(I_OnNickLogout, OnNickLogout(user)); } - nc->Users.clear(); + nc->users.clear(); } void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) anope_override { - Log(LOG_NORMAL, "nick", findbot(Config->NickServ)) << "Changing " << nc->display << " nickname group display to " << newdisplay; + Log(LOG_NORMAL, "nick", NickServ) << "Changing " << nc->display << " nickname group display to " << newdisplay; } void OnNickIdentify(User *u) anope_override { - const BotInfo *NickServ = findbot(Config->NickServ); - if (!Config->NoNicknameOwnership) { - const NickAlias *this_na = findnick(u->nick); + const NickAlias *this_na = NickAlias::Find(u->nick); if (this_na && this_na->nc == u->Account() && u->Account()->HasFlag(NI_UNCONFIRMED) == false) u->SetMode(NickServ, UMODE_REGISTERED); } @@ -250,7 +241,7 @@ class NickServCore : public Module ChannelContainer *cc = *it; Channel *c = cc->chan; if (c) - chan_set_correct_modes(u, c, 1, true); + c->SetCorrectModes(u, true, true); } if (!Config->NSModesOnID.empty()) @@ -269,17 +260,17 @@ class NickServCore : public Module if (u->Account()->HasFlag(NI_UNCONFIRMED)) { u->SendMessage(NickServ, _("Your email address is not confirmed. To confirm it, follow the instructions that were emailed to you when you registered.")); - const NickAlias *this_na = findnick(u->Account()->display); + const NickAlias *this_na = NickAlias::Find(u->Account()->display); time_t time_registered = Anope::CurTime - this_na->time_registered; if (Config->NSUnconfirmedExpire > time_registered) - u->SendMessage(NickServ, _("Your account will expire, if not confirmed, in %s"), duration(Config->NSUnconfirmedExpire - time_registered).c_str()); + u->SendMessage(NickServ, _("Your account will expire, if not confirmed, in %s"), Anope::Duration(Config->NSUnconfirmedExpire - time_registered).c_str()); } } void OnNickGroup(User *u, NickAlias *target) anope_override { if (target->nc->HasFlag(NI_UNCONFIRMED) == false) - u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); + u->SetMode(NickServ, UMODE_REGISTERED); } void OnNickUpdate(User *u) anope_override @@ -289,14 +280,13 @@ class NickServCore : public Module ChannelContainer *cc = *it; Channel *c = cc->chan; if (c) - chan_set_correct_modes(u, c, 1, false); + c->SetCorrectModes(u, true, true); } } void OnUserNickChange(User *u, const Anope::string &oldnick) anope_override { - const NickAlias *na = findnick(u->nick); - const BotInfo *NickServ = findbot(Config->NickServ); + const NickAlias *na = NickAlias::Find(u->nick); /* If the new nick isnt registerd or its registerd and not yours */ if (!na || na->nc != u->Account()) { @@ -308,7 +298,7 @@ class NickServCore : public Module else { /* Reset +r and re-send account (even though it really should be set at this point) */ - ircdproto->SendLogin(u); + IRCD->SendLogin(u); if (!Config->NoNicknameOwnership && na->nc == u->Account() && na->nc->HasFlag(NI_UNCONFIRMED) == false) u->SetMode(NickServ, UMODE_REGISTERED); Log(NickServ) << u->GetMask() << " automatically identified for group " << u->Account()->display; @@ -318,7 +308,7 @@ class NickServCore : public Module void OnUserModeSet(User *u, UserModeName Name) anope_override { if (Name == UMODE_REGISTERED && !u->IsIdentified()) - u->RemoveMode(findbot(Config->NickServ), Name); + u->RemoveMode(NickServ, Name); } EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override @@ -357,10 +347,10 @@ class NickServCore : public Module "nickname(s)."), Config->NickServ.c_str()); } - void OnUserConnect(dynamic_reference<User> &u, bool &exempt) anope_override + void OnUserConnect(Reference<User> &u, bool &exempt) anope_override { - if (!Config->NoNicknameOwnership && !Config->NSUnregisteredNotice.empty() && u && !findnick(u->nick)) - u->SendMessage(findbot(Config->NickServ), Config->NSUnregisteredNotice); + if (!Config->NoNicknameOwnership && !Config->NSUnregisteredNotice.empty() && u && !NickAlias::Find(u->nick)) + u->SendMessage(NickServ, Config->NSUnregisteredNotice); } }; diff --git a/modules/pseudoclients/nickserv.h b/modules/pseudoclients/nickserv.h index 750b77784..52934fe96 100644 --- a/modules/pseudoclients/nickserv.h +++ b/modules/pseudoclients/nickserv.h @@ -9,7 +9,8 @@ class NickServService : public Service virtual void Validate(User *u) = 0; }; -static service_reference<NickServService> nickserv("NickServService", "NickServ"); +static ServiceReference<NickServService> NickServService("NickServService", "NickServ"); +static Reference<BotInfo> NickServ; #endif // NICKSERV_H diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp index cc051d685..8ee8c211b 100644 --- a/modules/pseudoclients/operserv.cpp +++ b/modules/pseudoclients/operserv.cpp @@ -25,28 +25,28 @@ class SGLineManager : public XLineManager void OnExpire(const XLine *x) anope_override { - Log(findbot(Config->OperServ), "expire/akill") << "AKILL on \2" << x->Mask << "\2 has expired"; + Log(OperServ, "expire/akill") << "AKILL on \2" << x->mask << "\2 has expired"; } void Send(User *u, XLine *x) anope_override { - ircdproto->SendAkill(u, x); + IRCD->SendAkill(u, x); } void SendDel(XLine *x) anope_override { try { - if (!ircdproto->CanSZLine) + if (!IRCD->CanSZLine) throw SocketException("SZLine is not supported"); else if (x->GetUser() != "*") throw SocketException("Can not ZLine a username"); sockaddrs(x->GetHost()); - ircdproto->SendSZLineDel(x); + IRCD->SendSZLineDel(x); } catch (const SocketException &) { - ircdproto->SendAkillDel(x); + IRCD->SendAkillDel(x); } } @@ -101,30 +101,30 @@ class SQLineManager : public XLineManager void OnExpire(const XLine *x) anope_override { - Log(findbot(Config->OperServ), "expire/sqline") << "SQLINE on \2" << x->Mask << "\2 has expired"; + Log(OperServ, "expire/sqline") << "SQLINE on \2" << x->mask << "\2 has expired"; } void Send(User *u, XLine *x) anope_override { - ircdproto->SendSQLine(u, x); + IRCD->SendSQLine(u, x); } void SendDel(XLine *x) anope_override { - ircdproto->SendSQLineDel(x); + IRCD->SendSQLineDel(x); } bool Check(User *u, const XLine *x) anope_override { if (x->regex) return x->regex->Matches(u->nick); - return Anope::Match(u->nick, x->Mask); + return Anope::Match(u->nick, x->mask); } bool CheckChannel(Channel *c) { for (std::vector<XLine *>::const_iterator it = this->GetList().begin(), it_end = this->GetList().end(); it != it_end; ++it) - if (Anope::Match(c->name, (*it)->Mask, false, true)) + if (Anope::Match(c->name, (*it)->mask, false, true)) return true; return false; } @@ -142,24 +142,24 @@ class SNLineManager : public XLineManager void OnExpire(const XLine *x) anope_override { - Log(findbot(Config->OperServ), "expire/snline") << "SNLINE on \2" << x->Mask << "\2 has expired"; + Log(OperServ, "expire/snline") << "SNLINE on \2" << x->mask << "\2 has expired"; } void Send(User *u, XLine *x) anope_override { - ircdproto->SendSGLine(u, x); + IRCD->SendSGLine(u, x); } void SendDel(XLine *x) anope_override { - ircdproto->SendSGLineDel(x); + IRCD->SendSGLineDel(x); } bool Check(User *u, const XLine *x) anope_override { if (x->regex) return x->regex->Matches(u->realname); - return Anope::Match(u->realname, x->Mask, false, true); + return Anope::Match(u->realname, x->mask, false, true); } }; @@ -175,7 +175,8 @@ class OperServCore : public Module { this->SetAuthor("Anope"); - if (!findbot(Config->OperServ)) + OperServ = BotInfo::Find(Config->OperServ); + if (!OperServ) throw ModuleException("No bot named " + Config->OperServ); Implementation i[] = { I_OnBotPrivmsg, I_OnServerQuit, I_OnUserModeSet, I_OnUserModeUnset, I_OnUserConnect, I_OnUserNickChange, I_OnPreHelp }; @@ -203,7 +204,7 @@ class OperServCore : public Module if (Config->OSOpersOnly && !u->HasMode(UMODE_OPER) && bi->nick == Config->OperServ) { u->SendMessage(bi, ACCESS_DENIED); - Log(findbot(Config->OperServ), "bados") << "Denied access to " << Config->OperServ << " from " << u->GetMask() << " (non-oper)"; + Log(OperServ, "bados") << "Denied access to " << Config->OperServ << " from " << u->GetMask() << " (non-oper)"; return EVENT_STOP; } @@ -213,22 +214,22 @@ class OperServCore : public Module void OnServerQuit(Server *server) anope_override { if (server->HasFlag(SERVER_JUPED)) - Log(server, "squit", findbot(Config->OperServ)) << "Received SQUIT for juped server " << server->GetName(); + Log(server, "squit", OperServ) << "Received SQUIT for juped server " << server->GetName(); } void OnUserModeSet(User *u, UserModeName Name) anope_override { if (Name == UMODE_OPER) - Log(u, "oper", findbot(Config->OperServ)) << "is now an IRC operator."; + Log(u, "oper", OperServ) << "is now an IRC operator."; } void OnUserModeUnset(User *u, UserModeName Name) anope_override { if (Name == UMODE_OPER) - Log(u, "oper", findbot(Config->OperServ)) << "is no longer an IRC operator"; + Log(u, "oper", OperServ) << "is no longer an IRC operator"; } - void OnUserConnect(dynamic_reference<User> &u, bool &exempt) anope_override + void OnUserConnect(Reference<User> &u, bool &exempt) anope_override { if (u && !exempt) XLineManager::CheckAll(u); @@ -236,7 +237,7 @@ class OperServCore : public Module void OnUserNickChange(User *u, const Anope::string &oldnick) anope_override { - if (ircdproto->CanSQLine && !u->HasMode(UMODE_OPER)) + if (IRCD->CanSQLine && !u->HasMode(UMODE_OPER)) this->sqlines.CheckAllXLines(u); } diff --git a/modules/pseudoclients/operserv.h b/modules/pseudoclients/operserv.h new file mode 100644 index 000000000..dd9dafc76 --- /dev/null +++ b/modules/pseudoclients/operserv.h @@ -0,0 +1,6 @@ +#ifndef OPERSERV_H +#define OPERSERV_H + +static Reference<BotInfo> OperServ; + +#endif // OPERSERV_H |
