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:
Dylan K. Taylor
2018-02-27 13:22:15 +00:00
parent 0ba1b58ee0
commit d6d47feda9
3 changed files with 12 additions and 9 deletions

View File

@ -27,6 +27,7 @@ declare(strict_types=1);
*/
namespace pocketmine\network\query;
use pocketmine\network\AdvancedSourceInterface;
use pocketmine\Server;
use pocketmine\utils\Binary;
@ -73,7 +74,7 @@ class QueryHandler{
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;
$packetType = ord($packet{$offset++});
$sessionID = Binary::readInt(substr($packet, $offset, 4));
@ -86,7 +87,7 @@ class QueryHandler{
$reply .= Binary::writeInt($sessionID);
$reply .= self::getTokenString($this->token, $address) . "\x00";
$this->server->getNetwork()->sendPacket($address, $port, $reply);
$interface->sendRawPacket($address, $port, $reply);
break;
case self::STATISTICS: //Stat
$token = Binary::readInt(substr($payload, 0, 4));
@ -105,7 +106,7 @@ class QueryHandler{
}else{
$reply .= $this->shortData;
}
$this->server->getNetwork()->sendPacket($address, $port, $reply);
$interface->sendRawPacket($address, $port, $reply);
break;
}
}