diff --git a/config/config.php b/config/config.php index 2c3c9e8a..bfe464f6 100755 --- a/config/config.php +++ b/config/config.php @@ -23,6 +23,8 @@ define('RASPI_OPENVPN_CLIENT_LOGIN', '/etc/openvpn/client/login.conf'); define('RASPI_OPENVPN_SERVER_CONFIG', '/etc/openvpn/server/server.conf'); define('RASPI_TORPROXY_CONFIG', '/etc/tor/torrc'); define('RASPI_LIGHTTPD_CONFIG', '/etc/lighttpd/lighttpd.conf'); +define('RASPI_ACCESS_CHECK_IP', '1.1.1.1'); +define('RASPI_ACCESS_CHECK_DNS', 'one.one.one.one'); // Constant for the 5GHz wireless regulatory domain define('RASPI_5GHZ_ISO_ALPHA2', array('US')); diff --git a/includes/defaults.php b/includes/defaults.php index 524960f5..e1346112 100755 --- a/includes/defaults.php +++ b/includes/defaults.php @@ -27,6 +27,8 @@ $defaults = [ 'RASPI_OPENVPN_SERVER_CONFIG' => '/etc/openvpn/server/server.conf', 'RASPI_TORPROXY_CONFIG' => '/etc/tor/torrc', 'RASPI_LIGHTTPD_CONFIG' => '/etc/lighttpd/lighttpd.conf', + 'RASPI_ACCESS_CHECK_IP' => '1.1.1.1', + 'RASPI_ACCESS_CHECK_DNS' => 'one.one.one.one', // Optional services, set to true to enable. 'RASPI_WIFICLIENT_ENABLED' => true, diff --git a/includes/internetRoute.php b/includes/internetRoute.php new file mode 100644 index 00000000..78207a61 --- /dev/null +++ b/includes/internetRoute.php @@ -0,0 +1,30 @@ + $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); + $rInfo[$i]["gw-name"] = empty($host) ? "*" : $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].' '.RASPI_ACCESS_CHECK_IP.' | sed -rn "s/.*icmp_seq=1.*time=.*/OK/p"',$okip); + $rInfo[$i]["access-ip"] = empty($okip) ? false : true; + unset($okdns); + exec('ping -W1 -c 1 -I '.$prop[0].' '.RASPI_ACCESS_CHECK_DNS.' | sed -rn "s/.*icmp_seq=1.*time=.*/OK/p"',$okdns); + $rInfo[$i]["access-dns"] = empty($okdns) ? false : true; + } + } +} else { + $rInfo = array("error"=>"No route to the internet found"); +} +$rInfo_json = json_encode($rInfo); +?> diff --git a/locale/en_US/LC_MESSAGES/messages.po b/locale/en_US/LC_MESSAGES/messages.po index 70a9b06e..1ce53d99 100644 --- a/locale/en_US/LC_MESSAGES/messages.po +++ b/locale/en_US/LC_MESSAGES/messages.po @@ -451,6 +451,9 @@ msgstr "Configures the max_num_sta option of hostapd. The default and maximum is msgid "Summary" msgstr "Summary" +msgid "Internet connection" +msgstr "Internet connection" + msgid "Current settings" msgstr "Current settings" diff --git a/templates/networking.php b/templates/networking.php index 7723733b..b566a91d 100755 --- a/templates/networking.php +++ b/templates/networking.php @@ -17,21 +17,62 @@ $arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini'); // defaults to false $bridgedEnabled = $arrHostapdConf['BridgedEnable']; - ?> - - - + ?> + + + - +
-
+

+
+
+
+
+
+ + + + + + + + + + + "; + } else { + foreach($rInfo as $route) { + echo ""; + echo ""; + echo ""; + echo ""; + $checkok = $route["access-ip"] ? "✓" : "failed"; + echo ""; + $checkok = $route["access-dns"] ? "✓" : "failed"; + echo ""; + echo ""; + } + } + ?> + +
No route to the internet found
".$route["interface"]."".$route["ip-address"]."".$route["gateway"]."
".$route["gw-name"]."
".$checkok."
".RASPI_ACCESS_CHECK_IP."
".$checkok."
".RASPI_ACCESS_CHECK_DNS."
+
+
+
+
+

- +
@@ -50,7 +91,7 @@
- +
@@ -100,10 +141,10 @@
-
- +
+ - +