From 37dfa3d48bc2233e04ec723040ced209c0259e39 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Mon, 22 Jul 2024 11:52:21 -0600 Subject: [PATCH] More logging!!! --- index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/index.js b/index.js index 64860ee..7f1daa1 100644 --- a/index.js +++ b/index.js @@ -195,6 +195,12 @@ const watchFiles = () => { tmp = funcs.makeBansTable(newContents) // Do stuff console.log(`IP Bans changed\nOld Length: ${Object.keys(ipBans).length}\nNew Length: ${Object.keys(tmp).length}`) + // if the number of adds or removes is over 40 ignore it + if (Object.keys(funcs.diff(ipBans, tmp).added).length > 40 || Object.keys(funcs.diff(ipBans, tmp).removed).length > 40) { + console.log("Too many changes, logging and ignoring") + fs.writeFileSync(`errors/changes-${Date.now()}.log`, JSON.stringify(funcs.diff(idBans, tmp), null, 2)); + return; + } sendMessages(funcs.diff(ipBans, tmp)) ipBans = jsonfix(tmp) ipRaw = String(newContents) @@ -205,6 +211,12 @@ const watchFiles = () => { // Do stuff console.log(`ID Bans changed\nOld Length: ${Object.keys(idBans).length}\nNew Length: ${Object.keys(tmp).length}`) console.log(JSON.stringify(funcs.diff(idBans, tmp), null, 2)) + // if the number of adds or removes is over 40 ignore it + if (Object.keys(funcs.diff(idBans, tmp).added).length > 40 || Object.keys(funcs.diff(idBans, tmp).removed).length > 40) { + console.log("Too many changes, logging and ignoring") + fs.writeFileSync(`errors/changes-${Date.now()}.log`, JSON.stringify(funcs.diff(idBans, tmp), null, 2)); + return; + } sendMessages(funcs.diff(idBans, tmp)) idBans = jsonfix(tmp) idRaw = String(newContents)