diff options
| author | 2026-03-08 17:01:22 +0000 | |
|---|---|---|
| committer | 2026-03-08 17:47:44 +0000 | |
| commit | bb1e5a7b60ea200ddae99f263a38a219879f9617 (patch) | |
| tree | a5cecddf75a3458447d09ca1fa2f859c4486ddec /modules | |
| parent | Remove the unused remote user finding methods. (diff) | |
Replace IS_* with member functions.
- All user types get an Is* function.
- Only local users are cast using the old function so only local
users get an As* function.
Diffstat (limited to 'modules')
112 files changed, 263 insertions, 261 deletions
diff --git a/modules/account.cpp b/modules/account.cpp index c5c2f74af..2b68513d8 100644 --- a/modules/account.cpp +++ b/modules/account.cpp @@ -63,7 +63,7 @@ public: StringExtItem::FromNetwork(container, value); User* user = static_cast<User*>(container); - if (IS_LOCAL(user)) + if (user->IsLocal()) { if (value.empty()) { @@ -233,7 +233,7 @@ public: ModResult HandleMessage(User* user, const MessageTarget& target) { - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return MOD_RES_PASSTHRU; diff --git a/modules/alias.cpp b/modules/alias.cpp index 394c9f24f..9f15868f9 100644 --- a/modules/alias.cpp +++ b/modules/alias.cpp @@ -211,7 +211,7 @@ public: } // fcommands are only for local users. Spanningtree will send them back out as their original cmd. - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (!luser) { return; diff --git a/modules/allowinvite.cpp b/modules/allowinvite.cpp index f19ede8d4..6f50a0e1c 100644 --- a/modules/allowinvite.cpp +++ b/modules/allowinvite.cpp @@ -42,7 +42,7 @@ public: ModResult OnUserPreInvite(User* user, User* dest, Channel* channel, time_t timeout) override { - if (IS_LOCAL(user)) + if (user->IsLocal()) { ModResult res = extban.GetStatus(user, channel); if (res == MOD_RES_DENY) diff --git a/modules/anticaps.cpp b/modules/anticaps.cpp index 48f1d7b8b..d8ba8ee02 100644 --- a/modules/anticaps.cpp +++ b/modules/anticaps.cpp @@ -214,7 +214,7 @@ public: ModResult OnUserPreMessage(User* user, MessageTarget& target, MessageDetails& details) override { // We only want to operate on messages from local users. - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return MOD_RES_PASSTHRU; // The mode can only be applied to channels. diff --git a/modules/auditorium.cpp b/modules/auditorium.cpp index 439d8ed08..98852a1a5 100644 --- a/modules/auditorium.cpp +++ b/modules/auditorium.cpp @@ -143,7 +143,7 @@ public: for (const auto& [user, _] : memb->chan->GetUsers()) { - if (IS_LOCAL(user) && !CanSee(user, memb)) + if (user->IsLocal() && !CanSee(user, memb)) excepts.insert(user); } } @@ -174,7 +174,7 @@ public: // however, that might hide me from ops that can see me... for (const auto& [user, _] : memb->chan->GetUsers()) { - if (IS_LOCAL(user) && CanSee(user, memb)) + if (user->IsLocal() && CanSee(user, memb)) exception[user] = true; } } diff --git a/modules/autoop.cpp b/modules/autoop.cpp index f5a86ae26..3b6306052 100644 --- a/modules/autoop.cpp +++ b/modules/autoop.cpp @@ -102,7 +102,7 @@ public: void OnPostJoin(Membership* memb) override { - if (!IS_LOCAL(memb->user)) + if (!memb->user->IsLocal()) return; ListModeBase::ModeList* list = mh.GetList(memb->chan); diff --git a/modules/banredirect.cpp b/modules/banredirect.cpp index 744bad094..aa89b5353 100644 --- a/modules/banredirect.cpp +++ b/modules/banredirect.cpp @@ -162,7 +162,7 @@ public: if(mask[CHAN].length()) { - if (change.adding && IS_LOCAL(source)) + if (change.adding && source->IsLocal()) { if (!ServerInstance->Channels.IsChannel(mask[CHAN])) { diff --git a/modules/blockcolor.cpp b/modules/blockcolor.cpp index 032fdc7d5..d18f91adc 100644 --- a/modules/blockcolor.cpp +++ b/modules/blockcolor.cpp @@ -47,7 +47,7 @@ public: ModResult OnUserPreMessage(User* user, MessageTarget& target, MessageDetails& details) override { - if ((target.type == MessageTarget::TYPE_CHANNEL) && (IS_LOCAL(user))) + if ((target.type == MessageTarget::TYPE_CHANNEL) && (user->IsLocal())) { auto* c = target.Get<Channel>(); diff --git a/modules/callerid.cpp b/modules/callerid.cpp index 4c2b318c1..24e142f03 100644 --- a/modules/callerid.cpp +++ b/modules/callerid.cpp @@ -173,7 +173,7 @@ class CommandAccept final tok.erase(tok.begin()); User* target; - if (!cmdfrom || !IS_LOCAL(cmdfrom)) + if (!cmdfrom || !cmdfrom->IsLocal()) target = ServerInstance->Users.Find(tok, true); else target = ServerInstance->Users.FindNick(tok, true); @@ -237,7 +237,7 @@ public: return CmdResult::FAILURE; } - if ((!IS_LOCAL(user)) && (!IS_LOCAL(action.first))) + if ((!user->IsLocal()) && (!action.first->IsLocal())) // Neither source nor target is local, forward the command to the server of target return CmdResult::SUCCESS; @@ -257,7 +257,7 @@ public: // Or if the source is local then LoopCall() runs OnPostCommand() after each entry in the list, // meaning the linking module has sent an ACCEPT already for each entry in the list to the // appropriate server and the ACCEPT with the list of nicks (this) doesn't need to be sent anywhere. - if ((!IS_LOCAL(user)) && (parameters[0].find(',') != std::string::npos)) + if ((!user->IsLocal()) && (parameters[0].find(',') != std::string::npos)) return ROUTE_BROADCAST; // Find the target @@ -411,7 +411,7 @@ public: ModResult HandleMessage(User* user, const MessageTarget& target) { - if (!IS_LOCAL(user) || target.type != MessageTarget::TYPE_USER) + if (!user->IsLocal() || target.type != MessageTarget::TYPE_USER) return MOD_RES_PASSTHRU; auto* dest = target.Get<User>(); diff --git a/modules/cap.cpp b/modules/cap.cpp index f171d89a4..e4aa90609 100644 --- a/modules/cap.cpp +++ b/modules/cap.cpp @@ -284,8 +284,8 @@ namespace { std::string SerializeCaps(const Extensible* container, bool human) { - // XXX: Cast away the const because IS_LOCAL() doesn't handle it - LocalUser* user = IS_LOCAL(const_cast<User*>(static_cast<const User*>(container))); + // XXX: Cast away the const because HandleList doesn't handle it + auto* user = const_cast<User*>(static_cast<const User*>(container))->AsLocal(); if (!user) return {}; @@ -333,7 +333,7 @@ void Cap::ExtItem::FromInternal(Extensible* container, const std::string& value) if (container->extype != this->extype) return; - LocalUser* user = IS_LOCAL(static_cast<User*>(container)); + auto* user = static_cast<User*>(container)->AsLocal(); if (!user) return; // Can't happen diff --git a/modules/chancreate.cpp b/modules/chancreate.cpp index 5e17c22d1..07d4e2239 100644 --- a/modules/chancreate.cpp +++ b/modules/chancreate.cpp @@ -40,7 +40,7 @@ public: void OnUserJoin(Membership* memb, bool sync, bool created, CUList& except) override { - if ((created) && (IS_LOCAL(memb->user))) + if ((created) && (memb->user->IsLocal())) { ServerInstance->SNO.WriteGlobalSno('j', "Channel {} created by {} [{}]", memb->chan->name, memb->user->GetRealMask(), memb->user->GetAddress()); diff --git a/modules/chanfilter.cpp b/modules/chanfilter.cpp index ab8531058..d6bc01db2 100644 --- a/modules/chanfilter.cpp +++ b/modules/chanfilter.cpp @@ -71,7 +71,7 @@ class ModuleChanFilter final const ChanFilter::ListItem* Match(User* user, Channel* chan, const std::string& text) { - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return nullptr; // We don't handle remote users. if (user->HasPrivPermission("channels/ignore-chanfilter")) @@ -123,7 +123,7 @@ public: return; // Match() checks the user is local, we can assume from here - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); std::string oldreason(partmessage); partmessage = "Reason filtered"; diff --git a/modules/chanhistory.cpp b/modules/chanhistory.cpp index 86058c365..6578fc159 100644 --- a/modules/chanhistory.cpp +++ b/modules/chanhistory.cpp @@ -89,7 +89,7 @@ private: if (!Duration::TryFrom(durationstr, duration) || duration == 0) return false; - if (IS_LOCAL(user) && maxduration && duration > maxduration) + if (user->IsLocal() && maxduration && duration > maxduration) duration = maxduration; // Clamp for local users. return true; @@ -105,7 +105,7 @@ private: if (lines == 0) return false; - if (IS_LOCAL(user) && maxlines && lines > maxlines) + if (user->IsLocal() && maxlines && lines > maxlines) lines = maxlines; // Clamp for local users. return true; @@ -265,7 +265,7 @@ public: void OnPostJoin(Membership* memb) override { - LocalUser* localuser = IS_LOCAL(memb->user); + auto* localuser = memb->user->AsLocal(); if (!localuser) return; diff --git a/modules/channames.cpp b/modules/channames.cpp index f2d088be6..6e10f2799 100644 --- a/modules/channames.cpp +++ b/modules/channames.cpp @@ -85,7 +85,7 @@ public: Channel::MemberMap& users = c->userlist; for (Channel::MemberMap::iterator j = users.begin(); j != users.end(); ) { - if (IS_LOCAL(j->first)) + if (j->first->IsLocal()) { // KickUser invalidates the iterator Channel::MemberMap::iterator it = j++; diff --git a/modules/check.cpp b/modules/check.cpp index ba9cd8b8e..4935b5376 100644 --- a/modules/check.cpp +++ b/modules/check.cpp @@ -109,7 +109,7 @@ public: { public: List(CheckContext& context, const char* checktype) - : Numeric::GenericBuilder<' ', false, Numeric::WriteRemoteNumericSink>(Numeric::WriteRemoteNumericSink(context.GetUser()), RPL_CHECK, false, (IS_LOCAL(context.GetUser()) ? context.GetUser()->nick.length() : ServerInstance->Config->Limits.MaxNick) + strlen(checktype) + 1) + : Numeric::GenericBuilder<' ', false, Numeric::WriteRemoteNumericSink>(Numeric::WriteRemoteNumericSink(context.GetUser()), RPL_CHECK, false, (context.GetUser()->IsLocal() ? context.GetUser()->nick.length() : ServerInstance->Config->Limits.MaxNick) + strlen(checktype) + 1) { GetNumeric().push(checktype).push(std::string()); } @@ -164,7 +164,7 @@ public: if (targetuser) { - LocalUser* localtarget = IS_LOCAL(targetuser); + auto* localtarget = targetuser->AsLocal(); /* /check on a user */ context.Write("nuh", targetuser->GetMask()); context.Write("realnuh", targetuser->GetRealMask()); diff --git a/modules/classban.cpp b/modules/classban.cpp index 8bc15ef82..ecf4fa5fb 100644 --- a/modules/classban.cpp +++ b/modules/classban.cpp @@ -35,7 +35,7 @@ public: bool IsMatch(User* user, Channel* channel, const std::string& text, const ExtBan::MatchConfig& config) override { - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (!luser) return false; diff --git a/modules/clearchan.cpp b/modules/clearchan.cpp index fef47a21c..fc822bd79 100644 --- a/modules/clearchan.cpp +++ b/modules/clearchan.cpp @@ -72,7 +72,7 @@ public: const std::string reason = parameters.size() > 2 ? parameters.back() : "Clearing " + chan->name; if (!user->server->IsSilentService()) - ServerInstance->SNO.WriteToSnoMask((IS_LOCAL(user) ? 'a' : 'A'), user->nick + " has cleared \002" + chan->name + "\002 (" + method + "): " + reason); + ServerInstance->SNO.WriteToSnoMask((user->IsLocal() ? 'a' : 'A'), user->nick + " has cleared \002" + chan->name + "\002 (" + method + "): " + reason); user->WriteNotice("Clearing \002" + chan->name + "\002 (" + method + "): " + reason); @@ -102,7 +102,7 @@ public: const Channel::MemberMap::iterator currit = i; ++i; - if (!IS_LOCAL(curr) || curr->IsOper()) + if (!curr->IsLocal() || curr->IsOper()) continue; // If kicking users, remove them and skip the QuitUser() @@ -178,7 +178,7 @@ public: for (const auto& [member, _] : cmd.activechan->GetUsers()) { - LocalUser* curr = IS_LOCAL(member); + auto* curr = member->AsLocal(); if (!curr) continue; @@ -207,7 +207,7 @@ public: User* leaving = memb->user; for (const auto& [curr, _] : memb->chan->GetUsers()) { - if ((IS_LOCAL(curr)) && (!curr->IsOper()) && (curr != leaving)) + if ((curr->IsLocal()) && (!curr->IsOper()) && (curr != leaving)) excepts.insert(curr); } } diff --git a/modules/cloak.cpp b/modules/cloak.cpp index 0222f6548..6c436da7f 100644 --- a/modules/cloak.cpp +++ b/modules/cloak.cpp @@ -289,11 +289,11 @@ public: bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { // For remote users blindly allow this - LocalUser* user = IS_LOCAL(dest); + auto* user = dest->AsLocal(); if (!user) { // Remote setters broadcast mode before host while local setters do the opposite. - active = IS_LOCAL(source) ? change.adding : !change.adding; + active = source->IsLocal() ? change.adding : !change.adding; dest->SetMode(this, change.adding); return true; } @@ -354,7 +354,7 @@ private: { user->SetMode(cloakmode, false); - auto* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (luser) { Modes::ChangeList changelist; @@ -478,7 +478,7 @@ public: ModResult OnCheckBan(User* user, Channel* chan, const std::string& mask, bool full) override { - LocalUser* lu = IS_LOCAL(user); + auto* lu = user->AsLocal(); if (!lu) return MOD_RES_PASSTHRU; // We don't have cloaks for remote users. diff --git a/modules/cloak_custom.cpp b/modules/cloak_custom.cpp index dae917d64..1ca666797 100644 --- a/modules/cloak_custom.cpp +++ b/modules/cloak_custom.cpp @@ -52,7 +52,7 @@ public: Set(container, cloak, false); - auto *luser = IS_LOCAL(static_cast<User*>(container)); + auto *luser = static_cast<User*>(container)->AsLocal(); if (!luser || !cloakapi) return; diff --git a/modules/cloak_user.cpp b/modules/cloak_user.cpp index 8db96325e..76d7820fa 100644 --- a/modules/cloak_user.cpp +++ b/modules/cloak_user.cpp @@ -364,7 +364,7 @@ public: void OnAccountChange(User* user, const std::string& newaccount) override { - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (!luser || !cloakapi) return; @@ -374,14 +374,14 @@ public: void OnChangeRealUser(User* user, const std::string& newuser) override { - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (luser && cloakapi && cloakapi->IsActiveCloak(usernamecloak)) cloakapi->ResetCloaks(luser, true); } void OnUserPostNick(User* user, const std::string& oldnick) override { - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (luser && cloakapi && cloakapi->IsActiveCloak(nicknamecloak)) cloakapi->ResetCloaks(luser, true); } diff --git a/modules/conn_join.cpp b/modules/conn_join.cpp index a5cc5d29a..c49ca0618 100644 --- a/modules/conn_join.cpp +++ b/modules/conn_join.cpp @@ -96,7 +96,7 @@ public: void OnPostConnect(User* user) override { - LocalUser* localuser = IS_LOCAL(user); + auto* localuser = user->AsLocal(); if (!localuser) return; diff --git a/modules/core/core_channel/cmd_invite.cpp b/modules/core/core_channel/cmd_invite.cpp index d2e734b20..e511230fc 100644 --- a/modules/core/core_channel/cmd_invite.cpp +++ b/modules/core/core_channel/cmd_invite.cpp @@ -59,7 +59,7 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters) if (parameters.size() >= 2) { User* u; - if (IS_LOCAL(user)) + if (user->IsLocal()) u = ServerInstance->Users.FindNick(parameters[0], true); else u = ServerInstance->Users.Find(parameters[0], true); @@ -68,7 +68,7 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters) time_t timeout = 0; if (parameters.size() >= 3) { - if (IS_LOCAL(user)) + if (user->IsLocal()) { unsigned long duration; if (!Duration::TryFrom(parameters[2], duration)) @@ -94,7 +94,7 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters) } // Verify channel timestamp if the INVITE is coming from a remote server - if (!IS_LOCAL(user)) + if (!user->IsLocal()) { // Remote INVITE commands must carry a channel timestamp if (parameters.size() < 3) @@ -106,7 +106,7 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters) return CmdResult::FAILURE; } - if ((IS_LOCAL(user)) && (!c->HasUser(user))) + if ((user->IsLocal()) && (!c->HasUser(user))) { user->WriteNumeric(ERR_NOTONCHANNEL, c->name, "You're not on that channel!"); return CmdResult::FAILURE; @@ -126,7 +126,7 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters) } else if (modres == MOD_RES_PASSTHRU) { - if (IS_LOCAL(user)) + if (user->IsLocal()) { ModeHandler::Rank rank = c->GetPrefixValue(user); if (rank < HALFOP_VALUE) @@ -137,7 +137,7 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters) } } - LocalUser* const localtargetuser = IS_LOCAL(u); + auto* const localtargetuser = u->AsLocal(); if (localtargetuser) { invapi.Create(localtargetuser, c, timeout); @@ -145,7 +145,7 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters) localtargetuser->Send(ServerInstance->GetRFCEvents().invite, invitemsg); } - if (IS_LOCAL(user)) + if (user->IsLocal()) { user->WriteNumeric(RPL_INVITING, u->nick, c->name); if (u->IsAway()) @@ -193,11 +193,11 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters) c->Write(ServerInstance->GetRFCEvents().privmsg, privmsg, prefix, excepts); } } - else if (IS_LOCAL(user)) + else if (user->IsLocal()) { // pinched from ircu - invite with not enough parameters shows channels // youve been invited to but haven't joined yet. - const Invite::List* list = invapi.GetList(IS_LOCAL(user)); + const auto* list = invapi.GetList(user->AsLocal()); if (list) { for (const auto* invite : *list) @@ -210,5 +210,5 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters) RouteDescriptor CommandInvite::GetRouting(User* user, const Params& parameters) { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); + return (user->IsLocal() ? ROUTE_LOCALONLY : ROUTE_BROADCAST); } diff --git a/modules/core/core_channel/cmd_kick.cpp b/modules/core/core_channel/cmd_kick.cpp index 6b57c258b..c3e895803 100644 --- a/modules/core/core_channel/cmd_kick.cpp +++ b/modules/core/core_channel/cmd_kick.cpp @@ -46,7 +46,7 @@ CmdResult CommandKick::Handle(User* user, const Params& parameters) if (CommandParser::LoopCall(user, this, parameters, 1, extra)) return CmdResult::SUCCESS; - if (IS_LOCAL(user)) + if (user->IsLocal()) u = ServerInstance->Users.FindNick(parameters[1], true); else u = ServerInstance->Users.Find(parameters[1], true); @@ -63,7 +63,7 @@ CmdResult CommandKick::Handle(User* user, const Params& parameters) } Membership* srcmemb = nullptr; - if (IS_LOCAL(user)) + if (user->IsLocal()) { srcmemb = c->GetUser(user); if (!srcmemb) @@ -82,7 +82,7 @@ CmdResult CommandKick::Handle(User* user, const Params& parameters) Membership* const memb = victimiter->second; // KICKs coming from servers can carry a membership id - if ((!IS_LOCAL(user)) && (parameters.size() > 3)) + if ((!user->IsLocal()) && (parameters.size() > 3)) { // If the current membership id is not equal to the one in the message then the user rejoined if (memb->id != Membership::IdFromString(parameters[2])) @@ -131,5 +131,5 @@ CmdResult CommandKick::Handle(User* user, const Params& parameters) RouteDescriptor CommandKick::GetRouting(User* user, const Params& parameters) { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); + return (user->IsLocal() ? ROUTE_LOCALONLY : ROUTE_BROADCAST); } diff --git a/modules/core/core_channel/cmode_k.cpp b/modules/core/core_channel/cmode_k.cpp index a23e56127..5c753d344 100644 --- a/modules/core/core_channel/cmode_k.cpp +++ b/modules/core/core_channel/cmode_k.cpp @@ -42,7 +42,7 @@ bool ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, Modes:: { const std::string* key = ext.Get(channel); bool exists = (key != nullptr); - if (IS_LOCAL(source)) + if (source->IsLocal()) { if (exists == change.adding) return false; diff --git a/modules/core/core_channel/core_channel.cpp b/modules/core/core_channel/core_channel.cpp index 09ffccb61..5a863ec4c 100644 --- a/modules/core/core_channel/core_channel.cpp +++ b/modules/core/core_channel/core_channel.cpp @@ -131,7 +131,7 @@ class CoreModChannel final ModResult IsInvited(User* user, Channel* chan) { - LocalUser* localuser = IS_LOCAL(user); + auto* localuser = user->AsLocal(); if ((localuser) && (invapi.IsInvited(localuser, chan))) return MOD_RES_ALLOW; return MOD_RES_PASSTHRU; @@ -330,7 +330,7 @@ public: void OnPostJoin(Membership* memb) override { Channel* const chan = memb->chan; - LocalUser* const localuser = IS_LOCAL(memb->user); + auto* const localuser = memb->user->AsLocal(); if (localuser) { // Remove existing invite, if any diff --git a/modules/core/core_channel/modes.cpp b/modules/core/core_channel/modes.cpp index cb7f79b06..cc98b6578 100644 --- a/modules/core/core_channel/modes.cpp +++ b/modules/core/core_channel/modes.cpp @@ -81,7 +81,7 @@ bool ModeChannelLimit::OnSet(User* user, Channel* chan, std::string& parameter) size_t limit = ConvToNum<size_t>(parameter); if (limit < 1 || limit > INTPTR_MAX) { - if (IS_LOCAL(user)) + if (user->IsLocal()) { // If the setter is local then we can safely just reject this here. user->WriteNumeric(Numerics::InvalidModeParameter(chan, this, parameter)); diff --git a/modules/core/core_info/cmd_modules.cpp b/modules/core/core_info/cmd_modules.cpp index d17315c5d..4446743fb 100644 --- a/modules/core/core_info/cmd_modules.cpp +++ b/modules/core/core_info/cmd_modules.cpp @@ -48,7 +48,7 @@ CmdResult CommandModules::Handle(User* user, const Params& parameters) // Don't ask remote servers about their modules unless the local user asking is an oper // 2.0 asks anyway, so let's handle that the same way bool for_us = (parameters.empty() || irc::equals(parameters[0], ServerInstance->Config->ServerName)); - if ((!for_us) || (!IS_LOCAL(user))) + if ((!for_us) || (!user->IsLocal())) { if (!user->IsOper()) { @@ -61,7 +61,7 @@ CmdResult CommandModules::Handle(User* user, const Params& parameters) return CmdResult::SUCCESS; } - bool has_priv = IS_LOCAL(user) && user->HasPrivPermission("servers/auspex"); + const auto has_priv = user->IsLocal() && user->HasPrivPermission("servers/auspex"); for (const auto& [modname, mod] : ServerInstance->Modules.GetModules()) { const auto version = has_priv ? mod->GetVersion() : "*"; diff --git a/modules/core/core_info/cmd_motd.cpp b/modules/core/core_info/cmd_motd.cpp index 17b47de7f..342c1f894 100644 --- a/modules/core/core_info/cmd_motd.cpp +++ b/modules/core/core_info/cmd_motd.cpp @@ -44,14 +44,14 @@ CmdResult CommandMotd::Handle(User* user, const Params& parameters) if (!parameters.empty() && !irc::equals(parameters[0], ServerInstance->Config->ServerName)) { // Give extra penalty if a non-oper queries the /MOTD of a remote server - LocalUser* localuser = IS_LOCAL(user); + auto* localuser = user->AsLocal(); if ((localuser) && (!user->IsOper())) localuser->CommandFloodPenalty += 2000; return CmdResult::SUCCESS; } auto tag = ServerInstance->Config->EmptyTag; - LocalUser* localuser = IS_LOCAL(user); + auto* localuser = user->AsLocal(); if (localuser) tag = localuser->GetClass()->config; diff --git a/modules/core/core_info/cmd_version.cpp b/modules/core/core_info/cmd_version.cpp index 04e0800cf..d06664e98 100644 --- a/modules/core/core_info/cmd_version.cpp +++ b/modules/core/core_info/cmd_version.cpp @@ -50,7 +50,7 @@ void CommandVersion::BuildNumerics() CmdResult CommandVersion::Handle(User* user, const Params& parameters) { user->WriteNumeric(user->IsOper() ? operversion : version); - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (luser) isupport.SendTo(luser); return CmdResult::SUCCESS; diff --git a/modules/core/core_info/core_info.cpp b/modules/core/core_info/core_info.cpp index 0190089ad..739f95f08 100644 --- a/modules/core/core_info/core_info.cpp +++ b/modules/core/core_info/core_info.cpp @@ -270,7 +270,7 @@ public: void OnPostOperLogin(User* user, bool automatic) override { - auto* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (luser) isupport.SendOper(luser); } diff --git a/modules/core/core_info/isupport.cpp b/modules/core/core_info/isupport.cpp index 3efd7a48c..58a6e3cc7 100644 --- a/modules/core/core_info/isupport.cpp +++ b/modules/core/core_info/isupport.cpp @@ -180,7 +180,7 @@ void ISupportManager::Build() // Notify operators of the change. for (auto* oper : ServerInstance->Users.all_opers) { - auto* loper = IS_LOCAL(oper); + auto* loper = oper->AsLocal(); if (loper) SendOper(loper); } diff --git a/modules/core/core_message.cpp b/modules/core/core_message.cpp index 4b37adc3c..99d7fff73 100644 --- a/modules/core/core_message.cpp +++ b/modules/core/core_message.cpp @@ -129,7 +129,7 @@ private: static CmdResult FirePostEvent(User* source, const MessageTarget& msgtarget, const MessageDetails& msgdetails) { // If the source is local and was not sending a CTCP reply then update their idle time. - LocalUser* lsource = IS_LOCAL(source); + auto* lsource = source->AsLocal(); if (lsource && msgdetails.update_idle && (msgdetails.type != MessageType::NOTICE || !msgdetails.IsCTCP())) lsource->idle_lastmsg = ServerInstance->Time(); @@ -213,7 +213,7 @@ private: CmdResult HandleUserTarget(User* source, const Params& parameters) { User* target; - if (IS_LOCAL(source)) + if (source->IsLocal()) { // Local sources can specify either a nick or a nick@server mask as the target. const char* targetserver = strchr(parameters[0].c_str(), '@'); @@ -253,7 +253,7 @@ private: if (target->IsAway() && msgdetails.type == MessageType::PRIVMSG) source->WriteNumeric(RPL_AWAY, target->nick, target->away->message); - LocalUser* const localtarget = IS_LOCAL(target); + auto* const localtarget = target->AsLocal(); if (localtarget) { // Servers can fake the target of a message when it is sent to an individual user. @@ -325,7 +325,7 @@ public: RouteDescriptor GetRouting(User* user, const Params& parameters) override { - if (IS_LOCAL(user)) + if (user->IsLocal()) // This is handled by the OnUserPostMessage hook to split the LoopCall pieces return ROUTE_LOCALONLY; else @@ -355,7 +355,7 @@ public: } User* target; - if (IS_LOCAL(user)) + if (user->IsLocal()) { // Local sources can specify either a nick or a nick@server mask as the target. const char* targetserver = strchr(parameters[0].c_str(), '@'); @@ -420,7 +420,7 @@ public: ModResult OnUserPreMessage(User* user, MessageTarget& target, MessageDetails& details) override { - if (!IS_LOCAL(user) || target.type != MessageTarget::TYPE_CHANNEL) + if (!user->IsLocal() || target.type != MessageTarget::TYPE_CHANNEL) return MOD_RES_PASSTHRU; auto* chan = target.Get<Channel>(); diff --git a/modules/core/core_mode.cpp b/modules/core/core_mode.cpp index d99a12d87..f1259b06e 100644 --- a/modules/core/core_mode.cpp +++ b/modules/core/core_mode.cpp @@ -105,7 +105,7 @@ CmdResult CommandMode::Handle(User* user, const Params& parameters) User* targetuser = nullptr; if (!targetchannel) { - if (IS_LOCAL(user)) + if (user->IsLocal()) targetuser = ServerInstance->Users.FindNick(target); else targetuser = ServerInstance->Users.Find(target); @@ -134,7 +134,7 @@ CmdResult CommandMode::Handle(User* user, const Params& parameters) FIRST_MOD_RESULT(OnPreMode, modres, (user, targetuser, targetchannel, changelist)); ModeParser::ModeProcessFlag flags = ModeParser::MODE_NONE; - if (IS_LOCAL(user)) + if (user->IsLocal()) { if (modres == MOD_RES_PASSTHRU) { @@ -155,7 +155,7 @@ CmdResult CommandMode::Handle(User* user, const Params& parameters) else flags |= ModeParser::MODE_LOCALONLY; - if (IS_LOCAL(user)) + if (user->IsLocal()) ServerInstance->Modes.ProcessSingle(user, targetchannel, targetuser, changelist, flags); else ServerInstance->Modes.Process(user, targetchannel, targetuser, changelist, flags); @@ -173,7 +173,7 @@ CmdResult CommandMode::Handle(User* user, const Params& parameters) RouteDescriptor CommandMode::GetRouting(User* user, const Params& parameters) { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); + return (user->IsLocal() ? ROUTE_LOCALONLY : ROUTE_BROADCAST); } void CommandMode::DisplayListModes(User* user, Channel* chan, const std::string& mode_sequence) diff --git a/modules/core/core_oper/cmd_kill.cpp b/modules/core/core_oper/cmd_kill.cpp index b6d410867..b404151d7 100644 --- a/modules/core/core_oper/cmd_kill.cpp +++ b/modules/core/core_oper/cmd_kill.cpp @@ -81,10 +81,10 @@ CmdResult CommandKill::Handle(User* user, const Params& parameters) * just gets processed and passed on, otherwise, if they are local, it gets prefixed. Makes sense :-) -- w00t */ - if (IS_LOCAL(user)) + if (user->IsLocal()) { /* - * Moved this event inside the IS_LOCAL check also, we don't want half the network killing a user + * Moved this event inside the local check also, we don't want half the network killing a user * and the other half not. This would be a bad thing. ;p -- w00t */ ModResult modres; @@ -115,15 +115,15 @@ CmdResult CommandKill::Handle(User* user, const Params& parameters) if ((!hideservicekills) || (!user->server->IsService())) { - if (IS_LOCAL(user) && IS_LOCAL(target)) + if (user->IsLocal() && target->IsLocal()) ServerInstance->SNO.WriteGlobalSno('k', "Local kill by {}: {} ({})", user->nick, target->GetRealMask(), parameters[1]); else ServerInstance->SNO.WriteToSnoMask('K', "Remote kill by {}: {} ({})", user->nick, target->GetRealMask(), parameters[1]); } - if (IS_LOCAL(target)) + if (target->IsLocal()) { - LocalUser* localu = IS_LOCAL(target); + auto* localu = target->AsLocal(); KillMessage msg(protoev, user, localu, killreason, hidenick); ClientProtocol::Event killevent(protoev, msg); localu->Send(killevent); diff --git a/modules/core/core_oper/core_oper.cpp b/modules/core/core_oper/core_oper.cpp index 3f8b8ba68..2fd48abf5 100644 --- a/modules/core/core_oper/core_oper.cpp +++ b/modules/core/core_oper/core_oper.cpp @@ -69,7 +69,7 @@ public: void OnPostConnect(User* user) override { - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (!luser) return; @@ -100,7 +100,7 @@ public: void OnPostOperLogin(User* user, bool automatic) override { - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (!luser) return; @@ -132,7 +132,7 @@ public: void OnPostOperLogout(User* user, const std::shared_ptr<OperAccount>& oper) override { - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (!luser || luser->quitting) return; @@ -226,7 +226,7 @@ public: extra = FMT::format(": away for {} [since {}] ({})", awayperiod, awaytime, oper->away->message); } - auto* loper = IS_LOCAL(oper); + auto* loper = oper->AsLocal(); if (loper) { const std::string idleperiod = Duration::ToLongString(ServerInstance->Time() - loper->idle_lastmsg, true); diff --git a/modules/core/core_oper/umode_o.cpp b/modules/core/core_oper/umode_o.cpp index 54d45d7dc..bd6a00bb7 100644 --- a/modules/core/core_oper/umode_o.cpp +++ b/modules/core/core_oper/umode_o.cpp @@ -41,7 +41,7 @@ bool ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, Modes::C return false; // Notify server operators of the logout. - char snomask = IS_LOCAL(dest) ? 'o' : 'O'; + const auto snomask = dest->IsLocal() ? 'o' : 'O'; ServerInstance->SNO.WriteToSnoMask(snomask, "{} ({}) [{}] logged {}{}out of their server operator account.", source->nick, source->GetRealUserHost(), source->GetAddress(), source == dest ? "" : dest->nick, source == dest ? "" : " "); diff --git a/modules/core/core_oper/umode_s.cpp b/modules/core/core_oper/umode_s.cpp index 2d261ff07..c98fff52f 100644 --- a/modules/core/core_oper/umode_s.cpp +++ b/modules/core/core_oper/umode_s.cpp @@ -98,7 +98,7 @@ std::string ModeUserServerNoticeMask::ProcessNoticeMasks(User* user, const std:: default: // For local users check whether the given snomask is valid and enabled - IsSnomaskUsable() tests both. // For remote users accept what we were told, unless the snomask char is not a letter. - if (IS_LOCAL(user)) + if (user->IsLocal()) { if (!ServerInstance->SNO.IsSnomaskUsable(snomask)) { diff --git a/modules/core/core_reloadmodule.cpp b/modules/core/core_reloadmodule.cpp index fedefb4dd..9e77eba9d 100644 --- a/modules/core/core_reloadmodule.cpp +++ b/modules/core/core_reloadmodule.cpp @@ -352,7 +352,7 @@ size_t DataKeeper::GetSerializerIndex(ClientProtocol::Serializer* serializer) size_t DataKeeper::SaveSerializer(User* user) { - LocalUser* const localuser = IS_LOCAL(user); + auto* const localuser = user->AsLocal(); if ((!localuser) || (!localuser->serializer)) return UserData::UNUSED_INDEX; if (localuser->serializer->service_creator != mod) @@ -589,7 +589,7 @@ bool DataKeeper::RestoreSerializer(size_t serializerindex, User* user) return true; // The following checks are redundant - LocalUser* const localuser = IS_LOCAL(user); + auto* const localuser = user->AsLocal(); if (!localuser) return true; if (localuser->serializer != dummyserializer) diff --git a/modules/core/core_serialize_rfc.cpp b/modules/core/core_serialize_rfc.cpp index f9ced07a1..82f2030e8 100644 --- a/modules/core/core_serialize_rfc.cpp +++ b/modules/core/core_serialize_rfc.cpp @@ -242,7 +242,7 @@ public: if (type != ExtensionType::USER) return; - LocalUser* const user = IS_LOCAL(static_cast<User*>(item)); + auto* const user = static_cast<User*>(item)->AsLocal(); if ((user) && (user->serializer == &rfcserializer)) ServerInstance->Users.QuitUser(user, "Protocol serializer module unloading"); } diff --git a/modules/core/core_stats.cpp b/modules/core/core_stats.cpp index f617f8882..4dfc9864f 100644 --- a/modules/core/core_stats.cpp +++ b/modules/core/core_stats.cpp @@ -105,12 +105,12 @@ void CommandStats::DoStats(Stats::Context& stats) const char statschar = stats.GetSymbol(); bool isPublic = userstats.find(statschar) != std::string::npos; - bool isRemoteOper = IS_REMOTE(user) && (user->IsOper()); - bool isLocalOperWithPrivs = IS_LOCAL(user) && user->HasPrivPermission("servers/auspex"); + bool isRemoteOper = user->IsRemote() && (user->IsOper()); + bool isLocalOperWithPrivs = user->IsLocal() && user->HasPrivPermission("servers/auspex"); if (!isPublic && !isRemoteOper && !isLocalOperWithPrivs) { - const char* what = IS_LOCAL(user) ? "Stats" : "Remote stats"; + const auto* what = user->IsLocal() ? "Stats" : "Remote stats"; ServerInstance->SNO.WriteToSnoMask('t', "{} '{}' denied for {} ({})", what, statschar, user->nick, user->GetRealUserHost()); stats.AddRow(481, (std::string("Permission Denied - STATS ") + statschar + " requires the servers/auspex priv.")); return; @@ -119,7 +119,7 @@ void CommandStats::DoStats(Stats::Context& stats) ModResult res = statsevprov.FirstResult(&Stats::EventListener::OnStats, stats); if (res == MOD_RES_DENY) { - const char* what = IS_LOCAL(user) ? "Stats" : "Remote stats"; + const auto* what = user->IsLocal() ? "Stats" : "Remote stats"; ServerInstance->SNO.WriteToSnoMask('t', "{} '{}' requested by {} ({})", what, statschar, user->nick, user->GetRealUserHost()); stats.AddRow(219, statschar, "End of /STATS report"); return; @@ -356,7 +356,7 @@ void CommandStats::DoStats(Stats::Context& stats) } stats.AddRow(219, statschar, "End of /STATS report"); - ServerInstance->SNO.WriteToSnoMask('t', "{} '{}' requested by {} ({}@{})", (IS_LOCAL(user) ? "Stats" : "Remote stats"), + ServerInstance->SNO.WriteToSnoMask('t', "{} '{}' requested by {} ({}@{})", (user->IsLocal() ? "Stats" : "Remote stats"), statschar, user->nick, user->GetRealUser(), user->GetRealHost()); } @@ -365,7 +365,7 @@ CmdResult CommandStats::Handle(User* user, const Params& parameters) if (parameters.size() > 1 && !irc::equals(parameters[1], ServerInstance->Config->ServerName)) { // Give extra penalty if a non-oper does /STATS <remoteserver> - LocalUser* localuser = IS_LOCAL(user); + auto* localuser = user->AsLocal(); if ((localuser) && (!user->IsOper())) localuser->CommandFloodPenalty += 2000; return CmdResult::SUCCESS; diff --git a/modules/core/core_user/cmd_away.cpp b/modules/core/core_user/cmd_away.cpp index fcb9daec8..6421934b1 100644 --- a/modules/core/core_user/cmd_away.cpp +++ b/modules/core/core_user/cmd_away.cpp @@ -42,7 +42,7 @@ CommandAway::CommandAway(Module* parent) CmdResult CommandAway::Handle(User* user, const Params& parameters) { - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (!parameters.empty()) { std::string message(parameters[0]); @@ -78,5 +78,5 @@ CmdResult CommandAway::Handle(User* user, const Params& parameters) RouteDescriptor CommandAway::GetRouting(User* user, const Params& parameters) { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); + return (user->IsLocal() ? ROUTE_LOCALONLY : ROUTE_BROADCAST); } diff --git a/modules/core/core_user/cmd_part.cpp b/modules/core/core_user/cmd_part.cpp index 520ca52e4..7e5699c0f 100644 --- a/modules/core/core_user/cmd_part.cpp +++ b/modules/core/core_user/cmd_part.cpp @@ -44,7 +44,7 @@ CmdResult CommandPart::Handle(User* user, const Params& parameters) std::string reason; if (parameters.size() > 1) { - if (IS_LOCAL(user)) + if (user->IsLocal()) msgwrap.Wrap(parameters[1], reason); else reason = parameters[1]; @@ -72,5 +72,5 @@ CmdResult CommandPart::Handle(User* user, const Params& parameters) RouteDescriptor CommandPart::GetRouting(User* user, const Params& parameters) { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); + return (user->IsLocal() ? ROUTE_LOCALONLY : ROUTE_BROADCAST); } diff --git a/modules/core/core_user/cmd_quit.cpp b/modules/core/core_user/cmd_quit.cpp index 2b83a1dc7..cb1659673 100644 --- a/modules/core/core_user/cmd_quit.cpp +++ b/modules/core/core_user/cmd_quit.cpp @@ -39,7 +39,7 @@ CmdResult CommandQuit::Handle(User* user, const Params& parameters) std::string quitmsg; if (parameters.empty()) quitmsg = "Client exited"; - else if (IS_LOCAL(user)) + else if (user->IsLocal()) msgwrap.Wrap(parameters[0], quitmsg); else quitmsg = parameters[0]; @@ -52,5 +52,5 @@ CmdResult CommandQuit::Handle(User* user, const Params& parameters) RouteDescriptor CommandQuit::GetRouting(User* user, const Params& parameters) { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); + return (user->IsLocal() ? ROUTE_LOCALONLY : ROUTE_BROADCAST); } diff --git a/modules/core/core_user/core_user.cpp b/modules/core/core_user/core_user.cpp index 7caca8c96..8fad84271 100644 --- a/modules/core/core_user/core_user.cpp +++ b/modules/core/core_user/core_user.cpp @@ -105,7 +105,7 @@ public: } // set the user as alive so they survive to next ping - LocalUser* localuser = IS_LOCAL(user); + auto* localuser = user->AsLocal(); if (localuser) { // Increase penalty unless we've sent a PING and this is the reply diff --git a/modules/core/core_who.cpp b/modules/core/core_who.cpp index 8fa05bb2c..e7bffbe25 100644 --- a/modules/core/core_who.cpp +++ b/modules/core/core_who.cpp @@ -239,7 +239,7 @@ bool CommandWho::MatchChannel(LocalUser* source, Membership* memb, WhoData& data // The source only wants remote users. This user is eligible if: // (1) The source can't see server information. // (2) The source is not local to the current server. - LocalUser* lu = IS_LOCAL(memb->user); + const auto* lu = memb->user->AsLocal(); if (data.flags['f'] && source_can_see_server && lu) return false; @@ -270,7 +270,7 @@ bool CommandWho::MatchUser(LocalUser* source, User* user, WhoData& data) // The source only wants remote users. This user is eligible if: // (1) The source can't see server information. // (2) The source is not local to the current server. - LocalUser* lu = IS_LOCAL(user); + auto* lu = user->AsLocal(); if (data.flags['f'] && source_can_see_server && lu) return false; @@ -529,7 +529,7 @@ void CommandWho::SendWhoLine(LocalUser* source, const std::vector<std::string>& // Include the user's idle time. if (data.whox_fields['l']) { - LocalUser* lu = IS_LOCAL(user); + auto* lu = user->AsLocal(); unsigned long idle = lu ? ServerInstance->Time() - lu->idle_lastmsg : 0; wholine.push(ConvToStr(idle)); } diff --git a/modules/core/core_whois.cpp b/modules/core/core_whois.cpp index 943fee997..e41d94b93 100644 --- a/modules/core/core_whois.cpp +++ b/modules/core/core_whois.cpp @@ -264,7 +264,7 @@ CmdResult CommandWhois::HandleRemote(RemoteUser* target, const Params& parameter return CmdResult::FAILURE; // User doing the whois must be on this server - LocalUser* localuser = IS_LOCAL(user); + auto* localuser = user->AsLocal(); if (!localuser) return CmdResult::FAILURE; @@ -308,7 +308,7 @@ CmdResult CommandWhois::HandleLocal(LocalUser* user, const Params& parameters) * For remote users (/w remoteuser remoteuser), spanningtree will handle calling do_whois, so we can ignore this case. * Thanks to djGrrr for not being impatient while I have a crap day coding. :p -- w00t */ - LocalUser* localuser = IS_LOCAL(dest); + auto* localuser = dest->AsLocal(); if (localuser && (ServerInstance->Config->HideServer.empty() || parameters.size() > 1)) { idle = ServerInstance->Time() - localuser->idle_lastmsg; diff --git a/modules/core/core_xline/core_xline.cpp b/modules/core/core_xline/core_xline.cpp index b555533ba..9d0e8b0ef 100644 --- a/modules/core/core_xline/core_xline.cpp +++ b/modules/core/core_xline/core_xline.cpp @@ -131,7 +131,7 @@ public: void OnPostChangeRealHost(User* user) override { - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (!luser || luser->quitting) return; @@ -141,7 +141,7 @@ public: void OnPostChangeRealUser(User* user) override { - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (!luser || luser->quitting) return; diff --git a/modules/dccallow.cpp b/modules/dccallow.cpp index 71626bef4..5f14a3464 100644 --- a/modules/dccallow.cpp +++ b/modules/dccallow.cpp @@ -124,7 +124,7 @@ public: if (container->extype != this->extype) return; - LocalUser* user = IS_LOCAL(static_cast<User*>(container)); + auto* user = static_cast<User*>(container)->AsLocal(); if (!user) return; @@ -348,7 +348,7 @@ public: user->WriteNumeric(RPL_HELPTXT, "*", helpline); user->WriteNumeric(RPL_ENDOFHELP, "*", "End of DCCALLOW HELP"); - LocalUser* localuser = IS_LOCAL(user); + auto* localuser = user->AsLocal(); if (localuser) localuser->CommandFloodPenalty += 4000; } @@ -410,7 +410,7 @@ public: ModResult OnUserPreMessage(User* user, MessageTarget& target, MessageDetails& details) override { - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return MOD_RES_PASSTHRU; if (target.type == MessageTarget::TYPE_USER) diff --git a/modules/delayjoin.cpp b/modules/delayjoin.cpp index b844af33d..973bec65d 100644 --- a/modules/delayjoin.cpp +++ b/modules/delayjoin.cpp @@ -119,7 +119,7 @@ private: unjoined.Unset(memb); for (const auto& [member, _] : memb->chan->GetUsers()) { - if (member != memb->user && IS_LOCAL(member)) + if (member != memb->user && member->IsLocal()) except.insert(member); } } @@ -266,7 +266,7 @@ ModResult ModuleDelayJoin::OnRawMode(User* user, Channel* channel, const Modes:: return MOD_RES_PASSTHRU; User* dest; - if (IS_LOCAL(user)) + if (user->IsLocal()) dest = ServerInstance->Users.FindNick(change.param); else dest = ServerInstance->Users.Find(change.param); diff --git a/modules/delaymsg.cpp b/modules/delaymsg.cpp index b43025cae..df6876bf6 100644 --- a/modules/delaymsg.cpp +++ b/modules/delaymsg.cpp @@ -97,7 +97,7 @@ void DelayMsgMode::OnUnset(User* source, Channel* chan) void ModuleDelayMsg::OnUserJoin(Membership* memb, bool sync, bool created, CUList&) { - if ((IS_LOCAL(memb->user)) && (memb->chan->IsModeSet(djm))) + if ((memb->user->IsLocal()) && (memb->chan->IsModeSet(djm))) { djm.jointime.Set(memb, ServerInstance->Time()); } @@ -115,7 +115,7 @@ ModResult ModuleDelayMsg::OnUserPreTagMessage(User* user, MessageTarget& target, ModResult ModuleDelayMsg::HandleMessage(User* user, const MessageTarget& target) { - if (!IS_LOCAL(user) || target.type != MessageTarget::TYPE_CHANNEL) + if (!user->IsLocal() || target.type != MessageTarget::TYPE_CHANNEL) return MOD_RES_PASSTHRU; auto* channel = target.Get<Channel>(); diff --git a/modules/disable.cpp b/modules/disable.cpp index a3555260b..c18283fc9 100644 --- a/modules/disable.cpp +++ b/modules/disable.cpp @@ -157,7 +157,7 @@ public: if (numeric.GetNumeric() != RPL_COMMANDS || numeric.GetParams().empty()) return MOD_RES_PASSTHRU; // The numeric isn't the one we care about. - if (!fakenonexistent || !IS_LOCAL(user)) + if (!fakenonexistent || !user->IsLocal()) return MOD_RES_PASSTHRU; // We're not hiding the numeric OR the user is remote. if (!stdalgo::isin(commands, numeric.GetParams()[0]) || user->HasPrivPermission("servers/use-disabled-commands")) @@ -197,7 +197,7 @@ public: ModResult OnRawMode(User* user, Channel* chan, const Modes::Change& change) override { // If a mode change is remote or the source is not fully connected we do nothing. - if (!IS_LOCAL(user) || !user->IsFullyConnected()) + if (!user->IsLocal() || !user->IsFullyConnected()) return MOD_RES_PASSTHRU; // If the mode is not disabled or the user has the servers/use-disabled-modes priv we do nothing. diff --git a/modules/dnsbl.cpp b/modules/dnsbl.cpp index ab93e060e..6909be34a 100644 --- a/modules/dnsbl.cpp +++ b/modules/dnsbl.cpp @@ -430,7 +430,7 @@ public: CmdResult Handle(User* user, const Params& parameters) override { User* target; - if (IS_LOCAL(user)) + if (user->IsLocal()) target = ServerInstance->Users.FindNick(parameters[0], true); else target = ServerInstance->Users.FindUUID(parameters[0], true); @@ -442,7 +442,7 @@ public: return CmdResult::FAILURE; } - auto* ltarget = IS_LOCAL(target); + auto* ltarget = target->AsLocal(); if (!ltarget) return CmdResult::SUCCESS; // The user is on another server so just let it forward. diff --git a/modules/extra/ssl_gnutls.cpp b/modules/extra/ssl_gnutls.cpp index 4720c1034..71944215b 100644 --- a/modules/extra/ssl_gnutls.cpp +++ b/modules/extra/ssl_gnutls.cpp @@ -1178,7 +1178,7 @@ public: if (type != ExtensionType::USER) return; - auto* user = IS_LOCAL(static_cast<User*>(item)); + auto* user = static_cast<User*>(item)->AsLocal(); if (!user || !user->io->GetModHook(this)) return; diff --git a/modules/extra/ssl_openssl.cpp b/modules/extra/ssl_openssl.cpp index fdfa98e40..677eab529 100644 --- a/modules/extra/ssl_openssl.cpp +++ b/modules/extra/ssl_openssl.cpp @@ -1067,7 +1067,7 @@ public: if (type != ExtensionType::USER) return; - auto* user = IS_LOCAL(static_cast<User*>(item)); + auto* user = static_cast<User*>(item)->AsLocal(); if (!user || !user->io->GetModHook(this)) return; diff --git a/modules/filter.cpp b/modules/filter.cpp index 35dcc9792..b7bd2524f 100644 --- a/modules/filter.cpp +++ b/modules/filter.cpp @@ -262,7 +262,7 @@ CmdResult CommandFilter::Handle(User* user, const Params& parameters) if (static_cast<ModuleFilter*>(me)->DeleteFilter(parameters[0], reason)) { user->WriteNotice("*** Removed filter '" + parameters[0] + "': " + reason); - ServerInstance->SNO.WriteToSnoMask(IS_LOCAL(user) ? 'f' : 'F', "{} removed filter '{}': {}", + ServerInstance->SNO.WriteToSnoMask(user->IsLocal() ? 'f' : 'F', "{} removed filter '{}': {}", user->nick, parameters[0], reason); return CmdResult::SUCCESS; } @@ -323,7 +323,7 @@ CmdResult CommandFilter::Handle(User* user, const Params& parameters) flags, parameters[reasonindex]); user->WriteNotice("*** Added filter " + message); - ServerInstance->SNO.WriteToSnoMask(IS_LOCAL(user) ? 'f' : 'F', "{} added filter {}", user->nick, message); + ServerInstance->SNO.WriteToSnoMask(user->IsLocal() ? 'f' : 'F', "{} added filter {}", user->nick, message); return CmdResult::SUCCESS; } @@ -391,7 +391,7 @@ void ModuleFilter::FreeFilters() ModResult ModuleFilter::OnUserPreMessage(User* user, MessageTarget& msgtarget, MessageDetails& details) { // Leave remote users and servers alone - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return MOD_RES_PASSTHRU; flags = (details.type == MessageType::PRIVMSG) ? FLAG_PRIVMSG : FLAG_NOTICE; diff --git a/modules/helpmode.cpp b/modules/helpmode.cpp index 41d5a1ac5..6bca93ba5 100644 --- a/modules/helpmode.cpp +++ b/modules/helpmode.cpp @@ -108,7 +108,7 @@ public: extra = FMT::format(": away for {} [since {}] ({})", awayperiod, awaytime, helper->away->message); } - auto* lhelper = IS_LOCAL(helper); + auto* lhelper = helper->AsLocal(); if (lhelper) { const std::string idleperiod = Duration::ToLongString(ServerInstance->Time() - lhelper->idle_lastmsg, true); diff --git a/modules/hideoper.cpp b/modules/hideoper.cpp index fc2e26113..815ed02c1 100644 --- a/modules/hideoper.cpp +++ b/modules/hideoper.cpp @@ -161,7 +161,7 @@ public: extra = FMT::format(": away for {} [since {}] ({})", awayperiod, awaytime, oper->away->message); } - auto* loper = IS_LOCAL(oper); + auto* loper = oper->AsLocal(); if (loper) { const std::string idleperiod = Duration::ToLongString(ServerInstance->Time() - loper->idle_lastmsg, true); diff --git a/modules/hostcycle.cpp b/modules/hostcycle.cpp index 1b9408a83..d9af979f4 100644 --- a/modules/hostcycle.cpp +++ b/modules/hostcycle.cpp @@ -48,7 +48,7 @@ class ModuleHostCycle final exceptions.erase(user); for (const auto& [exception, sendto] : exceptions) { - LocalUser* u = IS_LOCAL(exception); + auto* u = exception->AsLocal(); if ((u) && (!u->quitting) && (!chghostcap.IsEnabled(u))) { if (sendto) @@ -72,7 +72,7 @@ class ModuleHostCycle final for (const auto& [chanuser, _] : c->GetUsers()) { - LocalUser* u = IS_LOCAL(chanuser); + auto* u = chanuser->AsLocal(); if (!u || u == user) continue; if (u->already_sent == silent_id) diff --git a/modules/httpd_stats.cpp b/modules/httpd_stats.cpp index 14f586b28..1e5d50f9e 100644 --- a/modules/httpd_stats.cpp +++ b/modules/httpd_stats.cpp @@ -276,7 +276,7 @@ namespace Stats if (u->IsOper()) serializer.Attribute("opertype", u->oper->GetType()); - LocalUser* lu = IS_LOCAL(u); + auto* lu = u->AsLocal(); if (lu) { serializer.Attribute("port", lu->server_sa.port()) @@ -365,7 +365,7 @@ namespace Stats switch (order) { case OB_LASTMSG: - return Compare(IS_LOCAL(u1)->idle_lastmsg, IS_LOCAL(u2)->idle_lastmsg); + return Compare(u1->AsLocal()->idle_lastmsg, u2->AsLocal()->idle_lastmsg); case OB_NICK: return Compare(u1->nick, u2->nick); default: @@ -420,7 +420,7 @@ namespace Stats if (!showunreg && !u->IsFullyConnected()) continue; - LocalUser* lu = IS_LOCAL(u); + auto* lu = u->AsLocal(); if (localonly && !lu) continue; diff --git a/modules/ircv3_ctctags.cpp b/modules/ircv3_ctctags.cpp index a1ce89102..420f5f973 100644 --- a/modules/ircv3_ctctags.cpp +++ b/modules/ircv3_ctctags.cpp @@ -67,7 +67,7 @@ private: CmdResult FirePostEvent(User* source, const MessageTarget& msgtarget, const CTCTags::TagMessageDetails& msgdetails) { // If the source is local then update its idle time. - LocalUser* lsource = IS_LOCAL(source); + auto* lsource = source->AsLocal(); if (lsource && msgdetails.update_idle) lsource->idle_lastmsg = ServerInstance->Time(); @@ -98,7 +98,7 @@ private: for (const auto& [user, memb] : chan->GetUsers()) { - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); // Don't send to remote users or the user who is the source. if (!luser || luser == source) @@ -163,7 +163,7 @@ private: CmdResult HandleUserTarget(User* source, const Params& parameters) { User* target; - if (IS_LOCAL(source)) + if (source->IsLocal()) { // Local sources can specify either a nick or a nick@server mask as the target. const char* targetserver = strchr(parameters[0].c_str(), '@'); @@ -205,7 +205,7 @@ private: if (!FirePreEvents(source, msgtarget, msgdetails)) return CmdResult::FAILURE; - LocalUser* const localtarget = IS_LOCAL(target); + auto* const localtarget = target->AsLocal(); if (localtarget && cap.IsEnabled(localtarget)) { // Servers can fake the target of a message when it is sent to an individual user. @@ -239,7 +239,7 @@ public: return CmdResult::SUCCESS; // Check that the source has the message tags capability. - if (IS_LOCAL(user) && !cap.IsEnabled(user)) + if (user->IsLocal() && !cap.IsEnabled(user)) return CmdResult::FAILURE; // The specified message tags were empty. This probably means that client @@ -278,7 +278,7 @@ public: RouteDescriptor GetRouting(User* user, const Params& parameters) override { - if (IS_LOCAL(user)) + if (user->IsLocal()) // This is handled by the OnUserPostTagMessage hook to split the LoopCall pieces return ROUTE_LOCALONLY; else @@ -354,7 +354,7 @@ public: // If the user is local then we check whether they have the message-tags cap // enabled. If not then we reject all client-only tags originating from them. - auto* lu = IS_LOCAL(user); + auto* lu = user->AsLocal(); if (lu) { if (!cap.IsEnabled(lu)) @@ -450,7 +450,7 @@ public: ModResult OnUserPreTagMessage(User* user, MessageTarget& target, CTCTags::TagMessageDetails& details) override { - if (IS_LOCAL(user) && target.type == MessageTarget::TYPE_CHANNEL) + if (user->IsLocal() && target.type == MessageTarget::TYPE_CHANNEL) { auto* chan = target.Get<Channel>(); if (chan->IsModeSet(noextmsgmode) && !chan->HasUser(user)) diff --git a/modules/ircv3_labeledresponse.cpp b/modules/ircv3_labeledresponse.cpp index 317e823a1..7e0729c60 100644 --- a/modules/ircv3_labeledresponse.cpp +++ b/modules/ircv3_labeledresponse.cpp @@ -50,7 +50,7 @@ public: // If the user is local then we check whether they have the labeled-response // cap enabled. If not then we reject the label tag originating from them. - LocalUser* lu = IS_LOCAL(user); + auto* lu = user->AsLocal(); if (lu && !cap.IsEnabled(lu)) return MOD_RES_DENY; diff --git a/modules/ircv3_msgid.cpp b/modules/ircv3_msgid.cpp index 96a57b1fa..63970e62d 100644 --- a/modules/ircv3_msgid.cpp +++ b/modules/ircv3_msgid.cpp @@ -35,7 +35,7 @@ public: return MOD_RES_PASSTHRU; // We should only allow this tag if it is added by a remote server. - return IS_LOCAL(user) ? MOD_RES_DENY : MOD_RES_ALLOW; + return user->IsLocal() ? MOD_RES_DENY : MOD_RES_ALLOW; } }; diff --git a/modules/kicknorejoin.cpp b/modules/kicknorejoin.cpp index a2356db1b..ba5a81c2f 100644 --- a/modules/kicknorejoin.cpp +++ b/modules/kicknorejoin.cpp @@ -110,7 +110,7 @@ public: return false; } - if (IS_LOCAL(source) && v > max) + if (source->IsLocal() && v > max) v = max; ext.Set(channel, v); @@ -154,7 +154,7 @@ public: void OnUserKick(User* source, Membership* memb, const std::string& reason, CUList& excepts) override { - if ((!IS_LOCAL(memb->user)) || (source == memb->user)) + if ((!memb->user->IsLocal()) || (source == memb->user)) return; KickRejoinData* data = kr.ext.Get(memb->chan); diff --git a/modules/messageflood.cpp b/modules/messageflood.cpp index 578963388..99e756ce3 100644 --- a/modules/messageflood.cpp +++ b/modules/messageflood.cpp @@ -272,7 +272,7 @@ public: return MOD_RES_PASSTHRU; auto* dest = target.Get<Channel>(); - if ((!IS_LOCAL(user)) || !dest->IsModeSet(mf)) + if ((!user->IsLocal()) || !dest->IsModeSet(mf)) return MOD_RES_PASSTHRU; ModResult res = exemptionprov.Check(user, dest, "flood"); diff --git a/modules/monitor.cpp b/modules/monitor.cpp index 5c41018ab..7b70f55da 100644 --- a/modules/monitor.cpp +++ b/modules/monitor.cpp @@ -413,7 +413,7 @@ public: void OnUserQuit(User* user, const std::string& message, const std::string& oper_message) override { - LocalUser* localuser = IS_LOCAL(user); + auto* localuser = user->AsLocal(); if (localuser) manager.UnwatchAll(localuser); SendAlert(RPL_MONOFFLINE, user->nick); diff --git a/modules/muteban.cpp b/modules/muteban.cpp index a705eb3b5..95d874e54 100644 --- a/modules/muteban.cpp +++ b/modules/muteban.cpp @@ -50,7 +50,7 @@ public: ModResult HandleMessage(User* user, const MessageTarget& target, bool& echo_original) { - if (!IS_LOCAL(user) || target.type != MessageTarget::TYPE_CHANNEL) + if (!user->IsLocal() || target.type != MessageTarget::TYPE_CHANNEL) return MOD_RES_PASSTHRU; auto* chan = target.Get<Channel>(); @@ -81,7 +81,7 @@ public: void OnUserPart(Membership* memb, std::string& partmessage, CUList& except_list) override { - LocalUser* luser = IS_LOCAL(memb->user); + auto* luser = memb->user->AsLocal(); if (!luser) return; diff --git a/modules/namedmodes.cpp b/modules/namedmodes.cpp index d8c52785c..995ea8e74 100644 --- a/modules/namedmodes.cpp +++ b/modules/namedmodes.cpp @@ -122,7 +122,7 @@ public: // Handle /MODE #chan Z void DisplayList(User* user, Channel* chan) override { - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (luser) ::DisplayList(luser, chan); } diff --git a/modules/nicklock.cpp b/modules/nicklock.cpp index 7ecda094a..4f25dd16c 100644 --- a/modules/nicklock.cpp +++ b/modules/nicklock.cpp @@ -59,7 +59,7 @@ public: } /* Do local sanity checks and bails */ - if (IS_LOCAL(user)) + if (user->IsLocal()) { if (!ServerInstance->Users.IsNick(parameters[1])) { @@ -71,7 +71,7 @@ public: } /* If we made it this far, extend the user */ - if (IS_LOCAL(target)) + if (target->IsLocal()) { locked.Set(target); @@ -118,7 +118,7 @@ public: return CmdResult::FAILURE; } - if (IS_LOCAL(target)) + if (target->IsLocal()) { if (locked.Get(target)) { diff --git a/modules/noctcp.cpp b/modules/noctcp.cpp index 31d69760f..61d100515 100644 --- a/modules/noctcp.cpp +++ b/modules/noctcp.cpp @@ -52,7 +52,7 @@ public: ModResult OnUserPreMessage(User* user, MessageTarget& target, MessageDetails& details) override { - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return MOD_RES_PASSTHRU; std::string_view ctcpname; diff --git a/modules/nonotice.cpp b/modules/nonotice.cpp index 9fb875eaf..97774d8f2 100644 --- a/modules/nonotice.cpp +++ b/modules/nonotice.cpp @@ -45,7 +45,7 @@ public: ModResult OnUserPreMessage(User* user, MessageTarget& target, MessageDetails& details) override { - if ((details.type == MessageType::NOTICE) && (target.type == MessageTarget::TYPE_CHANNEL) && (IS_LOCAL(user))) + if ((details.type == MessageType::NOTICE) && (target.type == MessageTarget::TYPE_CHANNEL) && (user->IsLocal())) { auto* c = target.Get<Channel>(); diff --git a/modules/operjoin.cpp b/modules/operjoin.cpp index d33376d44..f454b7e1c 100644 --- a/modules/operjoin.cpp +++ b/modules/operjoin.cpp @@ -52,7 +52,7 @@ public: void OnPostOperLogin(User* user, bool automatic) override { - LocalUser* localuser = IS_LOCAL(user); + auto* localuser = user->AsLocal(); if (!localuser) return; diff --git a/modules/operlevels.cpp b/modules/operlevels.cpp index 91ae55ac8..71dfe66b0 100644 --- a/modules/operlevels.cpp +++ b/modules/operlevels.cpp @@ -46,7 +46,7 @@ public: if (dest_level > source_level) { - if (IS_LOCAL(source)) + if (source->IsLocal()) { ServerInstance->SNO.WriteGlobalSno('a', "Oper {} (level {}) attempted to /KILL a higher level oper: {} (level {}), reason: {}", source->nick, source_level, dest->nick, dest_level, reason); diff --git a/modules/opermodes.cpp b/modules/opermodes.cpp index 729d03720..7dbe0526b 100644 --- a/modules/opermodes.cpp +++ b/modules/opermodes.cpp @@ -34,7 +34,7 @@ public: void OnPostOperLogin(User* user, bool automatic) override { - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return; // We don't handle remote users. const std::string opermodes = user->oper->GetConfig()->getString("modes"); diff --git a/modules/opermotd.cpp b/modules/opermotd.cpp index 03ef00c57..23b0d7c94 100644 --- a/modules/opermotd.cpp +++ b/modules/opermotd.cpp @@ -130,7 +130,7 @@ public: void OnPostOperLogin(User* user, bool automatic) override { - if (IS_LOCAL(user) && user->oper->GetConfig()->getBool("automotd", true)) + if (user->IsLocal() && user->oper->GetConfig()->getBool("automotd", true)) cmd.ShowOperMOTD(user, false); } diff --git a/modules/operprefix.cpp b/modules/operprefix.cpp index d0c16492f..d54e04e83 100644 --- a/modules/operprefix.cpp +++ b/modules/operprefix.cpp @@ -84,7 +84,7 @@ public: void OnPostJoin(Membership* memb) override { - if ((!IS_LOCAL(memb->user)) || (!memb->user->IsOper()) || (memb->user->IsModeSet(hideopermode))) + if ((!memb->user->IsLocal()) || (!memb->user->IsOper()) || (memb->user->IsModeSet(hideopermode))) return; if (memb->HasMode(&opm)) @@ -106,7 +106,7 @@ public: void OnPostOperLogin(User* user, bool automatic) override { - if (IS_LOCAL(user) && (!user->IsModeSet(hideopermode))) + if (user->IsLocal() && (!user->IsModeSet(hideopermode))) SetOperPrefix(user, true); } @@ -126,7 +126,7 @@ HideOperWatcher::HideOperWatcher(ModuleOperPrefixMode* parent) void HideOperWatcher::AfterMode(User* source, User* dest, Channel* channel, const Modes::Change& change) { // If hideoper is being unset because the user is deopering, don't set +y - if (IS_LOCAL(dest) && dest->IsOper()) + if (dest->IsLocal() && dest->IsOper()) parentmod->SetOperPrefix(dest, !change.adding); } diff --git a/modules/opmoderated.cpp b/modules/opmoderated.cpp index 470357678..96bea4569 100644 --- a/modules/opmoderated.cpp +++ b/modules/opmoderated.cpp @@ -34,7 +34,7 @@ private: ModResult HandleMessage(User* user, MessageTarget& target, CUList& exemptions) { // We only handle messages from local users. - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return MOD_RES_PASSTHRU; // We only handle messages non-statusmsg messages sent to channels. diff --git a/modules/override.cpp b/modules/override.cpp index 02428319c..31f7deced 100644 --- a/modules/override.cpp +++ b/modules/override.cpp @@ -75,8 +75,8 @@ public: bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { bool res = SimpleUserMode::OnModeChange(source, dest, channel, change); - if (change.adding && res && IS_LOCAL(dest) && timeout) - ext.Set(dest, new UnsetTimer(IS_LOCAL(dest), timeout, *this)); + if (change.adding && res && dest->IsLocal() && timeout) + ext.Set(dest, new UnsetTimer(dest->AsLocal(), timeout, *this)); return res; } }; @@ -163,7 +163,7 @@ public: ModResult OnPreTopicChange(User* source, Channel* channel, const std::string& topic) override { - if (IS_LOCAL(source) && source->IsOper() && CanOverride(source, "TOPIC")) + if (source->IsLocal() && source->IsOper() && CanOverride(source, "TOPIC")) { if (!channel->HasUser(source) || (channel->IsModeSet(topiclock) && channel->GetPrefixValue(source) < HALFOP_VALUE)) { @@ -196,7 +196,7 @@ public: { if (!channel) return MOD_RES_PASSTHRU; - if (!source->IsOper() || !IS_LOCAL(source)) + if (!source->IsOper() || !source->IsLocal()) return MOD_RES_PASSTHRU; const Modes::ChangeList::List& list = modes.getlist(); diff --git a/modules/passforward.cpp b/modules/passforward.cpp index 35483f597..26610559e 100644 --- a/modules/passforward.cpp +++ b/modules/passforward.cpp @@ -60,7 +60,7 @@ public: void OnPostConnect(User* ruser) override { - LocalUser* user = IS_LOCAL(ruser); + auto* user = ruser->AsLocal(); if (!user || user->password.empty()) return; diff --git a/modules/redirect.cpp b/modules/redirect.cpp index 957c477b2..42f9f3025 100644 --- a/modules/redirect.cpp +++ b/modules/redirect.cpp @@ -42,7 +42,7 @@ public: bool OnSet(User* source, Channel* channel, std::string& parameter) override { - if (IS_LOCAL(source)) + if (source->IsLocal()) { if (!ServerInstance->Channels.IsChannel(parameter)) { @@ -51,7 +51,7 @@ public: } } - if (IS_LOCAL(source) && !source->IsOper()) + if (source->IsLocal() && !source->IsOper()) { auto* c = ServerInstance->Channels.Find(parameter); if (!c) diff --git a/modules/remove.cpp b/modules/remove.cpp index 0bcf897f5..65e586f0d 100644 --- a/modules/remove.cpp +++ b/modules/remove.cpp @@ -58,7 +58,7 @@ public: /* Look up the user we're meant to be removing from the channel */ User* target; - if (IS_LOCAL(user)) + if (user->IsLocal()) target = ServerInstance->Users.FindNick(username, true); else target = ServerInstance->Users.Find(username, true); @@ -91,7 +91,7 @@ public: } /* We support the +Q channel mode via. the m_nokicks module, if the module is loaded and the mode is set then disallow the /remove */ - if ((!IS_LOCAL(user)) || (!supportnokicks) || (!channel->IsModeSet(nokicksmode))) + if ((!user->IsLocal()) || (!supportnokicks) || (!channel->IsModeSet(nokicksmode))) { /* We'll let everyone remove their level and below, eg: * ops can remove ops, halfops, voices, and those with no mode (no moders actually are set to 1) @@ -100,10 +100,10 @@ public: */ ModeHandler::Rank ulevel = channel->GetPrefixValue(user); ModeHandler::Rank tlevel = channel->GetPrefixValue(target); - if ((!IS_LOCAL(user)) || ((ulevel > VOICE_VALUE) && (ulevel >= tlevel) && ((protectedrank == 0) || (tlevel < protectedrank)))) + if ((!user->IsLocal()) || ((ulevel > VOICE_VALUE) && (ulevel >= tlevel) && ((protectedrank == 0) || (tlevel < protectedrank)))) { // REMOVE will be sent to the target's server and it will reply with a PART (or do nothing if it doesn't understand the command) - if (!IS_LOCAL(target)) + if (!target->IsLocal()) { CommandBase::Params p; p.push_back(channel->name); diff --git a/modules/repeat.cpp b/modules/repeat.cpp index c611e3cf7..764f6c9ae 100644 --- a/modules/repeat.cpp +++ b/modules/repeat.cpp @@ -181,7 +181,7 @@ public: return false; } - LocalUser* localsource = IS_LOCAL(source); + auto* localsource = source->AsLocal(); if ((localsource) && (!ValidateSettings(localsource, channel, parameter, settings))) return false; @@ -410,7 +410,7 @@ public: ModResult OnUserPreMessage(User* user, MessageTarget& target, MessageDetails& details) override { - if (target.type != MessageTarget::TYPE_CHANNEL || !IS_LOCAL(user)) + if (target.type != MessageTarget::TYPE_CHANNEL || !user->IsLocal()) return MOD_RES_PASSTHRU; auto* chan = target.Get<Channel>(); diff --git a/modules/restrictmsg.cpp b/modules/restrictmsg.cpp index c1003ed56..2f37a1382 100644 --- a/modules/restrictmsg.cpp +++ b/modules/restrictmsg.cpp @@ -32,7 +32,7 @@ class ModuleRestrictMsg final private: static ModResult HandleMessage(User* user, const MessageTarget& target) { - if ((target.type == MessageTarget::TYPE_USER) && (IS_LOCAL(user))) + if ((target.type == MessageTarget::TYPE_USER) && (user->IsLocal())) { const auto* u = target.Get<User>(); diff --git a/modules/rline.cpp b/modules/rline.cpp index 74c552b1e..491c3a0e3 100644 --- a/modules/rline.cpp +++ b/modules/rline.cpp @@ -54,7 +54,7 @@ public: bool Matches(User* u) const override { - LocalUser* lu = IS_LOCAL(u); + auto* lu = u->AsLocal(); if (lu && lu->exempt) return false; @@ -321,7 +321,7 @@ public: void OnUserPostNick(User* user, const std::string& oldnick) override { - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return; if (!matchonnickchange) diff --git a/modules/sacommands.cpp b/modules/sacommands.cpp index 483bcac13..f6c9177be 100644 --- a/modules/sacommands.cpp +++ b/modules/sacommands.cpp @@ -89,7 +89,7 @@ public: } const auto& targetchan = parameters[channelindex]; - if (IS_LOCAL(user) && !ServerInstance->Channels.IsChannel(targetchan)) + if (user->IsLocal() && !ServerInstance->Channels.IsChannel(targetchan)) { user->WriteRemoteNumeric(ERR_BADCHANMASK, targetchan, "Invalid channel name"); return CmdResult::FAILURE; @@ -102,7 +102,7 @@ public: return CmdResult::FAILURE; } - auto* ltarget = IS_LOCAL(target); + auto* ltarget = target->AsLocal(); if (!ltarget) return CmdResult::SUCCESS; // User will be handled by their own server. @@ -170,7 +170,7 @@ public: return CmdResult::FAILURE; } - if (!IS_LOCAL(target)) + if (!target->IsLocal()) return CmdResult::SUCCESS; // User will be handled by their own server. const std::string reason(parameters.size() > 2 ? parameters.back() : target->nick, 0, ServerInstance->Config->Limits.MaxKick); @@ -315,7 +315,7 @@ public: return CmdResult::FAILURE; } - if (!IS_LOCAL(target)) + if (!target->IsLocal()) return CmdResult::SUCCESS; // User will be handled by their own server. if (!target->ChangeNick(targetnewnick)) @@ -381,7 +381,7 @@ public: return CmdResult::FAILURE; } - if (!IS_LOCAL(target)) + if (!target->IsLocal()) return CmdResult::SUCCESS; // User will be handled by their own server. const auto& reason = parameters.size() > 2 ? parameters.back() : ""; @@ -435,7 +435,7 @@ public: return CmdResult::FAILURE; } - if (!IS_LOCAL(target)) + if (!target->IsLocal()) return CmdResult::SUCCESS; // User will be handled by their own server. const auto& reason = parameters.size() > 2 ? parameters.back() : ""; diff --git a/modules/sasl.cpp b/modules/sasl.cpp index 82aa2c3f6..5b820d80e 100644 --- a/modules/sasl.cpp +++ b/modules/sasl.cpp @@ -240,7 +240,7 @@ public: if (msg[2] == "C") { - LocalUser* const localuser = IS_LOCAL(user); + auto* const localuser = user->AsLocal(); if (localuser) { ClientProtocol::Message authmsg("AUTHENTICATE"); diff --git a/modules/seenicks.cpp b/modules/seenicks.cpp index 5fe7a79c2..3b825f425 100644 --- a/modules/seenicks.cpp +++ b/modules/seenicks.cpp @@ -39,7 +39,7 @@ public: void OnUserPostNick(User* user, const std::string& oldnick) override { - ServerInstance->SNO.WriteToSnoMask(IS_LOCAL(user) ? 'n' : 'N', "User {}!{} ({}) changed their nickname to {}", + ServerInstance->SNO.WriteToSnoMask(user->IsLocal() ? 'n' : 'N', "User {}!{} ({}) changed their nickname to {}", oldnick, user->GetRealUserHost(), user->GetAddress(), user->nick); } }; diff --git a/modules/services.cpp b/modules/services.cpp index 70deec43e..6097f36ba 100644 --- a/modules/services.cpp +++ b/modules/services.cpp @@ -118,7 +118,7 @@ public: bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { - if (IS_LOCAL(source)) + if (source->IsLocal()) { source->WriteNumeric(Numerics::NoPrivileges("only services may {} channel mode {} ({})", source->IsModeSet(this) ? "set" : "unset", GetModeChar(), this->service_name)); @@ -143,7 +143,7 @@ public: bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { - if (IS_LOCAL(source)) + if (source->IsLocal()) { source->WriteNumeric(Numerics::NoPrivileges("only services may {} user mode {} ({})", source->IsModeSet(this) ? "set" : "unset", GetModeChar(), this->service_name)); @@ -256,7 +256,7 @@ public: CmdResult Handle(User* user, const Params& parameters) override { // The command can only be executed by remote services servers. - if (IS_LOCAL(user) || !user->server->IsService()) + if (user->IsLocal() || !user->server->IsService()) return CmdResult::FAILURE; auto* u = ServerInstance->Users.FindUUID(parameters[0]); @@ -306,7 +306,7 @@ public: CmdResult Handle(User* user, const Params& parameters) override { // The command can only be executed by remote services servers. - if (IS_LOCAL(user) || !user->server->IsService()) + if (user->IsLocal() || !user->server->IsService()) return CmdResult::FAILURE; if (parameters.size() == 1) @@ -357,7 +357,7 @@ public: CmdResult Handle(User* user, const Params& parameters) override { // The command can only be executed by remote services servers. - if (IS_LOCAL(user) || !user->server->IsService()) + if (user->IsLocal() || !user->server->IsService()) return CmdResult::FAILURE; // Check for a valid channel name. @@ -370,7 +370,7 @@ public: return CmdResult::FAILURE; /* only join if it's local, otherwise just pass it on! */ - auto* lu = IS_LOCAL(u); + auto* lu = u->AsLocal(); if (lu) { bool override = false; @@ -407,11 +407,11 @@ public: CmdResult Handle(User* user, const Params& parameters) override { // The command can only be executed by remote services servers. - if (IS_LOCAL(user) || !user->server->IsService()) + if (user->IsLocal() || !user->server->IsService()) return CmdResult::FAILURE; auto* u = ServerInstance->Users.Find(parameters[0]); - if (u && IS_LOCAL(u)) + if (u && u->IsLocal()) { // The 4th parameter is optional and it is the expected nick TS of the target user. If // this parameter is present and it doesn't match the user's nick TS, the SVSNICK is not @@ -485,7 +485,7 @@ public: if (!target) return CmdResult::FAILURE; - if (IS_LOCAL(target)) + if (target->IsLocal()) { auto iter = ServerInstance->Config->OperTypes.find(parameters[1]); if (iter == ServerInstance->Config->OperTypes.end()) @@ -521,7 +521,7 @@ public: CmdResult Handle(User* user, const Params& parameters) override { // The command can only be executed by remote services servers. - if (IS_LOCAL(user) || !user->server->IsService()) + if (user->IsLocal() || !user->server->IsService()) return CmdResult::FAILURE; auto* u = ServerInstance->Users.FindUUID(parameters[0]); @@ -532,7 +532,7 @@ public: if (!c) return CmdResult::FAILURE; - if (IS_LOCAL(u)) + if (u->IsLocal()) c->PartUser(u, parameters.size() == 3 ? parameters[2] : "Services forced part"); return CmdResult::SUCCESS; @@ -558,7 +558,7 @@ public: CmdResult Handle(User* user, const Params& parameters) override { // The command can only be executed by remote services servers. - if (IS_LOCAL(user) || !user->server->IsService()) + if (user->IsLocal() || !user->server->IsService()) return CmdResult::FAILURE; auto* chan = ServerInstance->Channels.Find(parameters[0]); @@ -727,7 +727,7 @@ public: ModResult OnPreTopicChange(User* user, Channel* chan, const std::string& topic) override { - if (!IS_LOCAL(user) || !topiclockext.Get(chan)) + if (!user->IsLocal() || !topiclockext.Get(chan)) return MOD_RES_PASSTHRU; // Remote user or no topiclock. user->WriteNumeric(ERR_TOPICLOCK, chan->name, "Topic cannot be changed as it has been locked by services!"); @@ -736,7 +736,7 @@ public: ModResult OnRawMode(User* user, Channel* chan, const Modes::Change& change) override { - if (!IS_LOCAL(user) || !chan) + if (!user->IsLocal() || !chan) return MOD_RES_PASSTHRU; // Not our job to handle. if (!HandleProtectedService(user, chan, change)) diff --git a/modules/sethost.cpp b/modules/sethost.cpp index f783ba0bc..278410351 100644 --- a/modules/sethost.cpp +++ b/modules/sethost.cpp @@ -47,7 +47,7 @@ public: if (parameters.size() > 1) { const auto& targetnick = parameters[0]; - if (IS_LOCAL(user)) + if (user->IsLocal()) { // For local users we need to check if they can use the command. target = ServerInstance->Users.FindNick(targetnick, true); @@ -70,7 +70,7 @@ public: } } - if (!IS_LOCAL(target)) + if (!target->IsLocal()) return CmdResult::SUCCESS; // Their server will handle this. const auto& newhost = parameters.back(); diff --git a/modules/setident.cpp b/modules/setident.cpp index 89fe6d892..dc27ae621 100644 --- a/modules/setident.cpp +++ b/modules/setident.cpp @@ -46,7 +46,7 @@ public: if (parameters.size() > 1) { const auto& targetnick = parameters[0]; - if (IS_LOCAL(user)) + if (user->IsLocal()) { // For local users we need to check if they can use the command. target = ServerInstance->Users.FindNick(targetnick, true); @@ -69,7 +69,7 @@ public: } } - if (!IS_LOCAL(target)) + if (!target->IsLocal()) return CmdResult::SUCCESS; // Their server will handle this. const auto& newuser = parameters.back(); diff --git a/modules/setname.cpp b/modules/setname.cpp index 3d6cfe7b1..ea50ff29e 100644 --- a/modules/setname.cpp +++ b/modules/setname.cpp @@ -47,7 +47,7 @@ public: if (parameters.size() > 1) { const auto& targetnick = parameters[0]; - if (IS_LOCAL(user)) + if (user->IsLocal()) { // For local users we need to check if they can use the command. target = ServerInstance->Users.FindNick(targetnick, true); @@ -70,7 +70,7 @@ public: } } - if (!IS_LOCAL(target)) + if (!target->IsLocal()) return CmdResult::SUCCESS; // Their server will handle this. const auto& newreal = parameters.back(); diff --git a/modules/showfile.cpp b/modules/showfile.cpp index fd32ccea6..35e349dea 100644 --- a/modules/showfile.cpp +++ b/modules/showfile.cpp @@ -67,9 +67,9 @@ public: if (!endtext.empty() && endnumeric) user->WriteRemoteNumeric(endnumeric, endtext); } - else if (IS_LOCAL(user)) + else if (user->IsLocal()) { - LocalUser* const localuser = IS_LOCAL(user); + auto* const localuser = user->AsLocal(); for (const auto& line : contents) { ClientProtocol::Messages::Privmsg msg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, localuser, line, ((method == SF_MSG) ? MessageType::PRIVMSG : MessageType::NOTICE)); diff --git a/modules/showwhois.cpp b/modules/showwhois.cpp index 200699fdf..6c08cc9da 100644 --- a/modules/showwhois.cpp +++ b/modules/showwhois.cpp @@ -68,7 +68,7 @@ public: auto* source = ServerInstance->Users.Find(parameters[1]); - if (IS_LOCAL(dest) && source) + if (dest->IsLocal() && source) HandleFast(dest, source); return CmdResult::SUCCESS; @@ -110,7 +110,7 @@ public: if (source->HasPrivPermission("users/secret-whois")) return; - if (IS_LOCAL(dest)) + if (dest->IsLocal()) { WhoisNoticeCmd::HandleFast(dest, source); } diff --git a/modules/silence.cpp b/modules/silence.cpp index 3584dcc08..6e0b4af73 100644 --- a/modules/silence.cpp +++ b/modules/silence.cpp @@ -218,7 +218,7 @@ public: if (container->extype != this->extype) return; - LocalUser* user = IS_LOCAL(static_cast<User*>(container)); + auto* user = static_cast<User*>(container)->AsLocal(); if (!user) return; @@ -460,7 +460,7 @@ private: bool CanReceiveMessage(User* source, User* target, SilenceEntry::SilenceFlags flag, uint32_t* flags = nullptr) { // Servers handle their own clients. - if (!IS_LOCAL(target)) + if (!target->IsLocal()) return true; if (exemptservice && source->server->IsService()) diff --git a/modules/spanningtree/fmode.cpp b/modules/spanningtree/fmode.cpp index 931a9c7c9..3a2e40c59 100644 --- a/modules/spanningtree/fmode.cpp +++ b/modules/spanningtree/fmode.cpp @@ -50,7 +50,7 @@ CmdResult CommandFMode::Handle(User* who, Params& params) ServerInstance->Modes.ModeParamsToChangeList(who, MODETYPE_CHANNEL, params, changelist, 2); ModeParser::ModeProcessFlag flags = ModeParser::MODE_LOCALONLY; - if ((TS == ourTS) && IS_SERVER(who)) + if ((TS == ourTS) && who->IsServer()) flags |= ModeParser::MODE_MERGE; ServerInstance->Modes.Process(who, chan, nullptr, changelist, flags); @@ -93,7 +93,7 @@ CmdResult CommandLMode::Handle(User* who, Params& params) } ModeParser::ModeProcessFlag flags = ModeParser::MODE_LOCALONLY; - if (chants == chan->age && IS_SERVER(who)) + if (chants == chan->age && who->IsServer()) flags |= ModeParser::MODE_MERGE; ServerInstance->Modes.Process(who, chan, nullptr, changelist, flags); diff --git a/modules/spanningtree/idle.cpp b/modules/spanningtree/idle.cpp index 838d09045..0510f6054 100644 --- a/modules/spanningtree/idle.cpp +++ b/modules/spanningtree/idle.cpp @@ -43,7 +43,7 @@ CmdResult CommandIdle::HandleRemote(RemoteUser* issuer, Params& params) if (!target) return CmdResult::FAILURE; - LocalUser* localtarget = IS_LOCAL(target); + auto* localtarget = target->AsLocal(); if (!localtarget) { // Forward to target's server diff --git a/modules/spanningtree/main.cpp b/modules/spanningtree/main.cpp index 09793c7a2..91551e75e 100644 --- a/modules/spanningtree/main.cpp +++ b/modules/spanningtree/main.cpp @@ -383,7 +383,7 @@ ModResult ModuleSpanningTree::HandleConnect(const CommandBase::Params& parameter void ModuleSpanningTree::OnUserInvite(User* source, User* dest, Channel* channel, time_t expiry, ModeHandler::Rank notifyrank, CUList& notifyexcepts) { - if (IS_LOCAL(source)) + if (source->IsLocal()) { CmdBuilder params(source, "INVITE"); params.push(dest->uuid); @@ -409,7 +409,7 @@ ModResult ModuleSpanningTree::OnPreTopicChange(User* user, Channel* chan, const void ModuleSpanningTree::OnPostTopicChange(User* user, Channel* chan, const std::string& topic) { // Drop remote events on the floor. - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return; CommandFTopic::Builder(user, chan).Broadcast(); @@ -417,7 +417,7 @@ void ModuleSpanningTree::OnPostTopicChange(User* user, Channel* chan, const std: void ModuleSpanningTree::OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) { - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return; const char* message_type = (details.type == MessageType::PRIVMSG ? "PRIVMSG" : "NOTICE"); @@ -426,7 +426,7 @@ void ModuleSpanningTree::OnUserPostMessage(User* user, const MessageTarget& targ case MessageTarget::TYPE_USER: { auto* d = target.Get<User>(); - if (!IS_LOCAL(d)) + if (!d->IsLocal()) { CmdBuilder params(user, message_type); params.push_tags(details.tags_out); @@ -456,7 +456,7 @@ void ModuleSpanningTree::OnUserPostMessage(User* user, const MessageTarget& targ void ModuleSpanningTree::OnUserPostTagMessage(User* user, const MessageTarget& target, const CTCTags::TagMessageDetails& details) { - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return; switch (target.type) @@ -464,7 +464,7 @@ void ModuleSpanningTree::OnUserPostTagMessage(User* user, const MessageTarget& t case MessageTarget::TYPE_USER: { auto* d = target.Get<User>(); - if (!IS_LOCAL(d)) + if (!d->IsLocal()) { CmdBuilder params(user, "TAGMSG"); params.push_tags(details.tags_out); @@ -532,7 +532,7 @@ void ModuleSpanningTree::OnUserConnect(LocalUser* user) void ModuleSpanningTree::OnUserJoin(Membership* memb, bool sync, bool created_by_local, CUList& excepts) { // Only do this for local users - if (!IS_LOCAL(memb->user)) + if (!memb->user->IsLocal()) return; // Assign the current membership id to the new Membership and increase it @@ -563,7 +563,7 @@ void ModuleSpanningTree::OnUserJoin(Membership* memb, bool sync, bool created_by void ModuleSpanningTree::OnChangeHost(User* user, const std::string& newhost) { - if (!user->IsFullyConnected() || !IS_LOCAL(user)) + if (!user->IsFullyConnected() || !user->IsLocal()) return; CmdBuilder(user, "FHOST").push(newhost).push('*').Broadcast(); @@ -571,7 +571,7 @@ void ModuleSpanningTree::OnChangeHost(User* user, const std::string& newhost) void ModuleSpanningTree::OnChangeRealHost(User* user, const std::string& newhost) { - if (!user->IsFullyConnected() || !IS_LOCAL(user)) + if (!user->IsFullyConnected() || !user->IsLocal()) return; CmdBuilder(user, "FHOST").push('*').push(newhost).Broadcast(); @@ -579,7 +579,7 @@ void ModuleSpanningTree::OnChangeRealHost(User* user, const std::string& newhost void ModuleSpanningTree::OnChangeRealName(User* user, const std::string& real) { - if (!user->IsFullyConnected() || !IS_LOCAL(user)) + if (!user->IsFullyConnected() || !user->IsLocal()) return; CmdBuilder(user, "FNAME").push_last(real).Broadcast(); @@ -587,7 +587,7 @@ void ModuleSpanningTree::OnChangeRealName(User* user, const std::string& real) void ModuleSpanningTree::OnChangeUser(User* user, const std::string& newuser) { - if (!user->IsFullyConnected() || !IS_LOCAL(user)) + if (!user->IsFullyConnected() || !user->IsLocal()) return; CmdBuilder(user, "FIDENT").push(newuser).push("*").Broadcast(); @@ -595,7 +595,7 @@ void ModuleSpanningTree::OnChangeUser(User* user, const std::string& newuser) void ModuleSpanningTree::OnChangeRealUser(User* user, const std::string& newuser) { - if (!user->IsFullyConnected() || !IS_LOCAL(user)) + if (!user->IsFullyConnected() || !user->IsLocal()) return; CmdBuilder(user, "FIDENT").push("*").push(newuser).Broadcast(); @@ -603,7 +603,7 @@ void ModuleSpanningTree::OnChangeRealUser(User* user, const std::string& newuser void ModuleSpanningTree::OnUserPart(Membership* memb, std::string& partmessage, CUList& excepts) { - if (IS_LOCAL(memb->user)) + if (memb->user->IsLocal()) { CmdBuilder params(memb->user, "PART"); params.push(memb->chan->name); @@ -615,7 +615,7 @@ void ModuleSpanningTree::OnUserPart(Membership* memb, std::string& partmessage, void ModuleSpanningTree::OnUserQuit(User* user, const std::string& reason, const std::string& oper_message) { - if (IS_LOCAL(user)) + if (user->IsLocal()) { if (oper_message != reason) ServerInstance->PI->SendMetadata(user, "operquit", oper_message); @@ -642,7 +642,7 @@ void ModuleSpanningTree::OnUserQuit(User* user, const std::string& reason, const void ModuleSpanningTree::OnUserPostNick(User* user, const std::string& oldnick) { - if (IS_LOCAL(user)) + if (user->IsLocal()) { // The nick TS is updated by the core, we don't do it CmdBuilder params(user, "NICK"); @@ -658,14 +658,14 @@ void ModuleSpanningTree::OnUserPostNick(User* user, const std::string& oldnick) void ModuleSpanningTree::OnUserKick(User* source, Membership* memb, const std::string& reason, CUList& excepts) { - if ((!IS_LOCAL(source)) && (source != ServerInstance->FakeClient)) + if ((!source->IsLocal()) && (source != ServerInstance->FakeClient)) return; CmdBuilder params(source, "KICK"); params.push(memb->chan->name); params.push(memb->user->uuid); // If a remote user is being kicked by us then send the membership id in the kick too - if (!IS_LOCAL(memb->user)) + if (!memb->user->IsLocal()) params.push_int(memb->id); params.push_last(reason); params.Broadcast(); @@ -716,7 +716,7 @@ void ModuleSpanningTree::ReadConfig(ConfigStatus& status) std::string msg = "Error in configuration: "; msg.append(e.GetReason()); ServerInstance->SNO.WriteToSnoMask('l', msg); - if (status.srcuser && !IS_LOCAL(status.srcuser)) + if (status.srcuser && !status.srcuser->IsLocal()) ServerInstance->PI->SendSNONotice('L', msg); } } @@ -786,7 +786,7 @@ restart: void ModuleSpanningTree::OnOperLogin(User* user, const std::shared_ptr<OperAccount>& oper, bool automatic) { - if (!user->IsFullyConnected() || !IS_LOCAL(user)) + if (!user->IsFullyConnected() || !user->IsLocal()) return; // Note: The protocol does not allow direct umode +o; @@ -796,7 +796,7 @@ void ModuleSpanningTree::OnOperLogin(User* user, const std::shared_ptr<OperAccou void ModuleSpanningTree::OnAddLine(User* user, XLine* x) { - if (!x->IsBurstable() || loopCall || (user && !IS_LOCAL(user))) + if (!x->IsBurstable() || loopCall || (user && !user->IsLocal())) return; if (!user) @@ -807,7 +807,7 @@ void ModuleSpanningTree::OnAddLine(User* user, XLine* x) void ModuleSpanningTree::OnDelLine(User* user, XLine* x) { - if (!x->IsBurstable() || loopCall || (user && !IS_LOCAL(user))) + if (!x->IsBurstable() || loopCall || (user && !user->IsLocal())) return; if (!user) @@ -821,7 +821,7 @@ void ModuleSpanningTree::OnDelLine(User* user, XLine* x) void ModuleSpanningTree::OnUserAway(User* user, const std::optional<AwayState>& prevstate) { - if (IS_LOCAL(user) && user->IsFullyConnected()) + if (user->IsLocal() && user->IsFullyConnected()) CommandAway::Builder(user).Broadcast(); } diff --git a/modules/spanningtree/num.cpp b/modules/spanningtree/num.cpp index 595bc89ac..64cc0f62e 100644 --- a/modules/spanningtree/num.cpp +++ b/modules/spanningtree/num.cpp @@ -30,7 +30,7 @@ CmdResult CommandNum::HandleServer(TreeServer* server, CommandBase::Params& para if (!target) return CmdResult::FAILURE; - LocalUser* const localtarget = IS_LOCAL(target); + auto* const localtarget = target->AsLocal(); if (!localtarget) return CmdResult::SUCCESS; diff --git a/modules/spanningtree/override_whois.cpp b/modules/spanningtree/override_whois.cpp index 0e1ee727d..dfdb987eb 100644 --- a/modules/spanningtree/override_whois.cpp +++ b/modules/spanningtree/override_whois.cpp @@ -31,7 +31,7 @@ ModResult ModuleSpanningTree::HandleRemoteWhois(const CommandBase::Params& parameters, User* user) { auto* remote = ServerInstance->Users.FindNick(parameters[1]); - if (remote && !IS_LOCAL(remote)) + if (remote && !remote->IsLocal()) { CmdBuilder(user, "IDLE").push(remote->uuid).Unicast(remote); return MOD_RES_DENY; diff --git a/modules/spanningtree/postcommand.cpp b/modules/spanningtree/postcommand.cpp index fbb0ecc3c..1f9e20a55 100644 --- a/modules/spanningtree/postcommand.cpp +++ b/modules/spanningtree/postcommand.cpp @@ -115,7 +115,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm { // user target? auto* d = ServerInstance->Users.Find(dest); - if (!d || IS_LOCAL(d)) + if (!d || d->IsLocal()) return; TreeServer* tsd = TreeServer::Get(d)->GetRoute(); if (tsd == origin) diff --git a/modules/spanningtree/rconnect.cpp b/modules/spanningtree/rconnect.cpp index d787173d9..6ccdcf206 100644 --- a/modules/spanningtree/rconnect.cpp +++ b/modules/spanningtree/rconnect.cpp @@ -67,7 +67,7 @@ CmdResult CommandRConnect::Handle(User* user, const Params& parameters) * for those conditions here, as ModuleSpanningTree::HandleConnect() (which will run * on the target) does all the checking and error reporting. */ - if (IS_LOCAL(user)) + if (user->IsLocal()) { user->WriteNotice("*** RCONNECT: Sending remote connect to \002 " + parameters[0] + "\002 to connect server \002" + parameters[1] + "\002."); } diff --git a/modules/spanningtree/reply.cpp b/modules/spanningtree/reply.cpp index 4a407296e..095dc0eeb 100644 --- a/modules/spanningtree/reply.cpp +++ b/modules/spanningtree/reply.cpp @@ -30,7 +30,7 @@ CmdResult CommandReply::HandleServer(TreeServer* server, CommandBase::Params& pa if (!target) return CmdResult::FAILURE; // User has gone. - auto* ltarget = IS_LOCAL(target); + auto* ltarget = target->AsLocal(); if (!ltarget) return CmdResult::SUCCESS; // Not for us. diff --git a/modules/spanningtree/servercommand.h b/modules/spanningtree/servercommand.h index af1761cb0..e4e2062cf 100644 --- a/modules/spanningtree/servercommand.h +++ b/modules/spanningtree/servercommand.h @@ -71,9 +71,10 @@ public: CmdResult Handle(User* user, Params& parameters) override { - RemoteUser* remoteuser = IS_REMOTE(user); - if (!remoteuser) + if (!user->IsRemote()) throw ProtocolException("Invalid source"); + + auto* remoteuser = static_cast<RemoteUser*>(user); return static_cast<T*>(this)->HandleRemote(remoteuser, parameters); } }; @@ -91,8 +92,9 @@ public: CmdResult Handle(User* user, CommandBase::Params& parameters) override { - if (!IS_SERVER(user)) + if (!user->IsServer()) throw ProtocolException("Invalid source"); + TreeServer* server = TreeServer::Get(user); return static_cast<T*>(this)->HandleServer(server, parameters); } diff --git a/modules/spanningtree/tags.cpp b/modules/spanningtree/tags.cpp index 9b4077a98..ce13ca4ea 100644 --- a/modules/spanningtree/tags.cpp +++ b/modules/spanningtree/tags.cpp @@ -30,7 +30,7 @@ ModResult ServerTags::OnProcessTag(User* user, const std::string& tagname, std:: return MOD_RES_PASSTHRU; // Only allow tags from remote users. - return IS_LOCAL(user) ? MOD_RES_DENY : MOD_RES_ALLOW; + return user->IsLocal() ? MOD_RES_DENY : MOD_RES_ALLOW; } bool ServerTags::ShouldSendTag(LocalUser* user, const ClientProtocol::MessageTagData& tagdata) diff --git a/modules/spanningtree/utils.cpp b/modules/spanningtree/utils.cpp index 240d5a3ee..6254c0a41 100644 --- a/modules/spanningtree/utils.cpp +++ b/modules/spanningtree/utils.cpp @@ -150,7 +150,7 @@ void SpanningTreeUtilities::GetListOfServersForChannel(const Channel* c, TreeSoc TreeServer::ChildServers children = TreeRoot->GetChildren(); for (const auto& [user, memb] : c->GetUsers()) { - if (IS_LOCAL(user)) + if (user->IsLocal()) continue; if (minrank && memb->GetRank() < minrank) diff --git a/modules/sslinfo.cpp b/modules/sslinfo.cpp index 985da49fd..b74d4e30b 100644 --- a/modules/sslinfo.cpp +++ b/modules/sslinfo.cpp @@ -164,7 +164,7 @@ public: if (cert) return cert; - LocalUser* luser = IS_LOCAL(user); + auto* luser = user->AsLocal(); if (!luser || nosslext.Get(luser)) return nullptr; @@ -449,7 +449,7 @@ public: void OnPostConnect(User* user) override { - LocalUser* const localuser = IS_LOCAL(user); + auto* const localuser = user->AsLocal(); if (!localuser) return; diff --git a/modules/sslmodes.cpp b/modules/sslmodes.cpp index ea2339fd2..0c47d5843 100644 --- a/modules/sslmodes.cpp +++ b/modules/sslmodes.cpp @@ -101,7 +101,7 @@ public: if (change.adding == channel->IsModeSet(this)) return false; - if (change.adding && IS_LOCAL(source)) + if (change.adding && source->IsLocal()) { if (!sslapi) { @@ -148,7 +148,7 @@ public: if (change.adding == dest->IsModeSet(this)) return false; - if (change.adding && IS_LOCAL(user)) + if (change.adding && user->IsLocal()) { if (!sslapi) { diff --git a/modules/stripcolor.cpp b/modules/stripcolor.cpp index a485c0b60..fc475902f 100644 --- a/modules/stripcolor.cpp +++ b/modules/stripcolor.cpp @@ -48,7 +48,7 @@ public: ModResult OnUserPreMessage(User* user, MessageTarget& target, MessageDetails& details) override { - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return MOD_RES_PASSTHRU; bool active = false; @@ -88,7 +88,7 @@ public: User* user = memb->user; Channel* channel = memb->chan; - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return; if (extban.GetStatus(user, channel).check(!user->IsModeSet(csc))) diff --git a/modules/swhois.cpp b/modules/swhois.cpp index 084cf3820..2a2c40023 100644 --- a/modules/swhois.cpp +++ b/modules/swhois.cpp @@ -408,7 +408,7 @@ public: void OnPostOperLogin(User* user, bool automatic) override { - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return; std::string swhoisstr; @@ -426,7 +426,7 @@ public: void OnPostOperLogout(User* user, const std::shared_ptr<OperAccount>& oper) override { - if (!IS_LOCAL(user)) + if (!user->IsLocal()) return; // Remove any swhois entries added by the oper block. diff --git a/modules/timedbans.cpp b/modules/timedbans.cpp index 8c2b2f281..ad508477f 100644 --- a/modules/timedbans.cpp +++ b/modules/timedbans.cpp @@ -143,7 +143,7 @@ public: T.mask = mask; T.setter = user->nick; - T.expire = expire + (IS_REMOTE(user) ? 5 : 0); + T.expire = expire + (user->IsRemote() ? 5 : 0); T.chan = channel; TimedBanList.push_back(T); diff --git a/modules/uninvite.cpp b/modules/uninvite.cpp index 2d9eed36b..2af6c9980 100644 --- a/modules/uninvite.cpp +++ b/modules/uninvite.cpp @@ -49,7 +49,7 @@ public: CmdResult Handle(User* user, const Params& parameters) override { User* u; - if (IS_LOCAL(user)) + if (user->IsLocal()) u = ServerInstance->Users.FindNick(parameters[0], true); else u = ServerInstance->Users.Find(parameters[0]); @@ -70,7 +70,7 @@ public: return CmdResult::FAILURE; } - if (IS_LOCAL(user)) + if (user->IsLocal()) { if (c->GetPrefixValue(user) < HALFOP_VALUE) { @@ -83,7 +83,7 @@ public: * only if the target is local. Otherwise the command will be * passed to the target users server. */ - LocalUser* lu = IS_LOCAL(u); + auto* lu = u->AsLocal(); if (lu) { // XXX: The source of the numeric we send must be the server of the user doing the /UNINVITE, diff --git a/modules/watch.cpp b/modules/watch.cpp index 5931c0aab..119a5a6d0 100644 --- a/modules/watch.cpp +++ b/modules/watch.cpp @@ -242,7 +242,7 @@ public: void OnUserQuit(User* user, const std::string& message, const std::string& oper_message) override { - LocalUser* localuser = IS_LOCAL(user); + auto* localuser = user->AsLocal(); if (localuser) manager.UnwatchAll(localuser); Offline(user, user->nick); diff --git a/modules/websocket.cpp b/modules/websocket.cpp index bfec7673d..68cf0fb09 100644 --- a/modules/websocket.cpp +++ b/modules/websocket.cpp @@ -753,7 +753,7 @@ public: if (type != ExtensionType::USER) return; - auto* user = IS_LOCAL(static_cast<User*>(item)); + auto* user = static_cast<User*>(item)->AsLocal(); if (!user || !user->io->GetModHook(this)) return; |
