Add known ids
This commit is contained in:
parent
a5224b6384
commit
fea4f7bc5e
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -137,3 +137,5 @@ dist
|
|||
# Vite logs files
|
||||
vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
||||
*.log
|
||||
known.json
|
27
index.js
27
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();
|
||||
|
|
Loading…
Reference in a new issue