From 98b470674b740faf83507214a8d41f63eec279a5 Mon Sep 17 00:00:00 2001
From: Sadie Powell
Date: Fri, 14 Feb 2020 03:20:25 +0000
Subject: Only register the sts capability when we have a valid config.
This avoids announcing a bare sts cap when the config is wrong.
---
src/modules/m_ircv3_sts.cpp | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'src/modules')
diff --git a/src/modules/m_ircv3_sts.cpp b/src/modules/m_ircv3_sts.cpp
index a46322a87..86ea159c1 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() CXX11_OVERRIDE
--
cgit v1.3.1-10-gc9f91
From 45d5e5c7526a00784d2366bd1a2ca7d0c5384027 Mon Sep 17 00:00:00 2001
From: Sadie Powell
Date: Fri, 14 Feb 2020 06:25:06 +0000
Subject: Marginally improve the error pages created by httpd and httpd_acl.
---
src/modules/m_httpd.cpp | 8 +++++---
src/modules/m_httpd_acl.cpp | 8 +++++++-
2 files changed, 12 insertions(+), 4 deletions(-)
(limited to 'src/modules')
diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp
index cec52f66a..bdb1d50fc 100644
--- a/src/modules/m_httpd.cpp
+++ b/src/modules/m_httpd.cpp
@@ -251,10 +251,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(
- "
Server error %u: %s
"
- "Powered by InspIRCd", response, http_status_str((http_status)response));
+ ""
+ "Error %u
%s
"
+ "Powered by InspIRCd",
+ 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 25b7a73f5..cb82b15fa 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 << ""
+ << "Error " << returnval << "
"
+ << "Access to this resource is denied by an access control list.
"
+ << "Please contact your IRC administrator.
"
+ << "Powered by InspIRCd";
+
HTTPDocumentResponse response(this, *http, &data, returnval);
response.headers.SetHeader("X-Powered-By", MODNAME);
if (!extraheaderkey.empty())
--
cgit v1.3.1-10-gc9f91
From 169b194788de09259ff513401a02035d164b14c1 Mon Sep 17 00:00:00 2001
From: Sadie Powell
Date: Sat, 15 Feb 2020 05:24:24 +0000
Subject: Fix logic calling OnList when sending a cap notification.
It is possible for the cap to be null when a DEL for an unloaded
module is sent out so we should not blindly call it.
---
src/modules/m_ircv3_capnotify.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/modules')
diff --git a/src/modules/m_ircv3_capnotify.cpp b/src/modules/m_ircv3_capnotify.cpp
index f60c9c737..20efb5845 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
--
cgit v1.3.1-10-gc9f91
From f9b4c280f8e7bec0c9237f9648c4fc5a77cfc468 Mon Sep 17 00:00:00 2001
From: Sadie Powell
Date: Sat, 15 Feb 2020 05:43:02 +0000
Subject: Fix leaking the dccallow list instead of setting it in FromInternal.
---
src/modules/m_dccallow.cpp | 2 ++
1 file changed, 2 insertions(+)
(limited to 'src/modules')
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index 20dfa9db8..95c751734 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -154,6 +154,8 @@ class DCCAllowExt : public SimpleExtItem
list->push_back(dccallow);
}
+ // The value was well formed.
+ set(user, list);
}
std::string ToInternal(const Extensible* container, void* item) const CXX11_OVERRIDE
--
cgit v1.3.1-10-gc9f91
From 24f1224f770eb8f6a075d3c8bd083545c17bba10 Mon Sep 17 00:00:00 2001
From: Sadie Powell
Date: Sat, 15 Feb 2020 05:58:19 +0000
Subject: Add HasFd to EventHandler and switch code to use it.
---
include/socketengine.h | 3 +++
src/coremods/core_dns.cpp | 2 +-
src/listensocket.cpp | 2 +-
src/modules/m_ident.cpp | 2 +-
src/modules/m_spanningtree/main.cpp | 6 +-----
src/modules/m_spanningtree/resolvers.cpp | 6 +-----
src/socket.cpp | 2 +-
src/socketengine.cpp | 6 +-----
8 files changed, 10 insertions(+), 19 deletions(-)
(limited to 'src/modules')
diff --git a/include/socketengine.h b/include/socketengine.h
index e54dfca97..2b759dad8 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -182,6 +182,9 @@ class CoreExport EventHandler : public classbase
*/
inline int GetFd() const { return fd; }
+ /** Checks if this event handler has a fd associated with it. */
+ inline bool HasFd() const { return fd >= 0; }
+
inline int GetEventMask() const { return event_mask; }
/** Set a new file desciptor
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index 5dcc994ce..326135465 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -703,7 +703,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/listensocket.cpp b/src/listensocket.cpp
index 40639ba15..cb1c5c73f 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/m_ident.cpp b/src/modules/m_ident.cpp
index 5994caee5..dea411cea 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_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 1aab60eda..5e6e9b036 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -221,11 +221,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 f048283cf..14a96933d 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/socket.cpp b/src/socket.cpp
index e070b68c3..d2cc2af9a 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();
}
--
cgit v1.3.1-10-gc9f91
From 5ddbcd3f56bb79a5dc6b693fc2c6ad7a46ba5a3c Mon Sep 17 00:00:00 2001
From: Sadie Powell
Date: Mon, 3 Feb 2020 10:47:44 +0000
Subject: Add support for the IRCv3 extensions to the SETNAME command.
---
src/modules/m_setname.cpp | 48 +++++++++++++++++++++++++++++++++++------------
1 file changed, 36 insertions(+), 12 deletions(-)
(limited to 'src/modules')
diff --git a/src/modules/m_setname.cpp b/src/modules/m_setname.cpp
index 7510a79f7..25675dcee 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 = ":";
}
- CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
+ CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_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) CXX11_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() CXX11_OVERRIDE
{
return Version("Provides the SETNAME command", VF_VENDOR);
--
cgit v1.3.1-10-gc9f91
From 2e0cc3684df72b2a8de45b354848af43c6b47606 Mon Sep 17 00:00:00 2001
From: Sadie Powell
Date: Tue, 18 Feb 2020 17:49:32 +0000
Subject: Generalise XLine stats numerics using RPL_STATS from aircd.
---
include/numerics.h | 1 +
include/xline.h | 17 +++++++++--------
src/coremods/core_stats.cpp | 10 +++++-----
src/modules/m_cban.cpp | 2 +-
src/modules/m_rline.cpp | 2 +-
src/modules/m_shun.cpp | 2 +-
src/modules/m_svshold.cpp | 2 +-
src/xline.cpp | 27 +++++++++++++++++++++++++--
8 files changed, 44 insertions(+), 19 deletions(-)
(limited to 'src/modules')
diff --git a/include/numerics.h b/include/numerics.h
index baae8de5c..5a05a61eb 100644
--- a/include/numerics.h
+++ b/include/numerics.h
@@ -50,6 +50,7 @@ enum
RPL_ENDMAP = 17, // ircu
RPL_MAPUSERS = 18, // insp-specific
+ RPL_STATS = 210, // From aircd.
RPL_UMODEIS = 221,
RPL_LUSERCLIENT = 251,
diff --git a/include/xline.h b/include/xline.h
index 0aaa21a16..fe564358f 100644
--- a/include/xline.h
+++ b/include/xline.h
@@ -529,14 +529,15 @@ class CoreExport XLineManager
*/
void ApplyLines();
- /** Handle /STATS for a given type.
- * NOTE: Any items in the list for this particular line type which have expired
- * will be expired and removed before the list is displayed.
- * @param type The type of stats to show
- * @param numeric The numeric to give to each result line
- * @param stats Stats context
- */
- void InvokeStats(const std::string& type, unsigned int numeric, Stats::Context& stats);
+ /** DEPRECATED: use the `bool InvokeStats(const std::string&, Stats::Context&)` overload instead. */
+ DEPRECATED_METHOD(void InvokeStats(const std::string& type, unsigned int numeric, Stats::Context& stats));
+
+ /** Generates a /STATS response for the given X-line type.
+ * @param type The type of X-line to look up.
+ * @param context The stats context to respond with.
+ * @return True if a response was sent; otherwise, false.
+ */
+ bool InvokeStats(const std::string& type, Stats::Context& context);
/** Expire X-lines which were added by the server configuration and have been removed. */
void ExpireRemovedConfigLines(const std::string& type, const insp::flat_set& configlines);
diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp
index b95005c5b..4b30fa5b4 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/modules/m_cban.cpp b/src/modules/m_cban.cpp
index 22382bdb3..ff99ae5bd 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_rline.cpp b/src/modules/m_rline.cpp
index cb6c507f1..1876604c4 100644
--- a/src/modules/m_rline.cpp
+++ b/src/modules/m_rline.cpp
@@ -307,7 +307,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_shun.cpp b/src/modules/m_shun.cpp
index 3ffe553b0..99ff05c30 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_svshold.cpp b/src/modules/m_svshold.cpp
index 9cdc307b9..0c5578492 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/xline.cpp b/src/xline.cpp
index 13ea2f97c..04ac67f68 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -498,13 +498,36 @@ void XLineManager::InvokeStats(const std::string& type, unsigned int numeric, St
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);
+ stats.AddRow(numeric, i->second->Displayable(), i->second->set_time, i->second->duration, i->second->source, i->second->reason);
i = safei;
}
}
}
+bool XLineManager::InvokeStats(const std::string& type, Stats::Context& context)
+{
+ ContainerIter citer = lookup_lines.find(type);
+ if (citer == lookup_lines.end())
+ return false;
+
+ for (LookupIter liter = citer->second.begin(); liter != citer->second.end(); )
+ {
+ // 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++;
+
+ 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()
{
--
cgit v1.3.1-10-gc9f91
From 9822a57460d4c7edc17c8fb7c760ae32326bf99d Mon Sep 17 00:00:00 2001
From: Sadie Powell
Date: Tue, 18 Feb 2020 18:00:26 +0000
Subject: Send RPL_KNOCKDLVR when is set to numeric.
---
src/modules/m_knock.cpp | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
(limited to 'src/modules')
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp
index 54c6220cc..493913964 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;
}
--
cgit v1.3.1-10-gc9f91
From 042617e97f00c840bb740b0279bf921f4a6cbd01 Mon Sep 17 00:00:00 2001
From: Sadie Powell
Date: Tue, 18 Feb 2020 18:03:46 +0000
Subject: Add enum constants for list mode numerics.
---
src/coremods/core_channel/core_channel.h | 9 ++++++++-
src/modules/m_autoop.cpp | 11 ++++++++---
src/modules/m_banexception.cpp | 19 +++++++------------
src/modules/m_chanfilter.cpp | 11 ++++++++---
src/modules/m_exemptchanops.cpp | 10 +++++++---
src/modules/m_inviteexception.cpp | 19 +++++++------------
6 files changed, 45 insertions(+), 34 deletions(-)
(limited to 'src/modules')
diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h
index 2dd8f7feb..112cd0411 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 = "";
}
diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp
index 152e9d679..e1042c22b 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 = ":";
diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp
index f15c270b0..0501e7670 100644
--- a/src/modules/m_banexception.cpp
+++ b/src/modules/m_banexception.cpp
@@ -26,28 +26,23 @@
#include "inspircd.h"
#include "listmode.h"
-/* Written by Om, 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 = "";
}
};
-
class ModuleBanException : public Module
{
BanException be;
diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp
index 8d2408e7a..18e2791e6 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 = "";
}
diff --git a/src/modules/m_exemptchanops.cpp b/src/modules/m_exemptchanops.cpp
index ddc75ac3d..b8f62137c 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 = ":";
}
diff --git a/src/modules/m_inviteexception.cpp b/src/modules/m_inviteexception.cpp
index a6819cc98..1690ed6c7 100644
--- a/src/modules/m_inviteexception.cpp
+++ b/src/modules/m_inviteexception.cpp
@@ -26,23 +26,18 @@
#include "inspircd.h"
#include "listmode.h"
-/*
- * Written by Om , 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 = "";
}
--
cgit v1.3.1-10-gc9f91
From 815ab93a9a03c100abb15ac7bc55b70bfb8e43fd Mon Sep 17 00:00:00 2001
From: Sadie Powell
Date: Tue, 18 Feb 2020 20:23:43 +0000
Subject: Fix the syntax of the filter module's stats.
---
src/modules/m_filter.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/modules')
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index 5eef97e3f..9088ac3fa 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -899,7 +899,7 @@ ModResult ModuleFilter::OnStats(Stats::Context& stats)
{
for (std::vector::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)
{
--
cgit v1.3.1-10-gc9f91