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

@@ -75,7 +75,7 @@ use pocketmine\network\mcpe\NetworkCipher;
use pocketmine\network\mcpe\NetworkCompression;
use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\PacketStream;
use pocketmine\network\mcpe\protocol\Packet;
use pocketmine\network\mcpe\protocol\ClientboundPacket;
use pocketmine\network\mcpe\protocol\PlayerListPacket;
use pocketmine\network\mcpe\protocol\ProtocolInfo;
use pocketmine\network\mcpe\protocol\types\PlayerListEntry;
@@ -1535,18 +1535,18 @@ class Server{
/**
* Broadcasts a Minecraft packet to a list of players
*
* @param Player[] $players
* @param Packet $packet
* @param Player[] $players
* @param ClientboundPacket $packet
*
* @return bool
*/
public function broadcastPacket(array $players, Packet $packet) : bool{
public function broadcastPacket(array $players, ClientboundPacket $packet) : bool{
return $this->broadcastPackets($players, [$packet]);
}
/**
* @param Player[] $players
* @param Packet[] $packets
* @param Player[] $players
* @param ClientboundPacket[] $packets
*
* @return bool
*/