X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_user%2Fcore_user.cpp;h=8f90c4ec5c8669b6646112c105bfc9e1271b39d5;hb=ac7aeb8b02f9bfb78b2e4e4491bf59d786781fce;hp=c862c0eb1a3b711f3355c86cb52b7c746de3c253;hpb=55b7fabbc3cce02447a0bde21a541f8c66f7d863;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_user/core_user.cpp b/src/coremods/core_user/core_user.cpp index c862c0eb1..8f90c4ec5 100644 --- a/src/coremods/core_user/core_user.cpp +++ b/src/coremods/core_user/core_user.cpp @@ -20,34 +20,6 @@ #include "inspircd.h" #include "core_user.h" -class CommandMode : public Command -{ - public: - /** Constructor for mode. - */ - CommandMode(Module* parent) - : Command(parent, "MODE", 1) - { - syntax = " {}"; - } - - /** Handle command. - * @param parameters The parameters to the command - * @param user The user issuing the command - * @return A value from CmdResult to indicate command success or failure. - */ - CmdResult Handle(const std::vector& parameters, User* user) - { - ServerInstance->Modes->Process(parameters, user, (IS_LOCAL(user) ? ModeParser::MODE_NONE : ModeParser::MODE_LOCALONLY)); - return CMD_SUCCESS; - } - - RouteDescriptor GetRouting(User* user, const std::vector& parameters) - { - return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST); - } -}; - /** Handle /PASS. */ class CommandPass : public SplitCommand @@ -68,12 +40,13 @@ class CommandPass : public SplitCommand * @param user The user issuing the command * @return A value from CmdResult to indicate command success or failure. */ - CmdResult HandleLocal(const std::vector& parameters, LocalUser *user) + CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE { // Check to make sure they haven't registered -- Fix by FCS if (user->registered == REG_ALL) { - user->WriteNumeric(ERR_ALREADYREGISTERED, ":You may not reregister"); + user->CommandFloodPenalty += 1000; + user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not reregister"); return CMD_FAILURE; } user->password = parameters[0]; @@ -84,15 +57,14 @@ class CommandPass : public SplitCommand /** Handle /PING. */ -class CommandPing : public Command +class CommandPing : public SplitCommand { public: /** Constructor for ping. */ CommandPing(Module* parent) - : Command(parent, "PING", 1, 2) + : SplitCommand(parent, "PING", 1, 2) { - Penalty = 0; syntax = " [:]"; } @@ -101,9 +73,10 @@ class CommandPing : public Command * @param user The user issuing the command * @return A value from CmdResult to indicate command success or failure. */ - CmdResult Handle(const std::vector& parameters, User* user) + CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE { - user->WriteServ("PONG %s :%s", ServerInstance->Config->ServerName.c_str(), parameters[0].c_str()); + ClientProtocol::Messages::Pong pong(parameters[0]); + user->Send(ServerInstance->GetRFCEvents().pong, pong); return CMD_SUCCESS; } }; @@ -127,19 +100,46 @@ class CommandPong : public Command * @param user The user issuing the command * @return A value from CmdResult to indicate command success or failure. */ - CmdResult Handle(const std::vector& parameters, User* user) + CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { // set the user as alive so they survive to next ping - if (IS_LOCAL(user)) - IS_LOCAL(user)->lastping = 1; + LocalUser* localuser = IS_LOCAL(user); + if (localuser) + { + // Increase penalty unless we've sent a PING and this is the reply + if (localuser->lastping) + localuser->CommandFloodPenalty += 1000; + else + localuser->lastping = 1; + } return CMD_SUCCESS; } }; +void MessageWrapper::Wrap(const std::string& message, std::string& out) +{ + // If there is a fixed message, it is stored in prefix. Otherwise prefix contains + // only the prefix, so append the message and the suffix + out.assign(prefix); + if (!fixed) + out.append(message).append(suffix); +} + +void MessageWrapper::ReadConfig(const char* prefixname, const char* suffixname, const char* fixedname) +{ + ConfigTag* tag = ServerInstance->Config->ConfValue("options"); + prefix = tag->getString(fixedname); + fixed = (!prefix.empty()); + if (!fixed) + { + prefix = tag->getString(prefixname); + suffix = tag->getString(suffixname); + } +} + class CoreModUser : public Module { CommandAway cmdaway; - CommandMode cmdmode; CommandNick cmdnick; CommandPart cmdpart; CommandPass cmdpass; @@ -147,17 +147,39 @@ class CoreModUser : public Module CommandPong cmdpong; CommandQuit cmdquit; CommandUser cmduser; + CommandIson cmdison; + CommandUserhost cmduserhost; + SimpleUserModeHandler invisiblemode; + ModeUserOperator operatormode; + ModeUserServerNoticeMask snomaskmode; public: CoreModUser() - : cmdaway(this), cmdmode(this), cmdnick(this), cmdpart(this), cmdpass(this), cmdping(this) - , cmdpong(this), cmdquit(this), cmduser(this) + : cmdaway(this) + , cmdnick(this) + , cmdpart(this) + , cmdpass(this) + , cmdping(this) + , cmdpong(this) + , cmdquit(this) + , cmduser(this) + , cmdison(this) + , cmduserhost(this) + , invisiblemode(this, "invisible", 'i') + , operatormode(this) + , snomaskmode(this) + { + } + + void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { + cmdpart.msgwrap.ReadConfig("prefixpart", "suffixpart", "fixedpart"); + cmdquit.msgwrap.ReadConfig("prefixquit", "suffixquit", "fixedquit"); } Version GetVersion() CXX11_OVERRIDE { - return Version("Provides the AWAY, MODE, NICK, PART, PASS, PING, PONG, QUIT and USER commands", VF_VENDOR|VF_CORE); + return Version("Provides the AWAY, ISON, NICK, PART, PASS, PING, PONG, QUIT, USERHOST, and USER commands", VF_VENDOR|VF_CORE); } };