@woopsy/mcpanel 2.1.2 ā 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -431,6 +431,12 @@ class CommandRouter {
|
|
|
431
431
|
if (status.address && status.address !== 'None') {
|
|
432
432
|
output.push(`\nš® Connect at: ${colors.bold(colors.green(`${status.address}:${status.port}`))}`);
|
|
433
433
|
}
|
|
434
|
+
// Persistence diagnostics: whether the agent is claimed/saved, and where.
|
|
435
|
+
// If this says "Not saved", /tunnel will re-claim a new agent every run.
|
|
436
|
+
const hasSecret = !!this.playitManager.getSecret();
|
|
437
|
+
output.push('');
|
|
438
|
+
output.push(`Agent secret: ${hasSecret ? colors.green('Saved (will reuse this agent)') : colors.red('Not saved ā /tunnel will claim a new agent')}`);
|
|
439
|
+
output.push(colors.gray(`Config file: ${this.configManager.getConfigPath()}`));
|
|
434
440
|
output.push('');
|
|
435
441
|
return output.join('\n');
|
|
436
442
|
}
|
|
@@ -176,12 +176,19 @@ class ConfigManager {
|
|
|
176
176
|
*/
|
|
177
177
|
save() {
|
|
178
178
|
try {
|
|
179
|
+
// Defensively recreate the data dir ā if it's missing at write time the
|
|
180
|
+
// write throws ENOENT and (previously) the secret was lost silently.
|
|
181
|
+
fs.mkdirSync(path.dirname(CONFIG_PATH), { recursive: true });
|
|
179
182
|
fs.writeFileSync(CONFIG_PATH, JSON.stringify(this.config, null, 2), 'utf-8');
|
|
180
183
|
}
|
|
181
184
|
catch (error) {
|
|
182
185
|
console.error('ā Failed to save configuration file:', error);
|
|
183
186
|
}
|
|
184
187
|
}
|
|
188
|
+
/** Absolute path of the config file on disk (for status/diagnostics). */
|
|
189
|
+
getConfigPath() {
|
|
190
|
+
return CONFIG_PATH;
|
|
191
|
+
}
|
|
185
192
|
/**
|
|
186
193
|
* Retrieves the raw config reference
|
|
187
194
|
*/
|
|
@@ -214,6 +221,23 @@ class ConfigManager {
|
|
|
214
221
|
setPlayitSecret(secret) {
|
|
215
222
|
this.config.playitSettings.secret = secret;
|
|
216
223
|
this.save();
|
|
224
|
+
// The whole point of claiming once is that the secret survives a restart.
|
|
225
|
+
// If it didn't reach disk, fail loudly now instead of silently re-claiming
|
|
226
|
+
// a brand-new agent (and orphaning the old one) on the next launch.
|
|
227
|
+
if (!this.isPlayitSecretPersisted(secret)) {
|
|
228
|
+
throw new Error(`Could not persist the playit agent secret to ${CONFIG_PATH}. ` +
|
|
229
|
+
`Check that the folder exists and is writable, then run /tunnel again.`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** Confirms the agent secret is readable back from disk (not just in memory). */
|
|
233
|
+
isPlayitSecretPersisted(secret) {
|
|
234
|
+
try {
|
|
235
|
+
const onDisk = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
236
|
+
return onDisk?.playitSettings?.secret === secret;
|
|
237
|
+
}
|
|
238
|
+
catch {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
217
241
|
}
|
|
218
242
|
/**
|
|
219
243
|
* Persists the last known tunnel details for status reporting between sessions.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@woopsy/mcpanel",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "MCPANEL ā a terminal-based, single-server Minecraft server manager with an Arch/neofetch-style UI, live logs, backups, plugins and Playit.gg tunnels.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|