ajout heimdall

This commit is contained in:
2025-01-01 11:24:01 +01:00
parent f8be42e486
commit c52f60fca9
1477 changed files with 15692 additions and 0 deletions

View File

@@ -0,0 +1,162 @@
<?php namespace App\SupportedApps\Traefik;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
use Illuminate\Support\Collection;
class Traefik extends \App\SupportedApps implements \App\EnhancedApps {
public function getRequestAttrs()
{
$username = $this->getConfigValue('username', null);
$password = $this->getConfigValue('password', null);
$ignoreTls = $this->getConfigValue('ignore_tls', false);
$isLoginNeeded =
!is_null($username) && !empty($username)
&& !is_null($password) && !empty($password);
$attrs['headers'] = [ 'Accept' => 'application/json'];
if($isLoginNeeded) {
$attrs['auth'] = [ $username, $password ];
}
if($ignoreTls) {
$attrs['verify'] = false;
}
return $attrs;
}
public function test()
{
$attrs = $this->getRequestAttrs();
$test = parent::appTest($this->url('api/version'), $attrs);
echo $test->status;
}
public function livestats()
{
$apiEndpoints = collect([
'httpRouters' => 'api/http/routers',
'httpServices' => 'api/http/services',
'tcpRouters' => 'api/tcp/routers',
'tcpServices' => 'api/tcp/services'
]);
$status = 'active';
$attrs = $this->getRequestAttrs();
$responses = $apiEndpoints->mapWithKeys(function ($endpoint, $key) use ($attrs) {
$response = parent::execute($this->url($endpoint), $attrs);
$body = json_decode($response->getBody());
$bodyCollection = collect($body);
return [ $key => [
'data' => $bodyCollection->filter(function ($value, $key) { return $value->status === 'enabled'; })->count(),
'total' => $bodyCollection->count(),
] ];
});
$data = $this->getViewData($this->getConfigValue('fields', 'E'), $responses);
return parent::getLiveStats($status, $data);
}
public function getViewData($config, $responses)
{
$nullValue = [ 'data' => 0, 'total' => 0 ];
switch ($config) {
/* HTTP routers/services only */
case 'H':
return [
'left' => [
'title' => 'Routers',
'data' => $responses->get('httpRouters', $nullValue)['data'],
'total' => $responses->get('httpRouters', $nullValue)['total'],
],
'right' => [
'title' => 'Services',
'data' => $responses->get('httpServices', $nullValue)['data'],
'total' => $responses->get('httpServices', $nullValue)['total'],
],
];
break;
/* TCP routers/services only */
case 'T':
return [
'left' => [
'title' => 'Routers',
'data' => $responses->get('tcpRouters', $nullValue)['data'],
'total' => $responses->get('tcpRouters', $nullValue)['total'],
],
'right' => [
'title' => 'Services',
'data' => $responses->get('tcpServices', $nullValue)['data'],
'total' => $responses->get('tcpServices', $nullValue)['total'],
],
];
/* Routers only */
case 'R':
return [
'left' => [
'title' => 'HTTP',
'data' => $responses->get('httpRouters', $nullValue)['data'],
'total' => $responses->get('httpRouters', $nullValue)['total'],
],
'right' => [
'title' => 'TCP',
'data' => $responses->get('tcpRouters', $nullValue)['data'],
'total' => $responses->get('tcpRouters', $nullValue)['total'],
],
];
/* Services only */
case 'S':
return [
'left' => [
'title' => 'HTTP',
'data' => $responses->get('httpServices', $nullValue)['data'],
'total' => $responses->get('httpServices', $nullValue)['total'],
],
'right' => [
'title' => 'TCP',
'data' => $responses->get('tcpServices', $nullValue)['data'],
'total' => $responses->get('tcpServices', $nullValue)['total'],
],
];
/* Everything */
default:
return [
'left' => [
'title' => 'Routers',
'data' => $responses->get('httpRouters', $nullValue)['data'] + $responses->get('tcpRouters', $nullValue)['data'],
'total' => $responses->get('httpRouters', $nullValue)['total'] + $responses->get('tcpRouters', $nullValue)['total'],
],
'right' => [
'title' => 'Services',
'data' => $responses->get('httpServices', $nullValue)['data'] + $responses->get('tcpServices', $nullValue)['data'],
'total' => $responses->get('httpServices', $nullValue)['total'] + $responses->get('tcpServices', $nullValue)['total'],
],
];
}
}
public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url).$endpoint;
return $api_url;
}
public function getConfigValue($key, $default=null)
{
return (isset($this->config) && isset($this->config->$key)) ? $this->config->$key : $default;
}
}

View File

@@ -0,0 +1,10 @@
{
"appid": "a83e2ce54bbef3bef63aa7f02b08dbda7fdae4c5",
"name": "Traefik",
"website": "https://traefik.io/",
"license": "MIT License",
"description": "Træfik is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy. Træfik integrates with your existing infrastructure components and configures itself automatically and dynamically.",
"enhanced": true,
"tile_background": "dark",
"icon": "traefik.png"
}

View File

@@ -0,0 +1,39 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
<div class="items" style="flex-wrap: wrap;">
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', (isset($item) ? $item->getconfig()->override_url : null), array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>Which fields to show</label>
{!! Form::select('config[fields]', [ 'E' => 'Everything', 'H' => 'HTTP only', 'T' => 'TCP only', 'R' => 'Routers', 'S' => 'Services' ],
(isset($item) && isset($item->getconfig()->fields) ? $item->getconfig()->fields : null), array('id' => 'fields', 'class' => 'form-control config-item')) !!}
</div>
<div class="input">
<label>Skip TLS verification</label>
<div class="toggleinput" style="margin-top: 26px; padding-left: 15px;">
{!! Form::hidden('config[ignore_tls]', 0, [ 'class' => 'config-item', 'data-config' => 'ignore_tls' ]) !!}
<label class="switch">
<?php
$checked = false;
if(isset($item) && !empty($item) && isset($item->getconfig()->ignore_tls)) $checked = $item->getconfig()->ignore_tls;
$set_checked = ($checked) ? ' checked="checked"' : '';
?>
<input type="checkbox" class="config-item" data-config="ignore_tls" name="config[ignore_tls]" value="1"<?php echo $set_checked;?> />
<span class="slider round"></span>
</label>
</div>
</div>
<div class="input">
<label>{{ __('app.apps.username') }}</label>
{!! Form::text('config[username]', (isset($item) ? $item->getconfig()->username : null), array('placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.password') }}</label>
{!! Form::text('config[password]', (isset($item) ? $item->getconfig()->password : null), array('placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item')) !!}
</div>
<div class="input">
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
</div>
</div>

View File

@@ -0,0 +1,4 @@
<ul class="livestats">
<li><span class="title">{!! $left['title'] !!}</span><strong>{!! $left['data'] !!}<span>/{!! $left['total'] !!}</span></strong></li>
<li><span class="title">{!! $right['title'] !!}</span><strong>{!! $right['data'] !!}<span>/{!! $right['total'] !!}</span></strong></li>
</ul>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB