*/
ModeAction TryMode(User* user, User* targu, Channel* targc, Modes::Change& mcitem, bool SkipACL);
- /** Returns a list of user or channel mode characters.
- * Used for constructing the parts of the mode list in the 004 numeric.
- * @param mt Controls whether to list user modes or channel modes
- * @param needparam Return modes only if they require a parameter to be set
- * @return The available mode letters that satisfy the given conditions
- */
- std::string CreateModeList(ModeType mt, bool needparam = false);
-
- /** Recreate the cached mode list that is displayed in the 004 numeric
- * in Cached004ModeList.
- * Called when a mode handler is added or removed.
- */
- void RecreateModeListFor004Numeric();
-
/** Allocates an unused id for the given mode type, throws a ModuleException if out of ids.
* @param mt The type of the mode to allocate the id for
* @return The id
*/
ModeHandler::Id AllocateModeId(ModeType mt);
- /** Cached mode list for use in 004 numeric
- */
- TR1NS::array<std::string, 3> Cached004ModeList;
-
public:
typedef std::vector<ListModeBase*> ListModeList;
typedef std::vector<PrefixMode*> PrefixModeList;
*/
PrefixMode* FindPrefix(unsigned const char pfxletter);
- /** Returns an array of modes:
- * 1. User modes
- * 2. Channel modes
- * 3. Channel modes that require a parameter when set
- * This is sent to users as the last part of the 004 numeric
- */
- const TR1NS::array<std::string, 3>& GetModeListFor004Numeric();
-
/** Generates a list of modes, comma seperated by type:
* 1; Listmodes EXCEPT those with a prefix
* 2; Modes that take a param when adding or removing
void ShowListModeList(User* user, Channel* chan, ModeHandler* mh);
};
-inline const TR1NS::array<std::string, 3>& ModeParser::GetModeListFor004Numeric()
-{
- return Cached004ModeList;
-}
-
inline PrefixMode* ModeHandler::IsPrefixMode()
{
return (this->type_id == MC_PREFIX ? static_cast<PrefixMode*>(this) : NULL);
*/
enum
{
- /*
- * Reply range of numerics.
- */
- RPL_WELCOME = 1, // 2812, not 1459
- RPL_YOURHOSTIS = 2, // 2812, not 1459
- RPL_SERVERCREATED = 3, // 2812, not 1459
- RPL_SERVERVERSION = 4, // 2812, not 1459
RPL_ISUPPORT = 5, // not RFC, extremely common though (defined as RPL_BOUNCE in 2812, widely ignored)
RPL_SNOMASKIS = 8, // unrealircd
#include "inspircd.h"
#include "core_info.h"
+enum
+{
+ // From RFC 2812.
+ RPL_WELCOME = 1,
+ RPL_YOURHOST = 2,
+ RPL_CREATED = 3,
+ RPL_MYINFO = 4
+};
+
RouteDescriptor ServerTargetCommand::GetRouting(User* user, const Params& parameters)
{
// Parameter must be a server name, not a nickname or uuid
CommandMotd cmdmotd;
CommandTime cmdtime;
CommandVersion cmdversion;
+ Numeric::Numeric numeric004;
+ /** Returns a list of user or channel mode characters.
+ * Used for constructing the parts of the mode list in the 004 numeric.
+ * @param mt Controls whether to list user modes or channel modes
+ * @param needparam Return modes only if they require a parameter to be set
+ * @return The available mode letters that satisfy the given conditions
+ */
+ static std::string CreateModeList(ModeType mt, bool needparam = false)
+ {
+ std::string modestr;
+ for (unsigned char mode = 'A'; mode <= 'z'; mode++)
+ {
+ ModeHandler* mh = ServerInstance->Modes.FindMode(mode, mt);
+ if ((mh) && ((!needparam) || (mh->NeedsParam(true))))
+ modestr.push_back(mode);
+ }
+ return modestr;
+ }
+
+ void OnServiceChange(const ServiceProvider& prov)
+ {
+ if (prov.service != SERVICE_MODE)
+ return;
+
+ std::vector<std::string>& params = numeric004.GetParams();
+ params.erase(params.begin()+2, params.end());
+
+ // Create lists of modes
+ // 1. User modes
+ // 2. Channel modes
+ // 3. Channel modes that require a parameter when set
+ numeric004.push(CreateModeList(MODETYPE_USER));
+ numeric004.push(CreateModeList(MODETYPE_CHANNEL));
+ numeric004.push(CreateModeList(MODETYPE_CHANNEL, true));
+ }
public:
CoreModInfo()
- : cmdadmin(this), cmdcommands(this), cmdinfo(this), cmdmodules(this), cmdmotd(this), cmdtime(this), cmdversion(this)
+ : cmdadmin(this)
+ , cmdcommands(this)
+ , cmdinfo(this)
+ , cmdmodules(this)
+ , cmdmotd(this)
+ , cmdtime(this)
+ , cmdversion(this)
+ , numeric004(RPL_MYINFO)
{
+ numeric004.push(ServerInstance->Config->ServerName);
+ numeric004.push(INSPIRCD_BRANCH);
}
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
cmdadmin.AdminNick = tag->getString("nick", "admin");
}
+ void OnUserConnect(LocalUser* user) CXX11_OVERRIDE
+ {
+ user->WriteNumeric(RPL_WELCOME, InspIRCd::Format("Welcome to the %s IRC Network %s", ServerInstance->Config->Network.c_str(), user->GetFullRealHost().c_str()));
+ user->WriteNumeric(RPL_YOURHOST, InspIRCd::Format("Your host is %s, running version %s", ServerInstance->Config->ServerName.c_str(), INSPIRCD_BRANCH));
+ user->WriteNumeric(RPL_CREATED, InspIRCd::TimeString(ServerInstance->startup_time, "This server was created %H:%M:%S %b %d %Y"));
+ user->WriteNumeric(numeric004);
+
+ ServerInstance->ISupport.SendTo(user);
+
+ /* Trigger MOTD and LUSERS output, give modules a chance too */
+ ModResult MOD_RESULT;
+ std::string command("LUSERS");
+ CommandBase::Params parameters;
+ FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, user, true));
+ if (!MOD_RESULT)
+ ServerInstance->Parser.CallHandler(command, parameters, user);
+
+ MOD_RESULT = MOD_RES_PASSTHRU;
+ command = "MOTD";
+ FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, user, true));
+ if (!MOD_RESULT)
+ ServerInstance->Parser.CallHandler(command, parameters, user);
+
+ if (ServerInstance->Config->RawLog)
+ {
+ ClientProtocol::Messages::Privmsg rawlogmsg(ServerInstance->FakeClient, user, "*** Raw I/O logging is enabled on user server. All messages, passwords, and commands are being recorded.");
+ user->Send(ServerInstance->GetRFCEvents().privmsg, rawlogmsg);
+ }
+ }
+
+ void OnServiceAdd(ServiceProvider& service) CXX11_OVERRIDE
+ {
+ OnServiceChange(service);
+ }
+
+ void OnServiceDel(ServiceProvider& service) CXX11_OVERRIDE
+ {
+ OnServiceChange(service);
+ }
+
+ void Prioritize() CXX11_OVERRIDE
+ {
+ ServerInstance->Modules.SetPriority(this, I_OnUserConnect, PRIORITY_FIRST);
+ }
+
Version GetVersion() CXX11_OVERRIDE
{
return Version("Provides the ADMIN, COMMANDS, INFO, MODULES, MOTD, TIME and VERSION commands", VF_VENDOR|VF_CORE);
mhlist.prefix.push_back(pm);
else if (mh->IsListModeBase())
mhlist.list.push_back(mh->IsListModeBase());
-
- RecreateModeListFor004Numeric();
}
bool ModeParser::DelMode(ModeHandler* mh)
mhlist.prefix.erase(std::find(mhlist.prefix.begin(), mhlist.prefix.end(), mh->IsPrefixMode()));
else if (mh->IsListModeBase())
mhlist.list.erase(std::find(mhlist.list.begin(), mhlist.list.end(), mh->IsListModeBase()));
-
- RecreateModeListFor004Numeric();
return true;
}
return mh->IsPrefixMode();
}
-std::string ModeParser::CreateModeList(ModeType mt, bool needparam)
-{
- std::string modestr;
-
- for (unsigned char mode = 'A'; mode <= 'z'; mode++)
- {
- ModeHandler* mh = modehandlers[mt][mode-65];
- if ((mh) && ((!needparam) || (mh->NeedsParam(true))))
- modestr.push_back(mode);
- }
-
- return modestr;
-}
-
-void ModeParser::RecreateModeListFor004Numeric()
-{
- Cached004ModeList[0] = CreateModeList(MODETYPE_USER);
- Cached004ModeList[1] = CreateModeList(MODETYPE_CHANNEL);
- Cached004ModeList[2] = CreateModeList(MODETYPE_CHANNEL, true);
-}
-
PrefixMode* ModeParser::FindPrefix(unsigned const char pfxletter)
{
const PrefixModeList& list = GetPrefixModes();
if (quitting)
return;
- this->WriteNumeric(RPL_WELCOME, InspIRCd::Format("Welcome to the %s IRC Network %s", ServerInstance->Config->Network.c_str(), GetFullRealHost().c_str()));
- this->WriteNumeric(RPL_YOURHOSTIS, InspIRCd::Format("Your host is %s, running version %s", ServerInstance->Config->ServerName.c_str(), INSPIRCD_BRANCH));
- this->WriteNumeric(RPL_SERVERCREATED, InspIRCd::TimeString(ServerInstance->startup_time, "This server was created %H:%M:%S %b %d %Y"));
-
- const TR1NS::array<std::string, 3>& modelist = ServerInstance->Modes->GetModeListFor004Numeric();
- this->WriteNumeric(RPL_SERVERVERSION, ServerInstance->Config->ServerName, INSPIRCD_BRANCH, modelist[0], modelist[1], modelist[2]);
-
- ServerInstance->ISupport.SendTo(this);
-
- /* Now registered */
- if (ServerInstance->Users->unregistered_count)
- ServerInstance->Users->unregistered_count--;
-
- /* Trigger MOTD and LUSERS output, give modules a chance too */
- ModResult MOD_RESULT;
- std::string command("LUSERS");
- CommandBase::Params parameters;
- FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true));
- if (!MOD_RESULT)
- ServerInstance->Parser.CallHandler(command, parameters, this);
-
- MOD_RESULT = MOD_RES_PASSTHRU;
- command = "MOTD";
- FIRST_MOD_RESULT(OnPreCommand, MOD_RESULT, (command, parameters, this, true));
- if (!MOD_RESULT)
- ServerInstance->Parser.CallHandler(command, parameters, this);
-
- if (ServerInstance->Config->RawLog)
- {
- ClientProtocol::Messages::Privmsg rawlogmsg(ServerInstance->FakeClient, this, "*** Raw I/O logging is enabled on this server. All messages, passwords, and commands are being recorded.");
- this->Send(ServerInstance->GetRFCEvents().privmsg, rawlogmsg);
- }
-
/*
* We don't set REG_ALL until triggering OnUserConnect, so some module events don't spew out stuff
* for a user that doesn't exist yet.
*/
FOREACH_MOD(OnUserConnect, (this));
+ /* Now registered */
+ if (ServerInstance->Users->unregistered_count)
+ ServerInstance->Users->unregistered_count--;
this->registered = REG_ALL;
FOREACH_MOD(OnPostConnect, (this));