From d5b50d9ed107d6a8b9241a831c1dae713963b524 Mon Sep 17 00:00:00 2001 From: Matt Schatz Date: Thu, 24 Jan 2019 09:01:56 -0700 Subject: Add the reason to xline removal notices. (#1545) Show the reason in manual xline removal SNOTICEs, just like expiry SNOTICEs do. This modifies XLineManager::DelLine() to require another string reference passed to it. Requested by @Robby-.--- src/modules/m_cban.cpp | 6 ++++-- src/modules/m_rline.cpp | 6 ++++-- src/modules/m_shun.cpp | 10 ++++++---- src/modules/m_spanningtree/delline.cpp | 7 ++++--- src/modules/m_svshold.cpp | 6 ++++-- 5 files changed, 22 insertions(+), 13 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp index 3cdbbbdfb..8d08de9d9 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -98,9 +98,11 @@ class CommandCBan : public Command if (parameters.size() == 1) { - if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "CBAN", user)) + std::string reason; + + if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "CBAN", reason, user)) { - ServerInstance->SNO->WriteGlobalSno('x', "%s removed CBan on %s.",user->nick.c_str(),parameters[0].c_str()); + ServerInstance->SNO->WriteGlobalSno('x', "%s removed CBan on %s: %s", user->nick.c_str(), parameters[0].c_str(), reason.c_str()); } else { diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index 1247e81d3..1eb2d8ac3 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -190,9 +190,11 @@ class CommandRLine : public Command } else { - if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "R", user)) + std::string reason; + + if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "R", reason, user)) { - ServerInstance->SNO->WriteToSnoMask('x',"%s removed R-line on %s",user->nick.c_str(),parameters[0].c_str()); + ServerInstance->SNO->WriteToSnoMask('x', "%s removed R-line on %s: %s", user->nick.c_str(), parameters[0].c_str(), reason.c_str()); } else { diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 6453ace81..cd2743ab0 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -69,13 +69,15 @@ class CommandShun : public Command if (parameters.size() == 1) { - if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "SHUN", user)) + std::string reason; + + if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "SHUN", reason, user)) { - ServerInstance->SNO->WriteToSnoMask('x', "%s removed SHUN on %s", user->nick.c_str(), parameters[0].c_str()); + ServerInstance->SNO->WriteToSnoMask('x', "%s removed SHUN on %s: %s", user->nick.c_str(), parameters[0].c_str(), reason.c_str()); } - else if (ServerInstance->XLines->DelLine(target.c_str(), "SHUN", user)) + else if (ServerInstance->XLines->DelLine(target.c_str(), "SHUN", reason, user)) { - ServerInstance->SNO->WriteToSnoMask('x',"%s removed SHUN on %s", user->nick.c_str(), target.c_str()); + ServerInstance->SNO->WriteToSnoMask('x', "%s removed SHUN on %s: %s", user->nick.c_str(), target.c_str(), reason.c_str()); } else { diff --git a/src/modules/m_spanningtree/delline.cpp b/src/modules/m_spanningtree/delline.cpp index c64bec654..e376147fd 100644 --- a/src/modules/m_spanningtree/delline.cpp +++ b/src/modules/m_spanningtree/delline.cpp @@ -25,12 +25,13 @@ CmdResult CommandDelLine::Handle(User* user, Params& params) { const std::string& setter = user->nick; + std::string reason; // XLineManager::DelLine() returns true if the xline existed, false if it didn't - if (ServerInstance->XLines->DelLine(params[1].c_str(), params[0], user)) + if (ServerInstance->XLines->DelLine(params[1].c_str(), params[0], reason, user)) { - ServerInstance->SNO->WriteToSnoMask('X',"%s removed %s%s on %s", setter.c_str(), - params[0].c_str(), params[0].length() == 1 ? "-line" : "", params[1].c_str()); + ServerInstance->SNO->WriteToSnoMask('X', "%s removed %s%s on %s: %s", setter.c_str(), + params[0].c_str(), params[0].length() == 1 ? "-line" : "", params[1].c_str(), reason.c_str()); return CMD_SUCCESS; } return CMD_FAILURE; diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index 0aaf113f0..73fde6582 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -112,10 +112,12 @@ class CommandSvshold : public Command if (parameters.size() == 1) { - if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "SVSHOLD", user)) + std::string reason; + + if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "SVSHOLD", reason, user)) { if (!silent) - ServerInstance->SNO->WriteToSnoMask('x',"%s removed SVSHOLD on %s",user->nick.c_str(),parameters[0].c_str()); + ServerInstance->SNO->WriteToSnoMask('x', "%s removed SVSHOLD on %s: %s", user->nick.c_str(), parameters[0].c_str(), reason.c_str()); } else { -- cgit v1.3.1-10-gc9f91 From 963213132dd923d0e7dbd47ea6f20373cdef343b Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Thu, 24 Jan 2019 17:56:52 +0000 Subject: Fix parsing anticaps mode parameters. --- src/modules/m_anticaps.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_anticaps.cpp b/src/modules/m_anticaps.cpp index 6cb9b940b..aa605e6ed 100644 --- a/src/modules/m_anticaps.cpp +++ b/src/modules/m_anticaps.cpp @@ -34,9 +34,9 @@ class AntiCapsSettings public: const AntiCapsMethod method; const uint16_t minlen; - const uint8_t percent; + const uint16_t percent; - AntiCapsSettings(const AntiCapsMethod& Method, const uint16_t& MinLen, const uint8_t& Percent) + AntiCapsSettings(const AntiCapsMethod& Method, const uint16_t& MinLen, const uint16_t& Percent) : method(Method) , minlen(MinLen) , percent(Percent) @@ -83,13 +83,13 @@ class AntiCapsMode : public ParamMode(percentstr); + uint16_t result = ConvToNum(percentstr); if (result < 1 || result > 100) return false; @@ -108,7 +108,7 @@ class AntiCapsMode : public ParamMode # #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# -# Connection class ban module: Adds support for extban 'n' which +# Connection class ban module: Adds support for extban 'n' which # matches against the class name of the user's connection. # This module assumes that connection classes are named in a uniform # way on all servers of the network. @@ -1532,7 +1532,7 @@ # Oper modes module: Allows you to specify modes to add/remove on oper. # Specify the modes as the 'modes' parameter of the tag # and/or as the 'modes' parameter of the tag. -# This module is oper-only. For the user equivalent, see the +# This module is oper-only. For the user equivalent, see the # conn_umodes module. # diff --git a/include/message.h b/include/message.h index 7a968d866..1624a1de4 100644 --- a/include/message.h +++ b/include/message.h @@ -63,7 +63,7 @@ class CoreExport MessageDetails * @param body The location to store the parsed CTCP body. */ virtual bool IsCTCP(std::string& name, std::string& body) const = 0; - + /** Determines whether the specified message is a CTCP. If the specified message * is a CTCP then the CTCP name is extracted and stored in the name reference. * @param name The location to store the parsed CTCP name. diff --git a/include/modules/server.h b/include/modules/server.h index 54ea5d58c..f9907ef26 100644 --- a/include/modules/server.h +++ b/include/modules/server.h @@ -65,5 +65,4 @@ class ServerEventListener : public Events::ModuleEventListener * @param server The target of the burst. */ virtual void OnSyncNetwork(ProtocolServer& server) { } - }; diff --git a/make/calcdep.pl b/make/calcdep.pl index 5dc0f6878..279fdffce 100755 --- a/make/calcdep.pl +++ b/make/calcdep.pl @@ -112,7 +112,7 @@ END } } } - + my $core_mk = join ' ', @core_deps; my $mods = join ' ', @modlist; print MAKE < dirname dirname __FILE__; +use constant CONFIGURE_ROOT => dirname dirname __FILE__; use constant CONFIGURE_DIRECTORY => catdir(CONFIGURE_ROOT, '.configure'); use constant CONFIGURE_CACHE_FILE => catfile(CONFIGURE_DIRECTORY, 'cache.cfg'); use constant CONFIGURE_CACHE_VERSION => '1'; diff --git a/make/directive.pm b/make/directive.pm index ef6bb1bf5..c0c2aee85 100644 --- a/make/directive.pm +++ b/make/directive.pm @@ -164,7 +164,7 @@ sub __function_execute { return $defaults; } - # Executing the command failed and we don't have any defaults so give up. + # Executing the command failed and we don't have any defaults so give up. __error $file, "`<|GREEN $command|>` exited with a non-zero exit code!"; } diff --git a/make/template/inspircd.1 b/make/template/inspircd.1 index 38dd7dea4..2bc8fd044 100644 --- a/make/template/inspircd.1 +++ b/make/template/inspircd.1 @@ -24,7 +24,7 @@ .BR .SH "SYNOPSIS" -\t\fBinspircd\fR [--config ] [--debug] [--nofork] [--nolog] [--nopid] [--runasroot] [--version] +\t\fBinspircd\fR [--config ] [--debug] [--nofork] [--nolog] [--nopid] [--runasroot] [--version] .SH "OPTIONS" .TP diff --git a/src/coremods/core_oper/core_oper.cpp b/src/coremods/core_oper/core_oper.cpp index d4afab3b8..be4b87714 100644 --- a/src/coremods/core_oper/core_oper.cpp +++ b/src/coremods/core_oper/core_oper.cpp @@ -42,9 +42,8 @@ class CoreModOper : public Module void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { - ConfigTag* tag = ServerInstance->Config->ConfValue("power"); - + // The hash method for *BOTH* the die and restart passwords powerhash = tag->getString("hash"); diff --git a/src/coremods/core_serialize_rfc.cpp b/src/coremods/core_serialize_rfc.cpp index 23a4c2052..6b693bfb9 100644 --- a/src/coremods/core_serialize_rfc.cpp +++ b/src/coremods/core_serialize_rfc.cpp @@ -59,7 +59,7 @@ bool RFCSerializer::Parse(LocalUser* user, const std::string& line, ClientProtoc // Work out how long the message can actually be. size_t maxline = ServerInstance->Config->Limits.MaxLine - start - 2; if (line[start] == '@') - maxline += MAX_CLIENT_MESSAGE_TAG_LENGTH + 1; + maxline += MAX_CLIENT_MESSAGE_TAG_LENGTH + 1; irc::tokenstream tokens(line, start, maxline); ServerInstance->Logs->Log("USERINPUT", LOG_RAWIO, "C[%s] I %s", user->uuid.c_str(), tokens.GetMessage().c_str()); diff --git a/src/coremods/core_whois.cpp b/src/coremods/core_whois.cpp index 0db634810..880e5a533 100644 --- a/src/coremods/core_whois.cpp +++ b/src/coremods/core_whois.cpp @@ -365,7 +365,7 @@ class CoreModWhois : public Module else if (stdalgo::string::equalsci(splitwhois, "splitmsg")) newsplitstate = SPLITWHOIS_SPLITMSG; else - throw ModuleException(splitwhois + " is an invalid value, at " + tag->getTagLocation()); + throw ModuleException(splitwhois + " is an invalid value, at " + tag->getTagLocation()); ConfigTag* security = ServerInstance->Config->ConfValue("security"); cmd.genericoper = security->getBool("genericoper"); diff --git a/src/inspstring.cpp b/src/inspstring.cpp index 79aef52bd..faf34be91 100644 --- a/src/inspstring.cpp +++ b/src/inspstring.cpp @@ -136,7 +136,6 @@ void TokenList::AddList(const std::string& tokenlist) else Add(token); } - } void TokenList::Add(const std::string& token) { diff --git a/src/mode.cpp b/src/mode.cpp index 459eb21c8..50dd05d2d 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -607,7 +607,7 @@ void ModeParser::AddMode(ModeHandler* mh) if ((mh->GetModeType() == MODETYPE_USER) || (mh->IsParameterMode()) || (!mh->IsListMode())) modeid = AllocateModeId(mh->GetModeType()); - std::pair res = modehandlersbyname[mh->GetModeType()].insert(std::make_pair(mh->name, mh)); + std::pair res = modehandlersbyname[mh->GetModeType()].insert(std::make_pair(mh->name, mh)); if (!res.second) { ModeHandler* othermh = res.first->second; diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index df8201bde..4c89ad894 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -311,7 +311,7 @@ class ModuleCgiIRC } else { - throw ModuleException(type + " is an invalid type, at " + tag->getTagLocation()); + throw ModuleException(type + " is an invalid type, at " + tag->getTagLocation()); } } @@ -369,7 +369,7 @@ class ModuleCgiIRC user->ChangeIdent(newident); user->SetClientIP(address); - break; + break; } return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 3b00d3347..d9b2eb789 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -210,24 +210,24 @@ class ModuleCloaking : public Module { // The position at which we found the last dot. std::string::const_reverse_iterator dotpos; - + // The number of dots we have seen so far. unsigned int seendots = 0; - + for (std::string::const_reverse_iterator iter = host.rbegin(); iter != host.rend(); ++iter) { if (*iter != '.') continue; - + // We have found a dot! dotpos = iter; seendots += 1; - + // Do we have enough segments to stop? if (seendots >= domainparts) break; } - + // We only returns a domain part if more than one label is // present. See above for a full explanation. if (!seendots) @@ -435,7 +435,7 @@ class ModuleCloaking : public Module else if (stdalgo::string::equalsci(mode, "full")) newcloaks.push_back(CloakInfo(MODE_OPAQUE, key, prefix, suffix)); else - throw ModuleException(mode + " is an invalid value for ; acceptable values are 'half' and 'full', at " + tag->getTagLocation()); + throw ModuleException(mode + " is an invalid value for ; acceptable values are 'half' and 'full', at " + tag->getTagLocation()); } // The cloak configuration was valid so we can apply it. diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp index 4c9b24140..be503ba6b 100644 --- a/src/modules/m_hostchange.cpp +++ b/src/modules/m_hostchange.cpp @@ -34,7 +34,7 @@ class HostRule // Add the user's nickname to their hostname. HCA_ADDNICK, - // Set the user's hostname to the specific value. + // Set the user's hostname to the specific value. HCA_SET }; @@ -168,7 +168,7 @@ private: } else { - throw ModuleException(action + " is an invalid type, at " + tag->getTagLocation()); + throw ModuleException(action + " is an invalid type, at " + tag->getTagLocation()); } } diff --git a/src/modules/m_ircv3_sts.cpp b/src/modules/m_ircv3_sts.cpp index cbfdd1307..a8738b2ac 100644 --- a/src/modules/m_ircv3_sts.cpp +++ b/src/modules/m_ircv3_sts.cpp @@ -130,7 +130,7 @@ class ModuleIRCv3STS : public Module for (std::vector::const_iterator iter = ServerInstance->ports.begin(); iter != ServerInstance->ports.end(); ++iter) { ListenSocket* ls = *iter; - + // Is this listener on the right port? unsigned int saport = ls->bind_sa.port(); if (saport != port) diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp index d01e1a83b..70c149273 100644 --- a/src/modules/m_showwhois.cpp +++ b/src/modules/m_showwhois.cpp @@ -51,7 +51,7 @@ class WhoisNoticeCmd : public Command void HandleFast(User* dest, User* src) { dest->WriteNotice("*** " + src->nick + " (" + src->ident + "@" + - src->GetHost(dest->HasPrivPermission("users/auspex")) + + src->GetHost(dest->HasPrivPermission("users/auspex")) + ") did a /whois on you"); } diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index 01af56fa6..0729065fc 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -134,7 +134,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, CommandBase::Params } CmdResult CommandFHost::HandleRemote(RemoteUser* src, Params& params) -{ +{ src->ChangeDisplayedHost(params[0]); return CMD_SUCCESS; } diff --git a/src/socket.cpp b/src/socket.cpp index d48a1907c..b33664f84 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -39,7 +39,7 @@ bool InspIRCd::BindPort(ConfigTag* tag, const irc::sockets::sockaddrs& sa, std:: return true; } } - + ListenSocket* ll = new ListenSocket(tag, sa); if (ll->GetFd() < 0) { diff --git a/src/users.cpp b/src/users.cpp index 506cdf6d8..fd794d386 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1026,7 +1026,7 @@ void User::ChangeRealHost(const std::string& host, bool resetdisplay) const bool changehost = (realhost != host); if (!changehost && !resetdisplay) return; - + // If the displayhost is not set and we are not resetting it then // we need to copy it to the displayhost field. if (displayhost.empty() && !resetdisplay) -- cgit v1.3.1-10-gc9f91 From fa6cfec3f8befcc650214b37664569e52f21e6b8 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 25 Jan 2019 10:57:37 +0000 Subject: Fix sending the SSL connection notice when using a non-SSL gateway. --- src/modules/m_sslinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index 30dfd9a76..d3514eac6 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -251,7 +251,7 @@ class ModuleSSLInfo return; const SSLIOHook* const ssliohook = SSLIOHook::IsSSL(&localuser->eh); - if (!ssliohook) + if (!ssliohook || cmd.sslapi.nosslext.get(localuser)) return; ssl_cert* const cert = ssliohook->GetCertificate(); -- cgit v1.3.1-10-gc9f91 From 5ed970ca7d4e079ca9ff577974572a577c65e823 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 28 Jan 2019 10:31:55 +0000 Subject: Fix parsing anticaps mode parameters (again). It is better to fix the underlying bug than the result of it. This replaces commit 963213132dd923d0e7dbd47ea6f20373cdef343b. --- src/modules/m_anticaps.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_anticaps.cpp b/src/modules/m_anticaps.cpp index aa605e6ed..e916edd53 100644 --- a/src/modules/m_anticaps.cpp +++ b/src/modules/m_anticaps.cpp @@ -34,9 +34,9 @@ class AntiCapsSettings public: const AntiCapsMethod method; const uint16_t minlen; - const uint16_t percent; + const uint8_t percent; - AntiCapsSettings(const AntiCapsMethod& Method, const uint16_t& MinLen, const uint16_t& Percent) + AntiCapsSettings(const AntiCapsMethod& Method, const uint16_t& MinLen, const uint8_t& Percent) : method(Method) , minlen(MinLen) , percent(Percent) @@ -83,13 +83,13 @@ class AntiCapsMode : public ParamMode(percentstr); + uint8_t result = ConvToNum(percentstr); if (result < 1 || result > 100) return false; @@ -108,7 +108,7 @@ class AntiCapsMode : public ParamModeminlen)); out.push_back(':'); - out.append(ConvToStr(acs->percent)); + out.append(ConvNumeric(acs->percent)); } }; -- cgit v1.3.1-10-gc9f91 From e84858dc7f1efdfb76efc1e115e6999fd222af74 Mon Sep 17 00:00:00 2001 From: linuxdaemon Date: Mon, 28 Jan 2019 10:39:07 -0600 Subject: Refactor m_httpd_stats, add subpages (#1554) --- src/modules/m_httpd_stats.cpp | 414 +++++++++++++++++++++++++----------------- 1 file changed, 247 insertions(+), 167 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 6db292eb3..4b18eadc4 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -25,34 +25,41 @@ #include "modules/httpd.h" #include "xline.h" -class ModuleHttpStats : public Module, public HTTPRequestEventListener +namespace Stats { - static const insp::flat_map& entities; - HTTPdAPI API; + struct Entities + { + static const insp::flat_map& entities; + }; - public: - ModuleHttpStats() - : HTTPRequestEventListener(this) - , API(this) + static const insp::flat_map& init_entities() { + static insp::flat_map entities; + entities['<'] = "lt"; + entities['>'] = "gt"; + entities['&'] = "amp"; + entities['"'] = "quot"; + return entities; } - std::string Sanitize(const std::string &str) + const insp::flat_map& Entities::entities = init_entities(); + + std::string Sanitize(const std::string& str) { std::string ret; ret.reserve(str.length() * 2); for (std::string::const_iterator x = str.begin(); x != str.end(); ++x) { - insp::flat_map::const_iterator it = entities.find(*x); + insp::flat_map::const_iterator it = Entities::entities.find(*x); - if (it != entities.end()) + if (it != Entities::entities.end()) { ret += '&'; ret += it->second; ret += ';'; } - else if (*x == 0x09 || *x == 0x0A || *x == 0x0D || ((*x >= 0x20) && (*x <= 0x7e))) + else if (*x == 0x09 || *x == 0x0A || *x == 0x0D || ((*x >= 0x20) && (*x <= 0x7e))) { // The XML specification defines the following characters as valid inside an XML document: // Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] @@ -73,10 +80,10 @@ class ModuleHttpStats : public Module, public HTTPRequestEventListener return ret; } - void DumpMeta(std::stringstream& data, Extensible* ext) + void DumpMeta(std::ostream& data, Extensible* ext) { data << ""; - for(Extensible::ExtensibleStore::const_iterator i = ext->GetExtList().begin(); i != ext->GetExtList().end(); i++) + for (Extensible::ExtensibleStore::const_iterator i = ext->GetExtList().begin(); i != ext->GetExtList().end(); i++) { ExtensionItem* item = i->first; std::string value = item->serialize(FORMAT_USER, ext, i->second); @@ -88,156 +95,241 @@ class ModuleHttpStats : public Module, public HTTPRequestEventListener data << ""; } - ModResult HandleRequest(HTTPRequest* http) + std::ostream& ServerInfo(std::ostream& data) + { + return data << "" << ServerInstance->Config->ServerName << "" + << Sanitize(ServerInstance->Config->ServerDesc) << "" + << Sanitize(ServerInstance->GetVersionString()) << ""; + } + + std::ostream& ISupport(std::ostream& data) + { + data << ""; + const std::vector& isupport = ServerInstance->ISupport.GetLines(); + for (std::vector::const_iterator i = isupport.begin(); i != isupport.end(); ++i) + { + const Numeric::Numeric& num = *i; + for (std::vector::const_iterator j = num.GetParams().begin(); j != num.GetParams().end() - 1; ++j) + data << "" << Sanitize(*j) << ""; + } + return data << ""; + } + + std::ostream& General(std::ostream& data) + { + data << ""; + data << "" << ServerInstance->Users->GetUsers().size() << ""; + data << "" << ServerInstance->Users->GetLocalUsers().size() << ""; + data << "" << ServerInstance->GetChans().size() << ""; + data << "" << ServerInstance->Users->all_opers.size() << ""; + data << "" << (SocketEngine::GetUsedFds()) << "" << SocketEngine::GetMaxFds() << ""; + data << "" << ServerInstance->startup_time << ""; + + data << ISupport; + return data << ""; + } + + std::ostream& XLines(std::ostream& data) + { + data << ""; + std::vector xltypes = ServerInstance->XLines->GetAllTypes(); + for (std::vector::iterator it = xltypes.begin(); it != xltypes.end(); ++it) + { + XLineLookup* lookup = ServerInstance->XLines->GetAll(*it); + + if (!lookup) + continue; + for (LookupIter i = lookup->begin(); i != lookup->end(); ++i) + { + data << "c_str() << "\">" + << Sanitize(i->second->Displayable()) << "" + << i->second->set_time << "" << i->second->duration + << "" << Sanitize(i->second->reason) + << ""; + } + } + return data << ""; + } + + std::ostream& Modules(std::ostream& data) { - std::stringstream data(""); + data << ""; + const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules(); + for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i) { - ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Handling httpd event"); + Version v = i->second->GetVersion(); + data << "" << i->first << "" << Sanitize(v.description) << ""; + } + return data << ""; + } - if ((http->GetURI() == "/stats") || (http->GetURI() == "/stats/")) + std::ostream& Channels(std::ostream& data) + { + data << ""; + + const chan_hash& chans = ServerInstance->GetChans(); + for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i) + { + Channel* c = i->second; + + data << ""; + data << "" << c->GetUsers().size() << "" << Sanitize(c->name) << ""; + data << ""; + data << "" << Sanitize(c->topic) << ""; + data << "" << Sanitize(c->setby) << ""; + data << "" << c->topicset << ""; + data << ""; + data << "" << Sanitize(c->ChanModes(true)) << ""; + + const Channel::MemberMap& ulist = c->GetUsers(); + for (Channel::MemberMap::const_iterator x = ulist.begin(); x != ulist.end(); ++x) { - data << "" << ServerInstance->Config->ServerName << "" - << Sanitize(ServerInstance->Config->ServerDesc) << "" - << Sanitize(ServerInstance->GetVersionString()) << ""; - - data << ""; - data << "" << ServerInstance->Users->GetUsers().size() << ""; - data << "" << ServerInstance->GetChans().size() << ""; - data << "" << ServerInstance->Users->all_opers.size() << ""; - data << "" << (SocketEngine::GetUsedFds()) << "" << SocketEngine::GetMaxFds() << ""; - data << "" << ServerInstance->startup_time << ""; - - data << ""; - const std::vector& isupport = ServerInstance->ISupport.GetLines(); - for (std::vector::const_iterator i = isupport.begin(); i != isupport.end(); ++i) - { - const Numeric::Numeric& num = *i; - for (std::vector::const_iterator j = num.GetParams().begin(); j != num.GetParams().end()-1; ++j) - data << "" << Sanitize(*j) << "" << std::endl; - } - data << ""; - std::vector xltypes = ServerInstance->XLines->GetAllTypes(); - for (std::vector::iterator it = xltypes.begin(); it != xltypes.end(); ++it) - { - XLineLookup* lookup = ServerInstance->XLines->GetAll(*it); - - if (!lookup) - continue; - for (LookupIter i = lookup->begin(); i != lookup->end(); ++i) - { - data << "c_str() << "\">" - << Sanitize(i->second->Displayable()) << "" - << i->second->set_time << "" << i->second->duration - << "" << Sanitize(i->second->reason) - << ""; - } - } - - data << ""; - const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules(); - - for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i) - { - Version v = i->second->GetVersion(); - data << "" << i->first << "" << Sanitize(v.description) << ""; - } - data << ""; - - const chan_hash& chans = ServerInstance->GetChans(); - for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i) - { - Channel* c = i->second; - - data << ""; - data << "" << c->GetUsers().size() << "" << Sanitize(c->name) << ""; - data << ""; - data << "" << Sanitize(c->topic) << ""; - data << "" << Sanitize(c->setby) << ""; - data << "" << c->topicset << ""; - data << ""; - data << "" << Sanitize(c->ChanModes(true)) << ""; - - const Channel::MemberMap& ulist = c->GetUsers(); - for (Channel::MemberMap::const_iterator x = ulist.begin(); x != ulist.end(); ++x) - { - Membership* memb = x->second; - data << "" << memb->user->uuid << "" - << Sanitize(memb->GetAllPrefixChars()) << "" - << memb->modes << ""; - DumpMeta(data, memb); - data << ""; - } - - DumpMeta(data, c); - - data << ""; - } - - data << ""; - - const user_hash& users = ServerInstance->Users->GetUsers(); - for (user_hash::const_iterator i = users.begin(); i != users.end(); ++i) - { - User* u = i->second; - - data << ""; - data << "" << u->nick << "" << u->uuid << "" - << u->GetRealHost() << "" << u->GetDisplayedHost() << "" - << Sanitize(u->GetRealName()) << "" << u->server->GetName() << ""; - if (u->IsAway()) - data << "" << Sanitize(u->awaymsg) << "" << u->awaytime << ""; - if (u->IsOper()) - data << "" << Sanitize(u->oper->name) << ""; - data << "" << u->GetModeLetters().substr(1) << "" << Sanitize(u->ident) << ""; - LocalUser* lu = IS_LOCAL(u); - if (lu) - data << "" << lu->GetServerPort() << "" - << lu->server_sa.str() << ""; - data << "" << u->GetIPString() << ""; - - DumpMeta(data, u); - - data << ""; - } - - data << ""; - - ProtocolInterface::ServerList sl; - ServerInstance->PI->GetServerList(sl); - - for (ProtocolInterface::ServerList::const_iterator b = sl.begin(); b != sl.end(); ++b) - { - data << ""; - data << "" << b->servername << ""; - data << "" << b->parentname << ""; - data << "" << Sanitize(b->description) << ""; - data << "" << b->usercount << ""; + Membership* memb = x->second; + data << "" << memb->user->uuid << "" + << Sanitize(memb->GetAllPrefixChars()) << "" + << memb->modes << ""; + DumpMeta(data, memb); + data << ""; + } + + DumpMeta(data, c); + + data << ""; + } + + return data << ""; + } + + std::ostream& Users(std::ostream& data) + { + data << ""; + const user_hash& users = ServerInstance->Users->GetUsers(); + for (user_hash::const_iterator i = users.begin(); i != users.end(); ++i) + { + User* u = i->second; + + data << ""; + data << "" << u->nick << "" << u->uuid << "" + << u->GetRealHost() << "" << u->GetDisplayedHost() << "" + << Sanitize(u->GetRealName()) << "" << u->server->GetName() << ""; + if (u->IsAway()) + data << "" << Sanitize(u->awaymsg) << "" << u->awaytime << ""; + if (u->IsOper()) + data << "" << Sanitize(u->oper->name) << ""; + data << "" << u->GetModeLetters().substr(1) << "" << Sanitize(u->ident) << ""; + LocalUser* lu = IS_LOCAL(u); + if (lu) + data << "" << lu->GetServerPort() << "" + << lu->server_sa.str() << ""; + data << "" << u->GetIPString() << ""; + + DumpMeta(data, u); + + data << ""; + } + return data << ""; + } + + std::ostream& Servers(std::ostream& data) + { + data << ""; + + ProtocolInterface::ServerList sl; + ServerInstance->PI->GetServerList(sl); + + for (ProtocolInterface::ServerList::const_iterator b = sl.begin(); b != sl.end(); ++b) + { + data << ""; + data << "" << b->servername << ""; + data << "" << b->parentname << ""; + data << "" << Sanitize(b->description) << ""; + data << "" << b->usercount << ""; // This is currently not implemented, so, commented out. // data << "" << b->opercount << ""; - data << "" << b->latencyms << ""; - data << ""; - } - - data << ""; - - const CommandParser::CommandMap& commands = ServerInstance->Parser.GetCommands(); - for (CommandParser::CommandMap::const_iterator i = commands.begin(); i != commands.end(); ++i) - { - data << "" << i->second->name << "" << i->second->use_count << ""; - } - - data << ""; - - /* Send the document back to m_httpd */ - HTTPDocumentResponse response(this, *http, &data, 200); - response.headers.SetHeader("X-Powered-By", MODNAME); - response.headers.SetHeader("Content-Type", "text/xml"); - API->SendResponse(response); - return MOD_RES_DENY; // Handled - } + data << "" << b->latencyms << ""; + data << ""; + } + + return data << ""; + } + + std::ostream& Commands(std::ostream& data) + { + data << ""; + + const CommandParser::CommandMap& commands = ServerInstance->Parser.GetCommands(); + for (CommandParser::CommandMap::const_iterator i = commands.begin(); i != commands.end(); ++i) + { + data << "" << i->second->name << "" << i->second->use_count << ""; + } + return data << ""; + } +} + +class ModuleHttpStats : public Module, public HTTPRequestEventListener +{ + HTTPdAPI API; + + public: + ModuleHttpStats() + : HTTPRequestEventListener(this) + , API(this) + { + } + + ModResult HandleRequest(HTTPRequest* http) + { + std::string uri = http->GetURI(); + + if (uri != "/stats" && uri.substr(0, 7) != "/stats/") + return MOD_RES_PASSTHRU; + + if (uri[uri.size() - 1] == '/') + uri.erase(uri.size() - 1, 1); + + ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Handling httpd event"); + + bool found = true; + std::stringstream data; + data << ""; + + if (uri == "/stats") + { + data << Stats::ServerInfo << Stats::General + << Stats::XLines << Stats::Modules + << Stats::Channels << Stats::Users + << Stats::Servers << Stats::Commands; + } + else if (uri == "/stats/general") + { + data << Stats::General; + } + else if (uri == "/stats/users") + { + data << Stats::Users; } - return MOD_RES_PASSTHRU; + else + { + found = false; + } + + if (found) + { + data << ""; + } + else + { + data.clear(); + data.str(std::string()); + } + + /* Send the document back to m_httpd */ + HTTPDocumentResponse response(this, *http, &data, found ? 200 : 404); + response.headers.SetHeader("X-Powered-By", MODNAME); + response.headers.SetHeader("Content-Type", "text/xml"); + API->SendResponse(response); + return MOD_RES_DENY; // Handled } ModResult OnHTTPRequest(HTTPRequest& req) CXX11_OVERRIDE @@ -251,16 +343,4 @@ class ModuleHttpStats : public Module, public HTTPRequestEventListener } }; -static const insp::flat_map& init_entities() -{ - static insp::flat_map entities; - entities['<'] = "lt"; - entities['>'] = "gt"; - entities['&'] = "amp"; - entities['"'] = "quot"; - return entities; -} - -const insp::flat_map& ModuleHttpStats::entities = init_entities(); - MODULE_INIT(ModuleHttpStats) -- cgit v1.3.1-10-gc9f91 From 4818b1bc1b0dd8560b0c83901aa33ecaf6fb1275 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 28 Jan 2019 16:45:14 +0000 Subject: Fix not checking for server names case insensitively. --- src/coremods/core_info/cmd_admin.cpp | 2 +- src/coremods/core_info/cmd_info.cpp | 2 +- src/coremods/core_info/cmd_modules.cpp | 2 +- src/coremods/core_info/cmd_motd.cpp | 2 +- src/coremods/core_info/cmd_time.cpp | 2 +- src/coremods/core_stats.cpp | 2 +- src/modules/m_check.cpp | 2 +- src/modules/m_opermotd.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/modules') diff --git a/src/coremods/core_info/cmd_admin.cpp b/src/coremods/core_info/cmd_admin.cpp index 44827555d..58a799d77 100644 --- a/src/coremods/core_info/cmd_admin.cpp +++ b/src/coremods/core_info/cmd_admin.cpp @@ -32,7 +32,7 @@ CommandAdmin::CommandAdmin(Module* parent) */ CmdResult CommandAdmin::Handle(User* user, const Params& parameters) { - if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName) + if (parameters.size() > 0 && !irc::equals(parameters[0], ServerInstance->Config->ServerName)) return CMD_SUCCESS; user->WriteRemoteNumeric(RPL_ADMINME, InspIRCd::Format("Administrative info for %s", ServerInstance->Config->ServerName.c_str())); if (!AdminName.empty()) diff --git a/src/coremods/core_info/cmd_info.cpp b/src/coremods/core_info/cmd_info.cpp index ee0794934..431175f7a 100644 --- a/src/coremods/core_info/cmd_info.cpp +++ b/src/coremods/core_info/cmd_info.cpp @@ -78,7 +78,7 @@ static const char* const lines[] = { */ CmdResult CommandInfo::Handle(User* user, const Params& parameters) { - if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName) + if (parameters.size() > 0 && !irc::equals(parameters[0], ServerInstance->Config->ServerName)) return CMD_SUCCESS; int i=0; diff --git a/src/coremods/core_info/cmd_modules.cpp b/src/coremods/core_info/cmd_modules.cpp index 7212e9525..d68c8b9fd 100644 --- a/src/coremods/core_info/cmd_modules.cpp +++ b/src/coremods/core_info/cmd_modules.cpp @@ -42,7 +42,7 @@ CmdResult CommandModules::Handle(User* user, const Params& parameters) { // Don't ask remote servers about their modules unless the local user asking is an oper // 2.0 asks anyway, so let's handle that the same way - bool for_us = (parameters.empty() || parameters[0] == ServerInstance->Config->ServerName); + bool for_us = (parameters.empty() || irc::equals(parameters[0], ServerInstance->Config->ServerName)); if ((!for_us) || (!IS_LOCAL(user))) { if (!user->IsOper()) diff --git a/src/coremods/core_info/cmd_motd.cpp b/src/coremods/core_info/cmd_motd.cpp index e4c575539..eb6460f00 100644 --- a/src/coremods/core_info/cmd_motd.cpp +++ b/src/coremods/core_info/cmd_motd.cpp @@ -31,7 +31,7 @@ CommandMotd::CommandMotd(Module* parent) */ CmdResult CommandMotd::Handle(User* user, const Params& parameters) { - if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName) + if (parameters.size() > 0 && !irc::equals(parameters[0], ServerInstance->Config->ServerName)) { // Give extra penalty if a non-oper queries the /MOTD of a remote server LocalUser* localuser = IS_LOCAL(user); diff --git a/src/coremods/core_info/cmd_time.cpp b/src/coremods/core_info/cmd_time.cpp index 73987cf01..725ef6cb5 100644 --- a/src/coremods/core_info/cmd_time.cpp +++ b/src/coremods/core_info/cmd_time.cpp @@ -29,7 +29,7 @@ CommandTime::CommandTime(Module* parent) CmdResult CommandTime::Handle(User* user, const Params& parameters) { - if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName) + if (parameters.size() > 0 && !irc::equals(parameters[0], ServerInstance->Config->ServerName)) return CMD_SUCCESS; user->WriteRemoteNumeric(RPL_TIME, ServerInstance->Config->ServerName, InspIRCd::TimeString(ServerInstance->Time())); diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp index 6a4427aef..6576aa514 100644 --- a/src/coremods/core_stats.cpp +++ b/src/coremods/core_stats.cpp @@ -378,7 +378,7 @@ void CommandStats::DoStats(Stats::Context& stats) CmdResult CommandStats::Handle(User* user, const Params& parameters) { - if (parameters.size() > 1 && parameters[1] != ServerInstance->Config->ServerName) + if (parameters.size() > 1 && !irc::equals(parameters[1], ServerInstance->Config->ServerName)) { // Give extra penalty if a non-oper does /STATS LocalUser* localuser = IS_LOCAL(user); diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 1d030acc6..2d06df199 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -142,7 +142,7 @@ class CommandCheck : public Command CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { - if (parameters.size() > 1 && parameters[1] != ServerInstance->Config->ServerName) + if (parameters.size() > 1 && !irc::equals(parameters[1], ServerInstance->Config->ServerName)) return CMD_SUCCESS; User *targuser; diff --git a/src/modules/m_opermotd.cpp b/src/modules/m_opermotd.cpp index 49409a1c0..591dc97a8 100644 --- a/src/modules/m_opermotd.cpp +++ b/src/modules/m_opermotd.cpp @@ -36,7 +36,7 @@ class CommandOpermotd : public Command CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { - if ((parameters.empty()) || (parameters[0] == ServerInstance->Config->ServerName)) + if ((parameters.empty()) || (irc::equals(parameters[0], ServerInstance->Config->ServerName))) ShowOperMOTD(user); return CMD_SUCCESS; } -- cgit v1.3.1-10-gc9f91 From a032cd90ad5582914759e226085efee5aae1a1ef Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 28 Jan 2019 19:42:02 +0000 Subject: Allow configuring whether SETNAME sends snotices and is oper-only. --- docs/conf/modules.conf.example | 12 ++++++++++++ src/modules/m_setname.cpp | 17 ++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index a10f30154..1c219cbd6 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -1925,6 +1925,18 @@ #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # SETNAME module: Adds the /SETNAME command. # +# +#-#-#-#-#-#-#-#-#-#-#-#- SETNAME CONFIGURATION -#-#-#-#-#-#-#-#-#-#-#-# +# # +# operonly - Whether the SETNAME command should only be usable by # +# server operators. Defaults to no. # +# # +# notifyopers - Whether to send a snotice to snomask `a` when the # +# server operators. Defaults to to yes if oper-only and # +# no if usable by everyone. # +# # +# # #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Serverban: Implements extended ban 's', which stops anyone connected diff --git a/src/modules/m_setname.cpp b/src/modules/m_setname.cpp index efe7028b7..ae85fc98d 100644 --- a/src/modules/m_setname.cpp +++ b/src/modules/m_setname.cpp @@ -26,6 +26,7 @@ class CommandSetname : public Command { public: + bool notifyopers; CommandSetname(Module* Creator) : Command(Creator,"SETNAME", 1, 1) { allow_empty_last_param = false; @@ -42,7 +43,9 @@ class CommandSetname : public Command if (user->ChangeRealName(parameters[0])) { - ServerInstance->SNO->WriteGlobalSno('a', "%s used SETNAME to change their real name to '%s'", user->nick.c_str(), parameters[0].c_str()); + 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; @@ -59,6 +62,18 @@ class ModuleSetName : public Module { } + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE + { + ConfigTag* tag = ServerInstance->Config->ConfValue("cgiirc"); + + // Whether the module should only be usable by server operators. + bool operonly = tag->getBool("operonly"); + cmd.flags_needed = operonly ? 'o' : 0; + + // Whether a snotice should be sent out when a user changes their real name. + cmd.notifyopers = tag->getBool("notifyopers", !operonly); + } + Version GetVersion() CXX11_OVERRIDE { return Version("Provides support for the SETNAME command", VF_VENDOR); -- cgit v1.3.1-10-gc9f91 From fd6b8bddfa69d87d04f24c3e6e5aa8629cd9b578 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 28 Jan 2019 21:54:49 +0000 Subject: Fix the prioritisation of OnRawMode in m_samode. --- src/modules/m_samode.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp index db3345b98..634464ac2 100644 --- a/src/modules/m_samode.cpp +++ b/src/modules/m_samode.cpp @@ -124,8 +124,8 @@ class ModuleSaMode : public Module void Prioritize() CXX11_OVERRIDE { - Module* disabled = ServerInstance->Modules->Find("m_disabled.so"); - ServerInstance->Modules->SetPriority(this, I_OnRawMode, PRIORITY_BEFORE, disabled); + Module* disable = ServerInstance->Modules->Find("m_disable.so"); + ServerInstance->Modules->SetPriority(this, I_OnRawMode, PRIORITY_BEFORE, disable); Module *override = ServerInstance->Modules->Find("m_override.so"); ServerInstance->Modules->SetPriority(this, I_OnPreMode, PRIORITY_BEFORE, override); -- cgit v1.3.1-10-gc9f91 From 26a80ed2c783bda2bc7abca9dd435b86f3ce2eeb Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 28 Jan 2019 22:19:33 +0000 Subject: Read the muteban config in ReadConfig(). --- src/modules/m_muteban.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_muteban.cpp b/src/modules/m_muteban.cpp index 7698835b1..61d592b2b 100644 --- a/src/modules/m_muteban.cpp +++ b/src/modules/m_muteban.cpp @@ -22,7 +22,16 @@ class ModuleQuietBan : public Module { + private: + bool notifyuser; + public: + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE + { + ConfigTag* tag = ServerInstance->Config->ConfValue("muteban"); + notifyuser = tag->getBool("notifyuser", true); + } + Version GetVersion() CXX11_OVERRIDE { return Version("Implements extban +b m: - mute bans",VF_OPTCOMMON|VF_VENDOR); @@ -36,7 +45,6 @@ class ModuleQuietBan : public Module Channel* chan = target.Get(); if (chan->GetExtBanStatus(user, 'm') == MOD_RES_DENY && chan->GetPrefixValue(user) < VOICE_VALUE) { - bool notifyuser = ServerInstance->Config->ConfValue("muteban")->getBool("notifyuser", true); if (!notifyuser) { details.echo_original = true; -- cgit v1.3.1-10-gc9f91 From 4d768d823de020056d478b03107f6c2e390adca2 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 28 Jan 2019 23:23:41 +0000 Subject: Fix reading the setname config tag. --- src/modules/m_setname.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_setname.cpp b/src/modules/m_setname.cpp index ae85fc98d..5c27a655e 100644 --- a/src/modules/m_setname.cpp +++ b/src/modules/m_setname.cpp @@ -64,7 +64,7 @@ class ModuleSetName : public Module void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { - ConfigTag* tag = ServerInstance->Config->ConfValue("cgiirc"); + ConfigTag* tag = ServerInstance->Config->ConfValue("setname"); // Whether the module should only be usable by server operators. bool operonly = tag->getBool("operonly"); -- cgit v1.3.1-10-gc9f91 From 2ee2e8b60d707d7a1bb644a16060654cb86c7b9f Mon Sep 17 00:00:00 2001 From: linuxdaemon Date: Fri, 1 Feb 2019 03:47:20 -0600 Subject: Allow multiple fingerprints in an oper block (#1564) --- include/hashcomp.h | 6 ++++++ src/hashcomp.cpp | 10 ++++++++++ src/modules/m_sslinfo.cpp | 9 +++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/include/hashcomp.h b/include/hashcomp.h index 80c02332d..453e28c45 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -148,6 +148,12 @@ namespace irc * @return True if the end of the stream has been reached, otherwise false */ bool StreamEnd(); + + /** Returns true if the specified value exists in the stream + * @param value The value to search for + * @return True if the value was found, False otherwise + */ + bool Contains(const std::string& value); }; /** A derived form of sepstream, which seperates on commas diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index a51430a4b..4fee9fd55 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -287,6 +287,16 @@ bool irc::sepstream::StreamEnd() return this->pos > this->tokens.length(); } +bool irc::sepstream::Contains(const std::string& value) +{ + std::string token; + while (GetToken(token)) + if (value == token) + return true; + + return false; +} + irc::portparser::portparser(const std::string &source, bool allow_overlapped) : sep(source), in_range(0), range_begin(0), range_end(0), overlapped(allow_overlapped) { diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index d3514eac6..21857b3d9 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -188,6 +188,11 @@ class ModuleSSLInfo private: CommandSSLInfo cmd; + bool MatchFP(ssl_cert* const cert, const std::string& fp) const + { + return irc::spacesepstream(fp).Contains(cert->GetFingerprint()); + } + public: ModuleSSLInfo() : WebIRC::EventListener(this) @@ -231,7 +236,7 @@ class ModuleSSLInfo } std::string fingerprint; - if (ifo->oper_block->readString("fingerprint", fingerprint) && (!cert || cert->GetFingerprint() != fingerprint)) + if (ifo->oper_block->readString("fingerprint", fingerprint) && (!cert || !MatchFP(cert, fingerprint))) { user->WriteNumeric(ERR_NOOPERHOST, "This oper login requires a matching SSL certificate fingerprint."); user->CommandFloodPenalty += 10000; @@ -275,7 +280,7 @@ class ModuleSSLInfo { OperInfo* ifo = i->second; std::string fp = ifo->oper_block->getString("fingerprint"); - if (fp == cert->fingerprint && ifo->oper_block->getBool("autologin")) + if (MatchFP(cert, fp) && ifo->oper_block->getBool("autologin")) user->Oper(ifo); } } -- cgit v1.3.1-10-gc9f91 From 3b9ef1ae8dcaf2d36f0e31e8b39fe5cfea304d74 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 18 Jan 2019 13:12:00 +0000 Subject: ident: Fix making idents longer than maxident when a lookup fails. --- src/modules/m_ident.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 803c19846..302db0d97 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -254,9 +254,29 @@ class IdentRequestSocket : public EventHandler class ModuleIdent : public Module { + private: int RequestTimeout; bool NoLookupPrefix; SimpleExtItem ext; + + static void PrefixIdent(LocalUser* user) + { + // Check that they haven't been prefixed already. + if (user->ident[0] == '~') + return; + + // All invalid usernames are prefixed with a tilde. + std::string newident(user->ident); + newident.insert(newident.begin(), '~'); + + // If the username is too long then truncate it. + if (newident.length() > ServerInstance->Config->Limits.IdentMax) + newident.erase(ServerInstance->Config->Limits.IdentMax); + + // Apply the new username. + user->ChangeIdent(newident); + } + public: ModuleIdent() : ext("ident_socket", ExtensionItem::EXT_USER, this) @@ -320,8 +340,8 @@ class ModuleIdent : public Module IdentRequestSocket *isock = ext.get(user); if (!isock) { - if ((NoLookupPrefix) && (user->ident[0] != '~')) - user->ident.insert(user->ident.begin(), 1, '~'); + if (NoLookupPrefix) + PrefixIdent(user); return MOD_RES_PASSTHRU; } @@ -343,7 +363,7 @@ class ModuleIdent : public Module /* wooo, got a result (it will be good, or bad) */ if (isock->result.empty()) { - user->ident.insert(user->ident.begin(), 1, '~'); + PrefixIdent(user); user->WriteNotice("*** Could not find your ident, using " + user->ident + " instead."); } else -- cgit v1.3.1-10-gc9f91 From f35490427c17229e81b1ff266c7dcaf67d1a35b5 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 1 Feb 2019 10:39:11 +0000 Subject: ident: Change idents with the ChangeIdent method. --- src/modules/m_ident.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 302db0d97..74f049b44 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -368,11 +368,10 @@ class ModuleIdent : public Module } else { - user->ident = isock->result; + user->ChangeIdent(isock->result); user->WriteNotice("*** Found your ident, '" + user->ident + "'"); } - user->InvalidateCache(); isock->Close(); ext.unset(user); return MOD_RES_PASSTHRU; -- cgit v1.3.1-10-gc9f91 From d66757a43817966edc0fdbe62722415354b042aa Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 1 Feb 2019 10:43:51 +0000 Subject: ident: reduce the amount of messages sent when a lookup fails. --- src/modules/m_ident.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 74f049b44..7bd403fd8 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -352,7 +352,8 @@ class ModuleIdent : public Module if (ServerInstance->Time() >= compare) { /* Ident timeout */ - user->WriteNotice("*** Ident request timed out."); + PrefixIdent(user); + user->WriteNotice("*** Ident lookup timed out, using " + user->ident + " instead."); } else if (!isock->HasResult()) { @@ -361,7 +362,7 @@ class ModuleIdent : public Module } /* wooo, got a result (it will be good, or bad) */ - if (isock->result.empty()) + else if (isock->result.empty()) { PrefixIdent(user); user->WriteNotice("*** Could not find your ident, using " + user->ident + " instead."); -- cgit v1.3.1-10-gc9f91 From 965c55881b6804caa2f6c37f547dba06039c1194 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 1 Feb 2019 10:46:49 +0000 Subject: ident: store the timeout as an unsigned value and limit to 60s. --- src/modules/m_ident.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 7bd403fd8..f47901123 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -255,7 +255,7 @@ class IdentRequestSocket : public EventHandler class ModuleIdent : public Module { private: - int RequestTimeout; + unsigned int timeout; bool NoLookupPrefix; SimpleExtItem ext; @@ -291,7 +291,7 @@ class ModuleIdent : public Module void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("ident"); - RequestTimeout = tag->getDuration("timeout", 5, 1); + timeout = tag->getDuration("timeout", 5, 1, 60); NoLookupPrefix = tag->getBool("nolookupprefix", false); } @@ -345,8 +345,7 @@ class ModuleIdent : public Module return MOD_RES_PASSTHRU; } - time_t compare = isock->age; - compare += RequestTimeout; + time_t compare = isock->age + timeout; /* Check for timeout of the socket */ if (ServerInstance->Time() >= compare) -- cgit v1.3.1-10-gc9f91 From 09da1499d7bc3a380c2b828eed22e3639d6e5e27 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 1 Feb 2019 10:49:00 +0000 Subject: ident: rename nolookupprefix to prefixunqueried. --- docs/conf/modules.conf.example | 4 ++-- src/modules/m_ident.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/modules') diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index c9b6e298c..27068cbdb 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -1063,12 +1063,12 @@ # the timeout for ident lookups here. If not defined, it will default # # to 5 seconds. This is a non-blocking timeout which holds the user # # in a 'connecting' state until the lookup is complete. # -# nolookupprefix: If on, the idents of users being in a connect class # +# prefixunqueried: If on, the idents of users being in a connect class# # with ident lookups disabled (i.e. ) will be # # prefixed with a "~". If off, the ident of those users will not be # # prefixed. Default is off. # # -# +# #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Invite exception module: Adds support for channel invite exceptions diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index f47901123..f3f8e7dd7 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -256,7 +256,7 @@ class ModuleIdent : public Module { private: unsigned int timeout; - bool NoLookupPrefix; + bool prefixunqueried; SimpleExtItem ext; static void PrefixIdent(LocalUser* user) @@ -292,7 +292,7 @@ class ModuleIdent : public Module { ConfigTag* tag = ServerInstance->Config->ConfValue("ident"); timeout = tag->getDuration("timeout", 5, 1, 60); - NoLookupPrefix = tag->getBool("nolookupprefix", false); + prefixunqueried = tag->getBool("prefixunqueried"); } void OnSetUserIP(LocalUser* user) CXX11_OVERRIDE @@ -340,7 +340,7 @@ class ModuleIdent : public Module IdentRequestSocket *isock = ext.get(user); if (!isock) { - if (NoLookupPrefix) + if (prefixunqueried) PrefixIdent(user); return MOD_RES_PASSTHRU; } -- cgit v1.3.1-10-gc9f91 From 625e5435f51650f547f4411441c0b7b958c53d30 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Fri, 1 Feb 2019 10:51:08 +0000 Subject: ident: rename ext to socket. --- src/modules/m_ident.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index f3f8e7dd7..81bdf29c5 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -257,7 +257,7 @@ class ModuleIdent : public Module private: unsigned int timeout; bool prefixunqueried; - SimpleExtItem ext; + SimpleExtItem socket; static void PrefixIdent(LocalUser* user) { @@ -279,7 +279,7 @@ class ModuleIdent : public Module public: ModuleIdent() - : ext("ident_socket", ExtensionItem::EXT_USER, this) + : socket("ident_socket", ExtensionItem::EXT_USER, this) { } @@ -297,12 +297,12 @@ class ModuleIdent : public Module void OnSetUserIP(LocalUser* user) CXX11_OVERRIDE { - IdentRequestSocket* isock = ext.get(user); + IdentRequestSocket* isock = socket.get(user); if (isock) { // If an ident lookup request was in progress then cancel it. isock->Close(); - ext.unset(user); + socket.unset(user); } // The ident protocol requires that clients are connecting over a protocol with ports. @@ -322,7 +322,7 @@ class ModuleIdent : public Module try { isock = new IdentRequestSocket(user); - ext.set(user, isock); + socket.set(user, isock); } catch (ModuleException &e) { @@ -337,7 +337,7 @@ class ModuleIdent : public Module ModResult OnCheckReady(LocalUser *user) CXX11_OVERRIDE { /* Does user have an ident socket attached at all? */ - IdentRequestSocket *isock = ext.get(user); + IdentRequestSocket* isock = socket.get(user); if (!isock) { if (prefixunqueried) @@ -373,7 +373,7 @@ class ModuleIdent : public Module } isock->Close(); - ext.unset(user); + socket.unset(user); return MOD_RES_PASSTHRU; } -- cgit v1.3.1-10-gc9f91 From 26095b12f6d0037cfbbe9b2383398f0522f8f077 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 10:20:33 +0000 Subject: ident: fix erroneously prefixing an ident multiple times. --- src/modules/m_ident.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 81bdf29c5..bc1bad383 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -24,6 +24,24 @@ #include "inspircd.h" +enum +{ + // Either the ident looup has not started yet or the user is registered. + IDENT_UNKNOWN = 0, + + // Ident lookups are not enabled and a user has been marked as being skipped. + IDENT_SKIPPED, + + // Ident looups are not enabled and a user has been an insecure ident prefix. + IDENT_PREFIXED, + + // An ident lookup was done and an ident was found. + IDENT_FOUND, + + // An ident lookup was done but no ident was found + IDENT_MISSING +}; + /* -------------------------------------------------------------- * Note that this is the third incarnation of m_ident. The first * two attempts were pretty crashy, mainly due to the fact we tried @@ -258,6 +276,7 @@ class ModuleIdent : public Module unsigned int timeout; bool prefixunqueried; SimpleExtItem socket; + LocalIntExt state; static void PrefixIdent(LocalUser* user) { @@ -280,6 +299,7 @@ class ModuleIdent : public Module public: ModuleIdent() : socket("ident_socket", ExtensionItem::EXT_USER, this) + , state("ident_state", ExtensionItem::EXT_USER, this) { } @@ -315,7 +335,10 @@ class ModuleIdent : public Module ConfigTag* tag = user->MyClass->config; if (!tag->getBool("useident", true)) + { + state.set(user, IDENT_SKIPPED); return; + } user->WriteNotice("*** Looking up your ident..."); @@ -340,8 +363,11 @@ class ModuleIdent : public Module IdentRequestSocket* isock = socket.get(user); if (!isock) { - if (prefixunqueried) + if (prefixunqueried && state.get(user) == IDENT_SKIPPED) + { PrefixIdent(user); + state.set(user, IDENT_PREFIXED); + } return MOD_RES_PASSTHRU; } @@ -351,6 +377,7 @@ class ModuleIdent : public Module if (ServerInstance->Time() >= compare) { /* Ident timeout */ + state.set(user, IDENT_MISSING); PrefixIdent(user); user->WriteNotice("*** Ident lookup timed out, using " + user->ident + " instead."); } @@ -363,11 +390,13 @@ class ModuleIdent : public Module /* wooo, got a result (it will be good, or bad) */ else if (isock->result.empty()) { + state.set(user, IDENT_MISSING); PrefixIdent(user); user->WriteNotice("*** Could not find your ident, using " + user->ident + " instead."); } else { + state.set(user, IDENT_FOUND); user->ChangeIdent(isock->result); user->WriteNotice("*** Found your ident, '" + user->ident + "'"); } @@ -379,10 +408,16 @@ class ModuleIdent : public Module ModResult OnSetConnectClass(LocalUser* user, ConnectClass* myclass) CXX11_OVERRIDE { - if (myclass->config->getBool("requireident") && user->ident[0] == '~') + if (myclass->config->getBool("requireident") && state.get(user) != IDENT_FOUND) return MOD_RES_DENY; return MOD_RES_PASSTHRU; } + + void OnUserConnect(LocalUser* user) CXX11_OVERRIDE + { + // Clear this as it is no longer necessary. + state.unset(user); + } }; MODULE_INIT(ModuleIdent) -- cgit v1.3.1-10-gc9f91 From f434c03f518d8aa9e7ee088e28125a947e6c95a5 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 13:10:23 +0000 Subject: m_check: replace timestring() with a Write() overlod. --- src/modules/m_check.cpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 2d06df199..ecfe4dcb4 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -30,9 +30,18 @@ enum class CheckContext { + private: User* const user; const std::string& target; + std::string FormatTime(time_t ts) + { + std::string timestr(InspIRCd::TimeString(ts, "%Y-%m-%d %H:%M:%S UTC (", true)); + timestr.append(ConvToStr(ts)); + timestr.push_back(')'); + return timestr; + } + public: CheckContext(User* u, const std::string& targetstr) : user(u) @@ -51,6 +60,11 @@ class CheckContext user->WriteRemoteNumeric(RPL_CHECK, type, text); } + void Write(const std::string& type, time_t ts) + { + user->WriteRemoteNumeric(RPL_CHECK, type, FormatTime(ts)); + } + User* GetUser() const { return user; } void DumpListMode(const ListModeBase::ModeList* list) @@ -130,16 +144,6 @@ class CommandCheck : public Command flags_needed = 'o'; syntax = "||| "; } - std::string timestring(time_t time) - { - char timebuf[60]; - struct tm *mytime = gmtime(&time); - strftime(timebuf, 59, "%Y-%m-%d %H:%M:%S UTC (", mytime); - std::string ret(timebuf); - ret.append(ConvToStr(time)).push_back(')'); - return ret; - } - CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { if (parameters.size() > 1 && !irc::equals(parameters[1], ServerInstance->Config->ServerName)) @@ -173,15 +177,15 @@ class CommandCheck : public Command context.Write("snomasks", GetSnomasks(targuser)); context.Write("server", targuser->server->GetName()); context.Write("uid", targuser->uuid); - context.Write("signon", timestring(targuser->signon)); - context.Write("nickts", timestring(targuser->age)); + context.Write("signon", targuser->signon); + context.Write("nickts", targuser->age); if (loctarg) - context.Write("lastmsg", timestring(loctarg->idle_lastmsg)); + context.Write("lastmsg", loctarg->idle_lastmsg); if (targuser->IsAway()) { /* user is away */ - context.Write("awaytime", timestring(targuser->awaytime)); + context.Write("awaytime", targuser->awaytime); context.Write("awaymsg", targuser->awaymsg); } @@ -237,14 +241,14 @@ class CommandCheck : public Command else if (targchan) { /* /check on a channel */ - context.Write("timestamp", timestring(targchan->age)); + context.Write("timestamp", targchan->age); if (!targchan->topic.empty()) { /* there is a topic, assume topic related information exists */ context.Write("topic", targchan->topic); context.Write("topic_setby", targchan->setby); - context.Write("topic_setat", timestring(targchan->topicset)); + context.Write("topic_setat", targchan->topicset); } context.Write("modes", targchan->ChanModes(true)); -- cgit v1.3.1-10-gc9f91 From 7141ccc5bbf043ae2891905f8059635981b36717 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 14:18:32 +0000 Subject: m_check: remove unnecessary usage of CheckContext::List. --- src/modules/m_check.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index ecfe4dcb4..5e1c01acb 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -199,13 +199,8 @@ class CommandCheck : public Command std::string umodes = GetAllowedOperOnlyModes(loctarg, MODETYPE_USER); std::string cmodes = GetAllowedOperOnlyModes(loctarg, MODETYPE_CHANNEL); context.Write("modeperms", "user=" + umodes + " channel=" + cmodes); - - CheckContext::List opcmdlist(context, "commandperms"); - opcmdlist.Add(oper->AllowedOperCommands.ToString()); - opcmdlist.Flush(); - CheckContext::List privlist(context, "permissions"); - privlist.Add(oper->AllowedPrivs.ToString()); - privlist.Flush(); + context.Write("commandperms", oper->AllowedOperCommands.ToString()); + context.Write("permissions", oper->AllowedPrivs.ToString()); } } -- cgit v1.3.1-10-gc9f91 From 4690bbdee8b5a91938e3e2ac86f606951cccf2e8 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 14:22:49 +0000 Subject: m_check: split modeperms into chanmodeperms and usermodeperms. --- src/modules/m_check.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 5e1c01acb..39f0d190a 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -196,9 +196,8 @@ class CommandCheck : public Command context.Write("opertype", oper->name); if (loctarg) { - std::string umodes = GetAllowedOperOnlyModes(loctarg, MODETYPE_USER); - std::string cmodes = GetAllowedOperOnlyModes(loctarg, MODETYPE_CHANNEL); - context.Write("modeperms", "user=" + umodes + " channel=" + cmodes); + context.Write("chanmodeperms", GetAllowedOperOnlyModes(loctarg, MODETYPE_CHANNEL)); + context.Write("usermodeperms", GetAllowedOperOnlyModes(loctarg, MODETYPE_USER)); context.Write("commandperms", oper->AllowedOperCommands.ToString()); context.Write("permissions", oper->AllowedPrivs.ToString()); } -- cgit v1.3.1-10-gc9f91 From a7b52308dba32becb40522b76b1bfee8e37470fe Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 15:26:53 +0000 Subject: m_check: improve the output of the member key. --- src/modules/m_check.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 39f0d190a..3e9e46a3e 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -259,9 +259,9 @@ class CommandCheck : public Command * Unlike Asuka, I define a clone as coming from the same host. --w00t */ const UserManager::CloneCounts& clonecount = ServerInstance->Users->GetCloneCounts(i->first); - context.Write("member", InspIRCd::Format("%-3u %s%s (%s@%s) %s ", clonecount.global, - i->second->GetAllPrefixChars().c_str(), i->first->nick.c_str(), - i->first->ident.c_str(), i->first->GetDisplayedHost().c_str(), i->first->GetRealName().c_str())); + context.Write("member", InspIRCd::Format("%u %s%s (%s)", clonecount.global, + i->second->GetAllPrefixChars().c_str(), i->first->GetFullHost().c_str(), + i->first->GetRealName().c_str())); } const ModeParser::ListModeList& listmodes = ServerInstance->Modes->GetListModes(); -- cgit v1.3.1-10-gc9f91 From 0a229e70a5839b30d87f3585429d542db37c4cfd Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 15:28:01 +0000 Subject: m_check: rename the timestamp key to createdat. --- src/modules/m_check.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 3e9e46a3e..65cccec5b 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -235,7 +235,7 @@ class CommandCheck : public Command else if (targchan) { /* /check on a channel */ - context.Write("timestamp", targchan->age); + context.Write("createdat", targchan->age); if (!targchan->topic.empty()) { -- cgit v1.3.1-10-gc9f91 From 1ad063eff9d62c3331da5b11326d80511f9d135b Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 4 Feb 2019 18:46:02 +0000 Subject: m_check: improve the output when showing list modes. Closes #1568. --- src/modules/m_check.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index 65cccec5b..58e71aadc 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -67,16 +67,21 @@ class CheckContext User* GetUser() const { return user; } - void DumpListMode(const ListModeBase::ModeList* list) + void DumpListMode(ListModeBase* mode, Channel* chan) { + const ListModeBase::ModeList* list = mode->GetList(chan); if (!list) return; - CheckContext::List modelist(*this, "modelist"); for (ListModeBase::ModeList::const_iterator i = list->begin(); i != list->end(); ++i) - modelist.Add(i->mask); - - modelist.Flush(); + { + CheckContext::List listmode(*this, "listmode"); + listmode.Add(ConvToStr(mode->GetModeChar())); + listmode.Add(i->mask); + listmode.Add(i->setter); + listmode.Add(FormatTime(i->time)); + listmode.Flush(); + } } void DumpExt(Extensible* ext) @@ -266,7 +271,7 @@ class CommandCheck : public Command const ModeParser::ListModeList& listmodes = ServerInstance->Modes->GetListModes(); for (ModeParser::ListModeList::const_iterator i = listmodes.begin(); i != listmodes.end(); ++i) - context.DumpListMode((*i)->GetList(targchan)); + context.DumpListMode(*i, targchan); context.DumpExt(targchan); } -- cgit v1.3.1-10-gc9f91