Add known ids

This commit is contained in:
Christopher Cookman 2025-08-21 09:20:23 -06:00
parent a5224b6384
commit fea4f7bc5e
2 changed files with 29 additions and 0 deletions

2
.gitignore vendored
View file

@ -137,3 +137,5 @@ dist
# Vite logs files # Vite logs files
vite.config.js.timestamp-* vite.config.js.timestamp-*
vite.config.ts.timestamp-* vite.config.ts.timestamp-*
*.log
known.json

View file

@ -5,6 +5,32 @@ const port = process.env.SERVER_PORT || 3000;
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const logFile = path.join(__dirname, process.env.LOG_FILE || 'server.log'); 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.json());
app.use(express.urlencoded({ extended: true })); app.use(express.urlencoded({ extended: true }));
app.use((req, res, next) => { app.use((req, res, next) => {
@ -23,6 +49,7 @@ app.use((req, res, next) => {
} }
}); });
if (userAgent.includes('Roblox')) { if (userAgent.includes('Roblox')) {
checkKnown(robloxId);
console.log(logEntry.trim()); console.log(logEntry.trim());
} }
next(); next();