mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-05-01 03:45:58 +00:00
Compare commits
1 commit
eccb8ff72a
...
a71f04d0e9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a71f04d0e9 |
1 changed files with 9 additions and 67 deletions
|
|
@ -120,10 +120,6 @@
|
||||||
oldAllSetting: new AllSetting(),
|
oldAllSetting: new AllSetting(),
|
||||||
allSetting: new AllSetting(),
|
allSetting: new AllSetting(),
|
||||||
saveBtnDisable: true,
|
saveBtnDisable: true,
|
||||||
entryHost: null,
|
|
||||||
entryPort: null,
|
|
||||||
entryProtocol: null,
|
|
||||||
entryIsIP: false,
|
|
||||||
user: {},
|
user: {},
|
||||||
lang: LanguageManager.getLanguage(),
|
lang: LanguageManager.getLanguage(),
|
||||||
inboundOptions: [],
|
inboundOptions: [],
|
||||||
|
|
@ -237,31 +233,6 @@
|
||||||
loading(spinning = true) {
|
loading(spinning = true) {
|
||||||
this.loadingStates.spinning = spinning;
|
this.loadingStates.spinning = spinning;
|
||||||
},
|
},
|
||||||
_isIp(h) {
|
|
||||||
if (typeof h !== "string") return false;
|
|
||||||
|
|
||||||
// IPv4: four dot-separated octets 0-255
|
|
||||||
const v4 = h.split(".");
|
|
||||||
if (
|
|
||||||
v4.length === 4 &&
|
|
||||||
v4.every(p => /^\d{1,3}$/.test(p) && Number(p) <= 255)
|
|
||||||
) return true;
|
|
||||||
|
|
||||||
// IPv6: hex groups, optional single :: compression
|
|
||||||
if (!h.includes(":") || h.includes(":::")) return false;
|
|
||||||
const parts = h.split("::");
|
|
||||||
if (parts.length > 2) return false;
|
|
||||||
|
|
||||||
const splitGroups = s => (s ? s.split(":").filter(Boolean) : []);
|
|
||||||
const head = splitGroups(parts[0]);
|
|
||||||
const tail = splitGroups(parts[1]);
|
|
||||||
const validGroup = seg => /^[0-9a-fA-F]{1,4}$/.test(seg);
|
|
||||||
|
|
||||||
if (![...head, ...tail].every(validGroup)) return false;
|
|
||||||
const groups = head.length + tail.length;
|
|
||||||
|
|
||||||
return parts.length === 2 ? groups < 8 : groups === 8;
|
|
||||||
},
|
|
||||||
async getAllSetting() {
|
async getAllSetting() {
|
||||||
const msg = await HttpUtil.post("/panel/setting/all");
|
const msg = await HttpUtil.post("/panel/setting/all");
|
||||||
|
|
||||||
|
|
@ -336,41 +307,16 @@
|
||||||
this.loading(true);
|
this.loading(true);
|
||||||
const msg = await HttpUtil.post("/panel/setting/restartPanel");
|
const msg = await HttpUtil.post("/panel/setting/restartPanel");
|
||||||
this.loading(false);
|
this.loading(false);
|
||||||
if (!msg.success) return;
|
if (msg.success) {
|
||||||
|
this.loading(true);
|
||||||
this.loading(true);
|
await PromiseUtil.sleep(5000);
|
||||||
await PromiseUtil.sleep(5000);
|
var { webCertFile, webKeyFile, webDomain: host, webPort: port, webBasePath: base } = this.allSetting;
|
||||||
|
if (host == this.oldAllSetting.webDomain) host = null;
|
||||||
const { webDomain, webPort, webBasePath, webCertFile, webKeyFile } = this.allSetting;
|
if (port == this.oldAllSetting.webPort) port = null;
|
||||||
const newProtocol = (webCertFile || webKeyFile) ? "https:" : "http:";
|
const isTLS = webCertFile !== "" || webKeyFile !== "";
|
||||||
|
const url = URLBuilder.buildURL({ host, port, isTLS, base, path: "panel/settings" });
|
||||||
let base = webBasePath ? webBasePath.replace(/^\//, "") : "";
|
window.location.replace(url);
|
||||||
if (base && !base.endsWith("/")) base += "/";
|
|
||||||
|
|
||||||
if (!this.entryIsIP) {
|
|
||||||
const url = new URL(window.location.href);
|
|
||||||
url.pathname = `/${base}panel/settings`;
|
|
||||||
url.protocol = newProtocol;
|
|
||||||
window.location.replace(url.toString());
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let finalHost = this.entryHost;
|
|
||||||
let finalPort = this.entryPort || "";
|
|
||||||
|
|
||||||
if (webDomain && this._isIp(webDomain)) {
|
|
||||||
finalHost = webDomain;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (webPort && Number(webPort) !== Number(this.entryPort)) {
|
|
||||||
finalPort = String(webPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = new URL(`${newProtocol}//${finalHost}`);
|
|
||||||
if (finalPort) url.port = finalPort;
|
|
||||||
url.pathname = `/${base}panel/settings`;
|
|
||||||
|
|
||||||
window.location.replace(url.toString());
|
|
||||||
},
|
},
|
||||||
toggleTwoFactor(newValue) {
|
toggleTwoFactor(newValue) {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
|
|
@ -622,10 +568,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.entryHost = window.location.hostname;
|
|
||||||
this.entryPort = window.location.port;
|
|
||||||
this.entryProtocol = window.location.protocol;
|
|
||||||
this.entryIsIP = this._isIp(this.entryHost);
|
|
||||||
await this.getAllSetting();
|
await this.getAllSetting();
|
||||||
await this.loadInboundTags();
|
await this.loadInboundTags();
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue