fix: protocol checking during random uuidv4 generation
Release 3X-UI for Docker / build (push) Canceled after 0s
Release 3X-UI / build (386) (push) Canceled after 0s
Release 3X-UI / build (amd64) (push) Canceled after 0s
Release 3X-UI / build (arm64) (push) Canceled after 0s
Release 3X-UI / build (armv5) (push) Canceled after 0s
Release 3X-UI / build (armv6) (push) Canceled after 0s
Release 3X-UI / build (armv7) (push) Canceled after 0s
Release 3X-UI / build (s390x) (push) Canceled after 0s

fixes the https://github.com/MHSanaei/3x-ui/issues/2750 issue
This commit is contained in:
Shishkevich D. authored and GitHub committed 2025-03-10 22:09:51 +07:00 Unverified
1 parent 1893c3814d
commit a811225610
1 file changed
+12 -1
+12 -1
View File
@@ -124,7 +124,18 @@ class RandomUtil {
}
static randomUUID() {
return window.crypto.randomUUID();
if (window.location.protocol === "https:") {
return window.crypto.randomUUID();
} else {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.replace(/[xy]/g, function (c) {
const randomValues = new Uint8Array(1);
window.crypto.getRandomValues(randomValues);
let randomValue = randomValues[0] % 16;
let calculatedValue = (c === 'x') ? randomValue : (randomValue & 0x3 | 0x8);
return calculatedValue.toString(16);
});
}
}
static randomShadowsocksPassword() {