-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun-server.js
158 lines (137 loc) · 3.99 KB
/
run-server.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import { createBareServer } from '@tomphttp/bare-server-node';
import http from 'node:http';
import * as https from 'https';
import express from 'express';
import g from './serverlib/games.mjs';
import a from './serverlib/apps.mjs';
import { handler as ssrHandler } from './dist/server/entry.mjs';
import fetch from "node-fetch";
import { server as wisp } from "@mercuryworkshop/wisp-js";
import { epoxyPath } from "@mercuryworkshop/epoxy-transport";
import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
import dumpPage from './serverlib/corsProxy.js';
const server = http.createServer();
const bare = createBareServer('/bare/');
const PORT = 1921; // why is the port.. that
const app = express();
const __dirname = process.cwd();
const base = '/';
//https://en.wikipedia.org/wiki/Epoxy
app.use("/epoxy/", express.static(epoxyPath));
app.use("/baremux/", express.static(baremuxPath));
app.use(base, express.static('dist/client/'));
app.use(ssrHandler);
//why do we still use bare lmao
server.on('request', (req, res) => {
if (bare.shouldRoute(req)) {
bare.routeRequest(req, res)
} else {
app(req, res)
}
})
// BROKEN FOR NOW ILL FIX IT LATER OK
app.get('/api/cp/v1', async (req, res) => {
const url = req.query.q;
if (!url) {
return res.status(400).json({ error: '404' });
}
try {
const d = await dumpPage(url);
res.send(d);
} catch (error) {
console.log(error);
res.status(500).json({ error: error.message });
}
});
server.on('upgrade', (req, socket, head) => {
if (bare.shouldRoute(req)) {
bare.routeUpgrade(req, socket, head)
} else {
wisp.routeRequest(socket, head);
}
})
app.use(express.static(__dirname + '/public'))
app.get('/api/info/v1/', (req, res) => {
res.json([
{
Version: '2.4',
},
])
})
//forward the api req to lightspeed
//if your in here then you are either a skid or just wondering how this works
//either way get out :3
app.get("/api/fl/lightspeed/v1/", async (req, res) => {
const url = req.query.url;
let r = await fetch(`https://ghostapis.useghost.pro/api/fl/lightspeed/v1/?url=${url}`)
let d = await r.json()
res.json(d)
});
app.get("/api/fl/fortigaurd/v1/", async (req, res) => {
const url = req.query.url;
let r = await fetch(`https://ghostapis.useghost.pro/api/fl/fortigaurd/v1/?url=${url}`)
let d = await r.json()
res.json(d)
});
app.get("/api/fl/paloalto/v1", async (req, res) => {
const url = req.query.url;
let r = await fetch(`https://ghostapis.useghost.pro/api/fl/paloalto/v1/?url=${url}`)
let d = await r.json()
res.json(d)
});
app.get("/api/fl/blocksi/v1/", async (req, res) => {
const url = req.query.url;
let r = await fetch(`https://ghostapis.useghost.pro/api/fl/blocksi/v1/?url=${url}`)
let d = await r.json()
res.json(d)
});
var sg = []
var sa = []
function getrand() {
sg.splice(0, sg.length)
for (var i = 0; i < 8; i++) {
var rg = g.length
var random = Math.floor(Math.random() * rg)
if (!sg.includes(g[random])) {
sg.push(g[random])
} else {
i--
}
}
}
function getrandapps() {
sa.splice(0, sa.length)
for (var i = 0; i < 8; i++) {
var ra = a.length
var random = Math.floor(Math.random() * ra)
if (!sa.includes(a[random])) {
sa.push(a[random])
} else {
i--
}
}
}
setInterval(getrand, 500000)
setInterval(getrandapps, 500000)
getrand()
getrandapps()
app.get('/api/rg/v1/', (req, res) => {
res.json(sg)
});
app.get('/api/ra/v1/', (req, res) => {
res.json(sa)
});
server.listen(PORT)
server.on('listening', () => {
console.log(
'Thanks for using Ghost! The server is located on the link below! :3'
)
console.log('http://localhost:' + PORT)
})
// SIGMA SHUTDOWN
server.on('SIGTERM', () => {
debug('SIGTERM signal received: closing HTTP server')
server.close(() => {
debug('HTTP server closed')
})
})