mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-13 03:50:02 -04:00
Fixed
This commit is contained in:
parent
a02f6e7e30
commit
55910ea89e
2 changed files with 219 additions and 223 deletions
46
app.js
46
app.js
|
@ -8,7 +8,7 @@
|
||||||
sanitizer = require('sanitizer'),
|
sanitizer = require('sanitizer'),
|
||||||
fetch = require('node-fetch');
|
fetch = require('node-fetch');
|
||||||
|
|
||||||
const config = JSON.parse(fs.readFileSync('./config.json', { encoding: 'utf8' }));
|
const config = JSON.parse(fs.readFileSync('./config.json', {encoding:'utf8'}));
|
||||||
if (!config.prefix.startsWith('/')) {
|
if (!config.prefix.startsWith('/')) {
|
||||||
config.prefix = `/${config.prefix}`;
|
config.prefix = `/${config.prefix}`;
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,8 @@
|
||||||
key: fs.readFileSync('./ssl/default.key'),
|
key: fs.readFileSync('./ssl/default.key'),
|
||||||
cert: fs.readFileSync('./ssl/default.crt')
|
cert: fs.readFileSync('./ssl/default.crt')
|
||||||
}
|
}
|
||||||
if (config.ssl == true) {
|
if (config.ssl == true) { server = https.createServer(server_options, app); server_protocol = 'https://';}
|
||||||
server = https.createServer(server_options, app);
|
else { server = http.createServer(app); server_protocol = 'http://';};
|
||||||
server_protocol = 'https://';
|
|
||||||
} else {
|
|
||||||
server = http.createServer(app);
|
|
||||||
server_protocol = 'http://';
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
console.log(`Alloy Proxy now running on ${server_protocol}0.0.0.0:${config.port}! Proxy prefix is "${config.prefix}"!`);
|
console.log(`Alloy Proxy now running on ${server_protocol}0.0.0.0:${config.port}! Proxy prefix is "${config.prefix}"!`);
|
||||||
|
@ -62,8 +57,8 @@
|
||||||
secret: 'alloy',
|
secret: 'alloy',
|
||||||
saveUninitialized: true,
|
saveUninitialized: true,
|
||||||
resave: true
|
resave: true
|
||||||
}));
|
}));
|
||||||
// We made our own version of body-parser instead, due to issues.
|
// We made our own version of body-parser instead, due to issues.
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
if (req.method == 'POST') {
|
if (req.method == 'POST') {
|
||||||
req.raw_body = '';
|
req.raw_body = '';
|
||||||
|
@ -74,7 +69,7 @@
|
||||||
req.str_body = req.raw_body;
|
req.str_body = req.raw_body;
|
||||||
try {
|
try {
|
||||||
req.body = JSON.parse(req.raw_body);
|
req.body = JSON.parse(req.raw_body);
|
||||||
} catch (err) {
|
} catch(err) {
|
||||||
req.body = {}
|
req.body = {}
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
|
@ -83,7 +78,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use(`${config.prefix}utils/`, async(req, res, next) => {
|
app.use(`${config.prefix}utils/`, async(req, res, next) => {
|
||||||
if (req.url.startsWith('/assets/')) { res.sendFile(__dirname + '/utils' + req.url); }
|
if (req.url.startsWith('/assets/')){res.sendFile(__dirname + '/utils' + req.url);}
|
||||||
if (req.query.url) {
|
if (req.query.url) {
|
||||||
let url = atob(req.query.url);
|
let url = atob(req.query.url);
|
||||||
if (url.startsWith('https://') || url.startsWith('http://')) {
|
if (url.startsWith('https://') || url.startsWith('http://')) {
|
||||||
|
@ -99,9 +94,10 @@
|
||||||
|
|
||||||
app.post(`${config.prefix}session/`, async(req, res, next) => {
|
app.post(`${config.prefix}session/`, async(req, res, next) => {
|
||||||
let url = querystring.parse(req.raw_body).url;
|
let url = querystring.parse(req.raw_body).url;
|
||||||
if (url.startsWith('//')) { url = 'http:' + url; } else if (url.startsWith('https://') || url.startsWith('http://')) { url = url } else { url = 'http://' + url };
|
if (url.startsWith('//')) { url = 'http:' + url; }
|
||||||
|
else if (url.startsWith('https://') || url.startsWith('http://')) { url = url }
|
||||||
|
else {url = 'http://' + url};
|
||||||
return res.redirect(config.prefix + rewrite_url(url));
|
return res.redirect(config.prefix + rewrite_url(url));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use(config.prefix, async(req, res, next) => {
|
app.use(config.prefix, async(req, res, next) => {
|
||||||
|
@ -109,11 +105,11 @@
|
||||||
proxy.url = rewrite_url(req.url.slice(1), 'decode');
|
proxy.url = rewrite_url(req.url.slice(1), 'decode');
|
||||||
proxy.url = {
|
proxy.url = {
|
||||||
href: proxy.url,
|
href: proxy.url,
|
||||||
hostname: proxy.url.split('/').splice(2).splice(0, 1).join('/'),
|
hostname : proxy.url.split('/').splice(2).splice(0, 1).join('/'),
|
||||||
origin: proxy.url.split('/').splice(0, 3).join('/'),
|
origin : proxy.url.split('/').splice(0, 3).join('/'),
|
||||||
encoded_origin: btoa(proxy.url.split('/').splice(0, 3).join('/')),
|
encoded_origin : btoa(proxy.url.split('/').splice(0, 3).join('/')),
|
||||||
path: '/' + proxy.url.split('/').splice(3).join('/'),
|
path : '/' + proxy.url.split('/').splice(3).join('/'),
|
||||||
protocol: proxy.url.split('\:').splice(0, 1).join(''),
|
protocol : proxy.url.split('\:').splice(0, 1).join(''),
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy.url.encoded_origin = btoa(proxy.url.origin);
|
proxy.url.encoded_origin = btoa(proxy.url.origin);
|
||||||
|
@ -173,15 +169,15 @@
|
||||||
if (req.method == 'POST') {
|
if (req.method == 'POST') {
|
||||||
proxy.options.body = req.str_body;
|
proxy.options.body = req.str_body;
|
||||||
}
|
}
|
||||||
if (proxy.url.hostname == 'discord.com' && proxy.url.path == '/') { return res.redirect(307, config.prefix + rewrite_url('https://discord.com/login')); };
|
if (proxy.url.hostname == 'discord.com' && proxy.url.path == '/') { return res.redirect(307, config.prefix + rewrite_url('https://discord.com/login'));};
|
||||||
|
|
||||||
if (proxy.url.hostname == 'www.reddit.com') { return res.redirect(307, config.prefix + rewrite_url('https://old.reddit.com')); };
|
if (proxy.url.hostname == 'www.reddit.com') { return res.redirect(307, config.prefix + rewrite_url('https://old.reddit.com'));};
|
||||||
|
|
||||||
if (!req.url.slice(1).startsWith(`${proxy.url.encoded_origin}/`)) { return res.redirect(307, config.prefix + proxy.url.encoded_origin + '/'); };
|
if (!req.url.slice(1).startsWith(`${proxy.url.encoded_origin}/`)) { return res.redirect(307, config.prefix + proxy.url.encoded_origin + '/');};
|
||||||
|
|
||||||
proxy.response = await fetch(proxy.url.href, proxy.options).catch(err => res.send(fs.readFileSync('./utils/error/error.html', 'utf8').toString().replace('%ERROR%', `Error 400: Could not make request to '${sanitizer.sanitize(proxy.url.href)}'!`)));
|
proxy.response = await fetch(proxy.url.href, proxy.options).catch(err => res.send(fs.readFileSync('./utils/error/error.html', 'utf8').toString().replace('%ERROR%', `Error 400: Could not make request to '${sanitizer.sanitize(proxy.url.href)}'!`)));
|
||||||
|
|
||||||
if (typeof proxy.response.buffer != 'function') return;
|
if(typeof proxy.response.buffer != 'function')return;
|
||||||
|
|
||||||
proxy.buffer = await proxy.response.buffer();
|
proxy.buffer = await proxy.response.buffer();
|
||||||
|
|
||||||
|
@ -242,7 +238,7 @@
|
||||||
|
|
||||||
// Temp hotfix for Youtube search bar until my script injection can fix it.
|
// Temp hotfix for Youtube search bar until my script injection can fix it.
|
||||||
|
|
||||||
if (proxy.url.hostname == 'www.youtube.com') { proxy.sendResponse = proxy.sendResponse.replace(/\/results/gi, `${config.prefix}${proxy.url.encoded_origin}/results`); };
|
if (proxy.url.hostname == 'www.youtube.com') { proxy.sendResponse = proxy.sendResponse.replace(/\/results/gi, `${config.prefix}${proxy.url.encoded_origin}/results`);};
|
||||||
} else if (proxy.content_type.startsWith('text/css')) {
|
} else if (proxy.content_type.startsWith('text/css')) {
|
||||||
proxy.sendResponse = proxy.sendResponse.toString()
|
proxy.sendResponse = proxy.sendResponse.toString()
|
||||||
.replace(/url\("\/\/(.*?)"\)/gi, `url("http://` + `$1` + `")`)
|
.replace(/url\("\/\/(.*?)"\)/gi, `url("http://` + `$1` + `")`)
|
||||||
|
@ -265,7 +261,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
// We send the response from the server rewritten.
|
// We send the response from the server rewritten.
|
||||||
res.send(proxy.sendResponse);
|
res.send(proxy.sendResponse);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
10
app.json
10
app.json
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "Alloy Proxy",
|
"name": "Holy Unblocker",
|
||||||
"description": "A node.js web proxy featuring URL encoding, and amazing compatablity!",
|
"description": "A website that can be used to bypass web filters; both extension and firewall. Alloy Proxy hosted locally. (Can be used as a template.)",
|
||||||
"repository": "https://github.com/titaniumnetwork-dev/alloyproxy/",
|
"repository": "https://github.com/QuiteAFancyEmerald/HolyUnblockerPublic/",
|
||||||
"logo": "https://avatars1.githubusercontent.com/u/47227492?s=200&v=4",
|
"logo": "https://www.holyubofficial.ml/assets/img/i.png",
|
||||||
"keywords": ["node", "proxy", "unblocker"]
|
"keywords": ["node", "proxy", "unblocker", "webproxy", "games", "holyunblocker", "alloy"]
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue