Return a less obtuse structure for config file editing

This commit is contained in:
Dane Everitt 2020-04-12 12:22:50 -07:00
parent 3d224993cd
commit eafb0c061d
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 27 additions and 9 deletions

View file

@ -124,7 +124,22 @@ class EggConfigurationService
}
foreach ($value as $find => $replace) {
$append['replace'][] = ['match' => $find, 'value' => $replace];
if (is_object($replace)) {
foreach ($replace as $match => $replaceWith) {
$append['replace'][] = [
'match' => $find,
'if_value' => $match,
'replace_with' => $replaceWith,
];
}
continue;
}
$append['replace'][] = [
'match' => $find,
'replace_with' => $replace,
];
}
}
@ -155,17 +170,13 @@ class EggConfigurationService
return self::NOT_MATCHED;
}
// We don't want to do anything with config keys since the Daemon will need to handle
// that. For example, the Spigot egg uses "config.docker.interface" to identify the Docker
// interface to proxy through, but the Panel would be unaware of that.
if (Str::startsWith($key, 'config.')) {
return "{{{$key}}}";
}
// The legacy Daemon would set SERVER_MEMORY, SERVER_IP, and SERVER_PORT with their
// respective values on the Daemon side. Ensure that anything referencing those properly
// replaces them with the matching config value.
switch ($key) {
case 'config.docker.interface':
$key = 'config.docker.network.interface';
break;
case 'server.build.env.SERVER_MEMORY':
case 'env.SERVER_MEMORY':
$key = 'server.build.memory';
@ -180,6 +191,13 @@ class EggConfigurationService
break;
}
// We don't want to do anything with config keys since the Daemon will need to handle
// that. For example, the Spigot egg uses "config.docker.interface" to identify the Docker
// interface to proxy through, but the Panel would be unaware of that.
if (Str::startsWith($key, 'config.')) {
return "{{{$key}}}";
}
// Replace anything starting with "server." with the value out of the server configuration
// array that used to be created for the old daemon.
if (Str::startsWith($key, 'server.')) {

View file

@ -10,7 +10,7 @@
"image": "quay.io\/pterodactyl\/core:java",
"startup": "java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}",
"config": {
"files": "{\r\n \"config.yml\": {\r\n \"parser\": \"yaml\",\r\n \"find\": {\r\n \"listeners[0].query_enabled\": true,\r\n \"listeners[0].query_port\": \"{{server.build.default.port}}\",\r\n \"listeners[0].host\": \"0.0.0.0:{{server.build.default.port}}\",\r\n \"servers.*.address\": {\r\n \"127.0.0.1\": \"{{config.docker.interface}}\",\r\n \"localhost\": \"{{config.docker.interface}}\"\r\n }\r\n }\r\n }\r\n}",
"files": "{\r\n \"config.yml\": {\r\n \"parser\": \"yaml\",\r\n \"find\": {\r\n \"listeners[0].query_enabled\": true,\r\n \"listeners[0].query_port\": \"{{server.build.default.port}}\",\r\n \"listeners[0].host\": \"0.0.0.0:{{server.build.default.port}}\",\r\n \"servers.*.address\": {\r\n \"127.0.0.1\": \"{{config.docker.network.interface}}\",\r\n \"localhost\": \"{{config.docker.network.interface}}\"\r\n }\r\n }\r\n }\r\n}",
"startup": "{\r\n \"done\": \"Listening on \",\r\n \"userInteraction\": [\r\n \"Listening on \/0.0.0.0:25577\"\r\n ]\r\n}",
"logs": "{\r\n \"custom\": false,\r\n \"location\": \"proxy.log.0\"\r\n}",
"stop": "end"