diff --git a/src/usr/local/emhttp/plugins/tailscale/include/Pages/Status.php b/src/usr/local/emhttp/plugins/tailscale/include/Pages/Status.php index 1845acc..efc1a22 100644 --- a/src/usr/local/emhttp/plugins/tailscale/include/Pages/Status.php +++ b/src/usr/local/emhttp/plugins/tailscale/include/Pages/Status.php @@ -9,37 +9,52 @@ echo($tr->tr("tailscale_disabled")); return; } - -$tailscaleInfo = $tailscaleInfo ?? new Info($tr); ?> - - - - - - - - - - - - - - - - getPeerStatus() as $peer) { ?> - - - - - - - - - - - - - + + + + +
tr('info.dns'); ?>tr('info.ip'); ?>tr('status_page.login_name'); ?>tr('status'); ?>tr('status_page.exit_node'); ?>tr('status_page.connection_type'); ?>tr('status_page.connection_addr'); ?>tr('status_page.tx_bytes'); ?>tr('status_page.rx_bytes'); ?>
SharedUser ? $tr->tr('status_page.shared') : $peer->Name; ?>IP; ?>LoginName; ?>Online ? ($peer->Active ? $tr->tr('status_page.active') : $tr->tr('status_page.idle')) : $tr->tr('status_page.offline'); ?>ExitNodeActive ? $tr->tr('status_page.exit_active') : ($peer->ExitNodeAvailable ? $tr->tr('status_page.exit_available') : ""); ?>Active ? ($peer->Relayed ? $tr->tr('status_page.relay') : $tr->tr('status_page.direct')) : ""; ?>Active ? $peer->Address : ""; ?>Traffic ? $peer->TxBytes : ""; ?>Traffic ? $peer->RxBytes : ""; ?>

+ + + + +
\ No newline at end of file diff --git a/src/usr/local/emhttp/plugins/tailscale/include/data/Status.php b/src/usr/local/emhttp/plugins/tailscale/include/data/Status.php new file mode 100644 index 0000000..9f04cf4 --- /dev/null +++ b/src/usr/local/emhttp/plugins/tailscale/include/data/Status.php @@ -0,0 +1,79 @@ +Enable) { + echo("{}"); + return; + } + + $tailscaleInfo = $tailscaleInfo ?? new Info($tr); + $rows = ""; + + foreach ($tailscaleInfo->getPeerStatus() as $peer) { + $user = $peer->SharedUser ? $tr->tr('status_page.shared') : $peer->Name; + $online = $peer->Online ? ($peer->Active ? $tr->tr('status_page.active') : $tr->tr('status_page.idle')) : $tr->tr('status_page.offline'); + $exitNode = $peer->ExitNodeActive ? $tr->tr('status_page.exit_active') : ($peer->ExitNodeAvailable ? $tr->tr('status_page.exit_available') : ""); + $connection = $peer->Active ? ($peer->Relayed ? $tr->tr('status_page.relay') : $tr->tr('status_page.direct')) : ""; + $active = $peer->Active ? $peer->Address : ""; + $txBytes = $peer->Traffic ? $peer->TxBytes : ""; + $rxBytes = $peer->Traffic ? $peer->RxBytes : ""; + $pingHost = ($peer->SharedUser || $peer->Active || ! $peer->Online) ? "" : ""; + + $rows .= << + {$user} + {$peer->IP} + {$peer->LoginName} + {$online} + {$exitNode} + {$connection} + {$active} + {$txBytes} + {$rxBytes} + {$pingHost} + + EOT; + } + + $output = << + + + {$tr->tr('info.dns')} + {$tr->tr('info.ip')} + {$tr->tr('status_page.login_name')} + {$tr->tr('status')} + {$tr->tr('status_page.exit_node')} + {$tr->tr('status_page.connection_type')} + {$tr->tr('status_page.connection_addr')} + {$tr->tr('status_page.tx_bytes')} + {$tr->tr('status_page.rx_bytes')} + {$tr->tr('status_page.action')} + + + + {$rows} + + + EOT; + + $rtn = array(); + $rtn['html'] = $output; + echo json_encode($rtn); + break; + case 'ping': + $pingHost = escapeshellarg($_POST['host']); + + $out = Utils::run_command("tailscale ping --c 3 {$pingHost}"); + echo implode("
", $out); + + break; +} diff --git a/src/usr/local/emhttp/plugins/tailscale/locales/en_US.json b/src/usr/local/emhttp/plugins/tailscale/locales/en_US.json index 785df9b..0a00d55 100644 --- a/src/usr/local/emhttp/plugins/tailscale/locales/en_US.json +++ b/src/usr/local/emhttp/plugins/tailscale/locales/en_US.json @@ -120,6 +120,7 @@ "offline": "Offline", "active": "Active", "login_name": "Login Name", - "shared": "Shared-In User" + "shared": "Shared-In User", + "action": "Action" } } \ No newline at end of file