const fs = require('fs'); const path = require('path'); const mime = require('mime-types'); const authModes = [ "free", "confirmation", "whitelist", "password", ]; function getBase64fromPath (pathstring) { if (typeof pathstring === "string" && pathstring !== "") { if (!path.isAbsolute(pathstring)) pathstring = path.join(__dirname, "..", pathstring); const mimetype = mime.lookup(pathstring); const base64content = fs.readFileSync(pathstring, { encoding: 'base64' }); return `data:${mimetype};base64,${base64content}`; } return null; } function getBGMain () { return getBase64fromPath(global.config.source.bgmain); } function getFaviconMain () { return getBase64fromPath(global.config.source.favicon); } module.exports = { name: global.config.server.info.name, tag: global.config.server.info.tag, authMode: authModes[global.config.server["auth-mode"] ?? 1], secureMode: global.config.server.secureMode ?? false, extSource: { bgmain: getBGMain(), favicon: getFaviconMain(), } };