diff --git a/src/usr/local/emhttp/plugins/tailscale/include/Tailscale/Info.php b/src/usr/local/emhttp/plugins/tailscale/include/Tailscale/Info.php
index e6c1f00..a1ee2ab 100644
--- a/src/usr/local/emhttp/plugins/tailscale/include/Tailscale/Info.php
+++ b/src/usr/local/emhttp/plugins/tailscale/include/Tailscale/Info.php
@@ -236,7 +236,7 @@ public function getPeerStatus(): array
$peer = new PeerStatus();
$peer->Name = trim($status->DNSName, ".");
- $peer->IP = implode("
", $status->TailscaleIPs);
+ $peer->IP = $status->TailscaleIPs;
$peer->LoginName = $this->status->User->{$status->UserID}->LoginName;
$peer->SharedUser = isset($status->ShareeNode);
diff --git a/src/usr/local/emhttp/plugins/tailscale/include/Tailscale/PeerStatus.php b/src/usr/local/emhttp/plugins/tailscale/include/Tailscale/PeerStatus.php
index 49d0764..38a2a0e 100644
--- a/src/usr/local/emhttp/plugins/tailscale/include/Tailscale/PeerStatus.php
+++ b/src/usr/local/emhttp/plugins/tailscale/include/Tailscale/PeerStatus.php
@@ -5,10 +5,12 @@
class PeerStatus
{
public string $Name = "";
- public string $IP = "";
public string $LoginName = "";
public bool $SharedUser = false;
+ /** @var string[] */
+ public array $IP = array();
+
public string $Address = "";
public bool $Online = false;
diff --git a/src/usr/local/emhttp/plugins/tailscale/include/data/Status.php b/src/usr/local/emhttp/plugins/tailscale/include/data/Status.php
index 9f04cf4..995ac51 100644
--- a/src/usr/local/emhttp/plugins/tailscale/include/data/Status.php
+++ b/src/usr/local/emhttp/plugins/tailscale/include/data/Status.php
@@ -7,13 +7,13 @@
$tailscaleConfig = $tailscaleConfig ?? new Config();
$tr = $tr ?? new Translator();
+if ( ! $tailscaleConfig->Enable) {
+ echo("{}");
+ return;
+}
+
switch ($_POST['action']) {
case 'get':
- if ( ! $tailscaleConfig->Enable) {
- echo("{}");
- return;
- }
-
$tailscaleInfo = $tailscaleInfo ?? new Info($tr);
$rows = "";
@@ -26,11 +26,12 @@
$txBytes = $peer->Traffic ? $peer->TxBytes : "";
$rxBytes = $peer->Traffic ? $peer->RxBytes : "";
$pingHost = ($peer->SharedUser || $peer->Active || ! $peer->Online) ? "" : "";
+ $ips = implode("
", $peer->IP);
$rows .= <<
{$user} |
- {$peer->IP} |
+ {$ips} |
{$peer->LoginName} |
{$online} |
{$exitNode} |
@@ -70,10 +71,16 @@
echo json_encode($rtn);
break;
case 'ping':
- $pingHost = escapeshellarg($_POST['host']);
+ $tailscaleInfo = $tailscaleInfo ?? new Info($tr);
+ $out = "Could not find host.";
- $out = Utils::run_command("tailscale ping --c 3 {$pingHost}");
- echo implode("
", $out);
+ foreach ($tailscaleInfo->getPeerStatus() as $peer) {
+ if ($peer->Name == $_POST['host']) {
+ $out = implode("
", Utils::run_command("tailscale ping --c 3 {$peer->IP[0]}"));
+ break;
+ }
+ }
+ echo $out;
break;
}