diff options
| author | 2020-02-19 01:29:45 +0000 | |
|---|---|---|
| committer | 2020-02-19 01:29:45 +0000 | |
| commit | 7bdd72f634f994dcbd9bfbc865d0087143fb748d (patch) | |
| tree | 11784350f097d56704426e604fdc0009ec35afb2 /src/modules | |
| parent | Move FindNickOnly to UserManager. (diff) | |
| parent | Bump the module ABI version. (diff) | |
Merge branch 'insp3' into master.
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/m_autoop.cpp | 11 | ||||
| -rw-r--r-- | src/modules/m_banexception.cpp | 19 | ||||
| -rw-r--r-- | src/modules/m_cban.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_chanfilter.cpp | 11 | ||||
| -rw-r--r-- | src/modules/m_dccallow.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_exemptchanops.cpp | 10 | ||||
| -rw-r--r-- | src/modules/m_filter.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_httpd.cpp | 8 | ||||
| -rw-r--r-- | src/modules/m_httpd_acl.cpp | 8 | ||||
| -rw-r--r-- | src/modules/m_ident.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_inviteexception.cpp | 19 | ||||
| -rw-r--r-- | src/modules/m_ircv3_capnotify.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_ircv3_sts.cpp | 4 | ||||
| -rw-r--r-- | src/modules/m_knock.cpp | 10 | ||||
| -rw-r--r-- | src/modules/m_rline.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_setname.cpp | 48 | ||||
| -rw-r--r-- | src/modules/m_shun.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/main.cpp | 6 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/resolvers.cpp | 6 | ||||
| -rw-r--r-- | src/modules/m_svshold.cpp | 2 |
20 files changed, 108 insertions, 68 deletions
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; } |
