1
0
mirror of https://github.com/xPaw/PHP-Source-Query.git synced 2026-05-18 13:43:33 +02:00

Throw more when using RCON

This commit is contained in:
Pavel Djundik
2015-10-24 16:11:55 +03:00
parent 4be6bf48c1
commit 613299b2bc
3 changed files with 5 additions and 12 deletions
+3 -5
View File
@@ -71,7 +71,7 @@
if( $Buffer->GetByte( ) !== SourceQuery::S2A_RCON ) if( $Buffer->GetByte( ) !== SourceQuery::S2A_RCON )
{ {
return false; throw new InvalidPacketException( 'Invalid rcon response.', InvalidPacketException::PACKET_HEADER_MISMATCH );
} }
$Buffer = $Buffer->Get( ); $Buffer = $Buffer->Get( );
@@ -114,7 +114,7 @@
{ {
if( !$this->RconChallenge ) if( !$this->RconChallenge )
{ {
return false; throw new AuthenticationException( 'Tried to execute a RCON command before successful authorization.', AuthenticationException::BAD_PASSWORD );
} }
$this->Write( 0, 'rcon ' . $this->RconChallenge . ' "' . $this->RconPassword . '" ' . $Command . "\0" ); $this->Write( 0, 'rcon ' . $this->RconChallenge . ' "' . $this->RconPassword . '" ' . $Command . "\0" );
@@ -132,11 +132,9 @@
if( $Buffer->Get( 14 ) !== 'challenge rcon' ) if( $Buffer->Get( 14 ) !== 'challenge rcon' )
{ {
return false; throw new AuthenticationException( 'Failed to get RCON challenge.', AuthenticationException::BAD_PASSWORD );
} }
$this->RconChallenge = Trim( $Buffer->Get( ) ); $this->RconChallenge = Trim( $Buffer->Get( ) );
return true;
} }
} }
+1 -4
View File
@@ -503,8 +503,6 @@
* @throws AuthenticationException * @throws AuthenticationException
* @throws InvalidPacketException * @throws InvalidPacketException
* @throws SocketException * @throws SocketException
*
* @return bool True if authentication succeeded, false on failure
*/ */
public function SetRconPassword( $Password ) public function SetRconPassword( $Password )
{ {
@@ -530,8 +528,7 @@
} }
$this->Rcon->Open( ); $this->Rcon->Open( );
$this->Rcon->Authorize( $Password );
return $this->Rcon->Authorize( $Password );
} }
/** /**
+1 -3
View File
@@ -137,7 +137,7 @@
} }
else if( $Type !== SourceQuery::SERVERDATA_RESPONSE_VALUE ) else if( $Type !== SourceQuery::SERVERDATA_RESPONSE_VALUE )
{ {
return false; throw new InvalidPacketException( 'Invalid rcon response.', InvalidPacketException::PACKET_HEADER_MISMATCH );
} }
$Data = $Buffer->Get( ); $Data = $Buffer->Get( );
@@ -197,7 +197,5 @@
{ {
throw new AuthenticationException( 'RCON authorization failed.', AuthenticationException::BAD_PASSWORD ); throw new AuthenticationException( 'RCON authorization failed.', AuthenticationException::BAD_PASSWORD );
} }
return true;
} }
} }