delete inbounds
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
- Реквизиты / донаты:
|
||||
- Карта МИР: `2204320436318077`
|
||||
- Карта MasterCard: `5395452209474530`
|
||||
- ЮМоney: `4100116897060652`
|
||||
- PayPal: `vasiljevdenisx@gmail.com`
|
||||
- USDT | ETH (ERC20 | BEP20): `0x6fe140040f6Cdc1E1Ff2136cd1d60C0165809463`
|
||||
- USDT | TRX (TRC20): `TEWxXmJxvkAmhshp7E61XJGHB3VyM9hNAb`
|
||||
|
||||
@@ -107,7 +107,7 @@ function buildVmessLink(inbound, domain, uuid) {
|
||||
net: stream.network || "tcp",
|
||||
path: "/",
|
||||
port: inbound.port,
|
||||
ps: flag + ' ' + inbound.remark,
|
||||
ps: decodeURIComponent(flag) + ' ' + inbound.remark,
|
||||
scy: "",
|
||||
sni: "",
|
||||
tls: stream.security || "none",
|
||||
@@ -157,6 +157,6 @@ function buildTrojanLink(inbound, domain, password) {
|
||||
`&sni=${sni}` +
|
||||
`&sid=${sid}` +
|
||||
`&spx=${spx}` +
|
||||
`#${flag}%20${inbound.remark}-${password}`
|
||||
`#${flag}%20${inbound.remark}`
|
||||
);
|
||||
}
|
||||
@@ -14,7 +14,8 @@ export function buildVmessTcp({ port, uuid }) {
|
||||
totalGB: 0,
|
||||
expiryTime: 0,
|
||||
tgId: "",
|
||||
subId: "",
|
||||
subId: "0",
|
||||
alterId: "0",
|
||||
reset: 0
|
||||
}],
|
||||
}),
|
||||
|
||||
+32
-4
@@ -13,6 +13,7 @@ import { buildInboundLink } from "./builders/buildInboundLink.js";
|
||||
|
||||
const { UI_URL, UI_LOGIN, UI_PASSWORD, UI_HOST } = process.env;
|
||||
const SUB_FILE = "/subscriptions/list.txt";
|
||||
const LAST_INBOUNDS = '/subscriptions/latestInbounds.json';
|
||||
|
||||
const cookieJar = {};
|
||||
const api = axios.create({ baseURL: UI_URL, timeout: 15000, withCredentials: true });
|
||||
@@ -124,6 +125,26 @@ async function getInbounds() {
|
||||
} catch (e) { console.error("Get inbounds failed:", e.message); return []; }
|
||||
}
|
||||
|
||||
async function deleteInbounds() {
|
||||
try {
|
||||
const data = fs.readFileSync(LAST_INBOUNDS, 'utf-8');
|
||||
const oldIds = JSON.parse(data);
|
||||
|
||||
if (Array.isArray(oldIds) && oldIds.length > 0) {
|
||||
console.log(`Удаляем старые инбаунды: ${oldIds.length} шт.`);
|
||||
for (const id of oldIds) {
|
||||
try {
|
||||
await deleteInbound(id);
|
||||
} catch (err) {
|
||||
console.error(`Ошибка при удалении инбаунда ${id}:`, err.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Старых ID не найдено, пропускаем удаление.");
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteInbound(id) {
|
||||
try { await api.post(`/panel/api/inbounds/del/${id}`); } catch { }
|
||||
}
|
||||
@@ -131,7 +152,7 @@ async function deleteInbound(id) {
|
||||
async function addInbound(config) {
|
||||
try {
|
||||
const res = await api.post("/panel/api/inbounds/add", config);
|
||||
return res.data?.id || null;
|
||||
return res.data?.obj?.id || null;
|
||||
} catch (e) {
|
||||
console.error("Add inbound failed:", e.message);
|
||||
return null;
|
||||
@@ -147,8 +168,7 @@ async function rotate() {
|
||||
const usedPorts = new Set();
|
||||
const subs = [];
|
||||
|
||||
const existing = await getInbounds();
|
||||
for (const i of existing) await deleteInbound(i.id);
|
||||
await deleteInbounds();
|
||||
|
||||
const builders = [
|
||||
async (d) => buildVlessRealityTcp({ port: await isPortFree(8443) ? 8443 : await getFreePort(usedPorts), uuid: await uuid(), domain: d, keys: await generateRealityKeys() }),
|
||||
@@ -163,6 +183,8 @@ async function rotate() {
|
||||
async (d) => buildTrojanRealityTcp({ port: await getFreePort(usedPorts), uuid: await uuid(), domain: d, keys: await generateRealityKeys() }),
|
||||
];
|
||||
|
||||
const inboundIds = [];
|
||||
|
||||
for (const b of builders) {
|
||||
const domain = pickDomain(whitelist);
|
||||
const inbound = await b(domain);
|
||||
@@ -172,7 +194,13 @@ async function rotate() {
|
||||
// Build the link depending on the protocol
|
||||
const link = buildInboundLink(inbound, UI_HOST, idOrPass);
|
||||
if (link) subs.push(link);
|
||||
await addInbound(inbound);
|
||||
const id = await addInbound(inbound);
|
||||
inboundIds.push(id);
|
||||
}
|
||||
|
||||
if (inboundIds.length > 0) {
|
||||
fs.writeFileSync(LAST_INBOUNDS, JSON.stringify(inboundIds, null, 2));
|
||||
console.log(`Новые ID (${inboundIds.length} шт.) сохранены в ${LAST_INBOUNDS}`);
|
||||
}
|
||||
|
||||
fs.writeFileSync(SUB_FILE, subs.join("\n") + "\n", "utf8");
|
||||
|
||||
Reference in New Issue
Block a user