Compare commits

..

No commits in common. "6e905308ea7cf4a152325266f924e8f56ff1fb95" and "668dccdb719bc03e5ab5576cecd0372e86e340dc" have entirely different histories.

4 changed files with 12 additions and 8 deletions

View File

@ -6,7 +6,7 @@ const base = require('js-base64');
const cookie_parse = require('cookie-parser'); const cookie_parse = require('cookie-parser');
const cookie_encrypt = require('cookie-encrypter'); const cookie_encrypt = require('cookie-encrypter');
const APP_KEY = Buffer.from(process.env.APP_KEY, 'base64').toString('ascii'); const APP_KEY = Buffer.from(process.env.APP_KEY, 'base64');
router.use(cookie_parse(APP_KEY)); router.use(cookie_parse(APP_KEY));
router.use(cookie_encrypt(APP_KEY)); router.use(cookie_encrypt(APP_KEY));

View File

@ -2,7 +2,6 @@ const express = require('express');
const router = express.Router(); const router = express.Router();
const minify = require('express-minify'); const minify = require('express-minify');
const browser = require('express-browser-detect');
// custom // custom
router.use(require('./template')); router.use(require('./template'));
@ -18,6 +17,14 @@ router.use(minify({
css_match: /.css^/, css_match: /.css^/,
js_match: /.js^/ js_match: /.js^/
})); }));
router.use(browser);
// TODO: Maybe move all regexes into one file? Idk
const legacy_re = /(Firefox\/[0-5]\d{0,1}|Mozilla\/[0-4]|MSIE \d{1,2}\.\d{1,2}|Windows (NT|9\d)|Linux i686|(198\d|199\d|200\d|201[0-6])|Dillo|Naenara|Navscape|Netscape|QtWeb|Prism|Tencent|i(Phone|Pad|Pod)( OS [1-5]|))/g;
router.use((req, res, next) => {
req.legacymode = req.headers['user-agent'].match(legacy_re);
// res.send(req.headers['user-agent']);return;
next();
});
module.exports = router; module.exports = router;

View File

@ -23,7 +23,6 @@
"easy-crc": "^1.1.0", "easy-crc": "^1.1.0",
"express": "^4.18.2", "express": "^4.18.2",
"express-async-handler": "^1.2.0", "express-async-handler": "^1.2.0",
"express-browser-detect": "^1.0.0",
"express-minify": "^1.0.0", "express-minify": "^1.0.0",
"express-session": "^1.17.3", "express-session": "^1.17.3",
"glob": "^8.1.0", "glob": "^8.1.0",

View File

@ -1,16 +1,14 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os import os
import random import secrets
import base64 import base64
if (not os.path.exists('.env')): if (not os.path.exists('.env')):
print('No .env file found. Please create a dotenv to proceed.'); print('No .env file found. Please create a dotenv to proceed.');
exit(-1); exit(-1);
secrets = random.SystemRandom() key_bytes = secrets.token_bytes(32);
key_bytes = ''.join(secrets.choices(list('abcdef1234567890'), k=32)).encode('ascii');
dotenv_text = ''; dotenv_text = '';
with open('.env', 'tr', encoding='utf-8') as f: with open('.env', 'tr', encoding='utf-8') as f: