const cmn = require("../$common.js"); const fs = require("fs"); const bodyParser = require("body-parser"); let moddir = null; module.exports=function(app,io,_moddir){ moddir = _moddir; let config, accounts; try { accounts = require("./accounts.json"); } catch (e) { console.error(e); return false; } app.post("/up_log/log", bodyParser.json(), cmn.authgen(accounts), (req,res) => { if (typeof req.body.machine != "string") { return res.sendStatus(400); } const machine = req.body.machine.replace(/[^a-zA-Z0-9._-]/g, ""); fs.appendFileSync(moddir + "/log.txt", new Date().toISOString() + " machine=" + machine + "\n"); res.status(200).end(); }); };