CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
AroriaNetwork

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: AroriaNetwork/TacoProxy
Path: blob/main/app.js
Views: 311
1
/* -----------------------------------------------
2
/* Author : Titanium Network
3
/* MIT license: http://opensource.org/licenses/MIT
4
/* ----------------------------------------------- */
5
6
const express = require('express'),
7
alloy = require('alloyproxy'),
8
app = express(),
9
http = require('http'),
10
fs = require('fs'),
11
path = require('path');
12
13
const config = JSON.parse(fs.readFileSync('./config.json', {
14
encoding: 'utf8'
15
}));
16
17
const server = http.createServer(app);
18
19
//Local Alloy Proxy
20
21
const localprox = new alloy({
22
prefix: '/prefix/',
23
error: (proxy) => {
24
return proxy.res.send(fs.readFileSync(path.join(__dirname, 'public', 'error.html'), 'utf8'));
25
},
26
request: [],
27
response: [],
28
injection: true
29
});
30
31
app.use(localprox.app);
32
33
localprox.ws(server);
34
35
//Cloudflare Attack Mode Fix
36
37
app.post('/', async (req, res) => {
38
switch (req.url) {
39
case '/':
40
return res.send(fs.readFileSync(path.join(__dirname, 'public', 'index.html'), 'utf8'));
41
}
42
});
43
44
//Querystring Navigation
45
app.get('/', async (req, res) => {
46
47
switch (req.url) {
48
case '/':
49
return res.send(fs.readFileSync(path.join(__dirname, 'public', 'index.html'), 'utf8'));
50
}
51
52
switch (req.url) {
53
case '/?a':
54
return res.send(fs.readFileSync(path.join(__dirname, 'public', 'error.html'), 'utf8'));
55
}
56
57
});
58
59
app.use(express.static(path.join(__dirname, 'public')));
60
61
server.listen(process.env.PORT || config.port);
62
63