From b47f794ed028bde7937f8a2e1b9fb57f243ed711 Mon Sep 17 00:00:00 2001 From: Abdalrahman Date: Wed, 13 May 2026 15:42:20 +0300 Subject: [PATCH] fix: reality random target/sni buttons not working (#4337) (#4340) --- frontend/eslint.config.js | 3 --- frontend/src/models/inbound.js | 5 ++--- frontend/src/pages/inbounds/InboundFormModal.vue | 5 ++--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/frontend/eslint.config.js b/frontend/eslint.config.js index c1749c08..95c46dbb 100644 --- a/frontend/eslint.config.js +++ b/frontend/eslint.config.js @@ -19,9 +19,6 @@ export default [ globals: { ...globals.browser, ...globals.node, - // Legacy script tags inject a couple of helpers on window before - // the SPA boots; declared here so no-undef stops flagging them. - getRandomRealityTarget: 'readonly', }, }, rules: { diff --git a/frontend/src/models/inbound.js b/frontend/src/models/inbound.js index f8f1738e..fdfb4560 100644 --- a/frontend/src/models/inbound.js +++ b/frontend/src/models/inbound.js @@ -1,5 +1,6 @@ import dayjs from 'dayjs'; import { ObjectUtil, RandomUtil, Base64, NumberFormatter, SizeFormatter, Wireguard } from '@/utils'; +import { getRandomRealityTarget } from '@/models/reality-targets'; export const Protocols = { VMESS: 'vmess', @@ -897,9 +898,7 @@ export class RealityStreamSettings extends XrayCommonClass { super(); // If target/serverNames are not provided, use random values if (!target && !serverNames) { - const randomTarget = typeof getRandomRealityTarget !== 'undefined' - ? getRandomRealityTarget() - : { target: 'www.amazon.com:443', sni: 'www.amazon.com,amazon.com' }; + const randomTarget = getRandomRealityTarget(); target = randomTarget.target; serverNames = randomTarget.sni; } diff --git a/frontend/src/pages/inbounds/InboundFormModal.vue b/frontend/src/pages/inbounds/InboundFormModal.vue index 7eebd594..7151350c 100644 --- a/frontend/src/pages/inbounds/InboundFormModal.vue +++ b/frontend/src/pages/inbounds/InboundFormModal.vue @@ -12,6 +12,7 @@ import { SizeFormatter, Wireguard, } from '@/utils'; +import { getRandomRealityTarget } from '@/models/reality-targets'; import { Inbound, Protocols, @@ -339,11 +340,9 @@ function clearMldsa65() { inbound.value.stream.reality.settings.mldsa65Verify = ''; } -// Reality target/SNI randomizer — only available if the helper is loaded function randomizeRealityTarget() { if (!inbound.value?.stream?.reality) return; - if (typeof window.getRandomRealityTarget !== 'function') return; - const t = window.getRandomRealityTarget(); + const t = getRandomRealityTarget(); inbound.value.stream.reality.target = t.target; inbound.value.stream.reality.serverNames = t.sni; }