mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-12-23 06:42:41 +00:00
Compare commits
1 commit
aac4d7e82e
...
f4a3deab15
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4a3deab15 |
1 changed files with 2 additions and 26 deletions
|
|
@ -238,29 +238,7 @@
|
||||||
this.loadingStates.spinning = spinning;
|
this.loadingStates.spinning = spinning;
|
||||||
},
|
},
|
||||||
_isIp(h) {
|
_isIp(h) {
|
||||||
if (typeof h !== "string") return false;
|
return /^[0-9.]+$/.test(h) || /^[0-9a-fA-F:]+$/.test(h);
|
||||||
|
|
||||||
// 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");
|
||||||
|
|
@ -344,13 +322,11 @@
|
||||||
const { webDomain, webPort, webBasePath, webCertFile, webKeyFile } = this.allSetting;
|
const { webDomain, webPort, webBasePath, webCertFile, webKeyFile } = this.allSetting;
|
||||||
const newProtocol = (webCertFile || webKeyFile) ? "https:" : "http:";
|
const newProtocol = (webCertFile || webKeyFile) ? "https:" : "http:";
|
||||||
|
|
||||||
let base = webBasePath ? webBasePath.replace(/^\//, "") : "";
|
const base = webBasePath ? webBasePath.replace(/^\//, "") : "";
|
||||||
if (base && !base.endsWith("/")) base += "/";
|
|
||||||
|
|
||||||
if (!this.entryIsIP) {
|
if (!this.entryIsIP) {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
url.pathname = `/${base}panel/settings`;
|
url.pathname = `/${base}panel/settings`;
|
||||||
url.protocol = newProtocol;
|
|
||||||
window.location.replace(url.toString());
|
window.location.replace(url.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue