-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ae5cf9
commit 650f861
Showing
39 changed files
with
1,105 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,8 @@ language: php | |
dist: trusty | ||
|
||
php: | ||
- '7.2' | ||
- '7.3' | ||
# - '7.4' | ||
- '7.4' | ||
|
||
services: | ||
- mysql | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Azuriom\Games; | ||
|
||
use Azuriom\Models\User; | ||
|
||
/** | ||
* Fallback auth implementation unrelated to a game. | ||
*/ | ||
class FallbackGame extends Game | ||
{ | ||
public function name() | ||
{ | ||
return 'None'; | ||
} | ||
|
||
public function getAvatarUrl(User $user, int $size = 64) | ||
{ | ||
return 'https://www.gravatar.com/avatar/'.md5($user->email).'?d=mp&s='.$size; | ||
} | ||
|
||
public function getUserUniqueId(string $name) | ||
{ | ||
return null; | ||
} | ||
|
||
public function getUserName(User $user) | ||
{ | ||
return $user->name; | ||
} | ||
|
||
public function getSupportedServers() | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Azuriom\Games; | ||
|
||
use Azuriom\Models\User; | ||
|
||
class FallbackServerBridge extends ServerBridge | ||
{ | ||
public function getServerData() | ||
{ | ||
return null; | ||
} | ||
|
||
public function verifyLink() | ||
{ | ||
return false; | ||
} | ||
|
||
public function sendCommands(array $commands, User $user = null, bool $needConnected = false) | ||
{ | ||
foreach ($commands as $command) { | ||
$this->server->commands()->create([ | ||
'command' => $command, | ||
'user_id' => $user->name ?? null, | ||
'need_online' => $needConnected, | ||
]); | ||
} | ||
} | ||
|
||
public function canExecuteCommand() | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Azuriom\Games\Steam; | ||
|
||
use Azuriom\Games\Steam\Servers\Query; | ||
use Azuriom\Games\Steam\Servers\RustRcon; | ||
|
||
class RustGame extends SteamGame | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct('Rust'); | ||
} | ||
|
||
public function getSupportedServers() | ||
{ | ||
return [ | ||
'source-query' => Query::class, | ||
// Rust use a WebSocket based Rcon | ||
'rust-rcon' => RustRcon::class, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Azuriom\Games\Steam\Servers\Protocol; | ||
|
||
use WebSocket\Client; | ||
|
||
/** | ||
* A Rust RCON client implementation in PHP. | ||
* | ||
* Based on https://github.com/Facepunch/webrcon | ||
*/ | ||
class RustRcon | ||
{ | ||
/** | ||
* The websocket client. | ||
* | ||
* @var \WebSocket\Client | ||
*/ | ||
private $client; | ||
|
||
/** | ||
* Create a new Rcon instance. | ||
* | ||
* @param string $host | ||
* @param int $port | ||
* @param string $password | ||
*/ | ||
public function __construct(string $host, int $port, string $password) | ||
{ | ||
$this->client = new Client("ws://{$host}:{$port}/{$password}"); | ||
} | ||
|
||
/** | ||
* Send a command to the connected server. | ||
* | ||
* @param string $command | ||
* @return array | ||
* | ||
* @throws \WebSocket\BadOpcodeException | ||
*/ | ||
public function sendCommand(string $command) | ||
{ | ||
$data = [ | ||
'Identifier' => -1, | ||
'Message' => $command, | ||
'name' => 'AzuriomRcon', | ||
]; | ||
|
||
$this->client->send(json_encode($data)); | ||
|
||
return json_decode($this->client->receive(), true); | ||
} | ||
|
||
/** | ||
* Disconnect from the server. | ||
* | ||
* @return void | ||
*/ | ||
public function disconnect() | ||
{ | ||
$this->client->close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.