Compare commits

...

3 Commits

Author SHA1 Message Date
10a7bcbd2c Merge remote-tracking branch 'origin/master'
# Conflicts:
#	api/client/add.js
2025-10-18 12:59:12 +08:00
1730cb41a3 feat(api): 支持生成不同网络类型的客户端链接
- 添加对 TCP 网络类型链接生成的支持- 根据网络类型动态解析流设置参数
-优化 WS 和 TCP 链接格式的生成逻辑-修复构建脚本输出路径问题
- 调整代码格式以提高可读性
2025-10-18 12:56:30 +08:00
24f1f88a45 chore(project):重构项目入口文件结构
- 添加 index.js 作为新的入口文件
- 更新 package.json 中的 main 字段指向 index.js
- 修改 dev 脚本使用 index.js 启动应用
- 移除旧的 app.js 入口相关配置
- 添加 build 脚本用于打包应用
- 清理 package.json 中的冗余字段
2025-10-18 11:27:07 +08:00
3 changed files with 25 additions and 19 deletions

View File

@@ -1,10 +1,10 @@
const { randomUUID } = require("crypto");
const {randomUUID} = require("crypto");
const ins = require("../../utils/http");
const dayjs = require("dayjs");
const getCookie = require("../../auth/3xuiLogin");
module.exports = async (ctx) => {
let { id = 4, limitIp, expiryTime = 0, enable = !0, totalGB = 1, subId = "2rv0gb458kbfl532", email, uuid } = ctx.request.body;
let {id = 4, limitIp, expiryTime = 0, enable = !0, totalGB = 1, subId = "2rv0gb458kbfl532", email, uuid} = ctx.request.body;
if (!ctx.state.cookie) {
ctx.state.cookie = await getCookie();
ins.interceptors.request.use((config) => {
@@ -20,20 +20,26 @@ module.exports = async (ctx) => {
expiryTime = dayjs(expiryTime, "YYYY-MM-DD HH:mm:ss").valueOf();
}
totalGB = totalGB * 1024 * 1024 * 1024;
const settings = { clients: [{ id: uuid, flow: "", email, limitIp, enable, tgId: "", subId, reset: 0, totalGB, expiryTime }] };
const result = await ins.post("/panel/api/inbounds/addClient", { id, settings: JSON.stringify(settings) });
const settings = {clients: [{id: uuid, flow: "", email, limitIp, enable, tgId: "", subId, reset: 0, totalGB, expiryTime}]};
const result = await ins.post("/panel/api/inbounds/addClient", {id, settings: JSON.stringify(settings)});
if (result?.success) {
const { remark, port, protocol, streamSettings = "{}" } = inbound.obj || {};
const {
network = "ws",
security = "none",
wsSettings: { host, path },
} = JSON.parse(streamSettings);
ctx.body = {
code: "0",
data: `${protocol}://${uuid}@vless.jjcp52.com:${port}?type=${network}&path=${path}&host=${host}&security=${security}#${remark}-${email}`,
message: "success",
};
const {remark, port, protocol, streamSettings = "{}"} = inbound.obj || {};
const setting = JSON.parse(streamSettings || "{}"), {network = "ws", security = "none"} = setting;
if (network === "ws") {
const {wsSettings: {host, path}} = setting
ctx.body = {
code: "0", message: "success",
data: `${protocol}://${uuid}@vless.jjcp52.com:${port}?type=${network}&path=${path}&host=${host}&security=${security}#${remark}-${email}`,
};
} else if (network === "tcp") {
// 生成的链接格式 vless://842f52b6-4945-46c8-89ed-165bf51123fc@206.237.11.232:34261?type=tcp&security=reality&pbk=3-yeUp9rz5KacCLJqaLt_rHUY_6EKw6tveLpVB2hxQI&fp=random&sni=yahoo.com&sid=0f7f86d03b646595&spx=%2F#temu-reality-kubbo
const {serverNames: [sni], shortIds: [sid], settings: {publicKey, fingerprint, spiderX}} = (setting.realitySettings || {})
ctx.body = {
code: "0", message: "success",
data: `${protocol}://${uuid}@vless.jjcp52.com:${port}?type=${network}&security=${security}&pbk=${publicKey}&fp=${fingerprint}&sni=${sni}&sid=${sid}&spx=${spiderX}#${remark}-${email}`,
};
}
} else {
ctx.body = {
code: 1,

1
index.js Normal file
View File

@@ -0,0 +1 @@
require("./app")

View File

@@ -1,11 +1,10 @@
{
"name": "vless-api",
"version": "1.0.0",
"description": "",
"main": "app.js",
"main": "index.js",
"scripts": {
"start": "node app.js",
"dev": "nodemon app.js"
"dev": "nodemon index.js",
"build": "pkg index.js --targets=node18-win-x64,node18-linux-x64 --output=dist/"
},
"author": "kubbo",
"license": "ISC",