Commit dd80dea6 authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

sort interfaces in legacy_config_get_interfaces

PR: https://forum.opnsense.org/index.php?topic=3514

(cherry picked from commit 48769e27)
(cherry picked from commit 14d53f5b)
(cherry picked from commit 26a66802)
parent 16f224ac
......@@ -75,5 +75,8 @@ function legacy_config_get_interfaces($filters = array())
}
}
}
uasort($interfaces, function($a, $b) {
return strnatcmp($a['descr'], $b['descr']);
});
return $interfaces;
}
......@@ -280,27 +280,35 @@ function filter_rules_sort()
for ($i = 0; isset($config['filter']['rule'][$i]); $i++) {
$config['filter']['rule'][$i]['seq'] = $i;
}
usort($config['filter']['rule'], "filter_rules_compare");
usort($config['filter']['rule'], function($a, $b){
if (isset($a['floating']) && isset($b['floating'])) {
return $a['seq'] - $b['seq'];
} elseif (isset($a['floating'])) {
return -1;
} elseif (isset($b['floating'])) {
return 1;
} elseif ($a['interface'] == $b['interface']) {
return $a['seq'] - $b['seq'];
} elseif ($a['interface'] == $b['interface']) {
return 0;
} elseif ($a['interface'] == 'wan') {
return -1;
} elseif ($b['interface'] == 'wan') {
return 1;
} elseif ($a['interface'] == 'lan') {
return -1;
} elseif ($b['interface'] == 'lan') {
return 1;
} else {
return strnatcmp($a['interface'], $b['interface']);
}
});
/* strip the sequence numbers again */
for ($i = 0; isset($config['filter']['rule'][$i]); $i++) {
unset($config['filter']['rule'][$i]['seq']);
}
}
function filter_rules_compare($a, $b) {
if (isset($a['floating']) && isset($b['floating'])) {
return $a['seq'] - $b['seq'];
} elseif (isset($a['floating'])) {
return -1;
} elseif (isset($b['floating'])) {
return 1;
} elseif ($a['interface'] == $b['interface']) {
return $a['seq'] - $b['seq'];
} else {
return compare_interface_friendly_names($a['interface'], $b['interface']);
}
}
function filter_pflog_start()
{
if (isvalidpid('/var/run/filterlog.pid')) {
......
......@@ -741,23 +741,6 @@ function get_configured_vips_list()
return $alias_list;
}
/* comparison function for sorting by the order in which interfaces are normally created */
function compare_interface_friendly_names($a, $b)
{
if ($a == $b) {
return 0;
} elseif ($a == 'wan') {
return -1;
} elseif ($b == 'wan') {
return 1;
} elseif ($a == 'lan') {
return -1;
} elseif ($b == 'lan') {
return 1;
}
return strnatcmp($a, $b);
}
/* return the configured interfaces list. */
function get_configured_interface_list($only_opt = false, $withdisabled = false)
{
......
......@@ -155,7 +155,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
interface_sync_wireless_clones($config['interfaces'][$newifname], false);
}
uksort($config['interfaces'], "compare_interface_friendly_names");
write_config();
header("Location: interfaces_assign.php");
exit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment