From d8562054326cb4cdc6aa67332bc1f0fbf92a95cd Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 17 Apr 2022 14:16:05 +0100 Subject: [PATCH 1/4] Fix doxygen to include the public module header files. --- docs/Doxyfile | 3 +-- include/modules/ircv3_replies.h | 1 + include/modules/ircv3_servertime.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/Doxyfile b/docs/Doxyfile index 3af7e6d2d..75f236ef7 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -102,8 +102,7 @@ EXCLUDE = EXCLUDE_SYMLINKS = YES EXCLUDE_PATTERNS = */.git/* \ */doxygen/* \ - */coremods/* \ - */modules/* \ + */src/* \ */vendor/* EXCLUDE_SYMBOLS = EXAMPLE_PATH = diff --git a/include/modules/ircv3_replies.h b/include/modules/ircv3_replies.h index a97477368..05f3a7d63 100644 --- a/include/modules/ircv3_replies.h +++ b/include/modules/ircv3_replies.h @@ -191,6 +191,7 @@ class IRCv3::Replies::Reply * Sends a standard reply to the specified user if they have the specified cap * or a notice if they do not. * @param user The user to send the reply to. + * @param cap The capability that determines the type of message to send. * @param command The command that the reply relates to. * @param code A machine readable code for this reply. * @param description A human readable description of this reply. diff --git a/include/modules/ircv3_servertime.h b/include/modules/ircv3_servertime.h index 4befbaaba..d2d6655d3 100644 --- a/include/modules/ircv3_servertime.h +++ b/include/modules/ircv3_servertime.h @@ -29,7 +29,7 @@ namespace IRCv3 /** Format a unix timestamp into the format used by server-time. * @param secs UNIX timestamp to format. - * @params millisecs Number of milliseconds to format. + * @param millisecs Number of milliseconds to format. * @return Time in server-time format, as a string. */ inline std::string FormatTime(time_t secs, long millisecs = 0) From 7b72365bdf29b1e0aa6dea0a5d0584fe0a76f488 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Mon, 18 Apr 2022 13:16:47 +0100 Subject: [PATCH 2/4] Also send ACCOUNT to the user who is authenticating. Closes #1974. --- src/modules/m_ircv3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/m_ircv3.cpp b/src/modules/m_ircv3.cpp index abfd10ce6..58b6fd244 100644 --- a/src/modules/m_ircv3.cpp +++ b/src/modules/m_ircv3.cpp @@ -150,7 +150,7 @@ class ModuleIRCv3 const std::string& param = (newaccount.empty() ? joinhook.asterisk : newaccount); msg.PushParamRef(param); ClientProtocol::Event accountevent(accountprotoev, msg); - IRCv3::WriteNeighborsWithCap(user, accountevent, cap_accountnotify); + IRCv3::WriteNeighborsWithCap(user, accountevent, cap_accountnotify, true); } void OnUserAway(User* user) CXX11_OVERRIDE From b122c182cc93b621b9cc05111680c01facb1da73 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 20 Apr 2022 23:57:04 +0100 Subject: [PATCH 3/4] Fix an outdated comment. --- include/inspircd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/inspircd.h b/include/inspircd.h index b0e9903f2..e199b44de 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -192,7 +192,7 @@ class CoreExport InspIRCd struct timespec TIME; /** A 64k buffer used to read socket data into - * NOTE: update ValidateNetBufferSize if you change this + * Update the range of if you change this */ char ReadBuffer[65535]; From cdd80af74c43015b9b492bc3c5eabc3ab982a0df Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 21 Apr 2022 16:16:05 +0100 Subject: [PATCH 4/4] Add support for automatically expiring the override user mode. --- docs/conf/modules.conf.example | 9 ++++++- src/modules/m_override.cpp | 44 +++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index 9f4ef245c..69022ebd8 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -1688,9 +1688,16 @@ # requirekey - If enabled, overriding on join requires a channel # # key of "override" to be specified. # # # +# timeout: The time period after which to automatically remove # +# the override user mode. If not set then it will not # +# be removed automatically. # +# # # enableumode - If enabled, user mode +O is required for override. # # # -# +# #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Oper levels module: Gives each oper a level and prevents actions diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index c75b022e3..33add918a 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -34,15 +34,56 @@ #include "inspircd.h" #include "modules/invite.h" +class UnsetTimer CXX11_FINAL + : public Timer +{ + private: + ModeHandler& overridemode; + LocalUser* user; + + public: + UnsetTimer(LocalUser* u, unsigned long timeout, ModeHandler& om) + : Timer(timeout, false) + , overridemode(om) + , user(u) + { + ServerInstance->Timers.AddTimer(this); + } + + bool Tick(time_t time) CXX11_OVERRIDE + { + if (!user->quitting && user->IsModeSet(overridemode)) + { + Modes::ChangeList changelist; + changelist.push_remove(&overridemode); + ServerInstance->Modes.Process(ServerInstance->FakeClient, NULL, user, changelist); + } + return false; + } +}; + class Override : public SimpleUserModeHandler { public: - Override(Module* Creator) : SimpleUserModeHandler(Creator, "override", 'O') + SimpleExtItem ext; + unsigned long timeout; + + Override(Module* Creator) + : SimpleUserModeHandler(Creator, "override", 'O') + , ext("override-timer", ExtensionItem::EXT_USER, Creator) { oper = true; if (!ServerInstance->Config->ConfValue("override")->getBool("enableumode")) DisableAutoRegister(); } + + ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string& parameter, bool adding) CXX11_OVERRIDE + { + ModeAction res = SimpleUserModeHandler::OnModeChange(source, dest, channel, parameter, adding); + if (adding && res == MODEACTION_ALLOW && IS_LOCAL(dest) && timeout) + ext.set(dest, new UnsetTimer(IS_LOCAL(dest), timeout, *this)); + return res; + } }; class ModuleOverride : public Module @@ -107,6 +148,7 @@ class ModuleOverride : public Module ConfigTag* tag = ServerInstance->Config->ConfValue("override"); NoisyOverride = tag->getBool("noisy"); RequireKey = tag->getBool("requirekey"); + ou.timeout = tag->getDuration("timeout", 0); } void On005Numeric(std::map& tokens) CXX11_OVERRIDE