Refactor MitmServerCard to use input field for API key selection and enhance shutdown process to remove DNS entries synchronously. Added removeAllDNSEntriesSync function for safe cleanup during shutdown.

This commit is contained in:
decolua
2026-04-28 10:08:57 +07:00
parent 85959aac22
commit 8204bba79f
3 changed files with 46 additions and 15 deletions
+10 -1
View File
@@ -266,7 +266,16 @@ server.on("error", (e) => {
process.exit(1);
});
const shutdown = () => server.close(() => process.exit(0));
const { removeAllDNSEntriesSync } = require("./dns/dnsConfig");
let isShuttingDown = false;
const shutdown = () => {
if (isShuttingDown) return;
isShuttingDown = true;
// Strip tool hosts from /etc/hosts so other apps aren't broken after exit
removeAllDNSEntriesSync();
const forceExit = setTimeout(() => process.exit(0), 1500);
server.close(() => { clearTimeout(forceExit); process.exit(0); });
};
process.on("SIGTERM", shutdown);
process.on("SIGINT", shutdown);
if (process.platform === "win32") process.on("SIGBREAK", shutdown);