This commit is contained in:
Ilya Kryuchkov 2025-12-04 00:18:01 +01:00 committed by GitHub
commit f4a3deab15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -120,6 +120,10 @@
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: [],
@ -233,6 +237,9 @@
loading(spinning = true) { loading(spinning = true) {
this.loadingStates.spinning = spinning; this.loadingStates.spinning = spinning;
}, },
_isIp(h) {
return /^[0-9.]+$/.test(h) || /^[0-9a-fA-F:]+$/.test(h);
},
async getAllSetting() { async getAllSetting() {
const msg = await HttpUtil.post("/panel/setting/all"); const msg = await HttpUtil.post("/panel/setting/all");
@ -307,16 +314,39 @@
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) { if (!msg.success) return;
this.loading(true);
await PromiseUtil.sleep(5000); this.loading(true);
var { webCertFile, webKeyFile, webDomain: host, webPort: port, webBasePath: base } = this.allSetting; await PromiseUtil.sleep(5000);
if (host == this.oldAllSetting.webDomain) host = null;
if (port == this.oldAllSetting.webPort) port = null; const { webDomain, webPort, webBasePath, webCertFile, webKeyFile } = this.allSetting;
const isTLS = webCertFile !== "" || webKeyFile !== ""; const newProtocol = (webCertFile || webKeyFile) ? "https:" : "http:";
const url = URLBuilder.buildURL({ host, port, isTLS, base, path: "panel/settings" });
window.location.replace(url); const base = webBasePath ? webBasePath.replace(/^\//, "") : "";
if (!this.entryIsIP) {
const url = new URL(window.location.href);
url.pathname = `/${base}panel/settings`;
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) {
@ -568,6 +598,10 @@
} }
}, },
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) {