diff --git a/config/config.json b/config/config.json index 2fd13e9..d73ef86 100644 --- a/config/config.json +++ b/config/config.json @@ -8,8 +8,6 @@ "verboseLogs": false, "autoDownloadPlaylist": true, "customCodec": "h264", - - "logSystem": true, "outputTitleCheck": true, "downloadSystem": true, diff --git a/main.js b/main.js index 1dced18..e8a3a07 100644 --- a/main.js +++ b/main.js @@ -204,22 +204,49 @@ app.whenReady().then(async () => { ipcMain.handle("features", () => { return configFeatures; }); + + const featureWhitelist = new Set([ + "autoUpdate", + "discordRPC", + "customTopBar", + "autoCheckInfo", + "addThumbnail", + "addMetadata", + "verboseLogs", + "autoDownloadPlaylist", + "customCodec" + ]); + ipcMain.handle("set-feature", (event, { key, value }) => { - try { - // update mémoire - configFeatures[key] = value; + try { + if (!featureWhitelist.has(key)) { + logger.warn(`Rejected feature (not whitelisted): ${key}`); + return false; + } - // écriture directe sur le JSON - fs.writeFileSync(configFolderPath, JSON.stringify(configFeatures, null, 2), "utf-8"); + // optionnel mais propre + if (configFeatures[key] === value) { + return true; + } + + configFeatures[key] = value; + + fs.writeFileSync( + configFolderPath, + JSON.stringify(configFeatures, null, 2), + "utf-8" + ); + + logger.info(`Feature updated: ${key} = ${value}`); + return true; + + } catch (err) { + logger.error(`set-feature failed (${key}): ${err.message}`); + return false; + } + }); - logger.info(`Feature updated: ${key} = ${value}`); - return true; - } catch (err) { - logger.error(`set-feature failed (${key}): ${err.message}`); - return false; - } - }); configFeatures.discordRPC ? startRPC() : "";