mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
fix: generating shortIds for vless reality (#2745)
This commit is contained in:
parent
c35179d924
commit
ad13ce6cde
1 changed files with 14 additions and 5 deletions
|
@ -81,11 +81,20 @@ class PromiseUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
class RandomUtil {
|
class RandomUtil {
|
||||||
static getSeq({ hasNumbers = true, hasLowercase = true, hasUppercase = true } = {}) {
|
static getSeq({ type = "default", hasNumbers = true, hasLowercase = true, hasUppercase = true } = {}) {
|
||||||
let seq = '';
|
let seq = '';
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case "hex":
|
||||||
|
seq += "0123456789abcdef";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
if (hasNumbers) seq += "0123456789";
|
if (hasNumbers) seq += "0123456789";
|
||||||
if (hasLowercase) seq += "abcdefghijklmnopqrstuvwxyz";
|
if (hasLowercase) seq += "abcdefghijklmnopqrstuvwxyz";
|
||||||
if (hasUppercase) seq += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
if (hasUppercase) seq += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return seq;
|
return seq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +116,7 @@ class RandomUtil {
|
||||||
static randomShortIds() {
|
static randomShortIds() {
|
||||||
const lengths = [2, 4, 6, 8, 10, 12, 14, 16].sort(() => Math.random() - 0.5);
|
const lengths = [2, 4, 6, 8, 10, 12, 14, 16].sort(() => Math.random() - 0.5);
|
||||||
|
|
||||||
return lengths.map(len => this.randomSeq(len)).join(',');
|
return lengths.map(len => this.randomSeq(len, { type: "hex" })).join(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
static randomLowerAndNum(len) {
|
static randomLowerAndNum(len) {
|
||||||
|
|
Loading…
Reference in a new issue