mirror of
https://github.com/anope/anope.git
synced 2026-07-02 19:43:13 +02:00
Deduplicate code for checking if a user is securely connected.
This commit is contained in:
@@ -226,6 +226,11 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
|
||||
*/
|
||||
bool IsRecognized(bool check_secure = true) const;
|
||||
|
||||
/** Check if the user is connected securely.
|
||||
* @return True if the user is connected securely; otherwise, false.
|
||||
*/
|
||||
bool IsSecurelyConnected() const;
|
||||
|
||||
/** Check if the user is a services oper
|
||||
* @return true if they are an oper
|
||||
*/
|
||||
|
||||
@@ -119,7 +119,7 @@ class CommandCSEnforce : public Command
|
||||
if (user->IsProtected())
|
||||
continue;
|
||||
|
||||
if (!user->HasMode("SSL") && !user->HasExt("ssl"))
|
||||
if (!user->IsSecurelyConnected())
|
||||
users.push_back(user);
|
||||
}
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ class NSAJoin : public Module
|
||||
continue;
|
||||
else if (c->HasMode("ADMINONLY") && !u->HasMode("ADMIN"))
|
||||
continue;
|
||||
else if (c->HasMode("SSL") && !(u->HasMode("SSL") || u->HasExt("ssl")))
|
||||
else if (c->HasMode("SSL") && !u->IsSecurelyConnected())
|
||||
continue;
|
||||
else if (c->MatchesList(u, "BAN") == true && c->MatchesList(u, "EXCEPT") == false)
|
||||
need_invite = true;
|
||||
|
||||
@@ -107,7 +107,7 @@ void IRC2SQL::OnUserConnect(User *u, bool &exempt)
|
||||
query.SetValue("ip", u->ip.addr());
|
||||
query.SetValue("ident", u->GetIdent());
|
||||
query.SetValue("vident", u->GetVIdent());
|
||||
query.SetValue("secure", u->HasMode("SSL") || u->HasExt("ssl") ? "Y" : "N");
|
||||
query.SetValue("secure", u->IsSecurelyConnected() ? "Y" : "N");
|
||||
query.SetValue("account", u->Account() ? u->Account()->display : "");
|
||||
query.SetValue("fingerprint", u->fingerprint);
|
||||
query.SetValue("signon", u->signon);
|
||||
@@ -152,7 +152,7 @@ void IRC2SQL::OnUserAway(User *u, const Anope::string &message)
|
||||
void IRC2SQL::OnFingerprint(User *u)
|
||||
{
|
||||
query = "UPDATE `" + prefix + "user` SET secure=@secure@, fingerprint=@fingerprint@ WHERE nick=@nick@";
|
||||
query.SetValue("secure", u->HasMode("SSL") || u->HasExt("ssl") ? "Y" : "N");
|
||||
query.SetValue("secure", u->IsSecurelyConnected() ? "Y" : "N");
|
||||
query.SetValue("fingerprint", u->fingerprint);
|
||||
query.SetValue("nick", u->nick);
|
||||
this->RunQuery(query);
|
||||
|
||||
@@ -448,6 +448,11 @@ bool User::IsRecognized(bool check_secure) const
|
||||
return on_access;
|
||||
}
|
||||
|
||||
bool User::IsSecurelyConnected() const
|
||||
{
|
||||
return HasMode("SSL") || HasExt("ssl");
|
||||
}
|
||||
|
||||
bool User::IsServicesOper()
|
||||
{
|
||||
if (!this->nc || !this->nc->IsServicesOper())
|
||||
|
||||
Reference in New Issue
Block a user