Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion TechnitiumDNS/TechnitiumDNS.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion TechnitiumDNS/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
15 changes: 15 additions & 0 deletions TechnitiumDNS/config.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
<div class="items">
<input type="hidden" data-config="dataonly" class="config-item" name="config[dataonly]" value="1" />
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', isset($item) ? $item->getconfig()->override_url : null, ['placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control']) !!}
</div>
<div class="input">
<label>API Token</label>
{!! Form::text('config[apikey]', isset($item) && property_exists($item->getconfig(), 'apikey') ? $item->getconfig()->apikey : null, ['placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item']) !!}
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>
10 changes: 10 additions & 0 deletions TechnitiumDNS/livestats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<ul class="livestats">
<li>
<span class="title">Queries<br />Blocked</span>
<strong>{!! $queries_blocked !!}</strong>
</li>
<li>
<span class="title">Percent<br /> Blocked</span>
<strong>{!! $percent_blocked !!}</strong>
</li>
</ul>