Use YAML for configuration file

This commit is contained in:
Dane Everitt 2019-12-08 11:29:46 -08:00
parent c087f6429f
commit 979bdc1f9f
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
5 changed files with 104 additions and 115 deletions

View File

@ -102,6 +102,6 @@ class ActionController extends Controller
$node = Node::findOrFail($nodeId);
// Manually as getConfigurationAsJson() returns it in correct format already
return response($node->getConfigurationAsJson())->header('Content-Type', 'text/json');
return [];
}
}

View File

@ -2,6 +2,7 @@
namespace Pterodactyl\Models;
use Symfony\Component\Yaml\Yaml;
use Illuminate\Notifications\Notifiable;
use Pterodactyl\Models\Traits\Searchable;
@ -151,71 +152,58 @@ class Node extends Validable
/**
* Returns the configuration in JSON format.
*
* @param bool $pretty
* @return string
*/
public function getConfigurationAsJson($pretty = false)
public function getYamlConfiguration()
{
$config = [
'web' => [
'debug' => false,
'api' => [
'host' => '0.0.0.0',
'listen' => $this->daemonListen,
'port' => $this->daemonListen,
'ssl' => [
'enabled' => (! $this->behind_proxy && $this->scheme === 'https'),
'certificate' => '/etc/letsencrypt/live/' . $this->fqdn . '/fullchain.pem',
'key' => '/etc/letsencrypt/live/' . $this->fqdn . '/privkey.pem',
],
'upload_limit' => $this->upload_size,
],
'system' => [
'data' => $this->daemonBase,
'username' => 'pterodactyl',
'timezone_path' => '/etc/timezone',
'set_permissions_on_boot' => true,
'detect_clean_exit_as_crash' => false,
'sftp' => [
'use_internal' => true,
'disable_disk_checking' => false,
'bind_address' => '0.0.0.0',
'bind_port' => $this->daemonSFTP,
'read_only' => false,
],
],
'docker' => [
'container' => [
'user' => null,
],
'network' => [
'interface' => '172.18.0.1',
'name' => 'pterodactyl_nw',
'driver' => 'bridge',
],
'update_images' => true,
'socket' => '/var/run/docker.sock',
'autoupdate_images' => true,
'timezone_path' => '/etc/timezone',
],
'filesystem' => [
'server_logs' => '/tmp/pterodactyl',
'disk_check_timeout' => 30,
'throttles' => [
'kill_at_count' => 5,
'decay' => 10,
'bytes' => 4096,
'check_interval' => 100,
],
'internals' => [
'disk_use_seconds' => 30,
'set_permissions_on_boot' => true,
'throttle' => [
'enabled' => true,
'kill_at_count' => 5,
'decay' => 10,
'lines' => 1000,
'check_interval_ms' => 100,
],
],
'sftp' => [
'path' => $this->daemonBase,
'ip' => '0.0.0.0',
'port' => $this->daemonSFTP,
'keypair' => [
'bits' => 2048,
'e' => 65537,
],
],
'logger' => [
'path' => 'logs/',
'src' => false,
'level' => 'info',
'period' => '1d',
'count' => 3,
],
'remote' => [
'base' => route('index'),
],
'uploads' => [
'size_limit' => $this->upload_size,
],
'keys' => [$this->daemonSecret],
'remote' => route('index'),
'token' => $this->daemonSecret,
];
return json_encode($config, ($pretty) ? JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT : JSON_UNESCAPED_SLASHES);
return Yaml::dump($config, 4, 2);
}
/**

View File

@ -34,12 +34,13 @@
"s1lentium/iptools": "^1.1",
"spatie/laravel-fractal": "^5.6",
"staudenmeir/belongs-to-through": "^2.6",
"symfony/yaml": "^4.0",
"webmozart/assert": "^1.5"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"barryvdh/laravel-ide-helper": "^2.6",
"codedungeon/phpunit-result-printer": "^0.26",
"codedungeon/phpunit-result-printer": "0.25.1",
"friendsofphp/php-cs-fixer": "^2.15.1",
"laravel/dusk": "^5.5",
"php-mock/php-mock-phpunit": "^2.4",

132
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "54a69da316f2921ebcae63ec6b054468",
"content-hash": "39fbdca3eac026ce6a99684706ffa03b",
"packages": [
{
"name": "appstract/laravel-blade-directives",
@ -4441,6 +4441,65 @@
],
"time": "2019-08-26T08:26:39+00:00"
},
{
"name": "symfony/yaml",
"version": "v4.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "76de473358fe802578a415d5bb43c296cf09d211"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/76de473358fe802578a415d5bb43c296cf09d211",
"reference": "76de473358fe802578a415d5bb43c296cf09d211",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/polyfill-ctype": "~1.8"
},
"conflict": {
"symfony/console": "<3.4"
},
"require-dev": {
"symfony/console": "^3.4|^4.0|^5.0"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2019-11-12T14:51:11+00:00"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
"version": "2.2.1",
@ -4879,16 +4938,16 @@
},
{
"name": "codedungeon/phpunit-result-printer",
"version": "0.26.1",
"version": "0.25.1",
"source": {
"type": "git",
"url": "https://github.com/mikeerickson/phpunit-pretty-result-printer.git",
"reference": "70efe139f174954392582103355a1b4a3d9022e5"
"reference": "4a689ac40366eb4adf166cf4676da7ef30d82315"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mikeerickson/phpunit-pretty-result-printer/zipball/70efe139f174954392582103355a1b4a3d9022e5",
"reference": "70efe139f174954392582103355a1b4a3d9022e5",
"url": "https://api.github.com/repos/mikeerickson/phpunit-pretty-result-printer/zipball/4a689ac40366eb4adf166cf4676da7ef30d82315",
"reference": "4a689ac40366eb4adf166cf4676da7ef30d82315",
"shasum": ""
},
"require": {
@ -4899,7 +4958,7 @@
"symfony/yaml": "^2.7|^3.0|^4.0"
},
"require-dev": {
"phpunit/phpunit": "8.0.*",
"phpunit/phpunit": "7.5.*",
"spatie/phpunit-watcher": "^1.6"
},
"type": "library",
@ -4928,7 +4987,7 @@
"result-printer",
"testing"
],
"time": "2019-02-28T18:52:43+00:00"
"time": "2019-02-01T19:13:43+00:00"
},
{
"name": "composer/ca-bundle",
@ -7546,65 +7605,6 @@
"homepage": "https://symfony.com",
"time": "2019-08-07T11:52:19+00:00"
},
{
"name": "symfony/yaml",
"version": "v4.3.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "5a0b7c32dc3ec56fd4abae8a4a71b0cf05013686"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/5a0b7c32dc3ec56fd4abae8a4a71b0cf05013686",
"reference": "5a0b7c32dc3ec56fd4abae8a4a71b0cf05013686",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/polyfill-ctype": "~1.8"
},
"conflict": {
"symfony/console": "<3.4"
},
"require-dev": {
"symfony/console": "~3.4|~4.0"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Yaml\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2019-08-20T14:27:59+00:00"
},
{
"name": "theseer/tokenizer",
"version": "1.1.3",

View File

@ -40,10 +40,10 @@
<h3 class="box-title">Configuration File</h3>
</div>
<div class="box-body">
<pre class="no-margin">{{ $node->getConfigurationAsJson(true) }}</pre>
<pre class="no-margin">{{ $node->getYamlConfiguration() }}</pre>
</div>
<div class="box-footer">
<p class="no-margin">This file should be placed in your daemon's <code>config</code> directory in a file called <code>core.json</code>.</p>
<p class="no-margin">This file should be placed in your daemon's root directory (usually <code>/srv/wings</code>) in a file called <code>config.yml</code>.</p>
</div>
</div>
</div>