From 150258b1f110aad58c8882b76474a4ceb3b2ab97 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Sat, 9 Dec 2017 16:12:00 +0000 Subject: Clean up numeric usage in WHOIS and WHOWAS. - Add constants for all of the used numerics. - Switch RPL_CHANNELSMSG from 336 to 651 to avoid a conflict with RPL_INVITELIST from ircd-hybrid. - Switch RPL_WHOWASIP from 379 to 652 to avoid a conflict with RPL_WHOISMODES from UnrealIRCd. --- src/coremods/core_whois.cpp | 42 +++++++++++++++++++++++++++++------------- src/coremods/core_whowas.cpp | 10 ++++++++++ src/modules/m_botmode.cpp | 2 +- 3 files changed, 40 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/coremods/core_whois.cpp b/src/coremods/core_whois.cpp index 1dd087e12..19f5a862b 100644 --- a/src/coremods/core_whois.cpp +++ b/src/coremods/core_whois.cpp @@ -21,6 +21,22 @@ #include "inspircd.h" +enum +{ + // From RFC 1459. + RPL_WHOISUSER = 311, + RPL_WHOISOPERATOR = 313, + RPL_WHOISIDLE = 317, + RPL_WHOISCHANNELS = 319, + + // From UnrealIRCd. + RPL_WHOISHOST = 378, + RPL_WHOISMODES = 379, + + // InspIRCd-specific. + RPL_CHANNELSMSG = 651 +}; + class WhoisContextImpl : public Whois::Context { Events::ModuleEventProvider& lineevprov; @@ -101,7 +117,7 @@ class WhoisChanListNumericBuilder : public Numeric::GenericBuilder<' ', false, W { public: WhoisChanListNumericBuilder(WhoisContextImpl& whois) - : Numeric::GenericBuilder<' ', false, WhoisNumericSink>(WhoisNumericSink(whois), 319, false, whois.GetSource()->nick.size() + whois.GetTarget()->nick.size() + 1) + : Numeric::GenericBuilder<' ', false, WhoisNumericSink>(WhoisNumericSink(whois), RPL_WHOISCHANNELS, false, whois.GetSource()->nick.size() + whois.GetTarget()->nick.size() + 1) { GetNumeric().push(whois.GetTarget()->nick).push(std::string()); } @@ -147,7 +163,7 @@ class WhoisChanList { num.Flush(); if (!spynum.IsEmpty()) - whois.SendLine(336, "is on private/secret channels:"); + whois.SendLine(RPL_CHANNELSMSG, "is on private/secret channels:"); spynum.Flush(); } }; @@ -177,45 +193,45 @@ void CommandWhois::DoWhois(LocalUser* user, User* dest, time_t signon, unsigned { WhoisContextImpl whois(user, dest, lineevprov); - whois.SendLine(311, dest->ident, dest->GetDisplayedHost(), '*', dest->fullname); + whois.SendLine(RPL_WHOISUSER, dest->ident, dest->GetDisplayedHost(), '*', dest->fullname); if (whois.IsSelfWhois() || user->HasPrivPermission("users/auspex")) { - whois.SendLine(378, InspIRCd::Format("is connecting from %s@%s %s", dest->ident.c_str(), dest->GetRealHost().c_str(), dest->GetIPString().c_str())); + whois.SendLine(RPL_WHOISHOST, InspIRCd::Format("is connecting from %s@%s %s", dest->ident.c_str(), dest->GetRealHost().c_str(), dest->GetIPString().c_str())); } SendChanList(whois); if (!whois.IsSelfWhois() && !ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")) { - whois.SendLine(312, ServerInstance->Config->HideWhoisServer, ServerInstance->Config->Network); + whois.SendLine(RPL_WHOISSERVER, ServerInstance->Config->HideWhoisServer, ServerInstance->Config->Network); } else { - whois.SendLine(312, dest->server->GetName(), dest->server->GetDesc()); + whois.SendLine(RPL_WHOISSERVER, dest->server->GetName(), dest->server->GetDesc()); } if (dest->IsAway()) { - whois.SendLine(301, dest->awaymsg); + whois.SendLine(RPL_AWAY, dest->awaymsg); } if (dest->IsOper()) { if (ServerInstance->Config->GenericOper) - whois.SendLine(313, "is an IRC operator"); + whois.SendLine(RPL_WHOISOPERATOR, "is an IRC operator"); else - whois.SendLine(313, InspIRCd::Format("is %s %s on %s", (strchr("AEIOUaeiou",dest->oper->name[0]) ? "an" : "a"), dest->oper->name.c_str(), ServerInstance->Config->Network.c_str())); + whois.SendLine(RPL_WHOISOPERATOR, InspIRCd::Format("is %s %s on %s", (strchr("AEIOUaeiou",dest->oper->name[0]) ? "an" : "a"), dest->oper->name.c_str(), ServerInstance->Config->Network.c_str())); } if (whois.IsSelfWhois() || user->HasPrivPermission("users/auspex")) { if (dest->IsModeSet(snomaskmode)) { - whois.SendLine(379, InspIRCd::Format("is using modes %s %s", dest->GetModeLetters().c_str(), snomaskmode->GetUserParameter(dest).c_str())); + whois.SendLine(RPL_WHOISMODES, InspIRCd::Format("is using modes %s %s", dest->GetModeLetters().c_str(), snomaskmode->GetUserParameter(dest).c_str())); } else { - whois.SendLine(379, InspIRCd::Format("is using modes %s", dest->GetModeLetters().c_str())); + whois.SendLine(RPL_WHOISMODES, InspIRCd::Format("is using modes %s", dest->GetModeLetters().c_str())); } } @@ -227,10 +243,10 @@ void CommandWhois::DoWhois(LocalUser* user, User* dest, time_t signon, unsigned */ if ((idle) || (signon)) { - whois.SendLine(317, idle, signon, "seconds idle, signon time"); + whois.SendLine(RPL_WHOISIDLE, idle, signon, "seconds idle, signon time"); } - whois.SendLine(318, "End of /WHOIS list."); + whois.SendLine(RPL_ENDOFWHOIS, "End of /WHOIS list."); } CmdResult CommandWhois::HandleRemote(const std::vector& parameters, RemoteUser* target) diff --git a/src/coremods/core_whowas.cpp b/src/coremods/core_whowas.cpp index af1f99737..1f72fe2d2 100644 --- a/src/coremods/core_whowas.cpp +++ b/src/coremods/core_whowas.cpp @@ -23,6 +23,16 @@ #include "inspircd.h" #include "commands/cmd_whowas.h" +enum +{ + // From RFC 1459. + RPL_WHOWASUSER = 314, + RPL_ENDOFWHOWAS = 369, + + // InspIRCd-specific. + RPL_WHOWASIP = 652 +}; + CommandWhowas::CommandWhowas( Module* parent) : Command(parent, "WHOWAS", 1) { diff --git a/src/modules/m_botmode.cpp b/src/modules/m_botmode.cpp index 487bc140b..1544562c0 100644 --- a/src/modules/m_botmode.cpp +++ b/src/modules/m_botmode.cpp @@ -24,7 +24,7 @@ enum { // From UnrealIRCd. - RPL_WHOISBOT = 335, + RPL_WHOISBOT = 335 }; class ModuleBotMode : public Module, public Whois::EventListener -- cgit v1.2.3