aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-10-29 13:30:39 +0100
committerGravatar Sadie Powell2022-10-29 13:43:11 +0100
commit5a508c19ff3dec65bb4148883d38127d7c0be79e (patch)
tree2bdfcbadfdfbe0a6fd244260a9570be86a3eb8d4 /src
parentAllow UserManager::Find{Nick,UUID,} to ignore unregistered users. (diff)
Use User::IsFullyConnected instead of checking for REG_ALL.
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp2
-rw-r--r--src/command_parse.cpp6
-rw-r--r--src/commands.cpp4
-rw-r--r--src/coremods/core_lusers.cpp2
-rw-r--r--src/coremods/core_message.cpp2
-rw-r--r--src/coremods/core_oper/cmd_die.cpp2
-rw-r--r--src/coremods/core_user/cmd_nick.cpp2
-rw-r--r--src/coremods/core_user/core_user.cpp2
-rw-r--r--src/coremods/core_who.cpp2
-rw-r--r--src/coremods/core_xline/core_xline.cpp2
-rw-r--r--src/modules/m_alias.cpp2
-rw-r--r--src/modules/m_blockamsg.cpp2
-rw-r--r--src/modules/m_cap.cpp2
-rw-r--r--src/modules/m_chghost.cpp2
-rw-r--r--src/modules/m_cloaking.cpp4
-rw-r--r--src/modules/m_disable.cpp4
-rw-r--r--src/modules/m_gateway.cpp2
-rw-r--r--src/modules/m_httpd_stats.cpp4
-rw-r--r--src/modules/m_ident.cpp2
-rw-r--r--src/modules/m_ircv3_ctctags.cpp2
-rw-r--r--src/modules/m_ircv3_labeledresponse.cpp2
-rw-r--r--src/modules/m_shun.cpp2
-rw-r--r--src/modules/m_spanningtree/main.cpp12
-rw-r--r--src/modules/m_spanningtree/netburst.cpp2
-rw-r--r--src/modules/m_spanningtree/uid.cpp2
-rw-r--r--src/modules/m_starttls.cpp2
-rw-r--r--src/usermanager.cpp4
-rw-r--r--src/users.cpp6
28 files changed, 43 insertions, 41 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index ce20a689d..532a1ad1f 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -172,7 +172,7 @@ void Channel::SetDefaultModes()
*/
Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, const std::string& key)
{
- if (user->registered != REG_ALL)
+ if (!user->IsFullyConnected())
{
ServerInstance->Logs.Debug("CHANNELS", "Attempted to join unregistered user " + user->uuid + " to channel " + cname);
return nullptr;
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 028378eb4..dda2d2edd 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -211,7 +211,7 @@ void CommandParser::ProcessCommand(LocalUser* user, std::string& command, Comman
handler = GetHandler(command);
if (!handler)
{
- if (user->registered == REG_ALL)
+ if (user->IsFullyConnected())
user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "Unknown command");
ServerInstance->stats.Unknown++;
@@ -290,7 +290,7 @@ void CommandParser::ProcessCommand(LocalUser* user, std::string& command, Comman
case CmdAccess::SERVER:
{
- if (user->registered == REG_ALL)
+ if (user->IsFullyConnected())
user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "Unknown command");
ServerInstance->stats.Unknown++;
@@ -311,7 +311,7 @@ void CommandParser::ProcessCommand(LocalUser* user, std::string& command, Comman
return;
}
- if ((user->registered != REG_ALL) && (!handler->works_before_reg))
+ if (!user->IsFullyConnected() && !handler->works_before_reg)
{
user->CommandFloodPenalty += failpenalty;
handler->TellNotRegistered(user, command_p);
diff --git a/src/commands.cpp b/src/commands.cpp
index 1d6fdb299..bae8ef10b 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -69,9 +69,11 @@ void Command::RegisterService()
void Command::TellNotEnoughParameters(LocalUser* user, const Params& parameters)
{
user->WriteNumeric(ERR_NEEDMOREPARAMS, name, "Not enough parameters.");
- if (ServerInstance->Config->SyntaxHints && user->registered == REG_ALL)
+ if (ServerInstance->Config->SyntaxHints && user->IsFullyConnected())
+ {
for (const std::string& syntaxline : this->syntax)
user->WriteNumeric(RPL_SYNTAX, name, syntaxline);
+ }
}
void Command::TellNotRegistered(LocalUser* user, const Params& parameters)
diff --git a/src/coremods/core_lusers.cpp b/src/coremods/core_lusers.cpp
index 7f98b600f..852a2b385 100644
--- a/src/coremods/core_lusers.cpp
+++ b/src/coremods/core_lusers.cpp
@@ -133,7 +133,7 @@ public:
void AfterMode(User* source, User* dest, Channel* channel, const Modes::Change& change) override
{
- if (dest->registered != REG_ALL)
+ if (!dest->IsFullyConnected())
return;
if (dest->server->IsService())
diff --git a/src/coremods/core_message.cpp b/src/coremods/core_message.cpp
index 4a1efe450..5338d3666 100644
--- a/src/coremods/core_message.cpp
+++ b/src/coremods/core_message.cpp
@@ -197,7 +197,7 @@ private:
for (auto* luser : ServerInstance->Users.GetLocalUsers())
{
// Don't send to unregistered users or the user who is the source.
- if (luser->registered != REG_ALL || luser == source)
+ if (!luser->IsFullyConnected() || luser == source)
continue;
// Only send to non-exempt users.
diff --git a/src/coremods/core_oper/cmd_die.cpp b/src/coremods/core_oper/cmd_die.cpp
index c60f793a5..df2a306e0 100644
--- a/src/coremods/core_oper/cmd_die.cpp
+++ b/src/coremods/core_oper/cmd_die.cpp
@@ -46,7 +46,7 @@ void DieRestart::SendError(const std::string& message)
for (auto* user : ServerInstance->Users.GetLocalUsers())
{
- if (user->registered == REG_ALL)
+ if (user->IsFullyConnected())
{
user->WriteNotice(message);
}
diff --git a/src/coremods/core_user/cmd_nick.cpp b/src/coremods/core_user/cmd_nick.cpp
index 4cb641ed1..9dc23981a 100644
--- a/src/coremods/core_user/cmd_nick.cpp
+++ b/src/coremods/core_user/cmd_nick.cpp
@@ -47,7 +47,7 @@ CmdResult CommandNick::HandleLocal(LocalUser* user, const Params& parameters)
std::string newnick = parameters[0];
// anything except the initial NICK gets a flood penalty
- if (user->registered == REG_ALL)
+ if (user->IsFullyConnected())
user->CommandFloodPenalty += 4000;
if (newnick.empty())
diff --git a/src/coremods/core_user/core_user.cpp b/src/coremods/core_user/core_user.cpp
index 57591a3f4..57ad1b0d5 100644
--- a/src/coremods/core_user/core_user.cpp
+++ b/src/coremods/core_user/core_user.cpp
@@ -44,7 +44,7 @@ public:
CmdResult HandleLocal(LocalUser* user, const Params& parameters) override
{
// Check to make sure they haven't registered -- Fix by FCS
- if (user->registered == REG_ALL)
+ if (user->IsFullyConnected())
{
user->CommandFloodPenalty += 1000;
user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not reregister");
diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp
index 70b6f0bba..43494e15f 100644
--- a/src/coremods/core_who.cpp
+++ b/src/coremods/core_who.cpp
@@ -259,7 +259,7 @@ bool CommandWho::MatchChannel(LocalUser* source, Membership* memb, WhoData& data
bool CommandWho::MatchUser(LocalUser* source, User* user, WhoData& data)
{
// Users who are not fully registered can never match.
- if (user->registered != REG_ALL)
+ if (!user->IsFullyConnected())
return false;
bool source_has_users_auspex = source->HasPrivPermission("users/auspex");
diff --git a/src/coremods/core_xline/core_xline.cpp b/src/coremods/core_xline/core_xline.cpp
index 8ca0b963b..f9d786141 100644
--- a/src/coremods/core_xline/core_xline.cpp
+++ b/src/coremods/core_xline/core_xline.cpp
@@ -146,7 +146,7 @@ public:
return MOD_RES_PASSTHRU; // No match
// A Q-line matched the new nick, tell opers if the user is registered
- if (user->registered == REG_ALL)
+ if (user->IsFullyConnected())
{
ServerInstance->SNO.WriteGlobalSno('x', "Q-lined nickname %s from %s: %s",
newnick.c_str(), user->GetFullRealHost().c_str(), xline->reason.c_str());
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index b7de8c8a7..1a02b2972 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -163,7 +163,7 @@ public:
/* If they're not registered yet, we dont want
* to know.
*/
- if (user->registered != REG_ALL)
+ if (!user->IsFullyConnected())
return MOD_RES_PASSTHRU;
/* We dont have any commands looking like this? Stop processing. */
diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp
index 8fe7bfccc..793ec389d 100644
--- a/src/modules/m_blockamsg.cpp
+++ b/src/modules/m_blockamsg.cpp
@@ -78,7 +78,7 @@ public:
ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) override
{
// Don't do anything with unregistered users
- if (user->registered != REG_ALL)
+ if (!user->IsFullyConnected())
return MOD_RES_PASSTHRU;
if ((validated) && (parameters.size() >= 2) && ((command == "PRIVMSG") || (command == "NOTICE")))
diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp
index 63afcbeba..5f927438b 100644
--- a/src/modules/m_cap.cpp
+++ b/src/modules/m_cap.cpp
@@ -409,7 +409,7 @@ public:
CmdResult HandleLocal(LocalUser* user, const Params& parameters) override
{
- if (user->registered != REG_ALL)
+ if (!user->IsFullyConnected())
holdext.Set(user);
const std::string& subcommand = parameters[0];
diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp
index a0d3356ff..c98ea0208 100644
--- a/src/modules/m_chghost.cpp
+++ b/src/modules/m_chghost.cpp
@@ -60,7 +60,7 @@ public:
auto dest = ServerInstance->Users.Find(parameters[0]);
// Allow services to change the host of unregistered users
- if ((!dest) || ((dest->registered != REG_ALL) && (!user->server->IsService())))
+ if (!dest || (!dest->IsFullyConnected() && !user->server->IsService()))
{
user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
return CmdResult::FAILURE;
diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp
index 5d35173d1..3c25e0a58 100644
--- a/src/modules/m_cloaking.cpp
+++ b/src/modules/m_cloaking.cpp
@@ -153,7 +153,7 @@ public:
if (change.adding)
{
// assume this is more correct
- if (user->registered != REG_ALL && user->GetRealHost() != user->GetDisplayedHost())
+ if (!user->IsFullyConnected() && user->GetRealHost() != user->GetDisplayedHost())
return MODEACTION_DENY;
CloakList* cloaks = ext.Get(user);
@@ -535,7 +535,7 @@ public:
void OnChangeRemoteAddress(LocalUser* user) override
{
// Connecting users are handled in OnUserConnect not here.
- if (user->registered != REG_ALL || user->quitting)
+ if (!user->IsFullyConnected() || user->quitting)
return;
// Remove the cloaks and generate new ones.
diff --git a/src/modules/m_disable.cpp b/src/modules/m_disable.cpp
index 57f471d13..c718d0abc 100644
--- a/src/modules/m_disable.cpp
+++ b/src/modules/m_disable.cpp
@@ -142,7 +142,7 @@ public:
ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) override
{
// If a command is unvalidated or the source is not registered we do nothing.
- if (!validated || user->registered != REG_ALL)
+ if (!validated || !user->IsFullyConnected())
return MOD_RES_PASSTHRU;
// If the command is not disabled or the user has the servers/use-disabled-commands priv we do nothing.
@@ -170,7 +170,7 @@ public:
ModResult OnRawMode(User* user, Channel* chan, const Modes::Change& change) override
{
// If a mode change is remote or the source is not registered we do nothing.
- if (!IS_LOCAL(user) || user->registered != REG_ALL)
+ if (!IS_LOCAL(user) || !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/src/modules/m_gateway.cpp b/src/modules/m_gateway.cpp
index 6ca99fbb2..b4f7b78a6 100644
--- a/src/modules/m_gateway.cpp
+++ b/src/modules/m_gateway.cpp
@@ -252,7 +252,7 @@ public:
CmdResult HandleLocal(LocalUser* user, const Params& parameters) override
{
- if (user->registered == REG_ALL || realhost.Get(user))
+ if (user->IsFullyConnected() || realhost.Get(user))
return CmdResult::FAILURE;
for (const auto& host : hosts)
diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp
index f05c418cb..bcad9bf31 100644
--- a/src/modules/m_httpd_stats.cpp
+++ b/src/modules/m_httpd_stats.cpp
@@ -294,7 +294,7 @@ namespace Stats
serializer.BeginBlock("userlist");
for (const auto& [_, u] : ServerInstance->Users.GetUsers())
{
- if (u->registered != REG_ALL)
+ if (!u->IsFullyConnected())
continue;
DumpUser(serializer, u);
@@ -413,7 +413,7 @@ namespace Stats
NewUserList user_list;
for (const auto& [_, u] : ServerInstance->Users.GetUsers())
{
- if (!showunreg && u->registered != REG_ALL)
+ if (!showunreg && !u->IsFullyConnected())
continue;
LocalUser* lu = IS_LOCAL(u);
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index 7769c84d5..9adfaf3bd 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -327,7 +327,7 @@ public:
return;
// We don't want to look this up once the user has connected.
- if (user->registered == REG_ALL || user->quitting)
+ if (user->IsFullyConnected() || user->quitting)
return;
std::shared_ptr<ConfigTag> tag = user->GetClass()->config;
diff --git a/src/modules/m_ircv3_ctctags.cpp b/src/modules/m_ircv3_ctctags.cpp
index c21b9e762..5d9e74e8a 100644
--- a/src/modules/m_ircv3_ctctags.cpp
+++ b/src/modules/m_ircv3_ctctags.cpp
@@ -134,7 +134,7 @@ private:
for (auto* luser : ServerInstance->Users.GetLocalUsers())
{
// Don't send to unregistered users or the user who is the source.
- if (luser->registered != REG_ALL || luser == source)
+ if (!luser->IsFullyConnected() || luser == source)
continue;
// Don't send to exempt users.
diff --git a/src/modules/m_ircv3_labeledresponse.cpp b/src/modules/m_ircv3_labeledresponse.cpp
index c90154371..468fb0740 100644
--- a/src/modules/m_ircv3_labeledresponse.cpp
+++ b/src/modules/m_ircv3_labeledresponse.cpp
@@ -107,7 +107,7 @@ public:
return MOD_RES_PASSTHRU;
// We only care about registered users with the labeled-response and batch caps.
- if (user->registered != REG_ALL || !cap.IsEnabled(user) || !batchcap.IsEnabled(user))
+ if (!user->IsFullyConnected() || !cap.IsEnabled(user) || !batchcap.IsEnabled(user))
return MOD_RES_PASSTHRU;
const ClientProtocol::TagMap& tagmap = parameters.GetTags();
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp
index 8837eef95..3b0d7baf4 100644
--- a/src/modules/m_shun.cpp
+++ b/src/modules/m_shun.cpp
@@ -155,7 +155,7 @@ private:
bool IsShunned(LocalUser* user) const
{
// Exempt the user if they are not fully connected and allowconnect is enabled.
- if (allowconnect && user->registered != REG_ALL)
+ if (allowconnect && !user->IsFullyConnected())
return false;
// Exempt the user from shuns if they are an oper with the servers/ignore-shun privilege.
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 241c498f5..efcac01c7 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -550,7 +550,7 @@ void ModuleSpanningTree::OnUserJoin(Membership* memb, bool sync, bool created_by
void ModuleSpanningTree::OnChangeHost(User* user, const std::string& newhost)
{
- if (user->registered != REG_ALL || !IS_LOCAL(user))
+ if (!user->IsFullyConnected() || !IS_LOCAL(user))
return;
CmdBuilder(user, "FHOST").push(newhost).Broadcast();
@@ -558,7 +558,7 @@ void ModuleSpanningTree::OnChangeHost(User* user, const std::string& newhost)
void ModuleSpanningTree::OnChangeRealHost(User* user, const std::string& newhost)
{
- if (user->registered != REG_ALL || !IS_LOCAL(user))
+ if (!user->IsFullyConnected() || !IS_LOCAL(user))
return;
CmdBuilder(user, "FRHOST").push(newhost).Broadcast();
@@ -566,7 +566,7 @@ void ModuleSpanningTree::OnChangeRealHost(User* user, const std::string& newhost
void ModuleSpanningTree::OnChangeRealName(User* user, const std::string& real)
{
- if (user->registered != REG_ALL || !IS_LOCAL(user))
+ if (!user->IsFullyConnected() || !IS_LOCAL(user))
return;
CmdBuilder(user, "FNAME").push_last(real).Broadcast();
@@ -574,7 +574,7 @@ void ModuleSpanningTree::OnChangeRealName(User* user, const std::string& real)
void ModuleSpanningTree::OnChangeIdent(User* user, const std::string& ident)
{
- if ((user->registered != REG_ALL) || (!IS_LOCAL(user)))
+ if (!user->IsFullyConnected() || !IS_LOCAL(user))
return;
CmdBuilder(user, "FIDENT").push(ident).Broadcast();
@@ -774,7 +774,7 @@ restart:
void ModuleSpanningTree::OnOper(User* user)
{
- if (user->registered != REG_ALL || !IS_LOCAL(user))
+ if (!user->IsFullyConnected() || !IS_LOCAL(user))
return;
// Note: The protocol does not allow direct umode +o;
@@ -825,7 +825,7 @@ void ModuleSpanningTree::OnMode(User* source, User* u, Channel* c, const Modes::
if (u)
{
- if (u->registered != REG_ALL)
+ if (!u->IsFullyConnected())
return;
CmdBuilder params(source, "MODE");
diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp
index 7c49c58a6..5dcc88504 100644
--- a/src/modules/m_spanningtree/netburst.cpp
+++ b/src/modules/m_spanningtree/netburst.cpp
@@ -276,7 +276,7 @@ void TreeSocket::SendUsers(BurstState& bs)
{
for (const auto& [_, user] : ServerInstance->Users.GetUsers())
{
- if (user->registered != REG_ALL)
+ if (!user->IsFullyConnected())
continue;
this->WriteLine(CommandUID::Builder(user));
diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp
index 84dae98ef..ccedf8c3c 100644
--- a/src/modules/m_spanningtree/uid.cpp
+++ b/src/modules/m_spanningtree/uid.cpp
@@ -49,7 +49,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, CommandBase::Params
// See if there is a nick collision
auto collideswith = ServerInstance->Users.FindNick(params[2]);
- if ((collideswith) && (collideswith->registered != REG_ALL))
+ if (collideswith && !collideswith->IsFullyConnected())
{
// User that the incoming user is colliding with is not fully registered, we force nick change the
// unregistered user to their uuid and tell them what happened
diff --git a/src/modules/m_starttls.cpp b/src/modules/m_starttls.cpp
index 53819ce72..c95b7b4f5 100644
--- a/src/modules/m_starttls.cpp
+++ b/src/modules/m_starttls.cpp
@@ -53,7 +53,7 @@ public:
return CmdResult::FAILURE;
}
- if (user->registered == REG_ALL)
+ if (user->IsFullyConnected())
{
user->WriteNumeric(ERR_STARTTLS, "STARTTLS is not permitted after client registration is complete");
return CmdResult::FAILURE;
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index 9755da400..5e33002bc 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -277,7 +277,7 @@ void UserManager::QuitUser(User* user, const std::string& quitmessage, const std
ServerInstance->GlobalCulls.AddItem(user);
- if (user->registered == REG_ALL)
+ if (user->IsFullyConnected())
{
FOREACH_MOD(OnUserQuit, (user, quitmsg, operquitmsg));
WriteCommonQuit(user, quitmsg, operquitmsg);
@@ -291,7 +291,7 @@ void UserManager::QuitUser(User* user, const std::string& quitmessage, const std
FOREACH_MOD(OnUserDisconnect, (lu));
lu->eh.Close();
- if (lu->registered == REG_ALL)
+ if (lu->IsFullyConnected())
ServerInstance->SNO.WriteToSnoMask('q',"Client exiting: %s (%s) [%s]", user->GetFullRealHost().c_str(), user->GetIPString().c_str(), operquitmsg.c_str());
local_users.erase(lu);
}
diff --git a/src/users.cpp b/src/users.cpp
index f2a51a8f6..e5b38349d 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -626,7 +626,7 @@ bool User::ChangeNick(const std::string& newnick, time_t newts)
*/
if (InUse)
{
- if (InUse->registered != REG_ALL)
+ if (!InUse->IsFullyConnected())
{
/* force the camper to their UUID, and ask them to re-send a NICK. */
LocalUser* const localuser = static_cast<LocalUser*>(InUse);
@@ -643,7 +643,7 @@ bool User::ChangeNick(const std::string& newnick, time_t newts)
nickchanged = newts ? newts : ServerInstance->Time();
}
- if (this->registered == REG_ALL)
+ if (IsFullyConnected())
{
ClientProtocol::Messages::Nick nickmsg(this, newnick);
ClientProtocol::Event nickevent(ServerInstance->GetRFCEvents().nick, nickmsg);
@@ -656,7 +656,7 @@ bool User::ChangeNick(const std::string& newnick, time_t newts)
ServerInstance->Users.clientlist.erase(oldnick);
ServerInstance->Users.clientlist[newnick] = this;
- if (registered == REG_ALL)
+ if (IsFullyConnected())
FOREACH_MOD(OnUserPostNick, (this,oldnick));
return true;