mirror of https://github.com/aredn/aredn.git
Recalculate tunnels address range when tunnel server network changes (#1534)
This commit is contained in:
parent
4eb715c722
commit
cbe0cc3dc5
|
@ -420,6 +420,38 @@ 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;
|
||||
}
|
||||
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++;
|
||||
}
|
||||
}
|
||||
});
|
||||
function newTunnelEntry()
|
||||
{
|
||||
const type = htmx.find("#tunnel-templates select").value;
|
||||
|
|
Loading…
Reference in New Issue