Skip to content

Commit bbb6c4c

Browse files
committed
Revert "Add 1200 byte padding to all requests"
This reverts commit 7231921.
1 parent 9da781a commit bbb6c4c

File tree

4 files changed

+5
-34
lines changed

4 files changed

+5
-34
lines changed

SourceQuery/BaseSocket.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public function __destruct( )
4141
abstract public function Close( ) : void;
4242
abstract public function Open( string $Address, int $Port, int $Timeout, int $Engine ) : void;
4343
abstract public function Write( int $Header, string $String = '' ) : bool;
44-
abstract public function WritePadded( int $Header, string $String = '' ) : bool;
4544
abstract public function Read( int $Length = 1400 ) : Buffer;
4645

4746
protected function ReadInternal( Buffer $Buffer, int $Length, callable $SherlockFunction ) : Buffer

SourceQuery/Socket.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,6 @@ public function Write( int $Header, string $String = '' ) : bool
6161
return $Length === FWrite( $this->Socket, $Command, $Length );
6262
}
6363

64-
/**
65-
* Write a request packge to the socket. Pads it up to 1200 bytes to prevent reflective DoS.
66-
*
67-
* @see https://steamcommunity.com/discussions/forum/14/2989789048633291344/
68-
* @return bool Whether fwrite succeeded.
69-
*/
70-
public function WritePadded( int $Header, string $String = '' ) : bool
71-
{
72-
$Command = pack( 'ccccca*', 0xFF, 0xFF, 0xFF, 0xFF, $Header, $String );
73-
$Length = strlen( $Command );
74-
75-
if( $Length < 1200 )
76-
{
77-
$Command .= str_repeat( "\0", 1200 - $Length );
78-
$Length = 1200;
79-
}
80-
81-
return $Length === fwrite( $this->Socket, $Command, $Length );
82-
}
83-
8464
/**
8565
* Reads from socket and returns Buffer.
8666
*

SourceQuery/SourceQuery.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function GetInfo( ) : array
200200
throw new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );
201201
}
202202

203-
$this->Socket->WritePadded( self::A2S_INFO, "Source Engine Query\0" );
203+
$this->Socket->Write( self::A2S_INFO, "Source Engine Query\0" );
204204
$Buffer = $this->Socket->Read( );
205205

206206
$Type = $Buffer->GetByte( );
@@ -365,7 +365,7 @@ public function GetPlayers( ) : array
365365

366366
$this->GetChallenge( self::A2S_PLAYER, self::S2A_PLAYER );
367367

368-
$this->Socket->WritePadded( self::A2S_PLAYER, $this->Challenge );
368+
$this->Socket->Write( self::A2S_PLAYER, $this->Challenge );
369369
$Buffer = $this->Socket->Read( 14000 ); // Moronic Arma 3 developers do not split their packets, so we have to read more data
370370
// This violates the protocol spec, and they probably should fix it: https://developer.valvesoftware.com/wiki/Server_queries#Protocol
371371

@@ -411,7 +411,7 @@ public function GetRules( ) : array
411411

412412
$this->GetChallenge( self::A2S_RULES, self::S2A_RULES );
413413

414-
$this->Socket->WritePadded( self::A2S_RULES, $this->Challenge );
414+
$this->Socket->Write( self::A2S_RULES, $this->Challenge );
415415
$Buffer = $this->Socket->Read( );
416416

417417
$Type = $Buffer->GetByte( );
@@ -452,13 +452,10 @@ private function GetChallenge( int $Header, int $ExpectedResult ) : void
452452

453453
if( $this->UseOldGetChallengeMethod )
454454
{
455-
$this->Socket->Write( self::A2S_SERVERQUERY_GETCHALLENGE, "\xFF\xFF\xFF\xFF" );
456-
}
457-
else
458-
{
459-
$this->Socket->WritePadded( $Header, "\xFF\xFF\xFF\xFF" );
455+
$Header = self::A2S_SERVERQUERY_GETCHALLENGE;
460456
}
461457

458+
$this->Socket->Write( $Header, "\xFF\xFF\xFF\xFF" );
462459
$Buffer = $this->Socket->Read( );
463460

464461
$Type = $Buffer->GetByte( );

Tests/Tests.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ public function Write( int $Header, string $String = '' ) : bool
3838
return true;
3939
}
4040

41-
public function WritePadded( int $Header, string $String = '' ) : bool
42-
{
43-
return true;
44-
}
45-
4641
public function Read( int $Length = 1400 ) : Buffer
4742
{
4843
$Buffer = new Buffer( );

0 commit comments

Comments
 (0)