{
/** Constructor.
* @param cookie Ping cookie. Must remain valid as long as this object is alive.
+ * @param server Pinged server. Must remain valid as long as this object is alive if non-empty.
*/
- Pong(const std::string& cookie)
+ Pong(const std::string& cookie, const std::string& server = "")
: ClientProtocol::Message("PONG", ServerInstance->Config->ServerName)
{
PushParamRef(ServerInstance->Config->ServerName);
+ if (!server.empty())
+ PushParamRef(server);
PushParamRef(cookie);
}
};
/** Constructor for ping.
*/
CommandPing(Module* parent)
- : SplitCommand(parent, "PING", 1, 2)
+ : SplitCommand(parent, "PING", 1)
{
- syntax = "<servername> [:<servername>]";
+ syntax = "<cookie> [<servername>]";
}
/** Handle command.
*/
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;
}
/** 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.
*/
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)