mirror of https://github.com/OpenTTD/OpenTTD
(svn r25587) -Add FS#5643: Conclude rcon output sent to admin clients with an RCON_END packet (Xaroth)
parent
09a30ca7b5
commit
4a1bf704ee
|
@ -87,6 +87,7 @@ NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket(Packet *p)
|
||||||
case ADMIN_PACKET_SERVER_CONSOLE: return this->Receive_SERVER_CONSOLE(p);
|
case ADMIN_PACKET_SERVER_CONSOLE: return this->Receive_SERVER_CONSOLE(p);
|
||||||
case ADMIN_PACKET_SERVER_CMD_NAMES: return this->Receive_SERVER_CMD_NAMES(p);
|
case ADMIN_PACKET_SERVER_CMD_NAMES: return this->Receive_SERVER_CMD_NAMES(p);
|
||||||
case ADMIN_PACKET_SERVER_CMD_LOGGING: return this->Receive_SERVER_CMD_LOGGING(p);
|
case ADMIN_PACKET_SERVER_CMD_LOGGING: return this->Receive_SERVER_CMD_LOGGING(p);
|
||||||
|
case ADMIN_PACKET_SERVER_RCON_END: return this->Receive_SERVER_RCON_END(p);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (this->HasClientQuit()) {
|
if (this->HasClientQuit()) {
|
||||||
|
@ -162,5 +163,6 @@ NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON(Packet *p) { re
|
||||||
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CONSOLE(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CONSOLE); }
|
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CONSOLE(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CONSOLE); }
|
||||||
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_NAMES(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CMD_NAMES); }
|
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_NAMES(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CMD_NAMES); }
|
||||||
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_LOGGING(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CMD_LOGGING); }
|
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_LOGGING(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CMD_LOGGING); }
|
||||||
|
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON_END(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_RCON_END); }
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
|
@ -60,6 +60,7 @@ enum PacketAdminType {
|
||||||
ADMIN_PACKET_SERVER_CMD_NAMES, ///< The server sends out the names of the DoCommands to the admins.
|
ADMIN_PACKET_SERVER_CMD_NAMES, ///< The server sends out the names of the DoCommands to the admins.
|
||||||
ADMIN_PACKET_SERVER_CMD_LOGGING, ///< The server gives the admin copies of incoming command packets.
|
ADMIN_PACKET_SERVER_CMD_LOGGING, ///< The server gives the admin copies of incoming command packets.
|
||||||
ADMIN_PACKET_SERVER_GAMESCRIPT, ///< The server gives the admin information from the GameScript in JSON.
|
ADMIN_PACKET_SERVER_GAMESCRIPT, ///< The server gives the admin information from the GameScript in JSON.
|
||||||
|
ADMIN_PACKET_SERVER_RCON_END, ///< The server indicates that the remote console command has completed.
|
||||||
|
|
||||||
INVALID_ADMIN_PACKET = 0xFF, ///< An invalid marker for admin packets.
|
INVALID_ADMIN_PACKET = 0xFF, ///< An invalid marker for admin packets.
|
||||||
};
|
};
|
||||||
|
@ -454,6 +455,14 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual NetworkRecvStatus Receive_SERVER_CMD_LOGGING(Packet *p);
|
virtual NetworkRecvStatus Receive_SERVER_CMD_LOGGING(Packet *p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the admin connection that the rcon command has finished.
|
||||||
|
* string The command as requested by the admin connection.
|
||||||
|
* @param p The packet that was just received.
|
||||||
|
* @return The state the network should have.
|
||||||
|
*/
|
||||||
|
virtual NetworkRecvStatus Receive_SERVER_RCON_END(Packet *p);
|
||||||
|
|
||||||
NetworkRecvStatus HandlePacket(Packet *p);
|
NetworkRecvStatus HandlePacket(Packet *p);
|
||||||
public:
|
public:
|
||||||
NetworkRecvStatus CloseConnection(bool error = true);
|
NetworkRecvStatus CloseConnection(bool error = true);
|
||||||
|
|
|
@ -480,6 +480,20 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendChat(NetworkAction action
|
||||||
return NETWORK_RECV_STATUS_OKAY;
|
return NETWORK_RECV_STATUS_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a notification indicating the rcon command has completed.
|
||||||
|
* @param command The original command sent.
|
||||||
|
*/
|
||||||
|
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRconEnd(const char *command)
|
||||||
|
{
|
||||||
|
Packet *p = new Packet(ADMIN_PACKET_SERVER_RCON_END);
|
||||||
|
|
||||||
|
p->Send_string(command);
|
||||||
|
this->SendPacket(p);
|
||||||
|
|
||||||
|
return NETWORK_RECV_STATUS_OKAY;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the reply of an rcon command.
|
* Send the reply of an rcon command.
|
||||||
* @param colour The colour of the text.
|
* @param colour The colour of the text.
|
||||||
|
@ -509,7 +523,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_RCON(Packet *p)
|
||||||
_redirect_console_to_admin = this->index;
|
_redirect_console_to_admin = this->index;
|
||||||
IConsoleCmdExec(command);
|
IConsoleCmdExec(command);
|
||||||
_redirect_console_to_admin = INVALID_ADMIN_ID;
|
_redirect_console_to_admin = INVALID_ADMIN_ID;
|
||||||
return NETWORK_RECV_STATUS_OKAY;
|
return this->SendRconEnd(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT(Packet *p)
|
NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT(Packet *p)
|
||||||
|
|
|
@ -69,6 +69,7 @@ public:
|
||||||
NetworkRecvStatus SendGameScript(const char *json);
|
NetworkRecvStatus SendGameScript(const char *json);
|
||||||
NetworkRecvStatus SendCmdNames();
|
NetworkRecvStatus SendCmdNames();
|
||||||
NetworkRecvStatus SendCmdLogging(ClientID client_id, const CommandPacket *cp);
|
NetworkRecvStatus SendCmdLogging(ClientID client_id, const CommandPacket *cp);
|
||||||
|
NetworkRecvStatus SendRconEnd(const char *command);
|
||||||
|
|
||||||
static void Send();
|
static void Send();
|
||||||
static void AcceptConnection(SOCKET s, const NetworkAddress &address);
|
static void AcceptConnection(SOCKET s, const NetworkAddress &address);
|
||||||
|
|
Loading…
Reference in New Issue