Skip to content

Commit eafb0c0

Browse files
committed
Return a less obtuse structure for config file editing
1 parent 3d22499 commit eafb0c0

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

app/Services/Eggs/EggConfigurationService.php

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,22 @@ protected function replacePlaceholders(Server $server, object $configs)
124124
}
125125

126126
foreach ($value as $find => $replace) {
127-
$append['replace'][] = ['match' => $find, 'value' => $replace];
127+
if (is_object($replace)) {
128+
foreach ($replace as $match => $replaceWith) {
129+
$append['replace'][] = [
130+
'match' => $find,
131+
'if_value' => $match,
132+
'replace_with' => $replaceWith,
133+
];
134+
}
135+
136+
continue;
137+
}
138+
139+
$append['replace'][] = [
140+
'match' => $find,
141+
'replace_with' => $replace,
142+
];
128143
}
129144
}
130145

@@ -155,17 +170,13 @@ protected function matchAndReplaceKeys(string $value, array $structure): ?string
155170
return self::NOT_MATCHED;
156171
}
157172

158-
// We don't want to do anything with config keys since the Daemon will need to handle
159-
// that. For example, the Spigot egg uses "config.docker.interface" to identify the Docker
160-
// interface to proxy through, but the Panel would be unaware of that.
161-
if (Str::startsWith($key, 'config.')) {
162-
return "{{{$key}}}";
163-
}
164-
165173
// The legacy Daemon would set SERVER_MEMORY, SERVER_IP, and SERVER_PORT with their
166174
// respective values on the Daemon side. Ensure that anything referencing those properly
167175
// replaces them with the matching config value.
168176
switch ($key) {
177+
case 'config.docker.interface':
178+
$key = 'config.docker.network.interface';
179+
break;
169180
case 'server.build.env.SERVER_MEMORY':
170181
case 'env.SERVER_MEMORY':
171182
$key = 'server.build.memory';
@@ -180,6 +191,13 @@ protected function matchAndReplaceKeys(string $value, array $structure): ?string
180191
break;
181192
}
182193

194+
// We don't want to do anything with config keys since the Daemon will need to handle
195+
// that. For example, the Spigot egg uses "config.docker.interface" to identify the Docker
196+
// interface to proxy through, but the Panel would be unaware of that.
197+
if (Str::startsWith($key, 'config.')) {
198+
return "{{{$key}}}";
199+
}
200+
183201
// Replace anything starting with "server." with the value out of the server configuration
184202
// array that used to be created for the old daemon.
185203
if (Str::startsWith($key, 'server.')) {

database/seeds/eggs/minecraft/egg-bungeecord.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"image": "quay.io\/pterodactyl\/core:java",
1111
"startup": "java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}",
1212
"config": {
13-
"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}",
13+
"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}",
1414
"startup": "{\r\n \"done\": \"Listening on \",\r\n \"userInteraction\": [\r\n \"Listening on \/0.0.0.0:25577\"\r\n ]\r\n}",
1515
"logs": "{\r\n \"custom\": false,\r\n \"location\": \"proxy.log.0\"\r\n}",
1616
"stop": "end"

0 commit comments

Comments
 (0)