mirror of
https://github.com/xPaw/PHP-Source-Query.git
synced 2026-07-05 05:04:48 +02:00
Compare commits
3 Commits
2.1.0
..
cd3624704e
| Author | SHA1 | Date | |
|---|---|---|---|
| cd3624704e | |||
| e96807bb24 | |||
| 7f2e4484d5 |
@@ -9,12 +9,12 @@ The class also allows you to query servers using RCON although this only works f
|
||||
|
||||
[Minecraft](http://www.minecraft.net) also uses Source RCON protocol, and this means you can use this class to send commands to your minecraft server while having engine set to Source engine.
|
||||
|
||||
**:warning: Please do not create issues when you are unable to retrieve information from a server, unless you can prove that there is a bug within the library.**
|
||||
**:warning: Do not send me emails if this does not work for you, I will not help you.**
|
||||
|
||||
## Requirements
|
||||
* [Modern PHP version](https://php.net/supported-versions.php) (7.4 or newer)
|
||||
* 64-bit PHP or [gmp module](https://secure.php.net/manual/en/book.gmp.php)
|
||||
* Web server must allow UDP connections
|
||||
* Your server must allow UDP connections
|
||||
|
||||
## Protocol Specifications
|
||||
* https://developer.valvesoftware.com/wiki/Server_queries
|
||||
|
||||
+11
-10
@@ -38,7 +38,7 @@
|
||||
/**
|
||||
* Packets sent
|
||||
*/
|
||||
const A2S_PING = 0x69;
|
||||
const A2A_PING = 0x69;
|
||||
const A2S_INFO = 0x54;
|
||||
const A2S_PLAYER = 0x55;
|
||||
const A2S_RULES = 0x56;
|
||||
@@ -47,10 +47,10 @@
|
||||
/**
|
||||
* Packets received
|
||||
*/
|
||||
const S2A_PING = 0x6A;
|
||||
const S2A_CHALLENGE = 0x41;
|
||||
const S2A_INFO = 0x49;
|
||||
const S2A_INFO_OLD = 0x6D; // Old GoldSource, HLTV uses it
|
||||
const A2A_ACK = 0x6A;
|
||||
const S2C_CHALLENGE = 0x41;
|
||||
const S2A_INFO_SRC = 0x49;
|
||||
const S2A_INFO_OLD = 0x6D; // Old GoldSource, HLTV uses it (actually called S2A_INFO_DETAILED)
|
||||
const S2A_PLAYER = 0x44;
|
||||
const S2A_RULES = 0x45;
|
||||
const S2A_RCON = 0x6C;
|
||||
@@ -58,6 +58,7 @@
|
||||
/**
|
||||
* Source rcon sent
|
||||
*/
|
||||
const SERVERDATA_REQUESTVALUE = 0;
|
||||
const SERVERDATA_EXECCOMMAND = 2;
|
||||
const SERVERDATA_AUTH = 3;
|
||||
|
||||
@@ -179,10 +180,10 @@
|
||||
throw new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );
|
||||
}
|
||||
|
||||
$this->Socket->Write( self::A2S_PING );
|
||||
$this->Socket->Write( self::A2A_PING );
|
||||
$Buffer = $this->Socket->Read( );
|
||||
|
||||
return $Buffer->GetByte( ) === self::S2A_PING;
|
||||
return $Buffer->GetByte( ) === self::A2A_ACK;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,7 +214,7 @@
|
||||
$Type = $Buffer->GetByte( );
|
||||
$Server = [];
|
||||
|
||||
if( $Type === self::S2A_CHALLENGE )
|
||||
if( $Type === self::S2C_CHALLENGE )
|
||||
{
|
||||
$this->Challenge = $Buffer->Get( 4 );
|
||||
|
||||
@@ -263,7 +264,7 @@
|
||||
return $Server;
|
||||
}
|
||||
|
||||
if( $Type !== self::S2A_INFO )
|
||||
if( $Type !== self::S2A_INFO_SRC )
|
||||
{
|
||||
throw new InvalidPacketException( 'GetInfo: Packet header mismatch. (0x' . DecHex( $Type ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );
|
||||
}
|
||||
@@ -478,7 +479,7 @@
|
||||
|
||||
switch( $Type )
|
||||
{
|
||||
case self::S2A_CHALLENGE:
|
||||
case self::S2C_CHALLENGE:
|
||||
{
|
||||
$this->Challenge = $Buffer->Get( 4 );
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
// See https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Multiple-packet_Responses
|
||||
if( StrLen( $Data ) >= 4000 )
|
||||
{
|
||||
$this->Write( SourceQuery::SERVERDATA_RESPONSE_VALUE );
|
||||
$this->Write( SourceQuery::SERVERDATA_REQUESTVALUE );
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user