diff options
Diffstat (limited to 'src/coremods')
-rw-r--r-- | src/coremods/core_user/core_user.cpp | 24 | ||||
-rw-r--r-- | src/coremods/core_user/core_user.h | 6 |
2 files changed, 25 insertions, 5 deletions
diff --git a/src/coremods/core_user/core_user.cpp b/src/coremods/core_user/core_user.cpp index a5c2d4048..0f526305b 100644 --- a/src/coremods/core_user/core_user.cpp +++ b/src/coremods/core_user/core_user.cpp @@ -64,9 +64,9 @@ class CommandPing : public SplitCommand /** Constructor for ping. */ CommandPing(Module* parent) - : SplitCommand(parent, "PING", 1, 2) + : SplitCommand(parent, "PING", 1) { - syntax = "<servername> [:<servername>]"; + syntax = "<cookie> [<servername>]"; } /** Handle command. @@ -76,7 +76,14 @@ class CommandPing : public SplitCommand */ CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE { - ClientProtocol::Messages::Pong pong(parameters[0]); + size_t origin = parameters.size() > 1 ? 1 : 0; + if (parameters[origin].empty()) + { + user->WriteNumeric(ERR_NOORIGIN, "No origin specified"); + return CMD_FAILURE; + } + + ClientProtocol::Messages::Pong pong(parameters[0], origin ? parameters[1] : ""); user->Send(ServerInstance->GetRFCEvents().pong, pong); return CMD_SUCCESS; } @@ -90,10 +97,10 @@ class CommandPong : public Command /** Constructor for pong. */ CommandPong(Module* parent) - : Command(parent, "PONG", 0, 1) + : Command(parent, "PONG", 1) { Penalty = 0; - syntax = "<ping-text>"; + syntax = "<cookie> [<servername>]"; } /** Handle command. @@ -103,6 +110,13 @@ class CommandPong : public Command */ CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE { + size_t origin = parameters.size() > 1 ? 1 : 0; + if (parameters[origin].empty()) + { + user->WriteNumeric(ERR_NOORIGIN, "No origin specified"); + return CMD_FAILURE; + } + // set the user as alive so they survive to next ping LocalUser* localuser = IS_LOCAL(user); if (localuser) diff --git a/src/coremods/core_user/core_user.h b/src/coremods/core_user/core_user.h index 8289ad5a8..760ed9cf6 100644 --- a/src/coremods/core_user/core_user.h +++ b/src/coremods/core_user/core_user.h @@ -24,6 +24,12 @@ #include "listmode.h" #include "modules/away.h" +enum +{ + // From RFC 1459. + ERR_NOORIGIN = 409 +}; + class MessageWrapper { std::string prefix; |