Skip to content

Commit 6e10677

Browse files
authored
fix: metrics should use tailscale state (#31)
1 parent 4d79e0d commit 6e10677

File tree

1 file changed

+6
-19
lines changed
  • src/usr/local/emhttp/plugins/tailscale/include/Tailscale

1 file changed

+6
-19
lines changed

src/usr/local/emhttp/plugins/tailscale/include/Tailscale/Utils.php

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,16 @@ public static function sendUsageData(Config $config): void
7474
return;
7575
}
7676

77-
$prefs = Info::getPrefs();
77+
$tailscaleInfo = new Info(new Translator());
7878

79+
$prefs = Info::getPrefs();
7980
if (isset($prefs->LoggedOut) ? ($prefs->LoggedOut ? true : false) : true) {
8081
Utils::logmsg("Skipping usage data collection; not logged in.");
8182
return;
8283
}
8384

84-
$exit = false;
85-
$subnet = false;
8685
$customControl = false;
8786

88-
foreach (($prefs->AdvertiseRoutes ?? array()) as $net) {
89-
switch ($net) {
90-
case "0.0.0.0/0":
91-
case "::/0":
92-
$exit = true;
93-
break;
94-
default:
95-
$subnet = true;
96-
break;
97-
}
98-
}
99-
10087
if ($prefs->ControlURL != "https://controlplane.tailscale.com") {
10188
$customControl = true;
10289
}
@@ -107,11 +94,11 @@ public static function sendUsageData(Config $config): void
10794
'plugin_version' => $version['VERSION'],
10895
'plugin_branch' => $version['BRANCH'],
10996
'unraid_version' => $var['version'],
110-
'bool1' => $config->AllowDNS,
111-
'bool2' => $config->AllowRoutes,
97+
'bool1' => $tailscaleInfo->acceptsDNS(),
98+
'bool2' => $tailscaleInfo->acceptsRoutes(),
11299
'bool3' => $config->IncludeInterface,
113-
'bool4' => $subnet,
114-
'bool5' => $exit,
100+
'bool4' => (bool) $tailscaleInfo->getAdvertisedRoutes(),
101+
'bool5' => $tailscaleInfo->advertisesExitNode(),
115102
'num1' => $customControl ? 0 : 1
116103
);
117104

0 commit comments

Comments
 (0)