mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-12 19:40:02 -04:00
Better implementation of Corrosion
This commit is contained in:
parent
6db2f2d1e0
commit
1ccca9cfd5
2 changed files with 21 additions and 8 deletions
28
app.js
28
app.js
|
@ -4,7 +4,7 @@
|
||||||
* MIT license: http://opensource.org/licenses/MIT
|
* MIT license: http://opensource.org/licenses/MIT
|
||||||
* ----------------------------------------------- */
|
* ----------------------------------------------- */
|
||||||
const
|
const
|
||||||
corrosion = require('./src/Corrosion'),
|
corrosion = require('corrosion'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
config = require('./config.json'),
|
config = require('./config.json'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
|
@ -108,19 +108,31 @@ function tryReadFile(file) {
|
||||||
return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : text404;
|
return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : text404;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Local corrosion proxy
|
// Local Corrosion Proxy
|
||||||
const localCorrosion = new corrosion({
|
|
||||||
prefix: '/fetch/',
|
const proxy = new corrosion({
|
||||||
ws: true,
|
prefix: '/search/',
|
||||||
codec: 'plain'
|
title: 'Untitled Document',
|
||||||
|
ws: true,
|
||||||
|
codec: 'xor',
|
||||||
|
requestMiddleware: [
|
||||||
|
corrosion.middleware.blacklist([
|
||||||
|
'accounts.google.com',
|
||||||
|
], 'Page is blocked'),
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
proxy.bundleScripts();
|
||||||
|
|
||||||
/* Querystring Navigation */
|
/* Querystring Navigation */
|
||||||
app.get('/', async(req, res) => res.send(insertAll(tryReadFile(path.normalize(__dirname + '/views/' + (['/', '/?'].includes(req.url) ? siteIndex : pages[Object.keys(req.query)[0]]))))));
|
app.get('/', async(req, res) => res.send(insertAll(tryReadFile(path.normalize(__dirname + '/views/' + (['/', '/?'].includes(req.url) ? siteIndex : pages[Object.keys(req.query)[0]]))))));
|
||||||
|
|
||||||
/* Static Files Served */
|
/* Static Files Served */
|
||||||
app.use(express.static(path.normalize(__dirname + '/views')));
|
app.use(express.static(path.normalize(__dirname + '/views')));
|
||||||
app.use((req, res) => {if (req.url.startsWith(localCorrosion.prefix)) return localCorrosion.request(req, res); res.status(404, res.send(insertAll(text404)))});
|
app.use((req, res) => {
|
||||||
|
if (req.url.startsWith(proxy.prefix)) return proxy.request(req, res);
|
||||||
|
res.status(404, res.send(insertAll(text404)))
|
||||||
|
});
|
||||||
|
|
||||||
server.listen(port);
|
server.listen(port);
|
||||||
console.log('Holy Unblocker is listening on port ' + port + '. This is simply a public for Holy Unblocker. Certain functions may not work properly.');
|
console.log('Holy Unblocker is listening on port ' + port + '. This is simply a public for Holy Unblocker. Certain functions may not work properly.');
|
|
@ -15,6 +15,7 @@
|
||||||
"author": "Titanium Network",
|
"author": "Titanium Network",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"corrosion": "^1.0.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"mime-types": "^2.1.27",
|
"mime-types": "^2.1.27",
|
||||||
"ws": "^7.5.3"
|
"ws": "^7.5.3"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue