mirror of
https://github.com/xPaw/PHP-Source-Query.git
synced 2026-07-14 07:54:49 +02:00
Compare commits
2 Commits
4f88fb0c76
...
2.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| b4601cdf86 | |||
| 7231921b0b |
+4
-7
@@ -87,13 +87,11 @@
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<?php if( isset( $Exception ) ): ?>
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading"><?php echo Get_Class( $Exception ); ?> at line <?php echo $Exception->getLine( ); ?></div>
|
||||
<p><b><?php echo htmlspecialchars( $Exception->getMessage( ) ); ?></b></p>
|
||||
<p><?php echo nl2br( $e->getTraceAsString(), false ); ?></p>
|
||||
<?php if( $Exception !== '' ): ?>
|
||||
<div class="panel panel-error">
|
||||
<pre class="panel-body"><?php echo htmlspecialchars( $Exception->__toString( ) ); ?></pre>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php endif; ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<table class="table table-bordered table-striped">
|
||||
@@ -193,7 +191,6 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
abstract public function Close( ) : void;
|
||||
abstract public function Open( string $Address, int $Port, int $Timeout, int $Engine ) : void;
|
||||
abstract public function Write( int $Header, string $String = '' ) : bool;
|
||||
abstract public function WritePadded( int $Header, string $String = '' ) : bool;
|
||||
abstract public function Read( int $Length = 1400 ) : Buffer;
|
||||
|
||||
protected function ReadInternal( Buffer $Buffer, int $Length, callable $SherlockFunction ) : Buffer
|
||||
|
||||
@@ -61,6 +61,26 @@
|
||||
return $Length === FWrite( $this->Socket, $Command, $Length );
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a request packge to the socket. Pads it up to 1200 bytes to prevent reflective DoS.
|
||||
*
|
||||
* @see https://steamcommunity.com/discussions/forum/14/2989789048633291344/
|
||||
* @return bool Whether fwrite succeeded.
|
||||
*/
|
||||
public function WritePadded( int $Header, string $String = '' ) : bool
|
||||
{
|
||||
$Command = pack( 'ccccca*', 0xFF, 0xFF, 0xFF, 0xFF, $Header, $String );
|
||||
$Length = strlen( $Command );
|
||||
|
||||
if( $Length < 1200 )
|
||||
{
|
||||
$Command .= str_repeat( "\0", 1200 - $Length );
|
||||
$Length = 1200;
|
||||
}
|
||||
|
||||
return $Length === fwrite( $this->Socket, $Command, $Length );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads from socket and returns Buffer.
|
||||
*
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
throw new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );
|
||||
}
|
||||
|
||||
$this->Socket->Write( self::A2S_INFO, "Source Engine Query\0" );
|
||||
$this->Socket->WritePadded( self::A2S_INFO, "Source Engine Query\0" );
|
||||
$Buffer = $this->Socket->Read( );
|
||||
|
||||
$Type = $Buffer->GetByte( );
|
||||
@@ -365,7 +365,7 @@
|
||||
|
||||
$this->GetChallenge( self::A2S_PLAYER, self::S2A_PLAYER );
|
||||
|
||||
$this->Socket->Write( self::A2S_PLAYER, $this->Challenge );
|
||||
$this->Socket->WritePadded( 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
|
||||
// This violates the protocol spec, and they probably should fix it: https://developer.valvesoftware.com/wiki/Server_queries#Protocol
|
||||
|
||||
@@ -411,7 +411,7 @@
|
||||
|
||||
$this->GetChallenge( self::A2S_RULES, self::S2A_RULES );
|
||||
|
||||
$this->Socket->Write( self::A2S_RULES, $this->Challenge );
|
||||
$this->Socket->WritePadded( self::A2S_RULES, $this->Challenge );
|
||||
$Buffer = $this->Socket->Read( );
|
||||
|
||||
$Type = $Buffer->GetByte( );
|
||||
@@ -452,10 +452,13 @@
|
||||
|
||||
if( $this->UseOldGetChallengeMethod )
|
||||
{
|
||||
$Header = self::A2S_SERVERQUERY_GETCHALLENGE;
|
||||
$this->Socket->Write( self::A2S_SERVERQUERY_GETCHALLENGE, "\xFF\xFF\xFF\xFF" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->Socket->WritePadded( $Header, "\xFF\xFF\xFF\xFF" );
|
||||
}
|
||||
|
||||
$this->Socket->Write( $Header, "\xFF\xFF\xFF\xFF" );
|
||||
$Buffer = $this->Socket->Read( );
|
||||
|
||||
$Type = $Buffer->GetByte( );
|
||||
|
||||
@@ -38,6 +38,11 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
public function WritePadded( int $Header, string $String = '' ) : bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function Read( int $Length = 1400 ) : Buffer
|
||||
{
|
||||
$Buffer = new Buffer( );
|
||||
|
||||
Reference in New Issue
Block a user