Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShishkevich D. <135337715+shishkevichd@users.noreply.github.com>2025-03-10 18:09:51 +0300
committerGitHub <noreply@github.com>2025-03-10 18:09:51 +0300
commita811225610e27710b62b7a9b9cb43e448ee3130f (patch)
tree4daaecfdaa52415bc141b4e696c09d58fa483458
parent1893c3814df16bda51be4df8ec0004f654ec94ca (diff)
fix: protocol checking during random uuidv4 generation v2.5.5
fixes the https://github.com/MHSanaei/3x-ui/issues/2750 issue
-rw-r--r--web/assets/js/util/index.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/web/assets/js/util/index.js b/web/assets/js/util/index.js
index 44af6630..85d53352 100644
--- a/web/assets/js/util/index.js
+++ b/web/assets/js/util/index.js
@@ -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() {