mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-10-27 18:32:52 +00:00
Compare commits
10 commits
a0dd101d97
...
c35179d924
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c35179d924 | ||
|
|
cedc7f0fb8 | ||
|
|
64fa0e97a3 | ||
|
|
a45e9de472 | ||
|
|
101e9ebf35 | ||
|
|
17a76d2843 | ||
|
|
a23a5de540 | ||
|
|
a16e83468b | ||
|
|
1c59afe031 | ||
|
|
c49ec9a74c |
5 changed files with 48 additions and 67 deletions
|
|
@ -1050,7 +1050,7 @@ class Allocate extends XrayCommonClass {
|
||||||
|
|
||||||
class Inbound extends XrayCommonClass {
|
class Inbound extends XrayCommonClass {
|
||||||
constructor(
|
constructor(
|
||||||
port = RandomUtil.randomIntRange(10000, 60000),
|
port = RandomUtil.randomInteger(10000, 60000),
|
||||||
listen = '',
|
listen = '',
|
||||||
protocol = Protocols.VLESS,
|
protocol = Protocols.VLESS,
|
||||||
settings = null,
|
settings = null,
|
||||||
|
|
@ -1226,7 +1226,7 @@ class Inbound extends XrayCommonClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
this.port = RandomUtil.randomIntRange(10000, 60000);
|
this.port = RandomUtil.randomInteger(10000, 60000);
|
||||||
this.listen = '';
|
this.listen = '';
|
||||||
this.protocol = Protocols.VMESS;
|
this.protocol = Protocols.VMESS;
|
||||||
this.settings = Inbound.Settings.getSettings(Protocols.VMESS);
|
this.settings = Inbound.Settings.getSettings(Protocols.VMESS);
|
||||||
|
|
|
||||||
|
|
@ -80,66 +80,48 @@ class PromiseUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const seq = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
|
|
||||||
|
|
||||||
class RandomUtil {
|
class RandomUtil {
|
||||||
static randomIntRange(min, max) {
|
static getSeq({ hasNumbers = true, hasLowercase = true, hasUppercase = true } = {}) {
|
||||||
return Math.floor(Math.random() * (max - min) + min);
|
let seq = '';
|
||||||
|
if (hasNumbers) seq += "0123456789";
|
||||||
|
if (hasLowercase) seq += "abcdefghijklmnopqrstuvwxyz";
|
||||||
|
if (hasUppercase) seq += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
return seq;
|
||||||
}
|
}
|
||||||
|
|
||||||
static randomInt(n) {
|
static randomInteger(min, max) {
|
||||||
return this.randomIntRange(0, n);
|
const range = max - min + 1;
|
||||||
|
const randomBuffer = new Uint32Array(1);
|
||||||
|
window.crypto.getRandomValues(randomBuffer);
|
||||||
|
return Math.floor((randomBuffer[0] / (0xFFFFFFFF + 1)) * range) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
static randomSeq(count) {
|
static randomSeq(count, options = {}) {
|
||||||
let str = '';
|
const seq = this.getSeq(options);
|
||||||
for (let i = 0; i < count; ++i) {
|
const seqLength = seq.length;
|
||||||
str += seq[this.randomInt(62)];
|
const randomValues = new Uint32Array(count);
|
||||||
}
|
window.crypto.getRandomValues(randomValues);
|
||||||
return str;
|
return Array.from(randomValues, v => seq[v % seqLength]).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
static randomShortIds() {
|
static randomShortIds() {
|
||||||
const lengths = [2, 4, 6, 8, 10, 12, 14, 16];
|
const lengths = [2, 4, 6, 8, 10, 12, 14, 16].sort(() => Math.random() - 0.5);
|
||||||
for (let i = lengths.length - 1; i > 0; i--) {
|
|
||||||
const j = Math.floor(Math.random() * (i + 1));
|
|
||||||
[lengths[i], lengths[j]] = [lengths[j], lengths[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
let shortIds = [];
|
return lengths.map(len => this.randomSeq(len)).join(',');
|
||||||
for (let length of lengths) {
|
|
||||||
let shortId = '';
|
|
||||||
for (let i = 0; i < length; i++) {
|
|
||||||
shortId += seq[this.randomInt(16)];
|
|
||||||
}
|
|
||||||
shortIds.push(shortId);
|
|
||||||
}
|
|
||||||
return shortIds.join(',');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static randomLowerAndNum(len) {
|
static randomLowerAndNum(len) {
|
||||||
let str = '';
|
return this.randomSeq(len, { hasUppercase: false });
|
||||||
for (let i = 0; i < len; ++i) {
|
|
||||||
str += seq[this.randomInt(36)];
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static randomUUID() {
|
static randomUUID() {
|
||||||
const template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
return window.crypto.randomUUID();
|
||||||
return template.replace(/[xy]/g, function (c) {
|
|
||||||
const randomValues = new Uint8Array(1);
|
|
||||||
crypto.getRandomValues(randomValues);
|
|
||||||
let randomValue = randomValues[0] % 16;
|
|
||||||
let calculatedValue = (c === 'x') ? randomValue : (randomValue & 0x3 | 0x8);
|
|
||||||
return calculatedValue.toString(16);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static randomShadowsocksPassword() {
|
static randomShadowsocksPassword() {
|
||||||
let array = new Uint8Array(32);
|
const array = new Uint8Array(32);
|
||||||
window.crypto.getRandomValues(array);
|
window.crypto.getRandomValues(array);
|
||||||
return btoa(String.fromCharCode.apply(null, array));
|
return Base64.encode(String.fromCharCode(...array));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
<a-select-option value="wechat-video">WeChat</a-select-option>
|
<a-select-option value="wechat-video">WeChat</a-select-option>
|
||||||
<a-select-option value="dtls">DTLS 1.2</a-select-option>
|
<a-select-option value="dtls">DTLS 1.2</a-select-option>
|
||||||
<a-select-option value="wireguard">WireGuard</a-select-option>
|
<a-select-option value="wireguard">WireGuard</a-select-option>
|
||||||
|
<a-select-option value="dns">DNS</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
|
|
|
||||||
|
|
@ -927,7 +927,7 @@
|
||||||
expiryTime: dbInbound.expiryTime,
|
expiryTime: dbInbound.expiryTime,
|
||||||
|
|
||||||
listen: '',
|
listen: '',
|
||||||
port: RandomUtil.randomIntRange(10000, 60000),
|
port: RandomUtil.randomInteger(10000, 60000),
|
||||||
protocol: baseInbound.protocol,
|
protocol: baseInbound.protocol,
|
||||||
settings: Inbound.Settings.getSettings(baseInbound.protocol).toString(),
|
settings: Inbound.Settings.getSettings(baseInbound.protocol).toString(),
|
||||||
streamSettings: baseInbound.stream.toString(),
|
streamSettings: baseInbound.stream.toString(),
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
color: var(--dark-color-text-primary);
|
color: var(--dark-color-text-primary);
|
||||||
}
|
}
|
||||||
.ant-backup-list-item {
|
.ant-backup-list-item {
|
||||||
text-align: left;
|
gap: 10px;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
@ -272,7 +272,7 @@
|
||||||
</a-layout>
|
</a-layout>
|
||||||
<a-modal id="version-modal" v-model="versionModal.visible" title='{{ i18n "pages.index.xraySwitch" }}' :closable="true"
|
<a-modal id="version-modal" v-model="versionModal.visible" title='{{ i18n "pages.index.xraySwitch" }}' :closable="true"
|
||||||
@ok="() => versionModal.visible = false" :class="themeSwitcher.currentTheme" footer="">
|
@ok="() => versionModal.visible = false" :class="themeSwitcher.currentTheme" footer="">
|
||||||
<a-alert type="warning" style="margin-bottom: 12px; width: fit-content"
|
<a-alert type="warning" style="margin-bottom: 12px; width: 100%;"
|
||||||
message='{{ i18n "pages.index.xraySwitchClickDesk" }}' show-icon></a-alert>
|
message='{{ i18n "pages.index.xraySwitchClickDesk" }}' show-icon></a-alert>
|
||||||
<a-list class="ant-xray-version-list" bordered style="width: 100%;">
|
<a-list class="ant-xray-version-list" bordered style="width: 100%;">
|
||||||
<a-list-item class="ant-xray-version-list-item" v-for="version in versionModal.versions">
|
<a-list-item class="ant-xray-version-list-item" v-for="version in versionModal.versions">
|
||||||
|
|
@ -334,7 +334,6 @@
|
||||||
:closable="true"
|
:closable="true"
|
||||||
footer=""
|
footer=""
|
||||||
:class="themeSwitcher.currentTheme">
|
:class="themeSwitcher.currentTheme">
|
||||||
<a-space direction="horizontal" style="text-align: center; margin-bottom: 10px;">
|
|
||||||
<a-list class="ant-backup-list" bordered style="width: 100%;">
|
<a-list class="ant-backup-list" bordered style="width: 100%;">
|
||||||
<a-list-item class="ant-backup-list-item" @click="exportDatabase()">
|
<a-list-item class="ant-backup-list-item" @click="exportDatabase()">
|
||||||
<a-list-item-meta>
|
<a-list-item-meta>
|
||||||
|
|
@ -354,7 +353,6 @@
|
||||||
<a-icon type="right" />
|
<a-icon type="right" />
|
||||||
</a-list-item>
|
</a-list-item>
|
||||||
</a-list>
|
</a-list>
|
||||||
</a-space>
|
|
||||||
</a-modal>
|
</a-modal>
|
||||||
</a-layout>
|
</a-layout>
|
||||||
{{template "js" .}}
|
{{template "js" .}}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue