From fea4f7bc5e04b76e4459bf9e4305834d7b3d9679 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Thu, 21 Aug 2025 09:20:23 -0600 Subject: [PATCH] Add known ids --- .gitignore | 2 ++ index.js | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/.gitignore b/.gitignore index 9a5aced..430e8ca 100644 --- a/.gitignore +++ b/.gitignore @@ -137,3 +137,5 @@ dist # Vite logs files vite.config.js.timestamp-* vite.config.ts.timestamp-* +*.log +known.json \ No newline at end of file diff --git a/index.js b/index.js index 18e296a..127645f 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,32 @@ const port = process.env.SERVER_PORT || 3000; const path = require('path'); const fs = require('fs'); const logFile = path.join(__dirname, process.env.LOG_FILE || 'server.log'); +var known = []; +const reloadKnown = () => { + if (!fs.existsSync(path.join(__dirname, process.env.KNOWN_FILE || 'known.json'))) { + fs.writeFileSync(path.join(__dirname, process.env.KNOWN_FILE || 'known.json'), JSON.stringify([]), 'utf8'); + } + try { + const data = fs.readFileSync(path.join(__dirname, process.env.KNOWN_FILE || 'known.json'), 'utf8'); + known = JSON.parse(data); + } catch (err) { + console.error('Error reading known file:', err); + } +} + +reloadKnown(); + +const checkKnown = (id) => { + if (known.includes(id)) { + return true; + } else { + known.push(id); + console.log(`New ID added! ${id}`); + fs.writeFileSync(path.join(__dirname, process.env.KNOWN_FILE || 'known.json'), JSON.stringify(known), 'utf8'); + return false; + } +}; + app.use(express.json()); app.use(express.urlencoded({ extended: true })); app.use((req, res, next) => { @@ -23,6 +49,7 @@ app.use((req, res, next) => { } }); if (userAgent.includes('Roblox')) { + checkKnown(robloxId); console.log(logEntry.trim()); } next();