From eafb0c061d5ebb0253e95e9ec8599ee3ac038726 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 12 Apr 2020 12:22:50 -0700 Subject: [PATCH] Return a less obtuse structure for config file editing --- app/Services/Eggs/EggConfigurationService.php | 34 ++++++++++++++----- .../seeds/eggs/minecraft/egg-bungeecord.json | 2 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/Services/Eggs/EggConfigurationService.php b/app/Services/Eggs/EggConfigurationService.php index 96b6a72bb..e2dac7281 100644 --- a/app/Services/Eggs/EggConfigurationService.php +++ b/app/Services/Eggs/EggConfigurationService.php @@ -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.')) { diff --git a/database/seeds/eggs/minecraft/egg-bungeecord.json b/database/seeds/eggs/minecraft/egg-bungeecord.json index d527024f3..347ad2bec 100644 --- a/database/seeds/eggs/minecraft/egg-bungeecord.json +++ b/database/seeds/eggs/minecraft/egg-bungeecord.json @@ -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"