Add restrictions on packet send directions with interfaces

This prevents plugins sending wrong packets at the compiler level (or would, if we had a compiler). It's more robust than a getter for client/server and throwing an exception since a static analysis tool can detect faults created by sending wrong packets from the server. This is also used to deny service to dodgy clients which send wrong packets to the server to attack it.
This commit is contained in:
Dylan K. Taylor
2019-01-04 03:19:47 +00:00
parent b82e00ffdf
commit 76f1ee1827
130 changed files with 237 additions and 174 deletions

View File

@ -28,7 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\handler\SessionHandler;
class ClientToServerHandshakePacket extends DataPacket{
class ClientToServerHandshakePacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::CLIENT_TO_SERVER_HANDSHAKE_PACKET;
public function canBeSentBeforeLogin() : bool{