|
|
|
|
@@ -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,
|
|
|
|
|
|