2017-12-29 18:15:24 +01:00
|
|
|
<!DOCTYPE html>
|
2017-12-29 23:45:10 +01:00
|
|
|
<html>
|
2018-08-18 21:13:41 +02:00
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8" />
|
|
|
|
<title>Simple Babelweb</title>
|
|
|
|
<style>
|
|
|
|
table {
|
|
|
|
font-family: monospace, sans-serif;
|
|
|
|
border-collapse: collapse;
|
|
|
|
}
|
|
|
|
td, th {
|
|
|
|
border: 1px solid #fddddd;
|
|
|
|
text-align: left;
|
|
|
|
padding: 1px;
|
|
|
|
padding-right: 10px;
|
|
|
|
}
|
|
|
|
tr:nth-child(even) {
|
|
|
|
background-color: #dddddd;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<?php
|
|
|
|
error_reporting(0);
|
2018-10-24 16:10:41 +02:00
|
|
|
$file="/tmp/babeldump";
|
|
|
|
shell_exec('echo "dump" | nc ::1 33123 -q 0 > '.$file.'');
|
2018-08-18 21:13:41 +02:00
|
|
|
|
2018-10-24 16:10:41 +02:00
|
|
|
$file_handle = fopen($file, 'r');
|
|
|
|
$set=0;
|
|
|
|
$i=0;
|
|
|
|
while (1) {
|
|
|
|
$line = fgets($file_handle);
|
|
|
|
if ($i <= 5) {
|
|
|
|
$data[] = $line;
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
if (preg_match("/interface\b/", $line)) { $interface[] = $line; }
|
|
|
|
if (preg_match("/neighbour\b/", $line)) { $neighbour[] = $line; }
|
|
|
|
if (preg_match("/xroute\b/", $line)) { $xroute[] = $line; }
|
|
|
|
#if (preg_match("/\broute\b/", $read)){ break 1; }
|
|
|
|
if (preg_match("/\broute\b/", $line)){ $route[] = $line; }
|
|
|
|
if (preg_match("/ok/", $line)){ $set++; }
|
|
|
|
if ($set == 2) { break; }
|
|
|
|
}
|
|
|
|
fclose($file_handle);
|
2018-08-18 21:13:41 +02:00
|
|
|
|
|
|
|
$output['data'] = array(
|
|
|
|
'name' => $data[0],
|
|
|
|
'version' => $data[1],
|
|
|
|
'host' => $data[2],
|
|
|
|
'id' => $data[3],
|
|
|
|
);
|
2018-01-27 14:48:12 +01:00
|
|
|
|
2018-08-18 21:13:41 +02:00
|
|
|
foreach ($interface as $temp) {
|
|
|
|
$tempdata = explode(" ", $temp);
|
|
|
|
$output['interfaces'][] = array(
|
|
|
|
'interface' => $tempdata[2],
|
|
|
|
'up' => $tempdata[4],
|
|
|
|
'ipv6' => $tempdata[6],
|
|
|
|
'ipv4' => $tempdata[8],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
foreach ($neighbour as $temp) {
|
2018-08-19 09:27:34 +02:00
|
|
|
$address=explode(" ",strstr($temp,"address"));
|
2018-08-23 12:40:06 +02:00
|
|
|
$interface=explode(" ",strstr($temp,"if"));
|
2018-08-19 09:27:34 +02:00
|
|
|
$reach=explode(" ",strstr($temp,"reach"));
|
|
|
|
$rxcost=explode(" ",strstr($temp,"rxcost"));
|
|
|
|
$txcost=explode(" ",strstr($temp,"txcost"));
|
|
|
|
$rtt=explode(" ",strstr($temp,"rtt"));
|
|
|
|
$rttcost=explode(" ",strstr($temp,"rttcost"));
|
|
|
|
$cost=explode(" ",strstr($temp,"cost"));
|
2018-08-18 21:13:41 +02:00
|
|
|
$output['neighbours'][] = array(
|
2018-08-19 09:27:34 +02:00
|
|
|
'address' => $address[1],
|
|
|
|
'interface' => $interface[1],
|
|
|
|
'reach' => $reach[1],
|
|
|
|
'rxcost' => $rxcost[1],
|
|
|
|
'txcost' => $txcost[1],
|
|
|
|
'rtt' => $rtt[1],
|
|
|
|
'rttcost' => $rttcost[1],
|
|
|
|
'cost' => $cost[1],
|
2018-08-18 21:13:41 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($xroute as $temp) {
|
|
|
|
$tempdata = explode(" ", $temp);
|
|
|
|
$output['xroutes'][] = array(
|
|
|
|
'prefix' => $tempdata[4],
|
|
|
|
'metric' => $tempdata[8],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($route as $temp) {
|
|
|
|
$tempdata = explode(" ", $temp);
|
|
|
|
$output['routes'][] = array(
|
|
|
|
'target' => $tempdata[4],
|
|
|
|
'installed' => $tempdata[8],
|
|
|
|
'via' => $tempdata[16],
|
|
|
|
'interface' => $tempdata[18],
|
|
|
|
'metric' => $tempdata[12],
|
|
|
|
'destid' => $tempdata[10],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($_REQUEST['format'] == 'json') {
|
|
|
|
echo json_encode($output); }
|
|
|
|
else {
|
|
|
|
# Ausgabe
|
|
|
|
echo "<h1>Simple Babelweb</h1>";
|
2018-08-19 12:49:36 +02:00
|
|
|
?><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
|
|
|
|
<button type="submit" name="" value="">home</button>
|
|
|
|
<button type="submit" name="routes" value="1">show all babel routes</button>
|
|
|
|
<button type="submit" name="v4table" value="1">show import/export table ipv4</button>
|
|
|
|
<button type="submit" name="v6table" value="1">show import/export table ipv6</button>
|
2018-10-24 16:10:41 +02:00
|
|
|
<button type="submit" name="lg" value="1">Looking glass</button>
|
2018-08-19 12:49:36 +02:00
|
|
|
</form>
|
|
|
|
<H2>Babel information</H2><?php
|
|
|
|
|
2018-08-18 21:13:41 +02:00
|
|
|
echo "<table>";
|
2018-08-23 13:18:02 +02:00
|
|
|
echo '<tr><td><a href="https://github.com/rohammer/Simple-Babelweb">Quellcode Simple Babelweb</a></td></tr>';
|
2018-08-18 21:13:41 +02:00
|
|
|
foreach($output['data'] as $temp) { echo "<tr><td>$temp</td></tr>"; }
|
|
|
|
echo "</table>";
|
2018-08-19 09:40:16 +02:00
|
|
|
|
|
|
|
if($_GET['ip'] != '') {
|
|
|
|
echo '<H2>Wege zu '.$_GET["ip"].'</H2>';
|
|
|
|
echo '<table>
|
|
|
|
<tr>
|
|
|
|
<th>target</th>
|
|
|
|
<th>installed</th>
|
|
|
|
<th>via</th>
|
|
|
|
<th>device</th>
|
|
|
|
<th>metric</th>
|
|
|
|
<th>Destination ID</th>
|
|
|
|
</tr>';
|
|
|
|
foreach($output['routes'] as $route) {
|
|
|
|
if ($route['target'] == $_GET['ip']) {
|
|
|
|
echo "<tr>";
|
|
|
|
foreach($route as $temp) { echo "<td>$temp</td>"; }
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "</table>";
|
|
|
|
}
|
|
|
|
|
2018-08-19 12:49:36 +02:00
|
|
|
if (empty($_GET)) {
|
|
|
|
echo "<H2>Interfaces</H2>";
|
|
|
|
echo '<table>
|
2018-08-18 21:13:41 +02:00
|
|
|
<tr>
|
2018-08-19 12:49:36 +02:00
|
|
|
<th>Interface</th>
|
|
|
|
<th>up</th>
|
|
|
|
<th>ipv6</th>
|
|
|
|
<th>ipv4</th>
|
|
|
|
</tr>';
|
|
|
|
foreach($output['interfaces'] as $interface) {
|
|
|
|
echo "<tr>";
|
|
|
|
foreach($interface as $temp) { echo "<td>$temp</td>"; }
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
echo "</table>";
|
|
|
|
echo "<H2>Neighbours</H2>";
|
|
|
|
echo '<table>
|
|
|
|
<tr>
|
|
|
|
<th>address</th>
|
|
|
|
<th>interface</th>
|
|
|
|
<th>reach</th>
|
|
|
|
<th>rxcost</th>
|
|
|
|
<th>txcost</th>
|
|
|
|
<th>rtt</th>
|
|
|
|
<th>rttcost</th>
|
|
|
|
<th>cost</th>
|
|
|
|
</tr>';
|
|
|
|
foreach($output['neighbours'] as $neighbour) {
|
|
|
|
echo "<tr>";
|
|
|
|
foreach($neighbour as $temp) { echo "<td>$temp</td>"; }
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
echo "</table>";
|
|
|
|
echo "<H2>Redistributed routes</H2>";
|
|
|
|
echo '<table>
|
|
|
|
<tr>
|
|
|
|
<th>prefix</th>
|
|
|
|
<th>metric</th>
|
|
|
|
</tr>';
|
|
|
|
foreach($output['xroutes'] as $xroute) {
|
|
|
|
echo "<tr>";
|
|
|
|
foreach($xroute as $temp) { echo "<td>$temp</td>"; }
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
echo "</table>";
|
2018-08-18 21:13:41 +02:00
|
|
|
}
|
2018-08-19 09:47:48 +02:00
|
|
|
if($_GET['routes'] == '1') {
|
2018-08-18 21:13:41 +02:00
|
|
|
echo "<H2>routes</H2>";
|
|
|
|
echo '<table>
|
|
|
|
<tr>
|
|
|
|
<th>target</th>
|
|
|
|
<th>installed</th>
|
|
|
|
<th>via</th>
|
|
|
|
<th>device</th>
|
|
|
|
<th>metric</th>
|
|
|
|
<th>Destination ID</th>
|
|
|
|
</tr>';
|
|
|
|
foreach($output['routes'] as $route) {
|
2018-08-19 09:58:23 +02:00
|
|
|
$set=0;
|
2018-08-18 21:13:41 +02:00
|
|
|
echo "<tr>";
|
2018-08-19 09:58:23 +02:00
|
|
|
foreach($route as $temp) {
|
|
|
|
if ($set == 0) {
|
|
|
|
echo '<td><a href="'.$_SERVER["PHP_SELF"].'?ip='.$temp.'">'.$temp.'</a></td>';
|
|
|
|
$set=1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo "<td>$temp</td>";
|
|
|
|
}
|
|
|
|
}
|
2018-08-18 21:13:41 +02:00
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
echo "</table>";
|
|
|
|
}
|
2018-03-10 00:04:32 +01:00
|
|
|
|
|
|
|
|
2018-08-19 09:47:48 +02:00
|
|
|
if($_GET['v4table'] == '1') {
|
2018-08-18 21:13:41 +02:00
|
|
|
echo "<H2>ipv4 routing table</H2>";
|
|
|
|
echo '<table>';
|
2018-03-10 00:37:08 +01:00
|
|
|
$v4routen = shell_exec('ip r s t $(grep import-table /etc/babeld.conf | cut -f2 -d" ")');
|
2018-03-10 00:04:32 +01:00
|
|
|
$v4route = explode(PHP_EOL, $v4routen);
|
|
|
|
for($i = 0; $i < count($v4route); ++$i) {
|
|
|
|
echo "<tr>";
|
|
|
|
$line = explode(" ", $v4route[$i]);
|
|
|
|
for($n = 0; $n < 5; ++$n) {
|
2018-08-18 21:13:41 +02:00
|
|
|
if ($n == 0) {
|
2018-08-19 09:50:20 +02:00
|
|
|
echo '<td><a href="'.$_SERVER["PHP_SELF"].'?ip='.$line[$n].'">'.$line[$n].'</a></td>';
|
2018-08-18 21:13:41 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo '<td>'.$line[$n].'</td>';
|
|
|
|
}
|
2018-03-10 00:04:32 +01:00
|
|
|
}
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
2018-08-18 21:13:41 +02:00
|
|
|
echo "</table>";
|
|
|
|
}
|
|
|
|
|
2018-08-19 09:47:48 +02:00
|
|
|
if($_GET['v6table'] == '1') {
|
2018-08-18 21:13:41 +02:00
|
|
|
echo "<H2>ipv6 routing table</H2>";
|
2018-08-19 11:14:57 +02:00
|
|
|
echo '<table>
|
|
|
|
<tr>
|
|
|
|
<th>Destination</th>
|
|
|
|
<th>Source Specific</th>
|
|
|
|
<th>via</th>
|
|
|
|
<th>Device</th>
|
|
|
|
<th>proto</th>
|
|
|
|
<th>Kernelmetric</th>
|
|
|
|
</tr>';
|
2018-03-10 00:37:08 +01:00
|
|
|
$v6routen = shell_exec('ip -6 r s t $(grep import-table /etc/babeld.conf | cut -f2 -d" ")');
|
2018-03-10 00:04:32 +01:00
|
|
|
$v6route = explode(PHP_EOL, $v6routen);
|
|
|
|
for($i = 0; $i < count($v6route); ++$i) {
|
|
|
|
echo "<tr>";
|
2018-08-19 11:14:57 +02:00
|
|
|
$destination=explode(" ", $v6route[$i]);
|
2018-08-19 12:49:36 +02:00
|
|
|
$source=explode(" ", strstr($v6route[$i],"from"));
|
|
|
|
$via=explode(" ", strstr($v6route[$i],"via"));
|
|
|
|
$device=explode(" ", strstr($v6route[$i],"dev"));
|
|
|
|
$proto=explode(" ", strstr($v6route[$i],"proto"));
|
|
|
|
$metric=explode(" ", strstr($v6route[$i],"metric"));
|
2018-08-19 11:14:57 +02:00
|
|
|
echo '<td><a href="'.$_SERVER["PHP_SELF"].'?ip='.$destination[0].'">'.$destination[0].'</a></td>';
|
2018-08-19 12:49:36 +02:00
|
|
|
echo '<td>'.$source[1].'</td>';
|
|
|
|
echo '<td>'.$via[1].'</td>';
|
|
|
|
echo '<td>'.$device[1].'</td>';
|
|
|
|
echo '<td>'.$proto[1].'</td>';
|
|
|
|
echo '<td>'.$metric[1].'</td>';
|
2018-08-19 11:14:57 +02:00
|
|
|
|
2018-08-18 21:13:41 +02:00
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "</table>";
|
|
|
|
}
|
2018-10-24 16:10:41 +02:00
|
|
|
|
|
|
|
if($_GET['lg'] == '1') {
|
|
|
|
?>
|
|
|
|
<form action="index.php?lg=1" method="post">
|
2018-10-24 16:27:28 +02:00
|
|
|
IP Adresse (v4 und v6): <input type="text" size="17" name="IP">
|
2018-10-24 16:10:41 +02:00
|
|
|
<input type="submit" value="OK">
|
|
|
|
</form>
|
|
|
|
<?php
|
2018-10-24 16:29:34 +02:00
|
|
|
$ip =$_POST['IP'];
|
|
|
|
if (filter_var($ip, FILTER_VALIDATE_IP)) {
|
|
|
|
echo "Pinge $ip: <br /><pre>";
|
|
|
|
echo shell_exec('ping '.$ip.' -c 3');
|
|
|
|
echo "</pre>Traceroute $ipP <br /><pre>";
|
|
|
|
echo shell_exec('traceroute '.$ip.'');
|
2018-10-24 16:10:41 +02:00
|
|
|
echo "</pre>";
|
2018-10-24 16:27:28 +02:00
|
|
|
|
|
|
|
} else {
|
|
|
|
echo("$ip1 is not a valid IP address");
|
2018-10-24 16:10:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-18 21:13:41 +02:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
<br>
|
|
|
|
</body>
|
2017-12-30 01:44:52 +01:00
|
|
|
</html>
|