fix: reality random target/sni buttons not working (#4337) (#4340)

This commit is contained in:
Abdalrahman
2026-05-13 15:42:20 +03:00
committed by GitHub
parent 4e1b597914
commit b47f794ed0
3 changed files with 4 additions and 9 deletions
+2 -3
View File
@@ -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;
}
@@ -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;
}