1
0
mirror of https://github.com/xPaw/PHP-Source-Query.git synced 2026-06-10 23:03:15 +02:00

Remove engine from the Sockets.

Docblock changes.
Reorder methods to be logical.
This commit is contained in:
Anthony Birkett
2021-05-31 11:52:18 +01:00
parent b01c1f643f
commit d9bab8aa25
17 changed files with 369 additions and 408 deletions
-7
View File
@@ -17,13 +17,6 @@ namespace xPaw\SourceQuery;
use xPaw\SourceQuery\Exception\InvalidPacketException;
/**
* Class Buffer
*
* @package xPaw\SourceQuery
*
* @uses InvalidPacketException
*/
final class Buffer
{
/**
@@ -19,5 +19,5 @@ use Exception;
abstract class SourceQueryException extends Exception
{
// Base exception class
// Base exception class.
}
+19 -8
View File
@@ -2,6 +2,17 @@
declare(strict_types=1);
/**
* @author Pavel Djundik
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/
namespace xPaw\SourceQuery\Rcon;
use xPaw\SourceQuery\Buffer;
@@ -10,14 +21,6 @@ use xPaw\SourceQuery\Exception\InvalidPacketException;
abstract class AbstractRcon implements RconInterface
{
/**
* @param int|null $header
* @param string $string
*
* @return bool
*/
abstract protected function write(?int $header, string $string = ''): bool;
/**
* @throws AuthenticationException
* @throws InvalidPacketException
@@ -25,4 +28,12 @@ abstract class AbstractRcon implements RconInterface
* @return Buffer
*/
abstract protected function read(): Buffer;
/**
* @param int|null $header
* @param string $string
*
* @return bool
*/
abstract protected function write(?int $header, string $string = ''): bool;
}
+39 -47
View File
@@ -21,14 +21,6 @@ use xPaw\SourceQuery\Exception\InvalidPacketException;
use xPaw\SourceQuery\Socket\SocketInterface;
use xPaw\SourceQuery\SourceQuery;
/**
* Class GoldSourceRcon
*
* @package xPaw\SourceQuery
*
* @uses AuthenticationException
* @uses InvalidPacketException
*/
final class GoldSourceRcon extends AbstractRcon
{
/**
@@ -56,6 +48,13 @@ final class GoldSourceRcon extends AbstractRcon
$this->socket = $socket;
}
/**
* Open
*/
public function open(): void
{
}
/**
* Close
*/
@@ -66,10 +65,22 @@ final class GoldSourceRcon extends AbstractRcon
}
/**
* Open
* @param string $password
*
* @throws AuthenticationException
*/
public function open(): void
public function authorize(string $password): void
{
$this->rconPassword = $password;
$this->write(null, 'challenge rcon');
$buffer = $this->socket->read();
if ($buffer->get(14) !== 'challenge rcon') {
throw new AuthenticationException('Failed to get RCON challenge.', AuthenticationException::BAD_PASSWORD);
}
$this->rconChallenge = trim($buffer->get());
}
/**
@@ -92,39 +103,6 @@ final class GoldSourceRcon extends AbstractRcon
return $buffer->get();
}
/**
* @param string $password
*
* @throws AuthenticationException
*/
public function authorize(string $password): void
{
$this->rconPassword = $password;
$this->write(null, 'challenge rcon');
$buffer = $this->socket->read();
if ($buffer->get(14) !== 'challenge rcon') {
throw new AuthenticationException('Failed to get RCON challenge.', AuthenticationException::BAD_PASSWORD);
}
$this->rconChallenge = trim($buffer->get());
}
/**
* @param int|null $header
* @param string $string
*
* @return bool
*/
protected function write(?int $header, string $string = ''): bool
{
$command = pack('cccca*', 0xFF, 0xFF, 0xFF, 0xFF, $string);
$length = strlen($command);
return $length === fwrite($this->socket->getSocket(), $command, $length);
}
/**
* @throws AuthenticationException
* @throws InvalidPacketException
@@ -133,14 +111,14 @@ final class GoldSourceRcon extends AbstractRcon
*/
protected function read(): Buffer
{
// GoldSource RCON has same structure as Query
// GoldSource RCON has same structure as Query.
$buffer = $this->socket->read();
$stringBuffer = '';
// There is no indentifier of the end, so we just need to continue reading
// There is no identifier of the end, so we just need to continue reading.
do {
$readMore = $buffer->remaining() > 0;
$readMore = !$buffer->isEmpty();
if ($readMore) {
if ($buffer->getByte() !== SourceQuery::S2A_RCON) {
@@ -151,7 +129,7 @@ final class GoldSourceRcon extends AbstractRcon
$stringBuffer .= $packet;
//$stringBuffer .= SubStr( $packet, 0, -2 );
// Let's assume if this packet is not long enough, there are no more after this one
// Let's assume if this packet is not long enough, there are no more after this one.
$readMore = strlen($packet) > 1000; // use 1300?
if ($readMore) {
@@ -172,4 +150,18 @@ final class GoldSourceRcon extends AbstractRcon
return $buffer;
}
/**
* @param int|null $header
* @param string $string
*
* @return bool
*/
protected function write(?int $header, string $string = ''): bool
{
$command = pack('cccca*', 0xFF, 0xFF, 0xFF, 0xFF, $string);
$length = strlen($command);
return $length === fwrite($this->socket->getSocket(), $command, $length);
}
}
+20 -9
View File
@@ -2,6 +2,17 @@
declare(strict_types=1);
/**
* @author Pavel Djundik
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/
namespace xPaw\SourceQuery\Rcon;
use xPaw\SourceQuery\Exception\AuthenticationException;
@@ -15,15 +26,22 @@ interface RconInterface
*/
public function __construct(SocketInterface $socket);
/**
* Open
*/
public function open(): void;
/**
* Close
*/
public function close(): void;
/**
* Open
* @param string $password
*
* @throws AuthenticationException
*/
public function open(): void;
public function authorize(string $password): void;
/**
* @param string $command
@@ -34,11 +52,4 @@ interface RconInterface
* @throws InvalidPacketException
*/
public function command(string $command): string;
/**
* @param string $password
*
* @throws AuthenticationException
*/
public function authorize(string $password): void;
}
+63 -72
View File
@@ -22,15 +22,6 @@ use xPaw\SourceQuery\Exception\SocketException;
use xPaw\SourceQuery\Socket\SocketInterface;
use xPaw\SourceQuery\SourceQuery;
/**
* Class SourceRcon
*
* @package xPaw\SourceQuery
*
* @uses AuthenticationException
* @uses InvalidPacketException
* @uses SocketException
*/
final class SourceRcon extends AbstractRcon
{
/**
@@ -56,20 +47,6 @@ final class SourceRcon extends AbstractRcon
$this->socket = $socket;
}
/**
* Close
*/
public function close(): void
{
if ($this->rconSocket) {
fclose($this->rconSocket);
$this->rconSocket = null;
}
$this->rconRequestId = 0;
}
/**
* @throws SocketException
*/
@@ -94,6 +71,49 @@ final class SourceRcon extends AbstractRcon
}
}
/**
* Close
*/
public function close(): void
{
if ($this->rconSocket) {
fclose($this->rconSocket);
$this->rconSocket = null;
}
$this->rconRequestId = 0;
}
/**
* @param string $password
*
* @throws AuthenticationException
* @throws InvalidPacketException
*/
public function authorize(string $password): void
{
$this->write(SourceQuery::SERVERDATA_AUTH, $password);
$buffer = $this->read();
$requestId = $buffer->getLong();
$type = $buffer->getLong();
// If we receive SERVERDATA_RESPONSE_VALUE, then we need to read again.
// More info: https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Additional_Comments
if ($type === SourceQuery::SERVERDATA_RESPONSE_VALUE) {
$buffer = $this->read();
$requestId = $buffer->getLong();
$type = $buffer->getLong();
}
if ($requestId === -1 || $type !== SourceQuery::SERVERDATA_AUTH_RESPONSE) {
throw new AuthenticationException('RCON authorization failed.', AuthenticationException::BAD_PASSWORD);
}
}
/**
* @param string $command
*
@@ -119,7 +139,7 @@ final class SourceRcon extends AbstractRcon
$data = $buffer->get();
// We do this stupid hack to handle split packets
// We do this stupid hack to handle split packets.
// See https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Multiple-packet_Responses
if (strlen($data) >= 4000) {
$this->write(SourceQuery::SERVERDATA_REQUESTVALUE);
@@ -127,7 +147,7 @@ final class SourceRcon extends AbstractRcon
do {
$buffer = $this->read();
$buffer->getLong(); // RequestID
$buffer->getLong(); // RequestID.
if ($buffer->getLong() !== SourceQuery::SERVERDATA_RESPONSE_VALUE) {
break;
@@ -146,53 +166,6 @@ final class SourceRcon extends AbstractRcon
return rtrim($data, "\0");
}
/**
* @param string $password
*
* @throws AuthenticationException
* @throws InvalidPacketException
*/
public function authorize(string $password): void
{
$this->write(SourceQuery::SERVERDATA_AUTH, $password);
$buffer = $this->read();
$requestId = $buffer->getLong();
$type = $buffer->getLong();
// If we receive SERVERDATA_RESPONSE_VALUE, then we need to read again
// More info: https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Additional_Comments
if ($type === SourceQuery::SERVERDATA_RESPONSE_VALUE) {
$buffer = $this->read();
$requestId = $buffer->getLong();
$type = $buffer->getLong();
}
if ($requestId === -1 || $type !== SourceQuery::SERVERDATA_AUTH_RESPONSE) {
throw new AuthenticationException('RCON authorization failed.', AuthenticationException::BAD_PASSWORD);
}
}
/**
* @param int|null $header
* @param string $string
*
* @return bool
*/
protected function write(?int $header, string $string = ''): bool
{
// Pack the packet together
$command = pack('VV', ++$this->rconRequestId, $header) . $string . "\x00\x00";
// Prepend packet length
$command = pack('V', strlen($command)) . $command;
$length = strlen($command);
return $length === fwrite($this->rconSocket, $command, $length);
}
/**
* @return Buffer
*
@@ -232,4 +205,22 @@ final class SourceRcon extends AbstractRcon
return $buffer;
}
/**
* @param int|null $header
* @param string $string
*
* @return bool
*/
protected function write(?int $header, string $string = ''): bool
{
// Pack the packet together.
$command = pack('VV', ++$this->rconRequestId, $header) . $string . "\x00\x00";
// Prepend packet length.
$command = pack('V', strlen($command)) . $command;
$length = strlen($command);
return $length === fwrite($this->rconSocket, $command, $length);
}
}
+30 -45
View File
@@ -20,26 +20,8 @@ use xPaw\SourceQuery\Exception\InvalidArgumentException;
use xPaw\SourceQuery\Exception\InvalidPacketException;
use xPaw\SourceQuery\Exception\SocketException;
/**
* Base socket
*
* @package xPaw\SourceQuery
*
* @uses InvalidPacketException
* @uses SocketException
*/
abstract class AbstractSocket implements SocketInterface
{
/**
* @var resource|null
*/
public $socket;
/**
* @var int
*/
public int $engine = SocketType::SOURCE;
/**
* @var string $address
*/
@@ -50,6 +32,11 @@ abstract class AbstractSocket implements SocketInterface
*/
public int $port = 0;
/**
* @var resource|null
*/
public $socket;
/**
* @var int $timeout
*/
@@ -79,14 +66,6 @@ abstract class AbstractSocket implements SocketInterface
return $this->port;
}
/**
* @return int
*/
public function getTimeout(): int
{
return $this->timeout;
}
/**
* @return resource
*
@@ -102,29 +81,23 @@ abstract class AbstractSocket implements SocketInterface
}
/**
* Close
* @return int
*/
public function close(): void
public function getTimeout(): int
{
if ($this->socket) {
fclose($this->socket);
$this->socket = null;
}
return $this->timeout;
}
/**
* @param string $address
* @param int $port
* @param int $timeout
* @param int $engine
*
* @throws SocketException
*/
public function open(string $address, int $port, int $timeout, int $engine): void
public function open(string $address, int $port, int $timeout): void
{
$this->timeout = $timeout;
$this->engine = $engine;
$this->port = $port;
$this->address = $address;
@@ -140,17 +113,15 @@ abstract class AbstractSocket implements SocketInterface
}
/**
* @param int $header
* @param string $string
*
* @return bool
* Close
*/
public function write(int $header, string $string = ''): bool
public function close(): void
{
$command = pack('ccccca*', 0xFF, 0xFF, 0xFF, 0xFF, $header, $string);
$length = strlen($command);
if ($this->socket) {
fclose($this->socket);
return $length === fwrite($this->socket, $command, $length);
$this->socket = null;
}
}
/**
@@ -180,6 +151,20 @@ abstract class AbstractSocket implements SocketInterface
return $buffer;
}
/**
* @param int $header
* @param string $string
*
* @return bool
*/
public function write(int $header, string $string = ''): bool
{
$command = pack('ccccca*', 0xFF, 0xFF, 0xFF, 0xFF, $header, $string);
$length = strlen($command);
return $length === fwrite($this->socket, $command, $length);
}
/**
* @param Buffer $buffer
* @param int $length
@@ -230,7 +215,7 @@ abstract class AbstractSocket implements SocketInterface
*/
protected function readInternal(Buffer $buffer, int $length, callable $sherlockFunction): Buffer
{
if ($buffer->remaining() === 0) {
if ($buffer->isEmpty()) {
throw new InvalidPacketException('Failed to read any data from socket', InvalidPacketException::BUFFER_EMPTY);
}
+11
View File
@@ -2,6 +2,17 @@
declare(strict_types=1);
/**
* @author Pavel Djundik
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/
namespace xPaw\SourceQuery\Socket;
use xPaw\SourceQuery\Buffer;
+16 -17
View File
@@ -34,33 +34,39 @@ interface SocketInterface
*/
public function getPort(): int;
/**
* @return int
*/
public function getTimeout(): int;
/**
* @return resource
*/
public function getSocket();
/**
* @return int
*/
public function getTimeout(): int;
/**
* Get the socket type (goldsrc/src).
*/
public function getType(): int;
/**
* @param string $address
* @param int $port
* @param int $timeout
*/
public function open(string $address, int $port, int $timeout): void;
/**
* Close
*/
public function close(): void;
/**
* @param string $address
* @param int $port
* @param int $timeout
* @param int $engine
* @param int $length
*
* @return Buffer
*/
public function open(string $address, int $port, int $timeout, int $engine): void;
public function read(int $length = 1400): Buffer;
/**
* @param int $header
@@ -69,11 +75,4 @@ interface SocketInterface
* @return bool
*/
public function write(int $header, string $string = ''): bool;
/**
* @param int $length
*
* @return Buffer
*/
public function read(int $length = 1400): Buffer;
}
+11
View File
@@ -2,6 +2,17 @@
declare(strict_types=1);
/**
* @author Pavel Djundik
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/
namespace xPaw\SourceQuery\Socket;
abstract class SocketType
+13 -2
View File
@@ -2,6 +2,17 @@
declare(strict_types=1);
/**
* @author Pavel Djundik
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/
namespace xPaw\SourceQuery\Socket;
use xPaw\SourceQuery\Buffer;
@@ -37,11 +48,11 @@ final class SourceSocket extends AbstractSocket
$number = $buffer->getByte() + 1;
if ($isCompressed) {
$buffer->getLong(); // Split size
$buffer->getLong(); // Split size.
$checksum = $buffer->getUnsignedLong();
} else {
$buffer->getShort(); // Split size
$buffer->getShort(); // Split size.
}
}
}
+29 -20
View File
@@ -2,6 +2,17 @@
declare(strict_types=1);
/**
* @author Pavel Djundik
*
* @link https://xpaw.me
* @link https://github.com/xPaw/PHP-Source-Query
*
* @license GNU Lesser General Public License, version 2.1
*
* @internal
*/
namespace xPaw\SourceQuery\Socket;
use SplQueue;
@@ -49,36 +60,23 @@ final class TestableSocket extends AbstractSocket
$this->packetQueue->push($data);
}
/**
* Close.
*/
public function close(): void
{
}
/**
* @param string $address
* @param int $port
* @param int $timeout
* @param int $engine
*/
public function open(string $address, int $port, int $timeout, int $engine): void
public function open(string $address, int $port, int $timeout): void
{
$this->timeout = $timeout;
$this->engine = $engine;
$this->port = $port;
$this->address = $address;
}
/**
* @param int $header
* @param string $string
*
* @return bool
* Close.
*/
public function write(int $header, string $string = ''): bool
public function close(): void
{
return true;
}
/**
@@ -98,6 +96,17 @@ final class TestableSocket extends AbstractSocket
return $buffer;
}
/**
* @param int $header
* @param string $string
*
* @return bool
*/
public function write(int $header, string $string = ''): bool
{
return true;
}
/**
* @param Buffer $buffer
* @param int $length
@@ -166,7 +175,7 @@ final class TestableSocket extends AbstractSocket
* @param bool $isCompressed
* @param int|null $checksum
*/
protected function readInternalPacketDataGoldSource(
private function readInternalPacketDataGoldSource(
Buffer $buffer,
int &$count,
int &$number,
@@ -190,7 +199,7 @@ final class TestableSocket extends AbstractSocket
*
* @throws InvalidPacketException
*/
protected function readInternalPacketDataSource(
private function readInternalPacketDataSource(
Buffer $buffer,
int &$count,
int &$number,
@@ -201,11 +210,11 @@ final class TestableSocket extends AbstractSocket
$number = $buffer->getByte() + 1;
if ($isCompressed) {
$buffer->getLong(); // Split size
$buffer->getLong(); // Split size.
$checksum = $buffer->getUnsignedLong();
} else {
$buffer->getShort(); // Split size
$buffer->getShort(); // Split size.
}
}
}
+17 -31
View File
@@ -26,16 +26,6 @@ use xPaw\SourceQuery\Rcon\SourceRcon;
use xPaw\SourceQuery\Socket\SocketInterface;
use xPaw\SourceQuery\Socket\SocketType;
/**
* Class SourceQuery
*
* @package xPaw\SourceQuery
*
* @uses AuthenticationException
* @uses InvalidArgumentException
* @uses InvalidPacketException
* @uses SocketException
*/
final class SourceQuery
{
/**
@@ -53,7 +43,7 @@ final class SourceQuery
private const A2A_ACK = 0x6A;
private const S2C_CHALLENGE = 0x41;
private const S2A_INFO_SRC = 0x49;
private const S2A_INFO_OLD = 0x6D; // Old GoldSource, HLTV uses it (actually called S2A_INFO_DETAILED)
private const S2A_INFO_OLD = 0x6D; // Old GoldSource, HLTV uses it (actually called S2A_INFO_DETAILED).
private const S2A_PLAYER = 0x44;
private const S2A_RULES = 0x45;
public const S2A_RCON = 0x6C;
@@ -76,7 +66,7 @@ final class SourceQuery
*
* @var RconInterface|null
*/
private $rcon;
private ?RconInterface $rcon;
/**
* Points to socket class
@@ -104,6 +94,7 @@ final class SourceQuery
public function __construct(SocketInterface $socket)
{
$this->socket = $socket;
$this->rcon = null;
}
/**
@@ -120,12 +111,10 @@ final class SourceQuery
* @param string $address Server ip
* @param int $port Server port
* @param int $timeout Timeout period
* @param int $engine Engine the server runs on (goldsource, source)
*
* @throws InvalidArgumentException
* @throws SocketException
*/
public function connect(string $address, int $port, int $timeout = 3, int $engine = SocketType::SOURCE): void
public function connect(string $address, int $port, int $timeout = 3): void
{
$this->disconnect();
@@ -133,7 +122,7 @@ final class SourceQuery
throw new InvalidArgumentException('Timeout must be a positive integer.', InvalidArgumentException::TIMEOUT_NOT_INTEGER);
}
$this->socket->open($address, $port, $timeout, $engine);
$this->socket->open($address, $port, $timeout);
$this->connected = true;
}
@@ -175,7 +164,6 @@ final class SourceQuery
* Sends ping packet to the server
* NOTE: This may not work on some games (TF2 for example)
*
* @throws InvalidPacketException
* @throws SocketException
*
* @return bool True on success, false on failure
@@ -224,7 +212,7 @@ final class SourceQuery
$type = $buffer->getByte();
}
// Old GoldSource protocol, HLTV still uses it
// Old GoldSource protocol, HLTV still uses it.
if ($type === self::S2A_INFO_OLD && $this->socket->getType() === SocketType::GOLDSOURCE) {
/**
* If we try to read data again, and we get the result with type S2A_INFO (0x49)
@@ -290,8 +278,8 @@ final class SourceQuery
$server[ 'Version' ] = $buffer->getString();
// Extra Data Flags
if ($buffer->remaining() > 0) {
// Extra Data Flags.
if (!$buffer->isEmpty()) {
$server[ 'ExtraDataFlags' ] = $Flags = $buffer->getByte();
// S2A_EXTRA_DATA_HAS_GAME_PORT - Next 2 bytes include the game port.
@@ -299,12 +287,12 @@ final class SourceQuery
$server[ 'GamePort' ] = $buffer->getShort();
}
// S2A_EXTRA_DATA_HAS_STEAMID - Next 8 bytes are the steamID
// S2A_EXTRA_DATA_HAS_STEAMID - Next 8 bytes are the steamID.
// Want to play around with this?
// You can use https://github.com/xPaw/SteamID.php
if ($Flags & 0x10) {
$steamIdLower = $buffer->getUnsignedLong();
$steamIdInstance = $buffer->getUnsignedLong(); // This gets shifted by 32 bits, which should be steamid instance
$steamIdInstance = $buffer->getUnsignedLong(); // This gets shifted by 32 bits, which should be steamid instance.
if (PHP_INT_SIZE === 4) {
if (extension_loaded('gmp')) {
@@ -329,12 +317,12 @@ final class SourceQuery
$server[ 'SpecName' ] = $buffer->getString();
}
// S2A_EXTRA_DATA_HAS_GAMETAG_DATA - Next bytes are the game tag string
// S2A_EXTRA_DATA_HAS_GAMETAG_DATA - Next bytes are the game tag string.
if ($Flags & 0x20) {
$server[ 'GameTags' ] = $buffer->getString();
}
// S2A_EXTRA_DATA_GAMEID - Next 8 bytes are the gameID of the server
// S2A_EXTRA_DATA_GAMEID - Next 8 bytes are the gameID of the server.
if ($Flags & 0x01) {
$server[ 'GameID' ] = $buffer->getUnsignedLong() | ($buffer->getUnsignedLong() << 32);
}
@@ -367,7 +355,7 @@ final class SourceQuery
$this->getChallenge(self::A2S_PLAYER, self::S2A_PLAYER);
$this->socket->write(self::A2S_PLAYER, $this->challenge);
$buffer = $this->socket->read(14000); // Moronic Arma 3 developers do not split their packets, so we have to read more data
$buffer = $this->socket->read(14000); // Moronic Arma 3 developers do not split their packets, so we have to read more data.
// This violates the protocol spec, and they probably should fix it: https://developer.valvesoftware.com/wiki/Server_queries#Protocol
$type = $buffer->getByte();
@@ -379,7 +367,7 @@ final class SourceQuery
$players = [];
$count = $buffer->getByte();
while ($count-- > 0 && $buffer->remaining() > 0) {
while ($count-- > 0 && !$buffer->isEmpty()) {
$player = [];
$player[ 'Id' ] = $buffer->getByte(); // PlayerID, is it just always 0?
$player[ 'Name' ] = $buffer->getString();
@@ -421,7 +409,7 @@ final class SourceQuery
$rules = [];
$count = $buffer->getShort();
while ($count-- > 0 && $buffer->remaining() > 0) {
while ($count-- > 0 && !$buffer->isEmpty()) {
$rule = $buffer->getString();
$value = $buffer->getString();
@@ -440,7 +428,6 @@ final class SourceQuery
* @param int $expectedResult
*
* @throws InvalidPacketException
* @throws SocketException
*/
private function getChallenge(int $header, int $expectedResult): void
{
@@ -466,8 +453,7 @@ final class SourceQuery
}
case $expectedResult:
{
// Goldsource (HLTV)
// Goldsource (HLTV).
return;
}
case 0:
@@ -525,7 +511,7 @@ final class SourceQuery
* @param string $command Command to execute
*
* @return string Answer from server in string
*@throws InvalidPacketException
* @throws InvalidPacketException
* @throws SocketException
*
* @throws AuthenticationException