From 47ccc7b501faeac895e295e86fc4ae2aea3a31ed Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Tue, 23 May 2023 03:15:34 +0330 Subject: [feature] fallback link calculation Co-Authored-By: Alireza Ahmadi --- web/html/common/qrcode_modal.html | 1 + web/html/xui/inbounds.html | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'web') diff --git a/web/html/common/qrcode_modal.html b/web/html/common/qrcode_modal.html index 3271f3ad..acef9811 100644 --- a/web/html/common/qrcode_modal.html +++ b/web/html/common/qrcode_modal.html @@ -39,6 +39,7 @@ this.client = settings.clients[clientIndex]; remark = this.dbInbound.remark + "-" + this.client.email; address = this.dbInbound.address; + this.subId = ''; this.qrcodes = []; if (this.inbound.tls && !ObjectUtil.isArrEmpty(this.inbound.stream.tls.settings.domains)) { this.inbound.stream.tls.settings.domains.forEach((domain) => { diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html index b906fe00..7b9ba207 100644 --- a/web/html/xui/inbounds.html +++ b/web/html/xui/inbounds.html @@ -361,6 +361,7 @@ this.refreshing = true; const msg = await HttpUtil.post('/panel/inbound/list'); if (!msg.success) { + this.refreshing = false; return; } this.setInbounds(msg.obj); @@ -763,11 +764,32 @@ default: return client.id; } }, + checkFallback(dbInbound) { + newDbInbound = new DBInbound(dbInbound); + if (dbInbound.listen.startsWith("@")){ + rootInbound = this.inbounds.find((i) => + i.tls && + ['trojan','vless'].includes(i.protocol) && + i.settings.fallbacks.find(f => f.dest === dbInbound.listen) + ); + if (rootInbound) { + newDbInbound.listen = rootInbound.listen; + newDbInbound.port = rootInbound.port; + newInbound = newDbInbound.toInbound(); + newInbound.stream.security = 'tls'; + newInbound.stream.tls = rootInbound.stream.tls; + newDbInbound.streamSettings = newInbound.stream.toString(); + } + } + return newDbInbound; + }, showQrcode(dbInbound, clientIndex) { - qrModal.show('{{ i18n "qrCode"}}', dbInbound, clientIndex); + newDbInbound = this.checkFallback(dbInbound); + qrModal.show('{{ i18n "qrCode"}}', newDbInbound, clientIndex); }, showInfo(dbInbound, index) { - infoModal.show(dbInbound, index); + newDbInbound = this.checkFallback(dbInbound); + infoModal.show(newDbInbound, index); }, switchEnable(dbInboundId) { dbInbound = this.dbInbounds.find(row => row.id === dbInboundId); @@ -868,7 +890,8 @@ }, inboundLinks(dbInboundId) { dbInbound = this.dbInbounds.find(row => row.id === dbInboundId); - txtModal.show('{{ i18n "pages.inbounds.export"}}', dbInbound.genInboundLinks, dbInbound.remark); + newDbInbound = this.checkFallback(dbInbound); + txtModal.show('{{ i18n "pages.inbounds.export"}}', newDbInbound.genInboundLinks, newDbInbound.remark); }, exportAllLinks() { let copyText = ''; -- cgit v1.2.3