summaryrefslogtreecommitdiff
path: root/modules/operserv
diff options
context:
space:
mode:
Diffstat (limited to 'modules/operserv')
-rw-r--r--modules/operserv/akill.cpp25
-rw-r--r--modules/operserv/chankill.cpp13
-rw-r--r--modules/operserv/defcon.cpp59
-rw-r--r--modules/operserv/dns.cpp187
-rw-r--r--modules/operserv/forbid.cpp49
-rw-r--r--modules/operserv/ignore.cpp28
-rw-r--r--modules/operserv/info.cpp28
-rw-r--r--modules/operserv/login.cpp3
-rw-r--r--modules/operserv/logsearch.cpp2
-rw-r--r--modules/operserv/main/operserv.cpp46
-rw-r--r--modules/operserv/modinfo.cpp15
-rw-r--r--modules/operserv/module.cpp2
-rw-r--r--modules/operserv/news.cpp34
-rw-r--r--modules/operserv/noop.cpp3
-rw-r--r--modules/operserv/oper.cpp2
-rw-r--r--modules/operserv/reload.cpp2
-rw-r--r--modules/operserv/session.cpp67
-rw-r--r--modules/operserv/set.cpp2
-rw-r--r--modules/operserv/stats.cpp108
-rw-r--r--modules/operserv/sxline.cpp30
20 files changed, 418 insertions, 287 deletions
diff --git a/modules/operserv/akill.cpp b/modules/operserv/akill.cpp
index 7f366e0c9..1f62b2f55 100644
--- a/modules/operserv/akill.cpp
+++ b/modules/operserv/akill.cpp
@@ -1,21 +1,18 @@
/* OperServ core functions
*
- * (C) 2003-2014 Anope Team
+ * (C) 2003-2016 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
*/
#include "module.h"
-static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sgline");
-
class CommandOSAKill : public Command
{
- private:
+ ServiceReference<XLineManager> akills;
+
void DoAdd(CommandSource &source, const std::vector<Anope::string> &params)
{
Anope::string expiry, mask;
@@ -120,7 +117,12 @@ class CommandOSAKill : public Command
return;
}
- XLine *x = new XLine(mask, source.GetNick(), expires, reason);
+ XLine *x = Serialize::New<XLine *>();
+ x->SetMask(mask);
+ x->SetBy(source.GetNick());
+ x->SetExpires(expires);
+ x->SetReason(reason);
+
if (Config->GetModule("operserv")->Get<bool>("akillids"))
x->SetID(XLineManager::GenerateUID());
@@ -139,7 +141,7 @@ class CommandOSAKill : public Command
}
EventReturn MOD_RESULT;
- MOD_RESULT = Event::OnAddXLine(&Event::AddXLine::OnAddXLine, source, x, akills);
+ MOD_RESULT = EventManager::Get()->Dispatch(&Event::AddXLine::OnAddXLine, source, x, akills);
if (MOD_RESULT == EVENT_STOP)
{
delete x;
@@ -212,7 +214,7 @@ class CommandOSAKill : public Command
do
{
- Event::OnDelXLine(&Event::DelXLine::OnDelXLine, source, x, akills);
+ EventManager::Get()->Dispatch(&Event::DelXLine::OnDelXLine, source, x, akills);
Log(LOG_ADMIN, source, this) << "to remove " << x->GetMask() << " from the list";
source.Reply(_("\002{0}\002 deleted from the akill list."), x->GetMask());
@@ -256,7 +258,7 @@ class CommandOSAKill : public Command
unsigned int i = 0;
for (XLine *x : akills->GetXLines())
{
- if (mask.empty() || mask.equals_ci(x->GetMask()) || mask == x->id || Anope::Match(x->GetMask(), mask, false, true))
+ if (mask.empty() || mask.equals_ci(x->GetMask()) || mask == x->GetID() || Anope::Match(x->GetMask(), mask, false, true))
{
ListFormatter::ListEntry entry;
entry["Number"] = stringify(++i);
@@ -319,7 +321,7 @@ class CommandOSAKill : public Command
{
for (XLine *x : akills->GetXLines())
{
- Event::OnDelXLine(&Event::DelXLine::OnDelXLine, source, x, akills);
+ EventManager::Get()->Dispatch(&Event::DelXLine::OnDelXLine, source, x, akills);
x->Delete();
}
@@ -331,6 +333,7 @@ class CommandOSAKill : public Command
}
public:
CommandOSAKill(Module *creator) : Command(creator, "operserv/akill", 1, 2)
+ , akills("xlinemanager/sgline")
{
this->SetDesc(_("Manipulate the AKILL list"));
this->SetSyntax(_("ADD [+\037expiry\037] \037mask\037 \037reason\037"));
diff --git a/modules/operserv/chankill.cpp b/modules/operserv/chankill.cpp
index 8d3773e9d..81f04583b 100644
--- a/modules/operserv/chankill.cpp
+++ b/modules/operserv/chankill.cpp
@@ -11,12 +11,13 @@
#include "module.h"
-static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sgline");
-
class CommandOSChanKill : public Command
{
+ ServiceReference<XLineManager> akills;
+
public:
CommandOSChanKill(Module *creator) : Command(creator, "operserv/chankill", 2, 3)
+ , akills("xlinemanager/sgline")
{
this->SetDesc(_("AKILL all users on a specific channel"));
this->SetSyntax(_("[+\037expiry\037] \037channel\037 \037reason\037"));
@@ -83,7 +84,13 @@ class CommandOSChanKill : public Command
if (uc->user->server == Me || uc->user->HasMode("OPER"))
continue;
- XLine *x = new XLine("*@" + uc->user->host, source.GetNick(), expires, realreason, XLineManager::GenerateUID());
+ XLine *x = Serialize::New<XLine *>();
+ x->SetMask("*@" + uc->user->host);
+ x->SetBy(source.GetNick());
+ x->SetExpires(expires);
+ x->SetReason(realreason);
+ x->SetID(XLineManager::GenerateUID());
+
akills->AddXLine(x);
akills->OnMatch(uc->user, x);
}
diff --git a/modules/operserv/defcon.cpp b/modules/operserv/defcon.cpp
index fc4a096c9..ba081eb06 100644
--- a/modules/operserv/defcon.cpp
+++ b/modules/operserv/defcon.cpp
@@ -107,11 +107,11 @@ static Timer *timeout;
class DefConTimeout : public Timer
{
- EventHandlers<Event::DefconLevel> &eventdefcon;
int level;
+ ServiceReference<Global::GlobalService> global;
public:
- DefConTimeout(EventHandlers<Event::DefconLevel> &ev, Module *mod, int newlevel) : Timer(mod, DConfig.timeout), eventdefcon(ev), level(newlevel)
+ DefConTimeout(Module *mod, int newlevel) : Timer(mod, DConfig.timeout), level(newlevel)
{
timeout = this;
}
@@ -126,18 +126,18 @@ class DefConTimeout : public Timer
if (DConfig.defaultlevel != level)
{
DConfig.defaultlevel = level;
- this->eventdefcon(&Event::DefconLevel::OnDefconLevel, level);
+ EventManager::Get()->Dispatch(&Event::DefconLevel::OnDefconLevel, level);
Log(Config->GetClient("OperServ"), "operserv/defcon") << "Defcon level timeout, returning to level " << level;
- if (DConfig.globalondefcon && Global::service)
+ if (DConfig.globalondefcon && global)
{
if (!DConfig.offmessage.empty())
- Global::service->SendGlobal(NULL, "", DConfig.offmessage);
+ global->SendGlobal(NULL, "", DConfig.offmessage);
else
- Global::service->SendGlobal(NULL, "", Anope::printf(Language::Translate(_("The Defcon level is now at: \002%d\002")), DConfig.defaultlevel));
+ global->SendGlobal(NULL, "", Anope::printf(Language::Translate(_("The Defcon level is now at: \002%d\002")), DConfig.defaultlevel));
if (!DConfig.message.empty())
- Global::service->SendGlobal(NULL, "", DConfig.message);
+ global->SendGlobal(NULL, "", DConfig.message);
}
runDefCon();
@@ -147,6 +147,8 @@ class DefConTimeout : public Timer
class CommandOSDefcon : public Command
{
+ ServiceReference<Global::GlobalService> global;
+
void SendLevels(CommandSource &source)
{
if (DConfig.Check(DEFCON_NO_NEW_CHANNELS))
@@ -171,10 +173,8 @@ class CommandOSDefcon : public Command
source.Reply(_("* No new memos sent"));
}
- EventHandlers<Event::DefconLevel> &ondefconlevel;
-
public:
- CommandOSDefcon(Module *creator, EventHandlers<Event::DefconLevel> &event) : Command(creator, "operserv/defcon", 1, 1), ondefconlevel(event)
+ CommandOSDefcon(Module *creator) : Command(creator, "operserv/defcon", 1, 1)
{
this->SetDesc(_("Manipulate the DefCon system"));
this->SetSyntax(_("[\0021\002|\0022\002|\0023\002|\0024\002|\0025\002]"));
@@ -206,12 +206,12 @@ class CommandOSDefcon : public Command
DConfig.defaultlevel = newLevel;
- this->ondefconlevel(&Event::DefconLevel::OnDefconLevel, newLevel);
+ EventManager::Get()->Dispatch(&Event::DefconLevel::OnDefconLevel, newLevel);
delete timeout;
if (DConfig.timeout)
- timeout = new DefConTimeout(this->ondefconlevel, this->module, 5);
+ timeout = new DefConTimeout(this->module, 5);
source.Reply(_("Services are now at defcon \002{0}\002."), DConfig.defaultlevel);
this->SendLevels(source);
@@ -219,15 +219,15 @@ class CommandOSDefcon : public Command
/* Global notice the user what is happening. Also any Message that
the Admin would like to add. Set in config file. */
- if (DConfig.globalondefcon && Global::service)
+ if (DConfig.globalondefcon && global)
{
if (DConfig.defaultlevel == 5 && !DConfig.offmessage.empty())
- Global::service->SendGlobal(NULL, "", DConfig.offmessage);
+ global->SendGlobal(NULL, "", DConfig.offmessage);
else if (DConfig.defaultlevel != 5)
{
- Global::service->SendGlobal(NULL, "", Anope::printf(_("The defcon level is now at \002%d\002"), DConfig.defaultlevel));
+ global->SendGlobal(NULL, "", Anope::printf(_("The defcon level is now at \002%d\002"), DConfig.defaultlevel));
if (!DConfig.message.empty())
- Global::service->SendGlobal(NULL, "", DConfig.message);
+ global->SendGlobal(NULL, "", DConfig.message);
}
}
@@ -254,7 +254,6 @@ class OSDefcon : public Module
ServiceReference<SessionService> session_service;
ServiceReference<XLineManager> akills;
CommandOSDefcon commandosdefcon;
- EventHandlers<Event::DefconLevel> ondefconlevel;
void ParseModeString()
{
@@ -337,10 +336,14 @@ class OSDefcon : public Module
public:
OSDefcon(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
- , session_service("SessionService", "session")
- , akills("XLineManager", "xlinemanager/sgline")
- , commandosdefcon(this, ondefconlevel)
- , ondefconlevel(this)
+ , EventHook<Event::ChannelModeSet>(this)
+ , EventHook<Event::ChannelModeUnset>(this)
+ , EventHook<Event::PreCommand>(this)
+ , EventHook<Event::UserConnect>(this)
+ , EventHook<Event::ChannelModeAdd>(this)
+ , EventHook<Event::ChannelSync>(this)
+ , akills("xlinemanager/sgline")
+ , commandosdefcon(this)
{
}
@@ -463,7 +466,7 @@ class OSDefcon : public Module
{
return EVENT_STOP;
}
- else if (command->name == "nickserv/register" || command->name == "nickserv/group")
+ else if (command->GetName() == "nickserv/register" || command->GetName() == "nickserv/group")
{
if (DConfig.Check(DEFCON_NO_NEW_NICKS))
{
@@ -471,7 +474,7 @@ class OSDefcon : public Module
return EVENT_STOP;
}
}
- else if (command->name == "chanserv/mode" && params.size() > 1 && params[1].equals_ci("LOCK"))
+ else if (command->GetName() == "chanserv/mode" && params.size() > 1 && params[1].equals_ci("LOCK"))
{
if (DConfig.Check(DEFCON_NO_MLOCK_CHANGE))
{
@@ -479,7 +482,7 @@ class OSDefcon : public Module
return EVENT_STOP;
}
}
- else if (command->name == "chanserv/register")
+ else if (command->GetName() == "chanserv/register")
{
if (DConfig.Check(DEFCON_NO_NEW_CHANNELS))
{
@@ -487,7 +490,7 @@ class OSDefcon : public Module
return EVENT_STOP;
}
}
- else if (command->name == "memoserv/send")
+ else if (command->GetName() == "memoserv/send")
{
if (DConfig.Check(DEFCON_NO_NEW_MEMOS))
{
@@ -508,8 +511,11 @@ class OSDefcon : public Module
if (DConfig.Check(DEFCON_AKILL_NEW_CLIENTS) && akills)
{
Log(OperServ, "operserv/defcon") << "DEFCON: adding akill for *@" << u->host;
+#warning "xline allocated on stack"
+#if 0
XLine x("*@" + u->host, OperServ ? OperServ->nick : "defcon", Anope::CurTime + DConfig.akillexpire, DConfig.akillreason, XLineManager::GenerateUID());
akills->Send(NULL, &x);
+#endif
}
if (DConfig.Check(DEFCON_NO_NEW_CLIENTS) || DConfig.Check(DEFCON_AKILL_NEW_CLIENTS))
@@ -539,9 +545,12 @@ class OSDefcon : public Module
++session->hits;
if (akills && DConfig.max_session_kill && session->hits >= DConfig.max_session_kill)
{
+#warning "xline allocated on stack"
+#if 0
XLine x("*@" + session->addr.mask(), OperServ ? OperServ->nick : "", Anope::CurTime + DConfig.session_autokill_expiry, "Defcon session limit exceeded", XLineManager::GenerateUID());
akills->Send(NULL, &x);
Log(OperServ, "akill/defcon") << "[DEFCON] Added a temporary AKILL for \002*@" << session->addr.mask() << "\002 due to excessive connections";
+#endif
}
else
{
diff --git a/modules/operserv/dns.cpp b/modules/operserv/dns.cpp
index 1d714700d..2cf79d631 100644
--- a/modules/operserv/dns.cpp
+++ b/modules/operserv/dns.cpp
@@ -13,6 +13,10 @@ static std::map<Anope::string, std::list<time_t> > server_quit_times;
class DNSZoneImpl : public DNSZone
{
+ friend class DNSZoneType;
+
+ Anope::string name;
+
public:
DNSZoneImpl(Serialize::TypeBase *type) : DNSZone(type) { }
DNSZoneImpl(Serialize::TypeBase *type, Serialize::ID id) : DNSZone(type, id) { }
@@ -22,7 +26,7 @@ class DNSZoneImpl : public DNSZone
static DNSZone *Find(const Anope::string &name)
{
- for (DNSZone *zone : Serialize::GetObjects<DNSZone *>(dnszone))
+ for (DNSZone *zone : Serialize::GetObjects<DNSZone *>())
if (zone->GetName().equals_ci(name))
return zone;
return nullptr;
@@ -34,8 +38,8 @@ class DNSZoneType : public Serialize::Type<DNSZoneImpl>
public:
Serialize::Field<DNSZoneImpl, Anope::string> name;
- DNSZoneType(Module *creator) : Serialize::Type<DNSZoneImpl>(creator, "DNSZone")
- , name(this, "name")
+ DNSZoneType(Module *creator) : Serialize::Type<DNSZoneImpl>(creator)
+ , name(this, "name", &DNSZoneImpl::name)
{
}
};
@@ -52,6 +56,15 @@ void DNSZoneImpl::SetName(const Anope::string &name)
class DNSServerImpl : public DNSServer
{
+ friend class DNSServerType;
+
+ ServiceReference<DNS::Manager> manager;
+
+ DNSZone *zone = nullptr;
+ Anope::string name;
+ unsigned int limit = 0;
+ bool pooled = false;
+
/* is actually in the pool */
bool active = false;
@@ -85,17 +98,17 @@ class DNSServerImpl : public DNSServer
this->SetPool(p);
active = p;
- if (DNS::manager)
+ if (manager)
{
- DNS::manager->UpdateSerial();
+ manager->UpdateSerial();
for (std::set<Anope::string, ci::less>::iterator it = zones.begin(), it_end = zones.end(); it != it_end; ++it)
- DNS::manager->Notify(*it);
+ manager->Notify(*it);
}
}
static DNSServerImpl *Find(const Anope::string &s)
{
- for (DNSServerImpl *server : Serialize::GetObjects<DNSServerImpl *>(dnsserver))
+ for (DNSServerImpl *server : Serialize::GetObjects<DNSServerImpl *>())
if (server->GetName().equals_ci(s))
return server;
return nullptr;
@@ -110,11 +123,11 @@ class DNSServerType : public Serialize::Type<DNSServerImpl>
Serialize::Field<DNSServerImpl, unsigned int> limit;
Serialize::Field<DNSServerImpl, bool> pooled;
- DNSServerType(Module *creator) : Serialize::Type<DNSServerImpl>(creator, "DNSServer")
- , zone(this, "zone")
- , name(this, "name")
- , limit(this, "limit")
- , pooled(this, "pooled")
+ DNSServerType(Module *creator) : Serialize::Type<DNSServerImpl>(creator)
+ , zone(this, "zone", &DNSServerImpl::zone)
+ , name(this, "name", &DNSServerImpl::name)
+ , limit(this, "limit", &DNSServerImpl::limit)
+ , pooled(this, "pooled", &DNSServerImpl::pooled)
{
}
};
@@ -161,6 +174,11 @@ void DNSServerImpl::SetPool(const bool &p)
class DNSZoneMembershipImpl : public DNSZoneMembership
{
+ friend class DNSZoneMembershipType;
+
+ DNSServer *server = nullptr;
+ DNSZone *zone = nullptr;
+
public:
DNSZoneMembershipImpl(Serialize::TypeBase *type) : DNSZoneMembership(type) { }
DNSZoneMembershipImpl(Serialize::TypeBase *type, Serialize::ID id) : DNSZoneMembership(type, id) { }
@@ -173,7 +191,7 @@ class DNSZoneMembershipImpl : public DNSZoneMembership
static DNSZoneMembership *Find(DNSServer *server, DNSZone *zone)
{
- for (DNSZoneMembership *mem : Serialize::GetObjects<DNSZoneMembership *>(dnszonemembership))
+ for (DNSZoneMembership *mem : Serialize::GetObjects<DNSZoneMembership *>())
if (mem->GetServer() == server && mem->GetZone() == zone)
return mem;
return nullptr;
@@ -186,9 +204,9 @@ class DNSZoneMembershipType : public Serialize::Type<DNSZoneMembershipImpl>
Serialize::ObjectField<DNSZoneMembershipImpl, DNSServer *> server;
Serialize::ObjectField<DNSZoneMembershipImpl, DNSZone *> zone;
- DNSZoneMembershipType(Module *creator) : Serialize::Type<DNSZoneMembershipImpl>(creator, "DNSZoneMembership")
- , server(this, "server")
- , zone(this, "zone")
+ DNSZoneMembershipType(Module *creator) : Serialize::Type<DNSZoneMembershipImpl>(creator)
+ , server(this, "server", &DNSZoneMembershipImpl::server)
+ , zone(this, "zone", &DNSZoneMembershipImpl::zone)
{
}
};
@@ -215,6 +233,11 @@ void DNSZoneMembershipImpl::SetZone(DNSZone *z)
class DNSIPImpl : public DNSIP
{
+ friend class DNSIPType;
+
+ DNSServer *server = nullptr;
+ Anope::string ip;
+
public:
DNSIPImpl(Serialize::TypeBase *type) : DNSIP(type) { }
DNSIPImpl(Serialize::TypeBase *type, Serialize::ID id) : DNSIP(type, id) { }
@@ -229,12 +252,12 @@ class DNSIPImpl : public DNSIP
class DNSIPType : public Serialize::Type<DNSIPImpl>
{
public:
- Serialize::ObjectField<DNSServerImpl, DNSServer *> server;
- Serialize::Field<DNSServerImpl, Anope::string> ip;
+ Serialize::ObjectField<DNSIPImpl, DNSServer *> server;
+ Serialize::Field<DNSIPImpl, Anope::string> ip;
- DNSIPType(Module *creator) : Serialize::Type<DNSIPImpl>(creator, "DNSIP")
- , server(this, "server")
- , ip(this, "ip")
+ DNSIPType(Module *creator) : Serialize::Type<DNSIPImpl>(creator)
+ , server(this, "server", &DNSIPImpl::server)
+ , ip(this, "ip", &DNSIPImpl::ip)
{
}
};
@@ -261,9 +284,11 @@ void DNSIPImpl::SetIP(const Anope::string &ip)
class CommandOSDNS : public Command
{
+ ServiceReference<DNS::Manager> manager;
+
void DisplayPoolState(CommandSource &source)
{
- std::vector<DNSServerImpl *> servers = Serialize::GetObjects<DNSServerImpl *>(dnsserver);
+ std::vector<DNSServerImpl *> servers = Serialize::GetObjects<DNSServerImpl *>();
if (servers.empty())
{
@@ -282,7 +307,7 @@ class CommandOSDNS : public Command
entry["Limit"] = s->GetLimit() ? stringify(s->GetLimit()) : Language::Translate(source.GetAccount(), _("None"));
Anope::string ip_str;
- for (DNSIP *ip : s->GetRefs<DNSIP *>(dnsip))
+ for (DNSIP *ip : s->GetRefs<DNSIP *>())
ip_str += ip->GetIP() + " ";
ip_str.trim();
if (ip_str.empty())
@@ -305,7 +330,7 @@ class CommandOSDNS : public Command
std::vector<Anope::string> replies;
lf.Process(replies);
- std::vector<DNSZone *> zones = Serialize::GetObjects<DNSZone *>(dnszone);
+ std::vector<DNSZone *> zones = Serialize::GetObjects<DNSZone *>();
if (!zones.empty())
{
ListFormatter lf2(source.GetAccount());
@@ -317,7 +342,7 @@ class CommandOSDNS : public Command
entry["Zone"] = z->GetName();
Anope::string server_str;
- for (DNSServer *s : z->GetRefs<DNSServer *>(dnsserver))
+ for (DNSServer *s : z->GetRefs<DNSServer *>())
server_str += s->GetName() + " ";
server_str.trim();
@@ -351,7 +376,7 @@ class CommandOSDNS : public Command
Log(LOG_ADMIN, source, this) << "to add zone " << zone;
- DNSZone *z = dnszone.Create();
+ DNSZone *z = Serialize::New<DNSZone *>();
z->SetName(zone);
source.Reply(_("Added zone \002{0}\002."), zone);
}
@@ -372,13 +397,13 @@ class CommandOSDNS : public Command
Log(LOG_ADMIN, source, this) << "to delete zone " << z->GetName();
- for (DNSZoneMembership *mem : z->GetRefs<DNSZoneMembership *>(dnszonemembership))
+ for (DNSZoneMembership *mem : z->GetRefs<DNSZoneMembership *>())
mem->Delete();
- if (DNS::manager)
+ if (manager)
{
- DNS::manager->UpdateSerial();
- DNS::manager->Notify(z->GetName());
+ manager->UpdateSerial();
+ manager->Notify(z->GetName());
}
source.Reply(_("Zone \002{0}\002 removed."), z->GetName());
@@ -415,14 +440,14 @@ class CommandOSDNS : public Command
if (Anope::ReadOnly)
source.Reply(_("Services are in read-only mode. Any changes made may not persist."));
- mem = dnszonemembership.Create();
+ mem = Serialize::New<DNSZoneMembership *>();
mem->SetZone(z);
mem->SetServer(s);
- if (DNS::manager)
+ if (manager)
{
- DNS::manager->UpdateSerial();
- DNS::manager->Notify(zone);
+ manager->UpdateSerial();
+ manager->Notify(zone);
}
Log(LOG_ADMIN, source, this) << "to add server " << s->GetName() << " to zone " << z->GetName();
@@ -440,7 +465,7 @@ class CommandOSDNS : public Command
return;
}
- s = dnsserver.Create();
+ s = Serialize::New<DNSServer *>();
s->SetName(params[1]);
if (zone.empty())
{
@@ -465,14 +490,14 @@ class CommandOSDNS : public Command
Log(LOG_ADMIN, source, this) << "to add server " << s->GetName() << " to zone " << zone;
- DNSZoneMembership *mem = dnszonemembership.Create();
+ DNSZoneMembership *mem = Serialize::New<DNSZoneMembership *>();
mem->SetServer(s);
mem->SetZone(z);
- if (DNS::manager)
+ if (manager)
{
- DNS::manager->UpdateSerial();
- DNS::manager->Notify(z->GetName());
+ manager->UpdateSerial();
+ manager->Notify(z->GetName());
}
}
}
@@ -509,10 +534,10 @@ class CommandOSDNS : public Command
Log(LOG_ADMIN, source, this) << "to remove server " << s->GetName() << " from zone " << z->GetName();
- if (DNS::manager)
+ if (manager)
{
- DNS::manager->UpdateSerial();
- DNS::manager->Notify(z->GetName());
+ manager->UpdateSerial();
+ manager->Notify(z->GetName());
}
mem->Delete();
@@ -526,14 +551,14 @@ class CommandOSDNS : public Command
return;
}
- for (DNSZoneMembership *mem : s->GetRefs<DNSZoneMembership *>(dnszonemembership))
+ for (DNSZoneMembership *mem : s->GetRefs<DNSZoneMembership *>())
mem->Delete();
if (Anope::ReadOnly)
source.Reply(_("Services are in read-only mode. Any changes made may not persist."));
- if (DNS::manager)
- DNS::manager->UpdateSerial();
+ if (manager)
+ manager->UpdateSerial();
Log(LOG_ADMIN, source, this) << "to delete server " << s->GetName();
source.Reply(_("Removed server \002{0}\002."), s->GetName());
@@ -550,7 +575,7 @@ class CommandOSDNS : public Command
return;
}
- for (DNSIP *ip : s->GetRefs<DNSIP *>(dnsip))
+ for (DNSIP *ip : s->GetRefs<DNSIP *>())
if (params[2].equals_ci(ip->GetIP()))
{
source.Reply(_("IP \002{0}\002 already exists for \002{1}\002."), ip->GetIP(), s->GetName());
@@ -567,18 +592,18 @@ class CommandOSDNS : public Command
if (Anope::ReadOnly)
source.Reply(_("Services are in read-only mode. Any changes made may not persist."));
- DNSIP *ip = dnsip.Create();
+ DNSIP *ip = Serialize::New<DNSIP *>();
ip->SetServer(s);
ip->SetIP(params[2]);
source.Reply(_("Added IP \002{0}\002 to \002{1}\002."), params[2], s->GetName());
Log(LOG_ADMIN, source, this) << "to add IP " << params[2] << " to " << s->GetName();
- if (s->Active() && DNS::manager)
+ if (s->Active() && manager)
{
- DNS::manager->UpdateSerial();
- for (DNSZone *zone : s->GetRefs<DNSZone *>(dnszone))
- DNS::manager->Notify(zone->GetName());
+ manager->UpdateSerial();
+ for (DNSZone *zone : s->GetRefs<DNSZone *>())
+ manager->Notify(zone->GetName());
}
}
@@ -595,7 +620,7 @@ class CommandOSDNS : public Command
if (Anope::ReadOnly)
source.Reply(_("Services are in read-only mode. Any changes made may not persist."));
- for (DNSIP *ip : s->GetRefs<DNSIP *>(dnsip))
+ for (DNSIP *ip : s->GetRefs<DNSIP *>())
if (params[2].equals_ci(ip->GetIP()))
{
ip->Delete();
@@ -603,17 +628,17 @@ class CommandOSDNS : public Command
source.Reply(_("Removed IP \002{0}\002 from \002{1}\002."), params[2], s->GetName());
Log(LOG_ADMIN, source, this) << "to remove IP " << params[2] << " from " << s->GetName();
- if (s->GetRefs<DNSIP *>(dnsip).empty())
+ if (s->GetRefs<DNSIP *>().empty())
{
s->repool = 0;
s->SetPool(false);
}
- if (s->Active() && DNS::manager)
+ if (s->Active() && manager)
{
- DNS::manager->UpdateSerial();
- for (DNSZone *zone : s->GetRefs<DNSZone *>(dnszone))
- DNS::manager->Notify(zone->GetName());
+ manager->UpdateSerial();
+ for (DNSZone *zone : s->GetRefs<DNSZone *>())
+ manager->Notify(zone->GetName());
}
return;
@@ -677,7 +702,7 @@ class CommandOSDNS : public Command
return;
}
- if (s->GetRefs<DNSIP *>(dnsip).empty())
+ if (s->GetRefs<DNSIP *>().empty())
{
source.Reply(_("Server \002{0}\002 has no configured IPs."), s->GetName());
return;
@@ -791,32 +816,34 @@ class ModuleDNS : public Module
DNSIPType iptype;
CommandOSDNS commandosdns;
- time_t ttl;
- int user_drop_mark;
- time_t user_drop_time;
- time_t user_drop_readd_time;
- bool remove_split_servers;
- bool readd_connected_servers;
+ time_t ttl = 0;
+ int user_drop_mark = 0;
+ time_t user_drop_time = 0;
+ time_t user_drop_readd_time = 0;
+ bool remove_split_servers = 0;
+ bool readd_connected_servers = 0;
- time_t last_warn;
+ time_t last_warn = 0;
public:
ModuleDNS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR)
+ , EventHook<Event::NewServer>(this)
+ , EventHook<Event::ServerQuit>(this)
+ , EventHook<Event::UserConnect>(this)
+ , EventHook<Event::PreUserLogoff>(this)
+ , EventHook<Event::DnsRequest>(this)
, zonetype(this)
, servertype(this)
, zonemembtype(this)
, iptype(this)
, commandosdns(this)
- , last_warn(0)
{
-#if 0
- for (unsigned j = 0; j < dns_servers->size(); ++j)
- {
- DNSServer *s = dns_servers->at(j);
- if (s->Pooled() && Server::Find(s->GetName(), true))
+ /* enable active flag for linked servers */
+ std::vector<DNSServerImpl *> servers = Serialize::GetObjects<DNSServerImpl *>();
+
+ for (DNSServerImpl *s : servers)
+ if (s->GetPooled() && Server::Find(s->GetName(), true))
s->SetActive(true);
- }
-#endif
}
~ModuleDNS()
@@ -841,7 +868,7 @@ class ModuleDNS : public Module
if (!Me->IsSynced() || this->readd_connected_servers)
{
DNSServerImpl *dns = DNSServerImpl::Find(s->GetName());
- if (dns && dns->GetPooled() && !dns->Active() && !dns->GetRefs<DNSIP *>(dnsip).empty())
+ if (dns && dns->GetPooled() && !dns->Active() && !dns->GetRefs<DNSIP *>().empty())
{
dns->SetActive(true);
Log(this) << "Pooling server " << s->GetName();
@@ -934,12 +961,12 @@ class ModuleDNS : public Module
size_t answer_size = packet->answers.size();
if (zone)
{
- for (DNSServerImpl *s : zone->GetRefs<DNSServerImpl *>(dnsserver))
+ for (DNSServerImpl *s : zone->GetRefs<DNSServerImpl *>())
{
if (!s->Active())
continue;
- for (DNSIP *ip : s->GetRefs<DNSIP *>(dnsip))
+ for (DNSIP *ip : s->GetRefs<DNSIP *>())
{
DNS::QueryType q_type = ip->GetIP().find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A;
@@ -957,12 +984,12 @@ class ModuleDNS : public Module
if (packet->answers.size() == answer_size)
{
/* Default zone */
- for (DNSServerImpl *s : Serialize::GetObjects<DNSServerImpl *>(dnsserver))
+ for (DNSServerImpl *s : Serialize::GetObjects<DNSServerImpl *>())
{
if (!s->Active())
continue;
- for (DNSIP *ip : s->GetRefs<DNSIP *>(dnsip))
+ for (DNSIP *ip : s->GetRefs<DNSIP *>())
{
DNS::QueryType q_type = ip->GetIP().find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A;
@@ -986,8 +1013,8 @@ class ModuleDNS : public Module
}
/* Something messed up, just return them all and hope one is available */
- for (DNSServer *s : Serialize::GetObjects<DNSServer *>(dnsserver))
- for (DNSIP *ip : s->GetRefs<DNSIP *>(dnsip))
+ for (DNSServer *s : Serialize::GetObjects<DNSServer *>())
+ for (DNSIP *ip : s->GetRefs<DNSIP *>())
{
DNS::QueryType q_type = ip->GetIP().find(':') != Anope::string::npos ? DNS::QUERY_AAAA : DNS::QUERY_A;
diff --git a/modules/operserv/forbid.cpp b/modules/operserv/forbid.cpp
index 2375eddcd..6fb0172cf 100644
--- a/modules/operserv/forbid.cpp
+++ b/modules/operserv/forbid.cpp
@@ -16,6 +16,12 @@
class ForbidDataImpl : public ForbidData
{
+ friend class ForbidDataType;
+
+ Anope::string mask, creator, reason;
+ time_t created = 0, expires = 0;
+ ForbidType type = static_cast<ForbidType>(0);
+
public:
ForbidDataImpl(Serialize::TypeBase *type) : ForbidData(type) { }
ForbidDataImpl(Serialize::TypeBase *type, Serialize::ID id) : ForbidData(type, id) { }
@@ -46,13 +52,13 @@ class ForbidDataType : public Serialize::Type<ForbidDataImpl>
Serialize::Field<ForbidDataImpl, time_t> created, expires;
Serialize::Field<ForbidDataImpl, ForbidType> type;
- ForbidDataType(Module *me) : Serialize::Type<ForbidDataImpl>(me, "ForbidData")
- , mask(this, "mask")
- , creator(this, "creator")
- , reason(this, "reason")
- , created(this, "created")
- , expires(this, "expires")
- , type(this, "type")
+ ForbidDataType(Module *me) : Serialize::Type<ForbidDataImpl>(me)
+ , mask(this, "mask", &ForbidDataImpl::mask)
+ , creator(this, "creator", &ForbidDataImpl::creator)
+ , reason(this, "reason", &ForbidDataImpl::reason)
+ , created(this, "created", &ForbidDataImpl::created)
+ , expires(this, "expires", &ForbidDataImpl::expires)
+ , type(this, "type", &ForbidDataImpl::type)
{
}
};
@@ -134,7 +140,7 @@ class MyForbidService : public ForbidService
std::vector<ForbidData *> GetForbids() override
{
- for (ForbidData *d : Serialize::GetObjects<ForbidData *>(forbiddata))
+ for (ForbidData *d : Serialize::GetObjects<ForbidData *>())
if (d->GetExpires() && !Anope::NoExpire && Anope::CurTime >= d->GetExpires())
{
Anope::string ftype = "none";
@@ -148,15 +154,16 @@ class MyForbidService : public ForbidService
Log(LOG_NORMAL, "expire/forbid", Config->GetClient("OperServ")) << "Expiring forbid for " << d->GetMask() << " type " << ftype;
d->Delete();
}
- return Serialize::GetObjects<ForbidData *>(forbiddata);
+ return Serialize::GetObjects<ForbidData *>();
}
};
class CommandOSForbid : public Command
{
ServiceReference<ForbidService> fs;
+
public:
- CommandOSForbid(Module *creator) : Command(creator, "operserv/forbid", 1, 5), fs("ForbidService", "forbid")
+ CommandOSForbid(Module *creator) : Command(creator, "operserv/forbid", 1, 5)
{
this->SetDesc(_("Forbid usage of nicknames, channels, and emails"));
this->SetSyntax(_("ADD {NICK|CHAN|EMAIL|REGISTER} [+\037expiry\037] \037entry\037 \037reason\037"));
@@ -242,7 +249,7 @@ class CommandOSForbid : public Command
bool created = false;
if (d == NULL)
{
- d = forbiddata.Create();
+ d = Serialize::New<ForbidData *>();
created = true;
}
@@ -303,8 +310,11 @@ class CommandOSForbid : public Command
if (IRCD->CanSQLineChannel && OperServ)
{
time_t inhabit = Config->GetModule("chanserv")->Get<time_t>("inhabit", "15s");
+#warning "xline allocated on stack"
+#if 0
XLine x(c->name, OperServ->nick, Anope::CurTime + inhabit, d->GetReason());
IRCD->SendSQLine(NULL, &x);
+#endif
}
else if (ChanServ::service)
{
@@ -460,6 +470,10 @@ class OSForbid : public Module
public:
OSForbid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
+ , EventHook<Event::UserConnect>(this)
+ , EventHook<Event::UserNickChange>(this)
+ , EventHook<Event::CheckKick>(this)
+ , EventHook<Event::PreCommand>(this)
, forbid_service(this)
, type(this)
, commandosforbid(this)
@@ -491,8 +505,11 @@ class OSForbid : public Module
if (IRCD->CanSQLineChannel)
{
time_t inhabit = Config->GetModule("chanserv")->Get<time_t>("inhabit", "15s");
+#warning "xline allocated on stack"
+#if 0
XLine x(c->name, OperServ->nick, Anope::CurTime + inhabit, d->GetReason());
IRCD->SendSQLine(NULL, &x);
+#endif
}
else if (ChanServ::service)
{
@@ -509,7 +526,7 @@ class OSForbid : public Module
EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) override
{
- if (command->name == "nickserv/info" && params.size() > 0)
+ if (command->GetName() == "nickserv/info" && params.size() > 0)
{
ForbidData *d = this->forbid_service.FindForbid(params[0], FT_NICK);
if (d != NULL)
@@ -521,7 +538,7 @@ class OSForbid : public Module
return EVENT_STOP;
}
}
- else if (command->name == "chanserv/info" && params.size() > 0)
+ else if (command->GetName() == "chanserv/info" && params.size() > 0)
{
ForbidData *d = this->forbid_service.FindForbid(params[0], FT_CHAN);
if (d != NULL)
@@ -535,7 +552,7 @@ class OSForbid : public Module
}
else if (source.IsOper())
return EVENT_CONTINUE;
- else if (command->name == "nickserv/register" && params.size() > 1)
+ else if (command->GetName() == "nickserv/register" && params.size() > 1)
{
ForbidData *d = this->forbid_service.FindForbid(source.GetNick(), FT_REGISTER);
if (d != NULL)
@@ -551,7 +568,7 @@ class OSForbid : public Module
return EVENT_STOP;
}
}
- else if (command->name == "nickserv/set/email" && params.size() > 0)
+ else if (command->GetName() == "nickserv/set/email" && params.size() > 0)
{
ForbidData *d = this->forbid_service.FindForbid(params[0], FT_EMAIL);
if (d != NULL)
@@ -560,7 +577,7 @@ class OSForbid : public Module
return EVENT_STOP;
}
}
- else if (command->name == "chanserv/register" && !params.empty())
+ else if (command->GetName() == "chanserv/register" && !params.empty())
{
ForbidData *d = this->forbid_service.FindForbid(params[0], FT_REGISTER);
if (d != NULL)
diff --git a/modules/operserv/ignore.cpp b/modules/operserv/ignore.cpp
index 0aeab0718..ffd85e5e9 100644
--- a/modules/operserv/ignore.cpp
+++ b/modules/operserv/ignore.cpp
@@ -14,6 +14,11 @@
class IgnoreImpl : public Ignore
{
+ friend class IgnoreType;
+
+ Anope::string mask, creator, reason;
+ time_t time = 0;
+
public:
IgnoreImpl(Serialize::TypeBase *type) : Ignore(type) { }
IgnoreImpl(Serialize::TypeBase *type, Serialize::ID id) : Ignore(type, id) { }
@@ -37,11 +42,11 @@ class IgnoreType : public Serialize::Type<IgnoreImpl>
Serialize::Field<IgnoreImpl, Anope::string> mask, creator, reason;
Serialize::Field<IgnoreImpl, time_t> time;
- IgnoreType(Module *me) : Serialize::Type<IgnoreImpl>(me, "IgnoreData")
- , mask(this, "mask")
- , creator(this, "creator")
- , reason(this, "reason")
- , time(this, "time")
+ IgnoreType(Module *me) : Serialize::Type<IgnoreImpl>(me)
+ , mask(this, "mask", &IgnoreImpl::mask)
+ , creator(this, "creator", &IgnoreImpl::creator)
+ , reason(this, "reason", &IgnoreImpl::reason)
+ , time(this, "time", &IgnoreImpl::time)
{
}
};
@@ -96,7 +101,7 @@ class OSIgnoreService : public IgnoreService
Ignore *Find(const Anope::string &mask) override
{
User *u = User::Find(mask, true);
- std::vector<Ignore *> ignores = Serialize::GetObjects<Ignore *>(ignoretype);
+ std::vector<Ignore *> ignores = Serialize::GetObjects<Ignore *>();
std::vector<Ignore *>::iterator ign = ignores.begin(), ign_end = ignores.end();
if (u)
@@ -155,6 +160,8 @@ class OSIgnoreService : public IgnoreService
class CommandOSIgnore : public Command
{
+ ServiceReference<IgnoreService> ignore_service;
+
private:
Anope::string RealMask(const Anope::string &mask)
{
@@ -216,7 +223,7 @@ class CommandOSIgnore : public Command
if (Anope::ReadOnly)
source.Reply(_("Services are in read-only mode. Any changes made may not persist."));
- Ignore *ign = ignoretype.Create();
+ Ignore *ign = Serialize::New<Ignore *>();
ign->SetMask(mask);
ign->SetCreator(source.GetNick());
ign->SetReason(reason);
@@ -236,7 +243,7 @@ class CommandOSIgnore : public Command
void DoList(CommandSource &source)
{
- std::vector<Ignore *> ignores = Serialize::GetObjects<Ignore *>(ignoretype);
+ std::vector<Ignore *> ignores = Serialize::GetObjects<Ignore *>();
for (Ignore *id : ignores)
{
@@ -247,7 +254,7 @@ class CommandOSIgnore : public Command
}
}
- ignores = Serialize::GetObjects<Ignore *>(ignoretype);
+ ignores = Serialize::GetObjects<Ignore *>();
if (ignores.empty())
{
source.Reply(_("Ignore list is empty."));
@@ -312,7 +319,7 @@ class CommandOSIgnore : public Command
if (Anope::ReadOnly)
source.Reply(_("Services are in read-only mode. Any changes made may not persist."));
- for (Ignore *ign : Serialize::GetObjects<Ignore *>(ignoretype))
+ for (Ignore *ign : Serialize::GetObjects<Ignore *>())
ign->Delete();
Log(LOG_ADMIN, source, this) << "to CLEAR the list";
@@ -374,6 +381,7 @@ class OSIgnore : public Module
public:
OSIgnore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
+ , EventHook<Event::BotPrivmsg>(this)
, ignoretype(this)
, osignoreservice(this)
, commandosignore(this)
diff --git a/modules/operserv/info.cpp b/modules/operserv/info.cpp
index bb0eb8274..c1d625601 100644
--- a/modules/operserv/info.cpp
+++ b/modules/operserv/info.cpp
@@ -13,6 +13,12 @@
class OperInfoImpl : public OperInfo
{
+ friend class OperInfoType;
+
+ Serialize::Object *target = nullptr;
+ Anope::string info, creator;
+ time_t created = 0;
+
public:
OperInfoImpl(Serialize::TypeBase *type) : OperInfo(type) { }
OperInfoImpl(Serialize::TypeBase *type, Serialize::ID id) : OperInfo(type, id) { }
@@ -37,11 +43,11 @@ class OperInfoType : public Serialize::Type<OperInfoImpl>
Serialize::Field<OperInfoImpl, Anope::string> info, creator;
Serialize::Field<OperInfoImpl, time_t> created;
- OperInfoType(Module *c) : Serialize::Type<OperInfoImpl>(c, "OperInfo")
- , target(this, "target", true)
- , info(this, "info")
- , creator(this, "adder")
- , created(this, "created")
+ OperInfoType(Module *c) : Serialize::Type<OperInfoImpl>(c)
+ , target(this, "target", &OperInfoImpl::target, true)
+ , info(this, "info", &OperInfoImpl::info)
+ , creator(this, "adder", &OperInfoImpl::creator)
+ , created(this, "created", &OperInfoImpl::created)
{
}
};
@@ -133,7 +139,7 @@ class CommandOSInfo : public Command
return;
}
- std::vector<OperInfo *> oinfos = e->GetRefs<OperInfo *>(operinfo);
+ std::vector<OperInfo *> oinfos = e->GetRefs<OperInfo *>();
if (oinfos.size() >= Config->GetModule(this->module)->Get<unsigned int>("max", "10"))
{
source.Reply(_("The oper info list for \002{0}\002 is full."), target);
@@ -147,7 +153,7 @@ class CommandOSInfo : public Command
return;
}
- OperInfo *o = operinfo.Create();
+ OperInfo *o = Serialize::New<OperInfo *>();
o->SetTarget(e);
o->SetInfo(info);
o->SetCreator(source.GetNick());
@@ -167,7 +173,7 @@ class CommandOSInfo : public Command
return;
}
- std::vector<OperInfo *> oinfos = e->GetRefs<OperInfo *>(operinfo);
+ std::vector<OperInfo *> oinfos = e->GetRefs<OperInfo *>();
if (oinfos.empty())
{
source.Reply(_("Oper info list for \002{0}\002 is empty."), target);
@@ -193,7 +199,7 @@ class CommandOSInfo : public Command
}
else if (cmd.equals_ci("CLEAR"))
{
- std::vector<OperInfo *> oinfos = e->GetRefs<OperInfo *>(operinfo);
+ std::vector<OperInfo *> oinfos = e->GetRefs<OperInfo *>();
if (oinfos.empty())
{
@@ -235,12 +241,14 @@ class OSInfo : public Module
if (!source.IsOper())
return;
- for (OperInfo *o : e->GetRefs<OperInfo *>(operinfo))
+ for (OperInfo *o : e->GetRefs<OperInfo *>())
info[_("Oper Info")] = Anope::printf(_("(by %s on %s) %s"), o->GetCreator().c_str(), Anope::strftime(o->GetCreated(), source.GetAccount(), true).c_str(), o->GetInfo().c_str());
}
public:
OSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
+ , EventHook<Event::NickInfo>(this)
+ , EventHook<Event::ChanInfo>(this)
, commandosinfo(this)
, oinfotype(this)
{
diff --git a/modules/operserv/login.cpp b/modules/operserv/login.cpp
index 650c48e3d..fa4daf11d 100644
--- a/modules/operserv/login.cpp
+++ b/modules/operserv/login.cpp
@@ -100,7 +100,7 @@ class CommandOSLogout : public Command
}
Log(LOG_ADMIN, source, this);
- u->ShrinkOK<bool>("os_login");
+ u->Shrink<bool>("os_login");
source.Reply(_("You have been logged out."));
}
@@ -125,6 +125,7 @@ class OSLogin : public Module
public:
OSLogin(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
+ , EventHook<Event::IsServicesOperEvent>(this)
, commandoslogin(this)
, commandoslogout(this)
, os_login(this, "os_login")
diff --git a/modules/operserv/logsearch.cpp b/modules/operserv/logsearch.cpp
index 0fa425aba..543430c50 100644
--- a/modules/operserv/logsearch.cpp
+++ b/modules/operserv/logsearch.cpp
@@ -89,7 +89,7 @@ class CommandOSLogSearch : public Command
Log(LOG_ADMIN, source, this) << "for " << search_string;
- const Anope::string &logfile_name = Config->GetModule(this->owner)->Get<Anope::string>("logname");
+ const Anope::string &logfile_name = Config->GetModule(this->GetOwner())->Get<Anope::string>("logname");
std::list<Anope::string> matches;
for (int d = days - 1; d >= 0; --d)
{
diff --git a/modules/operserv/main/operserv.cpp b/modules/operserv/main/operserv.cpp
index 0a4f1b692..40c392ea7 100644
--- a/modules/operserv/main/operserv.cpp
+++ b/modules/operserv/main/operserv.cpp
@@ -13,15 +13,6 @@
#include "modules/help.h"
#include "modules/nickserv.h"
-class SGlineType : public XLineType
-{
- public:
- SGlineType(Module *creator) : XLineType(creator, "SGLine")
- {
- SetParent(xline);
- }
-};
-
class SGLineManager : public XLineManager
{
public:
@@ -74,15 +65,6 @@ class SGLineManager : public XLineManager
}
};
-class SQlineType : public XLineType
-{
- public:
- SQlineType(Module *creator) : XLineType(creator, "SQLine")
- {
- SetParent(xline);
- }
-};
-
class SQLineManager : public XLineManager
{
public:
@@ -152,15 +134,6 @@ class SQLineManager : public XLineManager
}
};
-class SNlineType : public XLineType
-{
- public:
- SNlineType(Module *creator) : XLineType(creator, "SNLine")
- {
- SetParent(xline);
- }
-};
-
class SNLineManager : public XLineManager
{
public:
@@ -211,20 +184,23 @@ class OperServCore : public Module
, public EventHook<Event::Log>
{
Reference<ServiceBot> OperServ;
- SGlineType sgtype;
SGLineManager sglines;
- SQlineType sqtype;
SQLineManager sqlines;
- SNlineType sntype;
SNLineManager snlines;
public:
OperServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR)
- , sgtype(this)
+ , EventHook<Event::BotPrivmsg>(this)
+ , EventHook<Event::ServerQuit>(this)
+ , EventHook<Event::UserModeSet>(this)
+ , EventHook<Event::UserModeUnset>(this)
+ , EventHook<Event::UserConnect>(this)
+ , EventHook<Event::UserNickChange>(this)
+ , EventHook<Event::CheckKick>(this)
+ , EventHook<Event::Help>(this)
+ , EventHook<Event::Log>(this)
, sglines(this)
- , sqtype(this)
, sqlines(this)
- , sntype(this)
, snlines(this)
{
@@ -250,11 +226,11 @@ class OperServCore : public Module
const Anope::string &osnick = conf->GetModule(this)->Get<Anope::string>("client");
if (osnick.empty())
- throw ConfigException(this->name + ": <client> must be defined");
+ throw ConfigException(Module::name + ": <client> must be defined");
ServiceBot *bi = ServiceBot::Find(osnick, true);
if (!bi)
- throw ConfigException(this->name + ": no bot named " + osnick);
+ throw ConfigException(Module::name + ": no bot named " + osnick);
OperServ = bi;
}
diff --git a/modules/operserv/modinfo.cpp b/modules/operserv/modinfo.cpp
index f3c6db00f..8fc76d3d7 100644
--- a/modules/operserv/modinfo.cpp
+++ b/modules/operserv/modinfo.cpp
@@ -31,16 +31,15 @@ class CommandOSModInfo : public Command
{
source.Reply(_("Module: \002{0}\002 Version: \002{1}\002 Author: \002{2}\002 Loaded: \002{3}\002"), m->name, !m->version.empty() ? m->version : "?", !m->author.empty() ? m->author : "Unknown", Anope::strftime(m->created, source.GetAccount()));
if (Anope::Debug)
- source.Reply(_(" Loaded at: {0}"), Anope::printf("%o", m->handle));
+ source.Reply(_(" Loaded at: {0}"), Anope::printf("0x%x", m->handle));
- std::vector<Anope::string> servicekeys = Service::GetServiceKeys("Command");
- for (unsigned i = 0; i < servicekeys.size(); ++i)
+ std::vector<Command *> commands = ServiceManager::Get()->FindServices<Command *>();
+ for (Command *c : commands)
{
- ServiceReference<Command> c("Command", servicekeys[i]);
- if (!c || c->owner != m)
+ if (c->GetOwner() != m)
continue;
- source.Reply(_(" Providing service: \002{0}\002"), c->name);
+ source.Reply(_(" Providing service: \002{0}\002"), c->GetName());
for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
{
@@ -55,9 +54,9 @@ class CommandOSModInfo : public Command
{
const Anope::string &c_name = cit->first;
const CommandInfo &info = cit->second;
- if (info.name != c->name)
+ if (info.name != c->GetName())
continue;
- source.Reply(_(" Command \002{0}\002 on \002{1}\002 is linked to \002{2}\002"), c_name, bi->nick, c->name);
+ source.Reply(_(" Command \002{0}\002 on \002{1}\002 is linked to \002{2}\002"), c_name, bi->nick, c->GetName());
}
}
}
diff --git a/modules/operserv/module.cpp b/modules/operserv/module.cpp
index 14bc897e3..311757bc0 100644
--- a/modules/operserv/module.cpp
+++ b/modules/operserv/module.cpp
@@ -137,7 +137,7 @@ class CommandOSModUnLoad : public Command
return;
}
- Log(this->owner) << "Trying to unload module [" << mname << "]";
+ Log(this->GetOwner()) << "Trying to unload module [" << mname << "]";
ModuleReturn status = ModuleManager::UnloadModule(m, source.GetUser());
diff --git a/modules/operserv/news.cpp b/modules/operserv/news.cpp
index c14103f2e..8180c3b3d 100644
--- a/modules/operserv/news.cpp
+++ b/modules/operserv/news.cpp
@@ -1,12 +1,10 @@
/* OperServ core functions
*
- * (C) 2003-2014 Anope Team
+ * (C) 2003-2016 Anope Team
* Contact us at info@anope.org
*
* Please read COPYING and README for further details.
*
- * Based on the original code of Epona by Lara.
- * Based on the original code of Services by Andy Church.
*/
#include "module.h"
@@ -67,6 +65,12 @@ static struct NewsMessages
class NewsItemImpl : public NewsItem
{
+ friend class NewsItemType;
+
+ NewsType type;
+ Anope::string text, who;
+ time_t time = 0;
+
public:
NewsItemImpl(Serialize::TypeBase *type) : NewsItem(type) { }
NewsItemImpl(Serialize::TypeBase *type, Serialize::ID id) : NewsItem(type, id) { }
@@ -92,11 +96,11 @@ class NewsItemType : public Serialize::Type<NewsItemImpl>
Serialize::Field<NewsItemImpl, Anope::string> who;
Serialize::Field<NewsItemImpl, time_t> time;
- NewsItemType(Module *me) : Serialize::Type<NewsItemImpl>(me, "NewsItem")
- , type(this, "type")
- , text(this, "text")
- , who(this, "who")
- , time(this, "time")
+ NewsItemType(Module *me) : Serialize::Type<NewsItemImpl>(me)
+ , type(this, "type", &NewsItemImpl::type)
+ , text(this, "text", &NewsItemImpl::text)
+ , who(this, "who", &NewsItemImpl::who)
+ , time(this, "time", &NewsItemImpl::time)
{
}
};
@@ -154,7 +158,7 @@ class NewsBase : public Command
protected:
void DoList(CommandSource &source, NewsType ntype, const char **msgs)
{
- std::vector<NewsItem *> list = Serialize::GetObjects<NewsItem *>(newsitem);
+ std::vector<NewsItem *> list = Serialize::GetObjects<NewsItem *>();
if (list.empty())
{
@@ -200,7 +204,7 @@ class NewsBase : public Command
if (Anope::ReadOnly)
source.Reply(_("Services are in read-only mode. Any changes made may not persist."));
- NewsItem *ni = newsitem.Create();
+ NewsItem *ni = Serialize::New<NewsItem *>();
ni->SetNewsType(ntype);
ni->SetText(text);
ni->SetTime(Anope::CurTime);
@@ -213,7 +217,7 @@ class NewsBase : public Command
void DoDel(CommandSource &source, const std::vector<Anope::string> &params, NewsType ntype, const char **msgs)
{
const Anope::string &text = params.size() > 1 ? params[1] : "";
- std::vector<NewsItem *> list = Serialize::GetObjects<NewsItem *>(newsitem);
+ std::vector<NewsItem *> list = Serialize::GetObjects<NewsItem *>();
if (text.empty())
{
@@ -304,7 +308,7 @@ class CommandOSLogonNews : public NewsBase
source.Reply(_("Edits or displays the list of logon news messages. When a user connects to the network, these messages will be sent to them."
" However, no more than \002{0}\002 messages will be sent in order to avoid flooding the user."
" If there are more news messages, only the most recent will be sent."),
- Config->GetModule(this->owner)->Get<unsigned>("newscount", "3"));
+ Config->GetModule(this->GetOwner())->Get<unsigned>("newscount", "3"));
return true;
}
};
@@ -328,7 +332,7 @@ class CommandOSOperNews : public NewsBase
" When a user opers up (with the /OPER command), these messages will be sent to them."
" However, no more than \002{0}\002 messages will be sent in order to avoid flooding the user."
" If there are more news messages, only the most recent will be sent."),
- Config->GetModule(this->owner)->Get<unsigned>("newscount", "3"));
+ Config->GetModule(this->GetOwner())->Get<unsigned>("newscount", "3"));
return true;
}
};
@@ -369,7 +373,7 @@ class OSNews : public Module
void DisplayNews(User *u, NewsType Type)
{
- std::vector<NewsItem *> list = Serialize::GetObjects<NewsItem *>(newsitem);
+ std::vector<NewsItem *> list = Serialize::GetObjects<NewsItem *>();
if (list.empty())
return;
@@ -426,6 +430,8 @@ class OSNews : public Module
public:
OSNews(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
+ , EventHook<Event::UserModeSet>(this)
+ , EventHook<Event::UserConnect>(this)
, newsitemtype(this)
, commandoslogonnews(this)
, commandosopernews(this)
diff --git a/modules/operserv/noop.cpp b/modules/operserv/noop.cpp
index a12bef6a2..d2711b7f4 100644
--- a/modules/operserv/noop.cpp
+++ b/modules/operserv/noop.cpp
@@ -52,7 +52,7 @@ class CommandOSNOOP : public Command
}
else if (cmd.equals_ci("REVOKE"))
{
- s->ShrinkOK<Anope::string>("noop");
+ s->Shrink<Anope::string>("noop");
IRCD->SendSVSNOOP(s, false);
Log(LOG_ADMIN, source, this) << "REVOKE on " << s->GetName();
source.Reply(_("All O:lines of \002{0}\002 have been reset."), s->GetName());
@@ -77,6 +77,7 @@ class OSNOOP : public Module
public:
OSNOOP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
+ , EventHook<Event::UserModeSet>(this)
, commandosnoop(this)
, noop(this, "noop")
{
diff --git a/modules/operserv/oper.cpp b/modules/operserv/oper.cpp
index 923137013..780c71903 100644
--- a/modules/operserv/oper.cpp
+++ b/modules/operserv/oper.cpp
@@ -79,7 +79,7 @@ class CommandOSOper : public Command
na->GetAccount()->o = nullptr;
}
- Oper *o = operblock.Create();
+ Oper *o = Serialize::New<Oper *>();
o->SetName(na->GetAccount()->GetDisplay());
o->SetType(ot);
o->SetRequireOper(true);
diff --git a/modules/operserv/reload.cpp b/modules/operserv/reload.cpp
index 217194e18..1d3d041d4 100644
--- a/modules/operserv/reload.cpp
+++ b/modules/operserv/reload.cpp
@@ -35,7 +35,7 @@ class CommandOSReload : public Command
}
catch (const ConfigException &ex)
{
- Log(this->owner) << "Error reloading configuration file: " << ex.GetReason();
+ Log(this->GetOwner()) << "Error reloading configuration file: " << ex.GetReason();
source.Reply(_("Error reloading configuration file: {0}"), ex.GetReason());
}
}
diff --git a/modules/operserv/session.cpp b/modules/operserv/session.cpp
index 0c20e6d7a..31944e9b6 100644
--- a/modules/operserv/session.cpp
+++ b/modules/operserv/session.cpp
@@ -33,12 +33,16 @@ namespace
/* Number of bits to use when comparing session IPs */
unsigned ipv4_cidr;
unsigned ipv6_cidr;
-
- EventHandlers<Event::Exception> *events;
}
class ExceptionImpl : public Exception
{
+ friend class ExceptionType;
+
+ Anope::string mask, who, reason;
+ unsigned int limit = 0;
+ time_t time = 0, expires = 0;
+
public:
ExceptionImpl(Serialize::TypeBase *type) : Exception(type) { }
ExceptionImpl(Serialize::TypeBase *type, Serialize::ID id) : Exception(type, id) { }
@@ -69,13 +73,13 @@ class ExceptionType : public Serialize::Type<ExceptionImpl>
Serialize::Field<ExceptionImpl, unsigned int> limit;
Serialize::Field<ExceptionImpl, time_t> time, expires;
- ExceptionType(Module *me) : Serialize::Type<ExceptionImpl>(me, "Exception")
- , mask(this, "mask")
- , who(this, "who")
- , reason(this, "reason")
- , limit(this, "limit")
- , time(this, "time")
- , expires(this, "expires")
+ ExceptionType(Module *me) : Serialize::Type<ExceptionImpl>(me)
+ , mask(this, "mask", &ExceptionImpl::mask)
+ , who(this, "who", &ExceptionImpl::who)
+ , reason(this, "reason", &ExceptionImpl::reason)
+ , limit(this, "limit", &ExceptionImpl::limit)
+ , time(this, "time", &ExceptionImpl::time)
+ , expires(this, "expires", &ExceptionImpl::expires)
{
}
};
@@ -149,7 +153,7 @@ class MySessionService : public SessionService
Exception *FindException(User *u) override
{
- for (Exception *e : Serialize::GetObjects<Exception *>(exception))
+ for (Exception *e : Serialize::GetObjects<Exception *>())
{
if (Anope::Match(u->host, e->GetMask()) || Anope::Match(u->ip.addr(), e->GetMask()))
return e;
@@ -162,7 +166,7 @@ class MySessionService : public SessionService
Exception *FindException(const Anope::string &host) override
{
- for (Exception *e : Serialize::GetObjects<Exception *>(exception))
+ for (Exception *e : Serialize::GetObjects<Exception *>())
{
if (Anope::Match(host, e->GetMask()))
return e;
@@ -211,6 +215,8 @@ class MySessionService : public SessionService
class CommandOSSession : public Command
{
+ ServiceReference<SessionService> session_service;
+
private:
void DoList(CommandSource &source, const std::vector<Anope::string> &params)
{
@@ -319,7 +325,7 @@ class CommandOSException : public Command
{
static void DoDel(CommandSource &source, Exception *e)
{
- (*events)(&Event::Exception::OnExceptionDel, source, e);
+ EventManager::Get()->Dispatch(&Event::Exception::OnExceptionDel, source, e);
e->Delete();
}
@@ -382,7 +388,7 @@ class CommandOSException : public Command
return;
}
- for (Exception *e : Serialize::GetObjects<Exception *>(exception))
+ for (Exception *e : Serialize::GetObjects<Exception *>())
if (e->GetMask().equals_ci(mask))
{
if (e->GetLimit() != limit)
@@ -395,7 +401,7 @@ class CommandOSException : public Command
return;
}
- Exception *e = exception.Create();
+ Exception *e = Serialize::New<Exception *>();
e->SetMask(mask);
e->SetLimit(limit);
e->SetReason(reason);
@@ -404,7 +410,7 @@ class CommandOSException : public Command
e->SetExpires(expires);
EventReturn MOD_RESULT;
- MOD_RESULT = (*events)(&Event::Exception::OnExceptionAdd, e);
+ MOD_RESULT = EventManager::Get()->Dispatch(&Event::Exception::OnExceptionAdd, e);
if (MOD_RESULT == EVENT_STOP)
return;
@@ -432,7 +438,7 @@ class CommandOSException : public Command
NumberList(mask, true,
[&](unsigned int number)
{
- std::vector<Exception *> exceptions = Serialize::GetObjects<Exception *>(exception);
+ std::vector<Exception *> exceptions = Serialize::GetObjects<Exception *>();
if (!number || number > exceptions.size())
return;
@@ -456,7 +462,7 @@ class CommandOSException : public Command
else
{
bool found = false;
- for (Exception *e : Serialize::GetObjects<Exception *>(exception))
+ for (Exception *e : Serialize::GetObjects<Exception *>())
if (mask.equals_ci(e->GetMask()))
{
Log(LOG_ADMIN, source, this) << "to remove the session limit exception for " << mask;
@@ -476,7 +482,7 @@ class CommandOSException : public Command
void ProcessList(CommandSource &source, const std::vector<Anope::string> &params, ListFormatter &list)
{
const Anope::string &mask = params.size() > 1 ? params[1] : "";
- std::vector<Exception *> exceptions = Serialize::GetObjects<Exception *>(exception);
+ std::vector<Exception *> exceptions = Serialize::GetObjects<Exception *>();
if (exceptions.empty())
{
@@ -621,24 +627,20 @@ class OSSession : public Module
CommandOSSession commandossession;
CommandOSException commandosexception;
ServiceReference<XLineManager> akills;
- EventHandlers<Event::Exception> exceptionevents;
ExceptionType etype;
public:
OSSession(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
- , EventHook<Event::UserConnect>(EventHook<Event::UserConnect>::Priority::FIRST)
- , EventHook<Event::UserQuit>(EventHook<Event::UserQuit>::Priority::FIRST)
- , EventHook<Event::ExpireTick>(EventHook<Event::ExpireTick>::Priority::FIRST)
+ , EventHook<Event::UserConnect>(this, EventHook<Event::UserConnect>::Priority::FIRST)
+ , EventHook<Event::UserQuit>(this, EventHook<Event::UserQuit>::Priority::FIRST)
+ , EventHook<Event::ExpireTick>(this, EventHook<Event::ExpireTick>::Priority::FIRST)
, ss(this)
, commandossession(this)
, commandosexception(this)
- , akills("XLineManager", "xlinemanager/sgline")
- , exceptionevents(this)
+ , akills("xlinemanager/sgline")
, etype(this)
{
this->SetPermanent(true);
-
- events = &exceptionevents;
}
void OnReload(Configuration::Conf *conf) override
@@ -658,7 +660,7 @@ class OSSession : public Module
ipv6_cidr = block->Get<unsigned>("session_ipv6_cidr", "128");
if (ipv4_cidr > 32 || ipv6_cidr > 128)
- throw ConfigException(this->name + ": session CIDR value out of range");
+ throw ConfigException(Module::name + ": session CIDR value out of range");
}
void OnUserConnect(User *u, bool &exempt) override
@@ -708,9 +710,16 @@ class OSSession : public Module
const Anope::string &akillmask = "*@" + session->addr.mask();
if (max_session_kill && session->hits >= max_session_kill && akills && !akills->HasEntry(akillmask))
{
- XLine *x = new XLine(akillmask, OperServ ? OperServ->nick : "", Anope::CurTime + session_autokill_expiry, "Session limit exceeded", XLineManager::GenerateUID());
+ XLine *x = Serialize::New<XLine *>();
+ x->SetMask(akillmask);
+ x->SetBy(OperServ ? OperServ->nick : "");
+ x->SetExpires(Anope::CurTime + session_autokill_expiry);
+ x->SetReason("Session limit exceeded");
+ x->SetID(XLineManager::GenerateUID());
+
akills->AddXLine(x);
akills->Send(NULL, x);
+
Log(OperServ, "akill/session") << "Added a temporary AKILL for \002" << akillmask << "\002 due to excessive connections";
}
else
@@ -753,7 +762,7 @@ class OSSession : public Module
if (Anope::NoExpire)
return;
- for (Exception *e : Serialize::GetObjects<Exception *>(exception))
+ for (Exception *e : Serialize::GetObjects<Exception *>())
{
if (!e->GetExpires() || e->GetExpires() > Anope::CurTime)
continue;
diff --git a/modules/operserv/set.cpp b/modules/operserv/set.cpp
index 45515fa4b..432480ffb 100644
--- a/modules/operserv/set.cpp
+++ b/modules/operserv/set.cpp
@@ -74,7 +74,7 @@ class CommandOSSet : public Command
*
* Rob
**/
- bool super_admin = Config->GetModule(this->owner)->Get<bool>("superadmin");
+ bool super_admin = Config->GetModule(this->GetOwner())->Get<bool>("superadmin");
if (!super_admin)
source.Reply(_("Super admin can not be set because it is not enabled in the configuration."));
else if (setting.equals_ci("ON"))
diff --git a/modules/operserv/stats.cpp b/modules/operserv/stats.cpp
index 025fe566c..0fc5e9ae1 100644
--- a/modules/operserv/stats.cpp
+++ b/modules/operserv/stats.cpp
@@ -11,32 +11,58 @@
#include "module.h"
#include "modules/operserv/session.h"
+#include "modules/operserv/stats.h"
-#if 0
-struct Stats : Serialize::Object
+class StatsImpl : public Stats
{
- static Stats *me;
+ friend class StatsType;
- Stats() : Serialize::Object("Stats")
- {
- me = this;
- }
+ unsigned int maxusercnt = 0;
+ time_t maxusertime = 0;
- void Serialize(Serialize::Data &data) const override
- {
- data["maxusercnt"] << MaxUserCount;
- data["maxusertime"] << MaxUserTime;
- }
+ public:
+
+ using Stats::Stats;
+
+ unsigned int GetMaxUserCount();
+ void SetMaxUserCount(unsigned int i);
+
+ time_t GetMaxUserTime();
+ void SetMaxUserTime(time_t t);
+};
+
+class StatsType : public Serialize::Type<StatsImpl>
+{
+ public:
+ Serialize::Field<StatsImpl, unsigned int> maxusercount;
+ Serialize::Field<StatsImpl, time_t> maxusertime;
- static Serializable* Unserialize(Serializable *obj, Serialize::Data &data)
+ StatsType(Module *me) : Serialize::Type<StatsImpl>(me)
+ , maxusercount(this, "maxusercount", &StatsImpl::maxusercnt)
+ , maxusertime(this, "maxusertime", &StatsImpl::maxusertime)
{
- data["maxusercnt"] >> MaxUserCount;
- data["maxusertime"] >> MaxUserTime;
- return me;
}
};
-Stats *Stats::me;
+unsigned int StatsImpl::GetMaxUserCount()
+{
+ return Get(&StatsType::maxusercount);
+}
+
+void StatsImpl::SetMaxUserCount(unsigned int i)
+{
+ Set(&StatsType::maxusercount, i);
+}
+
+time_t StatsImpl::GetMaxUserTime()
+{
+ return Get(&StatsType::maxusertime);
+}
+
+void StatsImpl::SetMaxUserTime(time_t t)
+{
+ Set(&StatsType::maxusertime, t);
+}
/**
* Count servers connected to server s
@@ -60,6 +86,8 @@ static int stats_count_servers(Server *s)
class CommandOSStats : public Command
{
ServiceReference<XLineManager> akills, snlines, sqlines;
+ ServiceReference<SessionService> session_service;
+
private:
void DoStatsAkill(CommandSource &source)
{
@@ -128,16 +156,19 @@ class CommandOSStats : public Command
void DoStatsReset(CommandSource &source)
{
- MaxUserCount = UserListByNick.size();
+ Stats *stats = Serialize::GetObject<Stats *>();
+ stats->SetMaxUserCount(UserListByNick.size());
source.Reply(_("Statistics reset."));
return;
}
void DoStatsUptime(CommandSource &source)
{
+ Stats *stats = Serialize::GetObject<Stats *>();
time_t uptime = Anope::CurTime - Anope::StartTime;
+
source.Reply(_("Current users: \002{0}\002 (\002{1}\002 ops)"), UserListByNick.size(), OperCount);
- source.Reply(_("Maximum users: \002{0}\002 ({1})"), MaxUserCount, Anope::strftime(MaxUserTime, source.GetAccount()));
+ source.Reply(_("Maximum users: \002{0}\002 ({1})"), stats->GetMaxUserCount(), Anope::strftime(stats->GetMaxUserTime(), source.GetAccount()));
source.Reply(_("Services up \002{0}\002."), Anope::Duration(uptime, source.GetAccount()));
}
@@ -195,8 +226,10 @@ class CommandOSStats : public Command
}
public:
- CommandOSStats(Module *creator) : Command(creator, "operserv/stats", 0, 1),
- akills("XLineManager", "xlinemanager/sgline"), snlines("XLineManager", "xlinemanager/snline"), sqlines("XLineManager", "xlinemanager/sqline")
+ CommandOSStats(Module *creator) : Command(creator, "operserv/stats", 0, 1)
+ , akills("sgline")
+ , snlines("snline")
+ , sqlines("sqline")
{
this->SetDesc(_("Show status of Services and network"));
this->SetSyntax("[AKILL | HASH | UPLINK | UPTIME | ALL | RESET]");
@@ -245,27 +278,42 @@ class CommandOSStats : public Command
};
class OSStats : public Module
+ , public EventHook<Event::UserConnect>
{
CommandOSStats commandosstats;
- //Serialize::TypeBase stats_type;
- Stats stats_saver;
+ StatsType stats_type;
+
+ Stats *GetStats()
+ {
+ Stats *stats = Serialize::GetObject<Stats *>();
+ if (stats)
+ return stats;
+ else
+ return Serialize::New<Stats *>();
+ }
public:
OSStats(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
+ , EventHook<Event::UserConnect>(this)
, commandosstats(this)
-// , stats_type("Stats", Stats::Unserialize)
+ , stats_type(this)
{
-
}
-#if 0
void OnUserConnect(User *u, bool &exempt) override
{
- if (UserListByNick.size() == MaxUserCount && Anope::CurTime == MaxUserTime)
- stats_saver.QueueUpdate();
+ Stats *stats = GetStats();
+
+ if (stats && UserListByNick.size() > stats->GetMaxUserCount())
+ {
+ stats->SetMaxUserCount(UserListByNick.size());
+ stats->SetMaxUserTime(Anope::CurTime);
+
+ Server *sserver = u->server;
+ if (sserver && sserver->IsSynced())
+ Log(this, "maxusers") << "connected - new maximum user count: " << UserListByNick.size();
+ }
}
-#endif
};
MODULE_INIT(OSStats)
-#endif
diff --git a/modules/operserv/sxline.cpp b/modules/operserv/sxline.cpp
index 61c95bc45..c1be6ad5b 100644
--- a/modules/operserv/sxline.cpp
+++ b/modules/operserv/sxline.cpp
@@ -71,7 +71,7 @@ class CommandOSSXLineBase : public Command
return;
}
- Event::OnDelXLine(&Event::DelXLine::OnDelXLine, source, x, this->xlm());
+ EventManager::Get()->Dispatch(&Event::DelXLine::OnDelXLine, source, x, this->xlm());
x->Delete();
source.Reply(_("\002{0}\002 deleted from the {1} list."), mask, source.command);
@@ -118,7 +118,7 @@ class CommandOSSXLineBase : public Command
unsigned int i = 0;
for (XLine *x : this->xlm()->GetXLines())
{
- if (mask.empty() || mask.equals_ci(x->GetMask()) || mask == x->id || Anope::Match(x->GetMask(), mask, false, true))
+ if (mask.empty() || mask.equals_ci(x->GetMask()) || mask == x->GetID() || Anope::Match(x->GetMask(), mask, false, true))
{
ListFormatter::ListEntry entry;
entry["Number"] = stringify(i + 1);
@@ -163,7 +163,7 @@ class CommandOSSXLineBase : public Command
void OnClear(CommandSource &source)
{
- Event::OnDelXLine(&Event::DelXLine::OnDelXLine, source, nullptr, this->xlm());
+ EventManager::Get()->Dispatch(&Event::DelXLine::OnDelXLine, source, nullptr, this->xlm());
for (XLine *x : this->xlm()->GetXLines())
x->Delete();
@@ -307,7 +307,12 @@ class CommandOSSNLine : public CommandOSSXLineBase
return;
}
- XLine *x = new XLine(mask, source.GetNick(), expires, reason);
+ XLine *x = Serialize::New<XLine *>();
+ x->SetMask(mask);
+ x->SetBy(source.GetNick());
+ x->SetExpires(expires);
+ x->SetReason(reason);
+
if (Config->GetModule("operserv")->Get<bool>("akillids"))
x->SetID(XLineManager::GenerateUID());
@@ -326,7 +331,7 @@ class CommandOSSNLine : public CommandOSSXLineBase
}
EventReturn MOD_RESULT;
- MOD_RESULT = Event::OnAddXLine(&Event::AddXLine::OnAddXLine, source, x, this->xlm());
+ MOD_RESULT = EventManager::Get()->Dispatch(&Event::AddXLine::OnAddXLine, source, x, this->xlm());
if (MOD_RESULT == EVENT_STOP)
{
delete x;
@@ -358,7 +363,8 @@ class CommandOSSNLine : public CommandOSSXLineBase
ServiceReference<XLineManager> snlines;
public:
- CommandOSSNLine(Module *creator) : CommandOSSXLineBase(creator, "operserv/snline"), snlines("XLineManager", "xlinemanager/snline")
+ CommandOSSNLine(Module *creator) : CommandOSSXLineBase(creator, "operserv/snline")
+ , snlines("xlinemanager/snline")
{
this->SetSyntax(_("ADD [+\037expiry\037] \037mask\037:\037reason\037"));
this->SetSyntax(_("DEL {\037mask\037 | \037entry-num\037 | \037list\037 | \037id\037}"));
@@ -512,7 +518,12 @@ class CommandOSSQLine : public CommandOSSXLineBase
return;
}
- XLine *x = new XLine(mask, source.GetNick(), expires, reason);
+ XLine *x = Serialize::New<XLine *>();
+ x->SetMask(mask);
+ x->SetBy(source.GetNick());
+ x->SetExpires(expires);
+ x->SetReason(reason);
+
if (Config->GetModule("operserv")->Get<bool>("akillids"))
x->SetID(XLineManager::GenerateUID());
@@ -531,7 +542,7 @@ class CommandOSSQLine : public CommandOSSXLineBase
}
EventReturn MOD_RESULT;
- MOD_RESULT = Event::OnAddXLine(&Event::AddXLine::OnAddXLine, source, x, this->xlm());
+ MOD_RESULT = EventManager::Get()->Dispatch(&Event::AddXLine::OnAddXLine, source, x, this->xlm());
if (MOD_RESULT == EVENT_STOP)
{
delete x;
@@ -589,7 +600,8 @@ class CommandOSSQLine : public CommandOSSXLineBase
ServiceReference<XLineManager> sqlines;
public:
- CommandOSSQLine(Module *creator) : CommandOSSXLineBase(creator, "operserv/sqline"), sqlines("XLineManager", "xlinemanager/sqline")
+ CommandOSSQLine(Module *creator) : CommandOSSXLineBase(creator, "operserv/sqline")
+ , sqlines("xlinemanager/sqline")
{
this->SetSyntax(_("ADD [+\037expiry\037] \037mask\037 \037reason\037"));
this->SetSyntax(_("DEL {\037mask\037 | \037entry-num\037 | \037list\037 | \037id\037}"));