Major network enhancements

This commit is contained in:
bergware
2018-02-06 18:59:43 +01:00
parent d582a65e45
commit 4ea4e98cae
6 changed files with 87 additions and 53 deletions
+11 -10
View File
@@ -14,14 +14,15 @@
$task = $_POST['task'];
switch ($task) {
case 'delete':
$gateway = str_replace(' ','-',trim($_POST['gateway']));
$gateway = str_replace(['via ',' '],['','-'],trim($_POST['gateway']));
$route = trim($_POST['route']);
if ($gateway && $route) exec("/etc/rc.d/rc.inet1 ".escapeshellarg("{$gateway}_{$route}_del"));
$metric = trim($_POST['metric'] ?: "1");
if ($gateway && $route) exec("/etc/rc.d/rc.inet1 ".escapeshellarg("{$gateway}_{$route}_{$metric}_del"));
break;
case 'Add Route':
$gateway = str_replace(' ','-',trim($_POST['gateway']));
$gateway = str_replace(['via ',' '],['','-'],trim($_POST['gateway']));
$route = trim($_POST['route']);
$metric = strlen($_POST['metric']) ? trim($_POST['metric']) : 1;
$metric = trim($_POST['metric'] ?: "1");
if ($gateway && $route) exec("/etc/rc.d/rc.inet1 ".escapeshellarg("{$gateway}_{$route}_{$metric}_add"));
break;
default:
@@ -31,20 +32,20 @@ default:
$cell = explode(' ',$info);
$route = $cell[0];
$gateway = $cell[2];
$button = 'bt-'.preg_replace('/[\.:\/]/','',$gateway.$route);
if ($route=='default') $gateway .= " via {$cell[4]}";
$metric = '1';
for ($i=3; $i<count($cell); $i++) if ($cell[$i] == 'metric') {$metric = $cell[$i+1]; break;}
echo "<tr><td>IPv4</td><td>$route</td><td>$gateway</td><td>$metric</td><td style='text-align:center'><a id='$button' href='#' onclick='deleteRoute(\"#$button\",\"$gateway\",\"$route\");return false'><i class='fa fa-trash-o'></i></a></td></tr>";
for ($i=5; $i<count($cell); $i++) if ($cell[$i]=='metric') {$metric = $cell[$i+1]; break;}
echo "<tr><td>IPv4</td><td>$route</td><td>$gateway</td><td>$metric</td><td style='text-align:center'><a href='#' onclick='deleteRoute(\"$gateway\",\"$route\",\"$metric\");return false'><i class='fa fa-trash-o'></i></a></td></tr>";
}
if ($ipv6) echo "<tr class='tr_last'><td colspan='5'>&nbsp;</td></tr>";
foreach ($ipv6 as $info) {
$cell = explode(' ',$info);
$route = $cell[0];
$gateway = $route=='anycast' ? $cell[3] : $cell[2];
$button = 'bt-'.preg_replace('/[\.:\/]/','',$gateway.$route);
if ($route=='default') $gateway .= " via {$cell[4]}";
$metric = '1';
for ($i=3; $i<count($cell); $i++) if ($cell[$i] == 'metric') {$metric = $cell[$i+1]; break;}
echo "<tr><td>IPv6</td><td>$route</td><td>$gateway</td><td>$metric</td><td style='text-align:center'><a id='$button' href='#' onclick='deleteRoute(\"#$button\",\"$gateway\",\"$route\");return false'><i class='fa fa-trash-o'></i></a></td></tr>";
for ($i=5; $i<count($cell); $i++) if ($cell[$i]=='metric') {$metric = $cell[$i+1]; break;}
echo "<tr><td>IPv6</td><td>$route</td><td>$gateway</td><td>$metric</td><td style='text-align:center'><a href='#' onclick='deleteRoute(\"$gateway\",\"$route\",\"$metric\");return false'><i class='fa fa-trash-o'></i></a></td></tr>";
}
echo "<tr class='tr_last'><td colspan='5'>&nbsp;</td></tr>";
}