forked from maple3142/cf-warp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (25 loc) · 925 Bytes
/
Copy pathserver.js
File metadata and controls
32 lines (25 loc) · 925 Bytes
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
const express = require('express');
const app = express();
const path = require('path');
const generate = require('./lib/generate');
const register = require('./lib/register');
const info = require('./lib/info');
const ref = require('./lib/ref');
const conf = require('./lib/conf');
const port = process.env.PORT || 3000;
app.get('/', (req, res) => {
res.status(200);
res.set('Content-Type', 'text/html');
res.sendFile(path.join(__dirname, '/web.html'));
});
app.get('/warp.conf', async (req, res) => {
const keys = await generate();
const data = await register(keys);
const combined = Object.assign({}, keys, data, await info(data));
if (req.query.dl === 'true') res.set('Content-Disposition', 'attachment; filename="warp.conf"');
res.set('Content-Type', 'text/plain');
res.send(conf(combined, req.query.preset));
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});