last modif
This commit is contained in:
@@ -40,16 +40,16 @@ const isAuthenticated = async (req, res, next) => {
|
||||
const currentday = dayjs().date();
|
||||
fs.ensureDirSync(`../tmp/tokens`);
|
||||
let menagedone = fs.existsSync(
|
||||
`../../../tmp/tokens/menagedone${currentday}`
|
||||
`../../tmp/tokens/menagedone${currentday}`
|
||||
);
|
||||
if (menagedone) console.log(Date.now(),`menagedone${currentday} was it done today?:${menagedone}`);
|
||||
if (!menagedone) {
|
||||
// clean oldest
|
||||
const tsday = dayjs().valueOf(); // now in timestamp format
|
||||
glob.sync(`../../../tmp/tokens/menagedone*`).forEach((f) => {
|
||||
glob.sync(`../../tmp/tokens/menagedone*`).forEach((f) => {
|
||||
fs.removeSync(f);
|
||||
});
|
||||
glob.sync(`../../../tmp/tokens/*.json`).forEach((f) => {
|
||||
glob.sync(`../../tmp/tokens/*.json`).forEach((f) => {
|
||||
const fsplit = f.split("_");
|
||||
const elapse = tsday - parseInt(fsplit[2]);
|
||||
//24h 86400000 milliseconde 15mn 900000
|
||||
@@ -58,11 +58,11 @@ const isAuthenticated = async (req, res, next) => {
|
||||
}
|
||||
});
|
||||
//clean tmp
|
||||
glob.sync(`../../../tmp/*.txt`).forEach((f) => {
|
||||
glob.sync(`../../tmp/*.txt`).forEach((f) => {
|
||||
fs.remove(f);
|
||||
});
|
||||
fs.outputFile(
|
||||
`../../../tmp/tokens/menagedone${currentday}`,
|
||||
`../../tmp/tokens/menagedone${currentday}`,
|
||||
"done by middleware/isAUthenticated"
|
||||
);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ const isAuthenticated = async (req, res, next) => {
|
||||
return res.status(resnotauth.status).json(resnotauth);
|
||||
}
|
||||
|
||||
let tmpfs = `../../../tmp/tokens/${req.session.header.xalias}_${req.session.header.xtribe}_${req.session.header.xdays}`;
|
||||
let tmpfs = `../../tmp/tokens/${req.session.header.xalias}_${req.session.header.xtribe}_${req.session.header.xdays}`;
|
||||
//max filename in ext4: 255 characters
|
||||
tmpfs += `_${req.session.header.xhash.substring(
|
||||
150,
|
||||
@@ -97,7 +97,7 @@ const isAuthenticated = async (req, res, next) => {
|
||||
const sleep = (ms) => {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
};
|
||||
const failstamp = `../../../tmp/tokens/${alias}.json`;
|
||||
const failstamp = `../../tmp/tokens/${alias}.json`;
|
||||
if (action == "clean") {
|
||||
//to reinit bruteforce checker
|
||||
if (log) console.log(currentmod, "try to clean penalty file ", failstamp);
|
||||
|
Reference in New Issue
Block a user