Compare commits

..

2 Commits

Author SHA1 Message Date
b1ek 6e905308ea
add browser detection 2023-03-19 19:18:34 +10:00
b1ek adebf02419
fix keys(again) 2023-03-19 19:18:14 +10:00
4 changed files with 8 additions and 12 deletions

View File

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

View File

@ -2,6 +2,7 @@ const express = require('express');
const router = express.Router();
const minify = require('express-minify');
const browser = require('express-browser-detect');
// custom
router.use(require('./template'));
@ -17,14 +18,6 @@ router.use(minify({
css_match: /.css^/,
js_match: /.js^/
}));
// 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();
});
router.use(browser);
module.exports = router;

View File

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

View File

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