Spaces:
Paused

File size: 1,365 Bytes
6984a1d
 
ed09f2e
e7ed0f5
f7ff6bb
26e8de0
07424a2
6984a1d
f7ff6bb
 
 
 
 
 
 
 
26e8de0
6984a1d
f7ff6bb
26e8de0
 
6984a1d
f7ff6bb
26e8de0
6984a1d
 
f7ff6bb
 
 
 
 
6984a1d
ed09f2e
 
6984a1d
e7ed0f5
ed09f2e
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
const http = require('http');
const fs = require('fs');
const PORT = process.env.PORT || 7860;
const PUBLIC_IP = process.env.PUBLIC_IP || 'localhost';
const uuid = process.env.EFFECTIVE_UUID || 'subuuid';
const filePath = `/app/html/vless_links.txt`;

const server = http.createServer((req, res) => {
    if (req.url === '/') {
        // 首页提示信息,不暴露 UUID
        res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
        res.end(`🟢 恭喜!部署成功!

查看节点信息请访问: /你的UUID或/subuuid`);
    } else if (req.url === `/${uuid}`) {
        // 返回订阅内容
        fs.readFile(filePath, 'utf8', (err, data) => {
            if (err) {
                res.writeHead(500, { 'Content-Type': 'text/plain; charset=utf-8' });
                res.end('订阅文件读取失败');
                return;
            }
            res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
            res.end(data);
        });
    } else {
        // 其它路径返回 404 提示
        res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' });
        res.end(`❌ Not Found:路径错误!!!

查看节点信息请访问: /你的UUID或/subuuid`);
    }
});

server.listen(PORT, () => {
    console.log(`HTTP 订阅服务启动: http://${PUBLIC_IP}:${PORT}/${uuid}`);
});