mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
fix: protocol checking during random uuidv4 generation
fixes the https://github.com/MHSanaei/3x-ui/issues/2750 issue
This commit is contained in:
parent
1893c3814d
commit
a811225610
1 changed files with 12 additions and 1 deletions
|
@ -124,7 +124,18 @@ class RandomUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
static randomUUID() {
|
static randomUUID() {
|
||||||
|
if (window.location.protocol === "https:") {
|
||||||
return window.crypto.randomUUID();
|
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() {
|
static randomShadowsocksPassword() {
|
||||||
|
|
Loading…
Reference in a new issue