summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-03-12 16:50:30 +0000
committerSadie Powell <sadie@witchery.services>2024-03-12 16:50:30 +0000
commitb8cd00b4122b7a243a2071268f2d395808782472 (patch)
tree4b821af9a8a9969a97f4ded5b995228937ac851d /modules
parentb52e1b2b02c73195740ca836e21faeff281a36c2 (diff)
parentf4bd43e898e6ca415e22546f554e67139e62059e (diff)
Merge branch '2.0' into 2.1.
Diffstat (limited to 'modules')
-rw-r--r--modules/chanserv/cs_suspend.cpp28
-rw-r--r--modules/hostserv/hs_group.cpp2
-rw-r--r--modules/hostserv/hs_set.cpp2
-rw-r--r--modules/nickserv/ns_suspend.cpp21
-rw-r--r--modules/operserv/operserv.cpp3
-rw-r--r--modules/operserv/os_forbid.cpp53
6 files changed, 79 insertions, 30 deletions
diff --git a/modules/chanserv/cs_suspend.cpp b/modules/chanserv/cs_suspend.cpp
index a30227d6a..ba63e3f44 100644
--- a/modules/chanserv/cs_suspend.cpp
+++ b/modules/chanserv/cs_suspend.cpp
@@ -214,6 +214,13 @@ class CSSuspend final
}
};
+ void Expire(ChannelInfo *ci)
+ {
+ suspend.Unset(ci);
+ Log(this) << "Expiring suspend for " << ci->name;
+ }
+
+
bool Show(CommandSource &source, const Anope::string &what) const
{
return source.IsOper() || std::find(show.begin(), show.end(), what) != show.end();
@@ -259,23 +266,28 @@ public:
expire = false;
- if (!si->expires)
- return;
-
- if (si->expires < Anope::CurTime)
+ if (!Anope::NoExpire && si->expires && si->expires < Anope::CurTime)
{
ci->last_used = Anope::CurTime;
- suspend.Unset(ci);
-
- Log(this) << "Expiring suspend for " << ci->name;
+ Expire(ci);
}
}
EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override
{
- if (u->HasMode("OPER") || !c->ci || !suspend.HasExt(c->ci))
+ if (u->HasMode("OPER") || !c->ci)
return EVENT_CONTINUE;
+ CSSuspendInfo *si = suspend.Get(c->ci);
+ if (!si)
+ return EVENT_CONTINUE;
+
+ if (!Anope::NoExpire && si->expires && si->expires < Anope::CurTime)
+ {
+ Expire(c->ci);
+ return EVENT_CONTINUE;
+ }
+
reason = Language::Translate(u, _("This channel may not be used."));
return EVENT_STOP;
}
diff --git a/modules/hostserv/hs_group.cpp b/modules/hostserv/hs_group.cpp
index 2877fa16d..d28f00f7c 100644
--- a/modules/hostserv/hs_group.cpp
+++ b/modules/hostserv/hs_group.cpp
@@ -28,7 +28,7 @@ public:
setting = true;
for (auto *nick : *na->nc->aliases)
{
- if (nick)
+ if (nick && nick != na)
{
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
FOREACH_MOD(OnSetVhost, (nick));
diff --git a/modules/hostserv/hs_set.cpp b/modules/hostserv/hs_set.cpp
index 16e4cebf9..55f562e00 100644
--- a/modules/hostserv/hs_set.cpp
+++ b/modules/hostserv/hs_set.cpp
@@ -112,7 +112,7 @@ class CommandHSSetAll final
for (auto *nick : *na->nc->aliases)
{
- if (nick)
+ if (nick && nick != na)
nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator());
}
}
diff --git a/modules/nickserv/ns_suspend.cpp b/modules/nickserv/ns_suspend.cpp
index 8ce2806ca..fc5b6758a 100644
--- a/modules/nickserv/ns_suspend.cpp
+++ b/modules/nickserv/ns_suspend.cpp
@@ -225,6 +225,12 @@ class NSSuspend final
return source.IsOper() || std::find(show.begin(), show.end(), what) != show.end();
}
+ void Expire(NickAlias *na)
+ {
+ suspend.Unset(na->nc);
+ Log(LOG_NORMAL, "nickserv/expire", Config->GetClient("NickServ")) << "Expiring suspend for " << na->nick;
+ }
+
public:
NSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandnssuspend(this), commandnsunsuspend(this), suspend(this, "NS_SUSPENDED"),
@@ -265,15 +271,10 @@ public:
expire = false;
- if (!s->expires)
- return;
-
- if (s->expires < Anope::CurTime)
+ if (!Anope::NoExpire && s->expires && s->expires < Anope::CurTime)
{
na->last_seen = Anope::CurTime;
- suspend.Unset(na->nc);
-
- Log(LOG_NORMAL, "nickserv/expire", Config->GetClient("NickServ")) << "Expiring suspend for " << na->nick;
+ Expire(na);
}
}
@@ -283,6 +284,12 @@ public:
if (!s)
return EVENT_CONTINUE;
+ if (!Anope::NoExpire && s->expires && s->expires < Anope::CurTime)
+ {
+ Expire(na);
+ return EVENT_CONTINUE;
+ }
+
u->SendMessage(Config->GetClient("NickServ"), NICK_X_SUSPENDED, u->nick.c_str());
return EVENT_STOP;
}
diff --git a/modules/operserv/operserv.cpp b/modules/operserv/operserv.cpp
index 02866109c..0881b7654 100644
--- a/modules/operserv/operserv.cpp
+++ b/modules/operserv/operserv.cpp
@@ -126,6 +126,9 @@ public:
{
for (auto *x : this->GetList())
{
+ if (!Anope::NoExpire && x->expires && x->expires < Anope::CurTime)
+ continue; // Skip expired lines.
+
if (x->regex)
{
if (x->regex->Matches(c->name))
diff --git a/modules/operserv/os_forbid.cpp b/modules/operserv/os_forbid.cpp
index bb014c158..4b00e0759 100644
--- a/modules/operserv/os_forbid.cpp
+++ b/modules/operserv/os_forbid.cpp
@@ -68,6 +68,33 @@ class MyForbidService final
inline std::vector<ForbidData *>& forbids(unsigned t) { return (*this->forbid_data)[t - 1]; }
+ void Expire(ForbidData *fd, unsigned ft, size_t idx)
+ {
+ Anope::string typestr;
+ switch (ft)
+ {
+ case FT_NICK:
+ typestr = "nick";
+ break;
+ case FT_CHAN:
+ typestr = "chan";
+ break;
+ case FT_EMAIL:
+ typestr = "email";
+ break;
+ case FT_REGISTER:
+ typestr = "register";
+ break;
+ default:
+ typestr = "unknown";
+ break;
+ }
+
+ Log(LOG_NORMAL, "expire/forbid", Config->GetClient("OperServ")) << "Expiring forbid for " << fd->mask << " type " << typestr;
+ this->forbids(ft).erase(this->forbids(ft).begin() + idx);
+ delete fd;
+ }
+
public:
MyForbidService(Module *m) : ForbidService(m), forbid_data("ForbidData") { }
@@ -101,6 +128,12 @@ public:
{
ForbidData *d = this->forbids(ftype)[i - 1];
+ if (!Anope::NoExpire && d->expires && Anope::CurTime >= d->expires)
+ {
+ Expire(d, ftype, i - 1);
+ continue;
+ }
+
if (Anope::Match(mask, d->mask, false, true))
return d;
}
@@ -113,6 +146,12 @@ public:
{
ForbidData *d = this->forbids(ftype)[i - 1];
+ if (!Anope::NoExpire && d->expires && Anope::CurTime >= d->expires)
+ {
+ Expire(d, ftype, i - 1);
+ continue;
+ }
+
if (d->mask.equals_ci(mask))
return d;
}
@@ -128,19 +167,7 @@ public:
ForbidData *d = this->forbids(j).at(i - 1);
if (d->expires && !Anope::NoExpire && Anope::CurTime >= d->expires)
- {
- Anope::string ftype = "none";
- if (d->type == FT_NICK)
- ftype = "nick";
- else if (d->type == FT_CHAN)
- ftype = "chan";
- else if (d->type == FT_EMAIL)
- ftype = "email";
-
- Log(LOG_NORMAL, "expire/forbid", Config->GetClient("OperServ")) << "Expiring forbid for " << d->mask << " type " << ftype;
- this->forbids(j).erase(this->forbids(j).begin() + i - 1);
- delete d;
- }
+ Expire(d, j, i - 1);
else
f.push_back(d);
}