Add proper IP sorting to the groups->client table. Also implement subnet (CIDR notation) support into our existing IP sorting algorithm. This fixes #1268.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2020-05-11 23:53:24 +02:00
parent e96acc415d
commit a0bd88c7ef
3 changed files with 27 additions and 4 deletions

View File

@@ -23,9 +23,16 @@ jQuery.extend(jQuery.fn.dataTableExt.oSort, {
var m = a.split("."),
n = a.split(":"),
x = "",
xa = "";
xa = "",
cidr = [];
if (m.length === 4) {
// IPV4
// IPV4 (possibly with CIDR)
cidr = m[3].split("/");
if (cidr.length === 2) {
m.pop();
m = m.concat(cidr);
}
for (i = 0; i < m.length; i++) {
item = m[i];
@@ -38,7 +45,7 @@ jQuery.extend(jQuery.fn.dataTableExt.oSort, {
}
}
} else if (n.length > 0) {
// IPV6
// IPV6 (possibly with CIDR)
var count = 0;
for (i = 0; i < n.length; i++) {
item = n[i];
@@ -79,6 +86,21 @@ jQuery.extend(jQuery.fn.dataTableExt.oSort, {
x += item;
}
}
cidr = x.split("/");
x = cidr[0];
if (cidr.length === 2) {
item = cidr[1];
if (item.length === 1) {
x += "00" + item;
} else if (item.length === 2) {
x += "0" + item;
} else {
x += item;
}
}
console.log([a, n, xa, count, x]);
}
return x;