Fix allocation exception when advanced options isnt open (#1536)

This commit is contained in:
Tim Wilkinson 2024-09-17 22:00:31 -07:00 committed by GitHub
parent 4c902eef9f
commit 6821421512
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 32 additions and 29 deletions

View File

@ -420,38 +420,41 @@ This value is used by default, but each tunnel may overide it.
server = e.target.value;
}
});
htmx.on("input[name=tunnel_range_start]", "change", e => {
available.l = {};
available.w = {};
if (e.target.validity.valid) {
const l = e.target.value.split(".").map(v => parseInt(v));
const w = [ l[0], l[1], (l[2] === 255 ? 0 : l[2] + 1), l[3] ];
for (let i = 0; i < 62; i++) {
available.l[`${l[0]}.${l[1]}.${l[2]}.${l[3]}`] = 1;
l[3] += 4;
if (l[3] >= 252) {
l[2]++;
if (l[2] === 256) {
l[2] = 0;
const rangeStart = htmx.find("input[name=tunnel_range_start]");
if (rangeStart) {
htmx.on(rangeStart, "change", e => {
available.l = {};
available.w = {};
if (e.target.validity.valid) {
const l = e.target.value.split(".").map(v => parseInt(v));
const w = [ l[0], l[1], (l[2] === 255 ? 0 : l[2] + 1), l[3] ];
for (let i = 0; i < 62; i++) {
available.l[`${l[0]}.${l[1]}.${l[2]}.${l[3]}`] = 1;
l[3] += 4;
if (l[3] >= 252) {
l[2]++;
if (l[2] === 256) {
l[2] = 0;
}
l[3] = 4;
}
l[3] = 4;
}
let p = {{uciMesh.get("aredn", "@supernode[0]", "enable") === "1" ? 6526 : 5525}};
for (let i = 0; i < 126; i++) {
available.w[`${w[0]}.${w[1]}.${w[2]}.${w[3]}:${p}`] = 1;
w[3] += 2;
if (w[3] >= 254) {
w[2]++;
if (w[2] === 256) {
w[2] = 0;
}
w[3] = 2;
}
p++;
}
}
let p = {{uciMesh.get("aredn", "@supernode[0]", "enable") === "1" ? 6526 : 5525}};
for (let i = 0; i < 126; i++) {
available.w[`${w[0]}.${w[1]}.${w[2]}.${w[3]}:${p}`] = 1;
w[3] += 2;
if (w[3] >= 254) {
w[2]++;
if (w[2] === 256) {
w[2] = 0;
}
w[3] = 2;
}
p++;
}
}
});
});
}
function newTunnelEntry()
{
const type = htmx.find("#tunnel-templates select").value;