ajout heimdall
This commit is contained in:
10
heimdall/config/www/SupportedApps/ruTorrent/app.json
Executable file
10
heimdall/config/www/SupportedApps/ruTorrent/app.json
Executable file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"appid": "fbf13ee99afeadddc4f73e1183fd1b52774b3474",
|
||||
"name": "ruTorrent",
|
||||
"website": "https://github.com/Novik/ruTorrent",
|
||||
"license": "GNU General Public License v3.0 or later",
|
||||
"description": "ruTorrent is a front-end for the popular Bittorrent client rtorrent.",
|
||||
"enhanced": true,
|
||||
"tile_background": "dark",
|
||||
"icon": "rutorrent.png"
|
||||
}
|
||||
18
heimdall/config/www/SupportedApps/ruTorrent/config.blade.php
Executable file
18
heimdall/config/www/SupportedApps/ruTorrent/config.blade.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
|
||||
<div class="items">
|
||||
<div class="input">
|
||||
<label>{{ strtoupper(__('app.url')) }}</label>
|
||||
{!! Form::text('config[override_url]', (isset($item) && isset($item->getconfig()->override_url) ? $item->getconfig()->override_url : null), array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>{{ __('app.apps.username') }}</label>
|
||||
{!! Form::text('config[username]', (isset($item) && isset($item->getconfig()->username) ? $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::input('password', 'config[password]', (isset($item) && isset($item->getconfig()->password) ? $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>
|
||||
14
heimdall/config/www/SupportedApps/ruTorrent/livestats.blade.php
Executable file
14
heimdall/config/www/SupportedApps/ruTorrent/livestats.blade.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<ul class="livestats">
|
||||
@if($down_rate != "0 B/s")
|
||||
<li style="width:50%;">
|
||||
<span class="title">DOWN ↓</span>
|
||||
<strong>{!! $down_rate !!}</strong>
|
||||
</li>
|
||||
@endif
|
||||
@if($up_rate != "0 B/s")
|
||||
<li>
|
||||
<span class="title">UP ↑</span>
|
||||
<strong>{!! $up_rate !!}</strong>
|
||||
</li>
|
||||
@endif
|
||||
</ul>
|
||||
88
heimdall/config/www/SupportedApps/ruTorrent/ruTorrent.php
Executable file
88
heimdall/config/www/SupportedApps/ruTorrent/ruTorrent.php
Executable file
@@ -0,0 +1,88 @@
|
||||
<?php namespace App\SupportedApps\ruTorrent;
|
||||
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
||||
class ruTorrent extends \App\SupportedApps implements \App\EnhancedApps {
|
||||
|
||||
public $config;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
$data = $this->getXMLRPCData('throttle.global_down.rate');
|
||||
if( !isset($data) || $data == 'Err' || $data == null || !is_object($data))
|
||||
{
|
||||
echo 'There is an issue connecting to "' . $this->url('RPC2') . '". Please respect URL format "http(s)://IP:PORT". ' . $data;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'Connection successful!';
|
||||
}
|
||||
}
|
||||
|
||||
public function livestats()
|
||||
{
|
||||
$status = 'inactive';
|
||||
|
||||
$data = [];
|
||||
$data['down_rate'] = $this->formatBytes((float)$this->getXMLRPCData('throttle.global_down.rate')->params->param->value->i8, 1);
|
||||
|
||||
$data['up_rate'] = $this->formatBytes((float)$this->getXMLRPCData('throttle.global_up.rate')->params->param->value->i8, 1);
|
||||
|
||||
return parent::getLiveStats($status, $data);
|
||||
}
|
||||
|
||||
public function url($endpoint)
|
||||
{
|
||||
return parent::normaliseurl($this->config->url).$endpoint;
|
||||
}
|
||||
|
||||
public function getXMLRPCData($method)
|
||||
{
|
||||
$value='';
|
||||
|
||||
$body = '<methodCall><methodName>'.$method.'</methodName></methodCall>';
|
||||
|
||||
$this->vars = ['http_errors' => false, 'timeout' => 5, 'body' => $body];
|
||||
$this->attrs = [];
|
||||
$this->attrs['headers'] = ['Content-Type' => 'text/xml'];
|
||||
|
||||
if( isset($this->config->username) && isset($this->config->password) ) {
|
||||
$this->attrs['headers']['Authorization'] = 'Basic ' . base64_encode($this->config->username . ":" . $this->config->password);
|
||||
}
|
||||
|
||||
try{
|
||||
$res = parent::execute($this->url('RPC2'), $this->attrs, $this->vars);
|
||||
} catch(\GuzzleHttp\Exception\RequestException $e){
|
||||
return ''; // Connection failed, display default response
|
||||
}
|
||||
|
||||
if (function_exists('simplexml_load_string')) {
|
||||
try {
|
||||
$value = simplexml_load_string($res->getBody()->getContents());
|
||||
} catch(\ErrorException $e) {
|
||||
$value = 'Unexpected response. Are credentials correct?';
|
||||
}
|
||||
} else {
|
||||
$value = 'simplexml_load_string doesn\'t exist.';
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function formatBytes($bytes, $precision = 2)
|
||||
{
|
||||
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
||||
|
||||
$bytes = max($bytes, 0);
|
||||
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
||||
$pow = min($pow, count($units) - 1);
|
||||
|
||||
$bytes /= pow(1024, $pow);
|
||||
|
||||
return round($bytes, $precision) . ' ' . $units[$pow] . '/s';
|
||||
}
|
||||
}
|
||||
BIN
heimdall/config/www/SupportedApps/ruTorrent/rutorrent.png
Executable file
BIN
heimdall/config/www/SupportedApps/ruTorrent/rutorrent.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Reference in New Issue
Block a user