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