Skip to content

Commit 979bdc1

Browse files
committed
Use YAML for configuration file
1 parent c087f64 commit 979bdc1

File tree

5 files changed

+104
-115
lines changed

5 files changed

+104
-115
lines changed

app/Http/Controllers/Daemon/ActionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ public function configuration(Request $request, $token)
102102
$node = Node::findOrFail($nodeId);
103103

104104
// Manually as getConfigurationAsJson() returns it in correct format already
105-
return response($node->getConfigurationAsJson())->header('Content-Type', 'text/json');
105+
return [];
106106
}
107107
}

app/Models/Node.php

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Pterodactyl\Models;
44

5+
use Symfony\Component\Yaml\Yaml;
56
use Illuminate\Notifications\Notifiable;
67
use Pterodactyl\Models\Traits\Searchable;
78

@@ -151,71 +152,58 @@ public function getConnectionAddress(): string
151152
/**
152153
* Returns the configuration in JSON format.
153154
*
154-
* @param bool $pretty
155155
* @return string
156156
*/
157-
public function getConfigurationAsJson($pretty = false)
157+
public function getYamlConfiguration()
158158
{
159159
$config = [
160-
'web' => [
160+
'debug' => false,
161+
'api' => [
161162
'host' => '0.0.0.0',
162-
'listen' => $this->daemonListen,
163+
'port' => $this->daemonListen,
163164
'ssl' => [
164165
'enabled' => (! $this->behind_proxy && $this->scheme === 'https'),
165166
'certificate' => '/etc/letsencrypt/live/' . $this->fqdn . '/fullchain.pem',
166167
'key' => '/etc/letsencrypt/live/' . $this->fqdn . '/privkey.pem',
167168
],
169+
'upload_limit' => $this->upload_size,
168170
],
169-
'docker' => [
170-
'container' => [
171-
'user' => null,
171+
'system' => [
172+
'data' => $this->daemonBase,
173+
'username' => 'pterodactyl',
174+
'timezone_path' => '/etc/timezone',
175+
'set_permissions_on_boot' => true,
176+
'detect_clean_exit_as_crash' => false,
177+
'sftp' => [
178+
'use_internal' => true,
179+
'disable_disk_checking' => false,
180+
'bind_address' => '0.0.0.0',
181+
'bind_port' => $this->daemonSFTP,
182+
'read_only' => false,
172183
],
184+
],
185+
'docker' => [
173186
'network' => [
187+
'interface' => '172.18.0.1',
174188
'name' => 'pterodactyl_nw',
189+
'driver' => 'bridge',
175190
],
191+
'update_images' => true,
176192
'socket' => '/var/run/docker.sock',
177-
'autoupdate_images' => true,
178-
],
179-
'filesystem' => [
180-
'server_logs' => '/tmp/pterodactyl',
181-
],
182-
'internals' => [
183-
'disk_use_seconds' => 30,
184-
'set_permissions_on_boot' => true,
185-
'throttle' => [
186-
'enabled' => true,
187-
'kill_at_count' => 5,
188-
'decay' => 10,
189-
'lines' => 1000,
190-
'check_interval_ms' => 100,
191-
],
192-
],
193-
'sftp' => [
194-
'path' => $this->daemonBase,
195-
'ip' => '0.0.0.0',
196-
'port' => $this->daemonSFTP,
197-
'keypair' => [
198-
'bits' => 2048,
199-
'e' => 65537,
200-
],
201-
],
202-
'logger' => [
203-
'path' => 'logs/',
204-
'src' => false,
205-
'level' => 'info',
206-
'period' => '1d',
207-
'count' => 3,
208-
],
209-
'remote' => [
210-
'base' => route('index'),
193+
'timezone_path' => '/etc/timezone',
211194
],
212-
'uploads' => [
213-
'size_limit' => $this->upload_size,
195+
'disk_check_timeout' => 30,
196+
'throttles' => [
197+
'kill_at_count' => 5,
198+
'decay' => 10,
199+
'bytes' => 4096,
200+
'check_interval' => 100,
214201
],
215-
'keys' => [$this->daemonSecret],
202+
'remote' => route('index'),
203+
'token' => $this->daemonSecret,
216204
];
217205

218-
return json_encode($config, ($pretty) ? JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT : JSON_UNESCAPED_SLASHES);
206+
return Yaml::dump($config, 4, 2);
219207
}
220208

221209
/**

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@
3434
"s1lentium/iptools": "^1.1",
3535
"spatie/laravel-fractal": "^5.6",
3636
"staudenmeir/belongs-to-through": "^2.6",
37+
"symfony/yaml": "^4.0",
3738
"webmozart/assert": "^1.5"
3839
},
3940
"require-dev": {
4041
"barryvdh/laravel-debugbar": "^3.2",
4142
"barryvdh/laravel-ide-helper": "^2.6",
42-
"codedungeon/phpunit-result-printer": "^0.26",
43+
"codedungeon/phpunit-result-printer": "0.25.1",
4344
"friendsofphp/php-cs-fixer": "^2.15.1",
4445
"laravel/dusk": "^5.5",
4546
"php-mock/php-mock-phpunit": "^2.4",

composer.lock

Lines changed: 66 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/views/admin/nodes/view/configuration.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
<h3 class="box-title">Configuration File</h3>
4141
</div>
4242
<div class="box-body">
43-
<pre class="no-margin">{{ $node->getConfigurationAsJson(true) }}</pre>
43+
<pre class="no-margin">{{ $node->getYamlConfiguration() }}</pre>
4444
</div>
4545
<div class="box-footer">
46-
<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>
46+
<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>
4747
</div>
4848
</div>
4949
</div>

0 commit comments

Comments
 (0)