Merge branch 'master' of https://github.com/zbchristian/raspap-webgui into zbchristian-master

This commit is contained in:
billz 2020-06-28 16:08:23 +01:00
commit 6ed35a1aba
2 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,36 @@
<?php
define("ACCESS_CHECK_IP","1.1.1.1");
define("ACCESS_CHECK_DNS","one.one.one.one");
$rInfo=array();
// get all default routes
exec('ip route list | sed -rn "s/default via (([0-9]{1,3}\.){3}[0-9]{1,3}).*dev (\w*).*src (([0-9]{1,3}\.){3}[0-9]{1,3}).*/\3 \4 \1/p"',$routes);
if ( !empty($routes) ) {
foreach ($routes as $i => $route) {
$prop=explode(' ',$route);
$rInfo[$i]["interface"]=$prop[0];
$rInfo[$i]["ip-address"]=$prop[1];
$rInfo[$i]["gateway"]=$prop[2];
// resolve the name of the gateway (if possible)
unset($host);
exec('host '.$prop[2].' | sed -rn "s/.*domain name pointer (.*)\./\1/p" | head -n 1',$host);
if (empty($host)) $host[0]="*";
$rInfo[$i]["gw-name"] = $host[0];
if (isset($checkAccess) && $checkAccess) {
// check internet connectivity w/ and w/o DNS resolution
unset($okip);
exec('ping -W1 -c 1 -I '.$prop[0].' '.ACCESS_CHECK_IP.' | sed -rn "s/.*icmp_seq=1.*time=.*/\&check\;/p"',$okip);
if (empty($okip)) $okip[0]="failed";
$rInfo[$i]["access-ip"] = $okip[0];
unset($okdns);
exec('ping -W1 -c 1 -I '.$prop[0].' '.ACCESS_CHECK_DNS.' | sed -rn "s/.*icmp_seq=1.*time=.*/\&check\;/p"',$okdns);
if (empty($okdns)) $okdns[0]="failed";
$rInfo[$i]["access-dns"] = $okdns[0];
}
}
} else {
$rInfo = array("error"=>"No route to the internet found");
}
$rInfo_json = json_encode($rInfo);
?>

View File

@ -28,6 +28,46 @@
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="summary">
<h4 class="mt-3"><?php echo _("Internet connection"); ?></h4>
<div class="row">
<div class="col-sm-12"">
<div class="card ">
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th><?php echo _("Interface"); ?></th>
<th><?php echo _("IP Address"); ?></th>
<th><?php echo _("Gateway"); ?></th>
<th colspan="2"><?php echo _("Internet Access"); ?></th>
</tr>
</thead>
<tbody>
<?php
$checkAccess=True;
include("includes/internetRoute.php");
if (isset($rInfo["error"]) || empty($rInfo)) {
echo "<tr><td colspan=5>No route to the internet found</td></tr>";
} else {
foreach($rInfo as $route) {
echo "<tr>";
echo "<td>".$route["interface"]."</td>";
echo "<td>".$route["ip-address"]."</td>";
echo "<td>".$route["gateway"]."<br>".$route["gw-name"]."</td>";
echo "<td>".$route["access-ip"]."<br>".ACCESS_CHECK_IP."</td>";
echo "<td>".$route["access-dns"]."<br>".ACCESS_CHECK_DNS."</td>";
echo "</tr>";
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<h4 class="mt-3"><?php echo _("Current settings") ?></h4>
<div class="row">
<?php foreach ($interfaces as $if): ?>