Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fieu committed Jun 25, 2020
1 parent 502f5d9 commit fc5b408
Show file tree
Hide file tree
Showing 18 changed files with 4,853 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_style = space
indent_size = 2
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* text=auto
/.github export-ignore
.styleci.yml export-ignore
.scrutinizer.yml export-ignore
BACKERS.md export-ignore
CONTRIBUTING.md export-ignore
CHANGELOG.md export-ignore
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/vendor
/.idea
/.vscode
/.vagrant
/builds/phust
.phpunit.result.cache
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<p align="center">
<h1>phust</h1>
</p>

<h4> <center>Send RCON commands to your Rust server via the command-line</center></h4>

### Requirements
* PHP >= 7.2.5

### Installation
Download the latest binary from the [releases](https://github.com/coef/phust/releases) page.

### Usage
```sh
$ chmod +x phust
$ ./phust rcon:send --help
$ ./phust rcon:send --ip "server.ip" --port "28016" --pass "password" --command "status"
```

------

## License

Phust is an open-source software licensed under the [MIT license](https://github.com/coef/phust/blob/master/LICENSE.md).
Empty file added app/Commands/.gitkeep
Empty file.
58 changes: 58 additions & 0 deletions app/Commands/SendRconCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Commands;

use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
use WebSocket\Client;

class SendRconCommand extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'rcon:send {--command= : Command to be sent to server (required)}
{--ip= : IP of server (required)}
{--port= : Port of server (required)}
{--pass= : RCON Password (required)}';

/**
* The description of the command.
*
* @var string
*/
protected $description = 'Send RCON command';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$needs = [
'command',
'ip',
'port',
'pass',
];
foreach ($needs as $need) {
if (!array_key_exists($need, $this->options()) || empty($this->options()[$need])) {
$this->error('Please pass all required options');
exit(1);
}
}
$client = new Client("ws://{$this->option('ip')}:{$this->option('port')}/{$this->option('pass')}");
$data = json_encode([
'Identifier' => 0,
'Message' => $this->option('command'),
'Stacktrace' => '',
'Type' => 3
]);
$client->send($data);
$result = json_decode($client->receive());
echo $result->Message;
}
}
28 changes: 28 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}

/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}
50 changes: 50 additions & 0 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/

$app = new LaravelZero\Framework\Application(
dirname(__DIR__)
);

/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/

$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
LaravelZero\Framework\Kernel::class
);

$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
Illuminate\Foundation\Exceptions\Handler::class
);

/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/

return $app;
18 changes: 18 additions & 0 deletions box.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"chmod": "0755",
"directories": [
"app",
"bootstrap",
"config",
"vendor"
],
"files": [
"composer.json"
],
"exclude-composer-files": false,
"compression": "GZ",
"compactors": [
"KevinGH\\Box\\Compactor\\Php",
"KevinGH\\Box\\Compactor\\Json"
]
}
58 changes: 58 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "laravel-zero/laravel-zero",
"description": "The Laravel Zero Framework.",
"keywords": [
"framework",
"laravel",
"laravel zero",
"console",
"cli"
],
"homepage": "https://laravel-zero.com",
"type": "project",
"license": "MIT",
"support": {
"issues": "https://github.com/laravel-zero/laravel-zero/issues",
"source": "https://github.com/laravel-zero/laravel-zero"
},
"authors": [
{
"name": "Nuno Maduro",
"email": "[email protected]"
}
],
"require": {
"php": "^7.2.5",
"laravel-zero/framework": "^7.0",
"textalk/websocket": "^1.3"
},
"require-dev": {
"mockery/mockery": "^1.3.1",
"phpunit/phpunit": "^8.5"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"scripts": {
"post-create-project-cmd": [
"@php application app:rename"
]
},
"minimum-stability": "dev",
"prefer-stable": true,
"bin": [
"phust"
]
}
Loading

0 comments on commit fc5b408

Please sign in to comment.