From b9ef130e234b3e48c5e5f3ca9757d20a832f77b0 Mon Sep 17 00:00:00 2001 From: Jay Collett <486430+jaycollett@users.noreply.github.com> Date: Thu, 29 Jan 2026 12:20:55 -0500 Subject: [PATCH] feat(TechnitiumDNS): add enhanced app support with live stats Implement the EnhancedApps interface for Technitium DNS to display queries blocked and percentage blocked stats on the dashboard tile. - Add test() method for API connection validation - Add livestats() method to fetch stats from /api/dashboard/stats/get - Add config.blade.php for API token configuration - Add livestats.blade.php for stats display template - Set enhanced: true in app.json Closes linuxserver/Heimdall#1531 --- TechnitiumDNS/TechnitiumDNS.php | 40 ++++++++++++++++++++++++++++++- TechnitiumDNS/app.json | 2 +- TechnitiumDNS/config.blade.php | 15 ++++++++++++ TechnitiumDNS/livestats.blade.php | 10 ++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 TechnitiumDNS/config.blade.php create mode 100644 TechnitiumDNS/livestats.blade.php diff --git a/TechnitiumDNS/TechnitiumDNS.php b/TechnitiumDNS/TechnitiumDNS.php index 0459e69bf1..16e166e19b 100644 --- a/TechnitiumDNS/TechnitiumDNS.php +++ b/TechnitiumDNS/TechnitiumDNS.php @@ -2,6 +2,44 @@ namespace App\SupportedApps\TechnitiumDNS; -class TechnitiumDNS extends \App\SupportedApps +class TechnitiumDNS extends \App\SupportedApps implements \App\EnhancedApps { + public $config; + + public function test() + { + $test = parent::appTest($this->url("api/dashboard/stats/get")); + echo $test->status; + } + + public function livestats() + { + $status = "inactive"; + $data = []; + + $res = parent::execute($this->url("api/dashboard/stats/get")); + $details = json_decode($res->getBody()); + + if ($details && isset($details->response) && isset($details->response->stats)) { + $stats = $details->response->stats; + $data["queries_blocked"] = number_format($stats->totalBlocked); + + // Calculate percentage blocked + $percent = 0; + if ($stats->totalQueries > 0) { + $percent = ($stats->totalBlocked / $stats->totalQueries) * 100; + } + $data["percent_blocked"] = number_format($percent, 1); + $status = "active"; + } + + return parent::getLiveStats($status, $data); + } + + public function url($endpoint) + { + $api_url = parent::normaliseurl($this->config->url) . $endpoint; + $api_url .= "?token=" . $this->config->apikey . "&type=LastDay"; + return $api_url; + } } diff --git a/TechnitiumDNS/app.json b/TechnitiumDNS/app.json index 23ba764f74..ee876825e2 100644 --- a/TechnitiumDNS/app.json +++ b/TechnitiumDNS/app.json @@ -4,7 +4,7 @@ "website": "https://technitium.com/dns", "license": "GNU General Public License v3.0 only", "description": "Technitium DNS Server is an open source authoritative as well as recursive DNS server that can be used for self hosting a DNS server for privacy & security. It works out-of-the-box with no or minimal configuration and provides a user friendly web console accessible using any modern web browser.", - "enhanced": false, + "enhanced": true, "tile_background": "dark", "icon": "technitiumdns.png" } diff --git a/TechnitiumDNS/config.blade.php b/TechnitiumDNS/config.blade.php new file mode 100644 index 0000000000..b87e9ba085 --- /dev/null +++ b/TechnitiumDNS/config.blade.php @@ -0,0 +1,15 @@ +