diff options
Diffstat (limited to 'gui/checkra.php')
-rw-r--r-- | gui/checkra.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gui/checkra.php b/gui/checkra.php new file mode 100644 index 0000000..40f8f37 --- /dev/null +++ b/gui/checkra.php @@ -0,0 +1,43 @@ +<html> +<head> +<meta http-equiv="refresh" content="1; url=checkra.php"> +</head> +<body> +<?php +function get_status() +{ + exec("sudo -H -u rapid-tunneling /usr/sbin/rapid-tunneling-status -p", $pid, $status); + if (count($pid) > 0) + $pid = trim($pid[0]); + else + $pid = ""; + return array($pid, $status); + // $status = 0 if connected, 1 if connecting, 2 if not connected +} + +$res = get_status(); +$pid = $res[0]; +$status = $res[1]; +if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "disconnect" && $pid != "" && ($status == 0 || $status == 1)) { + // stop it + exec("sudo -H -u rapid-tunneling /usr/sbin/rapid-tunneling-status -s"); + $res = get_status(); + $pid = $res[0]; + $status = $res[1]; +} + +if ($status == 0) + $netstat = "<span style='color: green'>Connected</span>"; +elseif ($status == 1) + $netstat = "<span style='color: orange'>Connecting</span>"; +else + $netstat = "<span style='color: red'>Not connected</span>"; + +echo "Connection status:<br>\n"; +echo date("r") . " <b>$netstat</b><br>\n"; +if ($status == 0 || $status == 1) { + echo "<br><button onclick='location.href += \"?action=disconnect\"'>Disconnect</button>"; +} +?> +</body> +</html> |