summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-02-26 21:55:43 +0000
committerSadie Powell <sadie@witchery.services>2024-02-26 22:00:21 +0000
commit5fa4acb1950cd21812d577f9ea6f99caaef255eb (patch)
tree6c145d9c6533f0d77f7cf67af1c6ff6b300fe3c8 /src
parent79f215606dae66367277012b394009542e4f51a4 (diff)
Refactor User::IsServicesOper.
Diffstat (limited to 'src')
-rw-r--r--src/users.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/users.cpp b/src/users.cpp
index 075f6c157..e47cf93a6 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -467,14 +467,16 @@ bool User::IsSecurelyConnected() const
bool User::IsServicesOper()
{
if (!this->nc || !this->nc->IsServicesOper())
- // No opertype.
- return false;
- else if (this->nc->o->require_oper && !this->HasMode("OPER"))
- return false;
- else if (!this->nc->o->certfp.empty())
+ return false; // Account isn't a services oper.
+
+ auto *oper = this->nc->o;
+ if (oper->require_oper && !this->HasMode("OPER"))
+ return false; // User isn't an ircd oper.
+
+ if (!oper->certfp.empty())
{
bool match = false;
- for (const auto &certfp : this->nc->o->certfp)
+ for (const auto &certfp : oper->certfp)
{
if (this->fingerprint == certfp)
{
@@ -483,14 +485,15 @@ bool User::IsServicesOper()
}
}
if (!match)
- return false;
+ return false; // Wrong TLS fingerprint.
}
- else if (!this->nc->o->hosts.empty())
+
+ if (!oper->hosts.empty())
{
bool match = false;
Anope::string match_host = this->GetIdent() + "@" + this->host;
Anope::string match_ip = this->GetIdent() + "@" + this->ip.addr();
- for (const auto &userhost : this->nc->o->hosts)
+ for (const auto &userhost : oper->hosts)
{
if (Anope::Match(match_host, userhost) || Anope::Match(match_ip, userhost))
{
@@ -498,16 +501,13 @@ bool User::IsServicesOper()
break;
}
}
- if (match == false)
- return false;
+ if (!match)
+ return false; // Wrong user@host/ip.
}
EventReturn MOD_RESULT;
FOREACH_RESULT(IsServicesOper, MOD_RESULT, (this));
- if (MOD_RESULT == EVENT_STOP)
- return false;
-
- return true;
+ return MOD_RESULT != EVENT_STOP;
}
bool User::HasCommand(const Anope::string &command)