0) {
$_REQUEST['limit']++; // Account for the header line
$netstat .= " | /usr/bin/head -n {$_REQUEST['limit']}";
}
if (isset($_REQUEST['resolve'])) {
$netstat_output_array = explode("\n", shell_exec($netstat));
$output_text = "";
foreach ($netstat_output_array as $netstat_line) {
$netstat_columns_array = explode(" ", $netstat_line);
$output_line = "";
foreach ($netstat_columns_array as $netstat_column) {
// An address can be like:
// address%dev/CIDR ff01::%em0/32
// address%dev fe80::a00:1234:5678:9abc%em0
// address/CIDR 2001:470:12:abcd::/64 192.168.1.0/24
// or just an address 2001:470:12:abcd:1:2:3:4 192.168.1.1
// Separate the bit before and after any slash.
$slash_parts = explode("/", $netstat_column);
// Then separate the bit before and after any percent sign.
$percent_parts = explode("%", $slash_parts[0]);
if (is_ipaddr($percent_parts[0])) {
// Try and reverse resolve the first part, which looks like an IP Address
$output_line .= gethostbyaddr($percent_parts[0]);
if (strlen($percent_parts[1]) > 0) {
// Put back the percent bit.
$output_line .= "%" . $percent_parts[1];
}
if (strlen($slash_parts[1]) > 0) {
// Put back the slash bit.
$output_line .= "/" . $slash_parts[1];
}
} else {
$output_line .= $netstat_column;
}
$output_line .= " ";
}
$output_text .= trim($output_line) . "\n";
}
} else {
$output_text = shell_exec($netstat);
}
echo htmlspecialchars_decode($output_text);
exit;
}
$pgtitle = array(gettext("Diagnostics"), gettext("Routes"));
$shortcut_section = "routing";
include('head.inc');
$form = new Form(false);
$form->addGlobal(new Form_Input(
'isAjax',
null,
'hidden',
1
));
$section = new Form_Section('Routing Table Display Options');
$section->addInput(new Form_Checkbox(
'resolve',
'Resolve names',
'Enable',
$resolve
))->setHelp('Enabling name resolution may cause the query to take longer.'.
' It can be stopped at any time by clicking the Stop button in the browser.');
$validLimits = array('10', '50', '100', '200', '500', '1000', 'all');
$section->addInput(new Form_Select(
'limit',
'Rows to display',
$limit,
array_combine($validLimits, $validLimits)
));
$section->addInput(new Form_Input(
'filter',
'Filter',
'text',
$host
))->setHelp('Use a regular expression to filter the tables.');
$form->add($section);
$form->addGlobal(new Form_Button(
'Submit',
'Update',
null,
'fa-refresh'
))->addClass('btn-primary');
print $form;
?>
=gettext("IPv4 Routes")?>
|
=gettext("Gathering data, please wait...")?> |
=gettext("IPv6 Routes")?>
|
=gettext("Gathering data, please wait...")?> |