mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 15:05:33 +00:00
Query: Send responses to the source interface only, instead of all the things
who the fuck wrote this shitty code?
This commit is contained in:
parent
0ba1b58ee0
commit
d6d47feda9
@ -78,6 +78,7 @@ use pocketmine\nbt\tag\ListTag;
|
|||||||
use pocketmine\nbt\tag\LongTag;
|
use pocketmine\nbt\tag\LongTag;
|
||||||
use pocketmine\nbt\tag\ShortTag;
|
use pocketmine\nbt\tag\ShortTag;
|
||||||
use pocketmine\nbt\tag\StringTag;
|
use pocketmine\nbt\tag\StringTag;
|
||||||
|
use pocketmine\network\AdvancedSourceInterface;
|
||||||
use pocketmine\network\CompressBatchedTask;
|
use pocketmine\network\CompressBatchedTask;
|
||||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||||
@ -2452,16 +2453,17 @@ class Server{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $address
|
* @param AdvancedSourceInterface $interface
|
||||||
* @param int $port
|
* @param string $address
|
||||||
* @param string $payload
|
* @param int $port
|
||||||
|
* @param string $payload
|
||||||
*
|
*
|
||||||
* TODO: move this to Network
|
* TODO: move this to Network
|
||||||
*/
|
*/
|
||||||
public function handlePacket(string $address, int $port, string $payload){
|
public function handlePacket(AdvancedSourceInterface $interface, string $address, int $port, string $payload){
|
||||||
try{
|
try{
|
||||||
if(strlen($payload) > 2 and substr($payload, 0, 2) === "\xfe\xfd" and $this->queryHandler instanceof QueryHandler){
|
if(strlen($payload) > 2 and substr($payload, 0, 2) === "\xfe\xfd" and $this->queryHandler instanceof QueryHandler){
|
||||||
$this->queryHandler->handle($address, $port, $payload);
|
$this->queryHandler->handle($interface, $address, $port, $payload);
|
||||||
}
|
}
|
||||||
}catch(\Throwable $e){
|
}catch(\Throwable $e){
|
||||||
if(\pocketmine\DEBUG > 1){
|
if(\pocketmine\DEBUG > 1){
|
||||||
|
@ -165,7 +165,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function handleRaw(string $address, int $port, string $payload) : void{
|
public function handleRaw(string $address, int $port, string $payload) : void{
|
||||||
$this->server->handlePacket($address, $port, $payload);
|
$this->server->handlePacket($this, $address, $port, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendRawPacket(string $address, int $port, string $payload){
|
public function sendRawPacket(string $address, int $port, string $payload){
|
||||||
|
@ -27,6 +27,7 @@ declare(strict_types=1);
|
|||||||
*/
|
*/
|
||||||
namespace pocketmine\network\query;
|
namespace pocketmine\network\query;
|
||||||
|
|
||||||
|
use pocketmine\network\AdvancedSourceInterface;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
use pocketmine\utils\Binary;
|
use pocketmine\utils\Binary;
|
||||||
|
|
||||||
@ -73,7 +74,7 @@ class QueryHandler{
|
|||||||
return Binary::readInt(substr(hash("sha512", $salt . ":" . $token, true), 7, 4));
|
return Binary::readInt(substr(hash("sha512", $salt . ":" . $token, true), 7, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle($address, $port, $packet){
|
public function handle(AdvancedSourceInterface $interface, string $address, int $port, string $packet){
|
||||||
$offset = 2;
|
$offset = 2;
|
||||||
$packetType = ord($packet{$offset++});
|
$packetType = ord($packet{$offset++});
|
||||||
$sessionID = Binary::readInt(substr($packet, $offset, 4));
|
$sessionID = Binary::readInt(substr($packet, $offset, 4));
|
||||||
@ -86,7 +87,7 @@ class QueryHandler{
|
|||||||
$reply .= Binary::writeInt($sessionID);
|
$reply .= Binary::writeInt($sessionID);
|
||||||
$reply .= self::getTokenString($this->token, $address) . "\x00";
|
$reply .= self::getTokenString($this->token, $address) . "\x00";
|
||||||
|
|
||||||
$this->server->getNetwork()->sendPacket($address, $port, $reply);
|
$interface->sendRawPacket($address, $port, $reply);
|
||||||
break;
|
break;
|
||||||
case self::STATISTICS: //Stat
|
case self::STATISTICS: //Stat
|
||||||
$token = Binary::readInt(substr($payload, 0, 4));
|
$token = Binary::readInt(substr($payload, 0, 4));
|
||||||
@ -105,7 +106,7 @@ class QueryHandler{
|
|||||||
}else{
|
}else{
|
||||||
$reply .= $this->shortData;
|
$reply .= $this->shortData;
|
||||||
}
|
}
|
||||||
$this->server->getNetwork()->sendPacket($address, $port, $reply);
|
$interface->sendRawPacket($address, $port, $reply);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user