aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/coremods/core_channel/cmd_invite.cpp7
-rw-r--r--src/coremods/core_channel/core_channel.h9
-rw-r--r--src/coremods/core_dns.cpp2
-rw-r--r--src/coremods/core_reloadmodule.cpp2
-rw-r--r--src/coremods/core_stats.cpp10
-rw-r--r--src/listensocket.cpp2
-rw-r--r--src/modules.cpp5
-rw-r--r--src/modules/m_autoop.cpp11
-rw-r--r--src/modules/m_banexception.cpp19
-rw-r--r--src/modules/m_cban.cpp2
-rw-r--r--src/modules/m_chanfilter.cpp11
-rw-r--r--src/modules/m_dccallow.cpp2
-rw-r--r--src/modules/m_exemptchanops.cpp10
-rw-r--r--src/modules/m_filter.cpp2
-rw-r--r--src/modules/m_httpd.cpp8
-rw-r--r--src/modules/m_httpd_acl.cpp8
-rw-r--r--src/modules/m_ident.cpp2
-rw-r--r--src/modules/m_inviteexception.cpp19
-rw-r--r--src/modules/m_ircv3_capnotify.cpp2
-rw-r--r--src/modules/m_ircv3_sts.cpp4
-rw-r--r--src/modules/m_knock.cpp10
-rw-r--r--src/modules/m_rline.cpp2
-rw-r--r--src/modules/m_setname.cpp48
-rw-r--r--src/modules/m_shun.cpp2
-rw-r--r--src/modules/m_spanningtree/main.cpp6
-rw-r--r--src/modules/m_spanningtree/resolvers.cpp6
-rw-r--r--src/modules/m_svshold.cpp2
-rw-r--r--src/socket.cpp2
-rw-r--r--src/socketengine.cpp6
-rw-r--r--src/xline.cpp38
30 files changed, 151 insertions, 108 deletions
diff --git a/src/coremods/core_channel/cmd_invite.cpp b/src/coremods/core_channel/cmd_invite.cpp
index 851ee1426..8c0fa5ccf 100644
--- a/src/coremods/core_channel/cmd_invite.cpp
+++ b/src/coremods/core_channel/cmd_invite.cpp
@@ -31,6 +31,13 @@
#include "core_channel.h"
#include "invite.h"
+enum
+{
+ // From ircd-hybrid.
+ RPL_INVITELIST = 336,
+ RPL_ENDOFINVITELIST = 337
+};
+
CommandInvite::CommandInvite(Module* parent, Invite::APIImpl& invapiimpl)
: Command(parent, "INVITE", 0, 0)
, invapi(invapiimpl)
diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h
index aaf07c931..3b30ce798 100644
--- a/src/coremods/core_channel/core_channel.h
+++ b/src/coremods/core_channel/core_channel.h
@@ -50,6 +50,13 @@ namespace Invite
};
}
+enum
+{
+ // From RFC 1459.
+ RPL_BANLIST = 367,
+ RPL_ENDOFBANLIST = 368
+};
+
/** Handle /INVITE.
*/
class CommandInvite : public Command
@@ -164,7 +171,7 @@ class ModeChannelBan : public ListModeBase
{
public:
ModeChannelBan(Module* Creator)
- : ListModeBase(Creator, "ban", 'b', "End of channel ban list", 367, 368, true)
+ : ListModeBase(Creator, "ban", 'b', "End of channel ban list", RPL_BANLIST, RPL_ENDOFBANLIST, true)
{
syntax = "<mask>";
}
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index 35ec87858..b19d80b49 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -701,7 +701,7 @@ class MyManager : public Manager, public Timer, public EventHandler
void Rehash(const std::string& dnsserver, std::string sourceaddr, unsigned int sourceport)
{
- if (this->GetFd() > -1)
+ if (this->HasFd())
{
SocketEngine::Shutdown(this, 2);
SocketEngine::Close(this);
diff --git a/src/coremods/core_reloadmodule.cpp b/src/coremods/core_reloadmodule.cpp
index 138dc4cfe..e0cf5508f 100644
--- a/src/coremods/core_reloadmodule.cpp
+++ b/src/coremods/core_reloadmodule.cpp
@@ -720,11 +720,9 @@ class ReloadAction : public ActionBase
ReloadModule::DataKeeper datakeeper;
datakeeper.Save(mod);
- DLLManager* dll = mod->ModuleDLLManager;
std::string name = mod->ModuleSourceFile;
ServerInstance->Modules.DoSafeUnload(mod);
ServerInstance->GlobalCulls.Apply();
- delete dll;
bool result = ServerInstance->Modules.Load(name);
if (result)
diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp
index 66bfad07b..f3ca4b0c8 100644
--- a/src/coremods/core_stats.cpp
+++ b/src/coremods/core_stats.cpp
@@ -195,19 +195,19 @@ void CommandStats::DoStats(Stats::Context& stats)
break;
case 'k':
- ServerInstance->XLines->InvokeStats("K",216,stats);
+ ServerInstance->XLines->InvokeStats("K", stats);
break;
case 'g':
- ServerInstance->XLines->InvokeStats("G",223,stats);
+ ServerInstance->XLines->InvokeStats("G", stats);
break;
case 'q':
- ServerInstance->XLines->InvokeStats("Q",217,stats);
+ ServerInstance->XLines->InvokeStats("Q", stats);
break;
case 'Z':
- ServerInstance->XLines->InvokeStats("Z",223,stats);
+ ServerInstance->XLines->InvokeStats("Z", stats);
break;
case 'e':
- ServerInstance->XLines->InvokeStats("E",223,stats);
+ ServerInstance->XLines->InvokeStats("E", stats);
break;
case 'E':
{
diff --git a/src/listensocket.cpp b/src/listensocket.cpp
index 03f66b307..2e7b42720 100644
--- a/src/listensocket.cpp
+++ b/src/listensocket.cpp
@@ -130,7 +130,7 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t
ListenSocket::~ListenSocket()
{
- if (this->GetFd() > -1)
+ if (this->HasFd())
{
ServerInstance->Logs.Log("SOCKET", LOG_DEBUG, "Shut down listener on fd %d", this->fd);
SocketEngine::Shutdown(this, 2);
diff --git a/src/modules.cpp b/src/modules.cpp
index 254cb2918..28729ba63 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -57,6 +57,8 @@ Version::Version(const std::string &desc, int flags, const std::string& linkdata
// These declarations define the behavours of the base class Module (which does nothing at all)
CullResult Module::cull()
{
+ if (ModuleDLLManager)
+ ServerInstance->GlobalCulls.AddItem(ModuleDLLManager);
return classbase::cull();
}
@@ -441,11 +443,8 @@ namespace
UnloadAction(Module* m) : mod(m) {}
void Call() override
{
- DLLManager* dll = mod->ModuleDLLManager;
ServerInstance->Modules.DoSafeUnload(mod);
ServerInstance->GlobalCulls.Apply();
- // In pure static mode this is always NULL
- delete dll;
ServerInstance->GlobalCulls.AddItem(this);
}
};
diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp
index e27588268..01ed0a1f8 100644
--- a/src/modules/m_autoop.cpp
+++ b/src/modules/m_autoop.cpp
@@ -24,13 +24,18 @@
#include "inspircd.h"
#include "listmode.h"
-/** Handles +w channel mode
- */
+enum
+{
+ // InspIRCd-specific.
+ RPL_ACCESSLIST = 910,
+ RPL_ENDOFACCESSLIST = 911
+};
+
class AutoOpList : public ListModeBase
{
public:
AutoOpList(Module* Creator)
- : ListModeBase(Creator, "autoop", 'w', "End of Channel Access List", 910, 911, true)
+ : ListModeBase(Creator, "autoop", 'w', "End of Channel Access List", RPL_ACCESSLIST, RPL_ENDOFACCESSLIST, true)
{
ranktoset = ranktounset = OP_VALUE;
syntax = "<prefix>:<mask>";
diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp
index 5e2ec3aee..0511d8c73 100644
--- a/src/modules/m_banexception.cpp
+++ b/src/modules/m_banexception.cpp
@@ -27,28 +27,23 @@
#include "listmode.h"
#include "modules/isupport.h"
-/* Written by Om<om@inspircd.org>, April 2005. */
-/* Rewritten to use the listmode utility by Om, December 2005 */
-/* Adapted from m_exception, which was originally based on m_chanprotect and m_silence */
-
-// The +e channel mode takes a nick!ident@host, glob patterns allowed,
-// and if a user matches an entry on the +e list then they can join the channel, overriding any (+b) bans set on them
-// Now supports CIDR and IP addresses -- Brain
-
+enum
+{
+ // From RFC 2812.
+ RPL_EXCEPTLIST = 348,
+ RPL_ENDOFEXCEPTLIST = 349
+};
-/** Handles +e channel mode
- */
class BanException : public ListModeBase
{
public:
BanException(Module* Creator)
- : ListModeBase(Creator, "banexception", 'e', "End of Channel Exception List", 348, 349, true)
+ : ListModeBase(Creator, "banexception", 'e', "End of Channel Exception List", RPL_EXCEPTLIST, RPL_ENDOFEXCEPTLIST, true)
{
syntax = "<mask>";
}
};
-
class ModuleBanException
: public Module
, public ISupport::EventListener
diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp
index 2e786adbc..5c97914e3 100644
--- a/src/modules/m_cban.cpp
+++ b/src/modules/m_cban.cpp
@@ -188,7 +188,7 @@ class ModuleCBan : public Module, public Stats::EventListener
if (stats.GetSymbol() != 'C')
return MOD_RES_PASSTHRU;
- ServerInstance->XLines->InvokeStats("CBAN", 210, stats);
+ ServerInstance->XLines->InvokeStats("CBAN", stats);
return MOD_RES_DENY;
}
diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp
index 14f898406..d2beec8d5 100644
--- a/src/modules/m_chanfilter.cpp
+++ b/src/modules/m_chanfilter.cpp
@@ -27,15 +27,20 @@
#include "listmode.h"
#include "modules/exemption.h"
-/** Handles channel mode +g
- */
+enum
+{
+ // InspIRCd-specific.
+ RPL_ENDOFSPAMFILTER = 940,
+ RPL_SPAMFILTER = 941
+};
+
class ChanFilter : public ListModeBase
{
public:
unsigned long maxlen;
ChanFilter(Module* Creator)
- : ListModeBase(Creator, "filter", 'g', "End of channel spamfilter list", 941, 940, false)
+ : ListModeBase(Creator, "filter", 'g', "End of channel spamfilter list", RPL_SPAMFILTER, RPL_ENDOFSPAMFILTER, false)
{
syntax = "<pattern>";
}
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index 915801386..043f7a101 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -154,6 +154,8 @@ class DCCAllowExt : public SimpleExtItem<dccallowlist>
list->push_back(dccallow);
}
+ // The value was well formed.
+ set(user, list);
}
std::string ToInternal(const Extensible* container, void* item) const override
diff --git a/src/modules/m_exemptchanops.cpp b/src/modules/m_exemptchanops.cpp
index f5539c10c..46204761f 100644
--- a/src/modules/m_exemptchanops.cpp
+++ b/src/modules/m_exemptchanops.cpp
@@ -25,13 +25,17 @@
#include "listmode.h"
#include "modules/exemption.h"
-/** Handles channel mode +X
- */
+enum
+{
+ RPL_ENDOFEXEMPTIONLIST = 953,
+ RPL_EXEMPTIONLIST = 954
+};
+
class ExemptChanOps : public ListModeBase
{
public:
ExemptChanOps(Module* Creator)
- : ListModeBase(Creator, "exemptchanops", 'X', "End of channel exemptchanops list", 954, 953, false)
+ : ListModeBase(Creator, "exemptchanops", 'X', "End of channel exemptchanops list", RPL_EXEMPTIONLIST, RPL_ENDOFEXEMPTIONLIST, false)
{
syntax = "<restriction>:<prefix>";
}
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index dfce068e8..d377d7295 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -897,7 +897,7 @@ ModResult ModuleFilter::OnStats(Stats::Context& stats)
{
for (std::vector<FilterResult>::iterator i = filters.begin(); i != filters.end(); i++)
{
- stats.AddRow(223, RegexEngine.GetProvider()+":"+i->freeform+" "+i->GetFlags()+" "+FilterActionToString(i->action)+" "+ConvToStr(i->duration)+" :"+i->reason);
+ stats.AddRow(223, RegexEngine.GetProvider(), i->freeform, i->GetFlags(), FilterActionToString(i->action), i->duration, i->reason);
}
for (ExemptTargetSet::const_iterator i = exemptedchans.begin(); i != exemptedchans.end(); ++i)
{
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp
index e649cfaca..5bf7d8bdc 100644
--- a/src/modules/m_httpd.cpp
+++ b/src/modules/m_httpd.cpp
@@ -234,10 +234,12 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru
void SendHTTPError(unsigned int response)
{
- HTTPHeaders empty;
+ static HTTPHeaders empty;
std::string data = InspIRCd::Format(
- "<html><head></head><body>Server error %u: %s<br>"
- "<small>Powered by <a href='https://www.inspircd.org'>InspIRCd</a></small></body></html>", response, http_status_str((http_status)response));
+ "<html><head></head><body style='font-family: sans-serif; text-align: center'>"
+ "<h1 style='font-size: 48pt'>Error %u</h1><h2 style='font-size: 24pt'>%s</h2><hr>"
+ "<small>Powered by <a href='https://www.inspircd.org'>InspIRCd</a></small></body></html>",
+ response, http_status_str((http_status)response));
Page(data, response, &empty);
}
diff --git a/src/modules/m_httpd_acl.cpp b/src/modules/m_httpd_acl.cpp
index 402a5de43..e0a947ea8 100644
--- a/src/modules/m_httpd_acl.cpp
+++ b/src/modules/m_httpd_acl.cpp
@@ -103,7 +103,13 @@ class ModuleHTTPAccessList : public Module, public HTTPACLEventListener
{
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "BlockAccess (%u)", returnval);
- std::stringstream data("Access to this resource is denied by an access control list. Please contact your IRC administrator.");
+ std::stringstream data;
+ data << "<html><head></head><body style='font-family: sans-serif; text-align: center'>"
+ << "<h1 style='font-size: 48pt'>Error " << returnval << "</h1>"
+ << "<h2 style='font-size: 24pt'>Access to this resource is denied by an access control list.</h2>"
+ << "<h2 style='font-size: 24pt'>Please contact your IRC administrator.</h2><hr>"
+ << "<small>Powered by <a href='https://www.inspircd.org'>InspIRCd</a></small></body></html>";
+
HTTPDocumentResponse response(this, *http, &data, returnval);
response.headers.SetHeader("X-Powered-By", MODNAME);
if (!extraheaderkey.empty())
diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp
index a3ba64906..8b54183ed 100644
--- a/src/modules/m_ident.cpp
+++ b/src/modules/m_ident.cpp
@@ -187,7 +187,7 @@ class IdentRequestSocket : public EventHandler
/* Remove ident socket from engine, and close it, but dont detatch it
* from its parent user class, or attempt to delete its memory.
*/
- if (GetFd() > -1)
+ if (HasFd())
{
ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Close ident socket %d", GetFd());
SocketEngine::Close(this);
diff --git a/src/modules/m_inviteexception.cpp b/src/modules/m_inviteexception.cpp
index 32d536f25..fe5e81a05 100644
--- a/src/modules/m_inviteexception.cpp
+++ b/src/modules/m_inviteexception.cpp
@@ -27,23 +27,18 @@
#include "listmode.h"
#include "modules/isupport.h"
-/*
- * Written by Om <om@inspircd.org>, April 2005.
- * Based on m_exception, which was originally based on m_chanprotect and m_silence
- *
- * The +I channel mode takes a nick!ident@host, glob patterns allowed,
- * and if a user matches an entry on the +I list then they can join the channel,
- * ignoring if +i is set on the channel
- * Now supports CIDR and IP addresses -- Brain
- */
+enum
+{
+ // From RFC 2812.
+ RPL_INVEXLIST = 346,
+ RPL_ENDOFINVEXLIST = 347
+};
-/** Handles channel mode +I
- */
class InviteException : public ListModeBase
{
public:
InviteException(Module* Creator)
- : ListModeBase(Creator, "invex", 'I', "End of Channel Invite Exception List", 346, 347, true)
+ : ListModeBase(Creator, "invex", 'I', "End of Channel Invite Exception List", RPL_INVEXLIST, RPL_ENDOFINVEXLIST, true)
{
syntax = "<mask>";
}
diff --git a/src/modules/m_ircv3_capnotify.cpp b/src/modules/m_ircv3_capnotify.cpp
index 6563c8210..68f363b6e 100644
--- a/src/modules/m_ircv3_capnotify.cpp
+++ b/src/modules/m_ircv3_capnotify.cpp
@@ -103,7 +103,7 @@ class ModuleIRCv3CapNotify : public Module, public Cap::EventListener, public Re
continue;
// Check that this user can actually see the cap.
- if (!cap->OnList(user))
+ if (add && (!cap || !cap->OnList(user)))
continue;
// If the cap is being added and the client supports cap values then show the value, if any
diff --git a/src/modules/m_ircv3_sts.cpp b/src/modules/m_ircv3_sts.cpp
index 177f6adef..dbf99153e 100644
--- a/src/modules/m_ircv3_sts.cpp
+++ b/src/modules/m_ircv3_sts.cpp
@@ -70,6 +70,7 @@ class STSCap : public Cap::Capability
STSCap(Module* mod)
: Cap::Capability(mod, "sts")
{
+ DisableAutoRegister();
}
~STSCap()
@@ -173,6 +174,9 @@ class ModuleIRCv3STS : public Module
unsigned long duration = tag->getDuration("duration", 60*60*24*30*2);
bool preload = tag->getBool("preload");
cap.SetPolicy(host, duration, port, preload);
+
+ if (!cap.IsRegistered())
+ ServerInstance->Modules.AddService(cap);
}
Version GetVersion() override
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index 8b5a4c8a1..3d3335d25 100644
--- a/src/modules/m_knock.cpp
+++ b/src/modules/m_knock.cpp
@@ -33,6 +33,8 @@ enum
ERR_CANNOTKNOCK = 480,
// From ircd-ratbox.
+ RPL_KNOCK = 710,
+ RPL_KNOCKDLVR = 711,
ERR_CHANOPEN = 713,
ERR_KNOCKONCHAN = 714
};
@@ -84,18 +86,22 @@ class CommandKnock : public Command
}
if (sendnotice)
+ {
c->WriteNotice(InspIRCd::Format("User %s is KNOCKing on %s (%s)", user->nick.c_str(), c->name.c_str(), parameters[1].c_str()));
+ user->WriteNotice("KNOCKing on " + c->name);
+ }
if (sendnumeric)
{
- Numeric::Numeric numeric(710);
+ Numeric::Numeric numeric(RPL_KNOCK);
numeric.push(c->name).push(user->GetFullHost()).push("is KNOCKing: " + parameters[1]);
ClientProtocol::Messages::Numeric numericmsg(numeric, c->name);
c->Write(ServerInstance->GetRFCEvents().numeric, numericmsg);
+
+ user->WriteNumeric(RPL_KNOCKDLVR, c->name, "KNOCKing on channel");
}
- user->WriteNotice("KNOCKing on " + c->name);
return CMD_SUCCESS;
}
diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp
index 45f3aafbf..f93dfe8c5 100644
--- a/src/modules/m_rline.cpp
+++ b/src/modules/m_rline.cpp
@@ -306,7 +306,7 @@ class ModuleRLine : public Module, public Stats::EventListener
if (stats.GetSymbol() != 'R')
return MOD_RES_PASSTHRU;
- ServerInstance->XLines->InvokeStats("R", 223, stats);
+ ServerInstance->XLines->InvokeStats("R", stats);
return MOD_RES_DENY;
}
diff --git a/src/modules/m_setname.cpp b/src/modules/m_setname.cpp
index cd56c66a4..9b1108432 100644
--- a/src/modules/m_setname.cpp
+++ b/src/modules/m_setname.cpp
@@ -26,45 +26,58 @@
#include "inspircd.h"
+#include "modules/ircv3.h"
+#include "modules/ircv3_replies.h"
-
-
-class CommandSetname : public Command
+class CommandSetName : public SplitCommand
{
+private:
+ IRCv3::Replies::Fail fail;
+
public:
+ Cap::Capability cap;
bool notifyopers;
- CommandSetname(Module* Creator) : Command(Creator,"SETNAME", 1, 1)
+
+ CommandSetName(Module* Creator)
+ : SplitCommand(Creator, "SETNAME", 1, 1)
+ , fail(Creator)
+ , cap(Creator, "setname")
{
allow_empty_last_param = false;
syntax = ":<realname>";
}
- CmdResult Handle(User* user, const Params& parameters) override
+ CmdResult HandleLocal(LocalUser* user, const Params& parameters) override
{
if (parameters[0].size() > ServerInstance->Config->Limits.MaxReal)
{
- user->WriteNotice("*** SETNAME: Real name is too long");
+ fail.SendIfCap(user, cap, this, "INVALID_REALNAME", "Real name is too long");
return CMD_FAILURE;
}
- if (user->ChangeRealName(parameters[0]))
+ if (!user->ChangeRealName(parameters[0]))
{
- if (notifyopers)
- ServerInstance->SNO.WriteGlobalSno('a', "%s used SETNAME to change their real name to '%s'",
- user->nick.c_str(), parameters[0].c_str());
+ fail.SendIfCap(user, cap, this, "CANNOT_CHANGE_REALNAME", "Unable to change your real name");
+ return CMD_FAILURE;
}
+ if (notifyopers)
+ ServerInstance->SNO.WriteGlobalSno('a', "%s used SETNAME to change their real name to '%s'",
+ user->nick.c_str(), parameters[0].c_str());
return CMD_SUCCESS;
}
};
-
class ModuleSetName : public Module
{
- CommandSetname cmd;
+ private:
+ CommandSetName cmd;
+ ClientProtocol::EventProvider setnameevprov;
+
public:
ModuleSetName()
: cmd(this)
+ , setnameevprov(this, "SETNAME")
{
}
@@ -80,6 +93,17 @@ class ModuleSetName : public Module
cmd.notifyopers = tag->getBool("notifyopers", !operonly);
}
+ void OnChangeRealName(User* user, const std::string& real) override
+ {
+ if (!(user->registered & REG_NICKUSER))
+ return;
+
+ ClientProtocol::Message msg("SETNAME", user);
+ msg.PushParamRef(real);
+ ClientProtocol::Event protoev(setnameevprov, msg);
+ IRCv3::WriteNeighborsWithCap(user, protoev, cmd.cap, true);
+ }
+
Version GetVersion() override
{
return Version("Provides the SETNAME command", VF_VENDOR);
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp
index 7b87232b7..068c51cdc 100644
--- a/src/modules/m_shun.cpp
+++ b/src/modules/m_shun.cpp
@@ -187,7 +187,7 @@ class ModuleShun : public Module, public Stats::EventListener
if (stats.GetSymbol() != 'H')
return MOD_RES_PASSTHRU;
- ServerInstance->XLines->InvokeStats("SHUN", 223, stats);
+ ServerInstance->XLines->InvokeStats("SHUN", stats);
return MOD_RES_DENY;
}
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index e595c680f..472f78c37 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -219,11 +219,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
{
// Create a TreeServer object that will start connecting immediately in the background
TreeSocket* newsocket = new TreeSocket(x, y, sa);
- if (newsocket->GetFd() > -1)
- {
- /* Handled automatically on success */
- }
- else
+ if (!newsocket->HasFd())
{
ServerInstance->SNO.WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",
x->Name.c_str(), newsocket->getError().c_str());
diff --git a/src/modules/m_spanningtree/resolvers.cpp b/src/modules/m_spanningtree/resolvers.cpp
index e044153a2..50cef5aa1 100644
--- a/src/modules/m_spanningtree/resolvers.cpp
+++ b/src/modules/m_spanningtree/resolvers.cpp
@@ -71,11 +71,7 @@ void ServernameResolver::OnLookupComplete(const DNS::Query *r)
if (!CheckDupe) /* Check that nobody tried to connect it successfully while we were resolving */
{
TreeSocket* newsocket = new TreeSocket(MyLink, myautoconnect, sa);
- if (newsocket->GetFd() > -1)
- {
- /* We're all OK */
- }
- else
+ if (!newsocket->HasFd())
{
/* Something barfed, show the opers */
ServerInstance->SNO.WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",
diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp
index 6098d784e..864f33b63 100644
--- a/src/modules/m_svshold.cpp
+++ b/src/modules/m_svshold.cpp
@@ -203,7 +203,7 @@ class ModuleSVSHold : public Module, public Stats::EventListener
if (stats.GetSymbol() != 'S')
return MOD_RES_PASSTHRU;
- ServerInstance->XLines->InvokeStats("SVSHOLD", 210, stats);
+ ServerInstance->XLines->InvokeStats("SVSHOLD", stats);
return MOD_RES_DENY;
}
diff --git a/src/socket.cpp b/src/socket.cpp
index e63f04bc3..eb733cc6e 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -47,7 +47,7 @@ bool InspIRCd::BindPort(ConfigTag* tag, const irc::sockets::sockaddrs& sa, std::
}
ListenSocket* ll = new ListenSocket(tag, sa);
- if (ll->GetFd() < 0)
+ if (!ll->HasFd())
{
ServerInstance->Logs.Log("SOCKET", LOG_DEFAULT, "Failed to listen on %s from tag at %s: %s",
sa.str().c_str(), tag->getTagLocation().c_str(), strerror(errno));
diff --git a/src/socketengine.cpp b/src/socketengine.cpp
index 61655732e..e1aef6439 100644
--- a/src/socketengine.cpp
+++ b/src/socketengine.cpp
@@ -180,11 +180,7 @@ EventHandler* SocketEngine::GetRef(int fd)
bool SocketEngine::BoundsCheckFd(EventHandler* eh)
{
- if (!eh)
- return false;
- if (eh->GetFd() < 0)
- return false;
- return true;
+ return eh && eh->HasFd();
}
diff --git a/src/xline.cpp b/src/xline.cpp
index 012e9c53a..e3b2b82e2 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -477,35 +477,31 @@ void XLineManager::ApplyLines()
pending_lines.clear();
}
-void XLineManager::InvokeStats(const std::string& type, unsigned int numeric, Stats::Context& stats)
+bool XLineManager::InvokeStats(const std::string& type, Stats::Context& context)
{
- ContainerIter n = lookup_lines.find(type);
-
- time_t current = ServerInstance->Time();
-
- LookupIter safei;
+ ContainerIter citer = lookup_lines.find(type);
+ if (citer == lookup_lines.end())
+ return false;
- if (n != lookup_lines.end())
+ for (LookupIter liter = citer->second.begin(); liter != citer->second.end(); )
{
- XLineLookup& list = n->second;
- for (LookupIter i = list.begin(); i != list.end(); )
- {
- safei = i;
- safei++;
+ // We might be about to expire the XLine so we have to increment the
+ // iterator early to avoid doing that causing iterator invalidation.
+ LookupIter current = liter++;
- if (i->second->duration && current > i->second->expiry)
- {
- ExpireLine(n, i);
- }
- else
- stats.AddRow(numeric, i->second->Displayable()+" "+
- ConvToStr(i->second->set_time)+" "+ConvToStr(i->second->duration)+" "+i->second->source+" :"+i->second->reason);
- i = safei;
+ XLine* xline = current->second;
+ if (xline->duration && xline->expiry <= ServerInstance->Time())
+ {
+ // This XLine has expired so remove and skip it.
+ ExpireLine(citer, current);
+ continue;
}
+
+ context.AddRow(RPL_STATS, context.GetSymbol(), xline->Displayable(), xline->set_time, xline->duration, xline->source, xline->reason);
}
+ return true;
}
-
XLineManager::XLineManager()
{
GLineFactory* GFact;