Add network-wide API to filter raw packets by regex, stricter validation for Query

This commit is contained in:
Dylan K. Taylor 2018-12-28 16:30:04 +00:00
parent f06e67a792
commit 3ebd7e8ba6
5 changed files with 22 additions and 4 deletions

8
composer.lock generated
View File

@ -351,12 +351,12 @@
"source": {
"type": "git",
"url": "https://github.com/pmmp/RakLib.git",
"reference": "a92e0508b13386e938a8092201ddfd3da17b8dd0"
"reference": "b447c7895b5672b7d2f6b92f0919ae814d6b13dc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/a92e0508b13386e938a8092201ddfd3da17b8dd0",
"reference": "a92e0508b13386e938a8092201ddfd3da17b8dd0",
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/b447c7895b5672b7d2f6b92f0919ae814d6b13dc",
"reference": "b447c7895b5672b7d2f6b92f0919ae814d6b13dc",
"shasum": ""
},
"require": {
@ -384,7 +384,7 @@
"source": "https://github.com/pmmp/RakLib/tree/master",
"issues": "https://github.com/pmmp/RakLib/issues"
},
"time": "2018-11-05T21:18:34+00:00"
"time": "2018-12-28T16:10:25+00:00"
},
{
"name": "pocketmine/snooze",

View File

@ -61,4 +61,11 @@ interface AdvancedNetworkInterface extends NetworkInterface{
*/
public function sendRawPacket(string $address, int $port, string $payload) : void;
/**
* Adds a regex filter for raw packets to this network interface. This filter should be used to check validity of
* raw packets before relaying them to the main thread.
*
* @param string $regex
*/
public function addRawPacketFilter(string $regex) : void;
}

View File

@ -195,6 +195,12 @@ class Network{
}
}
public function addRawPacketFilter(string $regex) : void{
foreach($this->advancedInterfaces as $interface){
$interface->addRawPacketFilter($regex);
}
}
public function scheduleSessionTick(NetworkSession $session) : void{
$this->updateSessions[spl_object_hash($session)] = $session;
}

View File

@ -169,6 +169,10 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
$this->interface->sendRaw($address, $port, $payload);
}
public function addRawPacketFilter(string $regex) : void{
$this->interface->addRawPacketFilter($regex);
}
public function notifyACK(string $identifier, int $identifierACK) : void{
}

View File

@ -39,6 +39,7 @@ class QueryHandler{
public function __construct(){
$this->server = Server::getInstance();
$this->server->getNetwork()->addRawPacketFilter('/^\xfe\xfd.+$/s');
$this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.server.query.start"));
$addr = $this->server->getIp();
$port = $this->server->getPort();