mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 04:17:07 +00:00
Add network-wide API to filter raw packets by regex, stricter validation for Query
This commit is contained in:
parent
f06e67a792
commit
3ebd7e8ba6
8
composer.lock
generated
8
composer.lock
generated
@ -351,12 +351,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pmmp/RakLib.git",
|
"url": "https://github.com/pmmp/RakLib.git",
|
||||||
"reference": "a92e0508b13386e938a8092201ddfd3da17b8dd0"
|
"reference": "b447c7895b5672b7d2f6b92f0919ae814d6b13dc"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/a92e0508b13386e938a8092201ddfd3da17b8dd0",
|
"url": "https://api.github.com/repos/pmmp/RakLib/zipball/b447c7895b5672b7d2f6b92f0919ae814d6b13dc",
|
||||||
"reference": "a92e0508b13386e938a8092201ddfd3da17b8dd0",
|
"reference": "b447c7895b5672b7d2f6b92f0919ae814d6b13dc",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -384,7 +384,7 @@
|
|||||||
"source": "https://github.com/pmmp/RakLib/tree/master",
|
"source": "https://github.com/pmmp/RakLib/tree/master",
|
||||||
"issues": "https://github.com/pmmp/RakLib/issues"
|
"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",
|
"name": "pocketmine/snooze",
|
||||||
|
@ -61,4 +61,11 @@ interface AdvancedNetworkInterface extends NetworkInterface{
|
|||||||
*/
|
*/
|
||||||
public function sendRawPacket(string $address, int $port, string $payload) : void;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -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{
|
public function scheduleSessionTick(NetworkSession $session) : void{
|
||||||
$this->updateSessions[spl_object_hash($session)] = $session;
|
$this->updateSessions[spl_object_hash($session)] = $session;
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,10 @@ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
|
|||||||
$this->interface->sendRaw($address, $port, $payload);
|
$this->interface->sendRaw($address, $port, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addRawPacketFilter(string $regex) : void{
|
||||||
|
$this->interface->addRawPacketFilter($regex);
|
||||||
|
}
|
||||||
|
|
||||||
public function notifyACK(string $identifier, int $identifierACK) : void{
|
public function notifyACK(string $identifier, int $identifierACK) : void{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ class QueryHandler{
|
|||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
$this->server = Server::getInstance();
|
$this->server = Server::getInstance();
|
||||||
|
$this->server->getNetwork()->addRawPacketFilter('/^\xfe\xfd.+$/s');
|
||||||
$this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.server.query.start"));
|
$this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.server.query.start"));
|
||||||
$addr = $this->server->getIp();
|
$addr = $this->server->getIp();
|
||||||
$port = $this->server->getPort();
|
$port = $this->server->getPort();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user