Finish implementing telemetry
This commit is contained in:
parent
c897348d8a
commit
b63c9951e0
5 changed files with 25 additions and 27 deletions
|
@ -9,6 +9,7 @@ use Illuminate\Contracts\Console\Kernel;
|
|||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
||||
use Pterodactyl\Services\Helpers\BlueprintVariableService;
|
||||
use Pterodactyl\Services\Helpers\BlueprintTelemetryService;
|
||||
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
||||
use Pterodactyl\Http\Requests\Admin\Extensions\Blueprint\BlueprintSettingsFormRequest;
|
||||
|
@ -22,6 +23,7 @@ class BlueprintExtensionController extends Controller
|
|||
*/
|
||||
public function __construct(
|
||||
private BlueprintVariableService $bp,
|
||||
private BlueprintTelemetryService $telemetry,
|
||||
|
||||
private SoftwareVersionService $version,
|
||||
private ViewFactory $view,
|
||||
|
@ -44,6 +46,7 @@ class BlueprintExtensionController extends Controller
|
|||
'admin.extensions.blueprint.index', [
|
||||
'version' => $this->version,
|
||||
'bp' => $this->bp,
|
||||
'telemetry' => $this->telemetry,
|
||||
'root' => "/admin/extensions/blueprint",
|
||||
'a' => $this->bp->a(),
|
||||
'b' => $this->bp->b(),
|
||||
|
|
|
@ -8,19 +8,12 @@
|
|||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Helpers;
|
||||
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
||||
use Pterodactyl\Services\Helpers\BlueprintVariableService;
|
||||
use Pterodactyl\Services\Helpers\BlueprintTelemetryService;
|
||||
use Pterodactyl\Services\Helpers\BlueprintPlaceholderService;
|
||||
|
||||
class BlueprintExtensionLibrary
|
||||
{
|
||||
// Construct BlueprintExtensionLibrary
|
||||
public function __construct(
|
||||
private SettingsRepositoryInterface $settings,
|
||||
private BlueprintVariableService $bp,
|
||||
private BlueprintTelemetryService $telemetry,
|
||||
private BlueprintPlaceholderService $placeholder,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
@ -2,18 +2,12 @@
|
|||
|
||||
namespace Pterodactyl\Services\Helpers;
|
||||
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
||||
use Pterodactyl\Services\Helpers\BlueprintVariableService;
|
||||
use Pterodactyl\Services\Helpers\BlueprintExtensionLibrary;
|
||||
use Pterodactyl\Services\Helpers\BlueprintTelemetryService;
|
||||
|
||||
class BlueprintPlaceholderService
|
||||
{
|
||||
// Construct BlueprintPlaceholderService
|
||||
public function __construct(
|
||||
private SettingsRepositoryInterface $settings,
|
||||
private BlueprintVariableService $bp,
|
||||
private BlueprintExtensionLibrary $lib,
|
||||
private BlueprintTelemetryService $telemetry,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
@ -2,28 +2,35 @@
|
|||
|
||||
namespace Pterodactyl\Services\Helpers;
|
||||
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
||||
use Pterodactyl\Services\Helpers\BlueprintVariableService;
|
||||
use Pterodactyl\Services\Helpers\BlueprintExtensionLibrary;
|
||||
use Pterodactyl\Services\Helpers\BlueprintPlaceholderService;
|
||||
|
||||
class BlueprintTelemetryService
|
||||
{
|
||||
// Construct BlueprintTelemetryService
|
||||
public function __construct(
|
||||
private SettingsRepositoryInterface $settings,
|
||||
private BlueprintVariableService $bp,
|
||||
private BlueprintExtensionLibrary $lib,
|
||||
private BlueprintPlaceholderService $placeholder,
|
||||
) {
|
||||
}
|
||||
|
||||
public function db($type, $table, $key, $value) {
|
||||
if ($type === "get") {
|
||||
return $this->settings->get($table."::".$key);
|
||||
};
|
||||
if ($type === "set") {
|
||||
return $this->settings->set($table."::".$key, $value);
|
||||
};
|
||||
return true;
|
||||
public function send($event) {
|
||||
if ($this->settings->get('blueprint::telemetry') == "false") { return; };
|
||||
if ($this->settings->get('blueprint::telemetry:id') == "") { $this->settings->set('blueprint::telemetry:id', uniqid(rand())); };
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'http://relay.ptero.shop:3511/send/'.$this->settings->get('blueprint::telemetry:id')."/".$event."/",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'GET',
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
@section('content')
|
||||
{{ $bp->rlKey() }}
|
||||
{{ $telemetry->send("SERVE_BLUEPRINT_ADMIN") }}
|
||||
<p>Blueprint is the framework that powers all Blueprint-compatible extensions, enabling multiple extensions to be installed and used simultaneously.</p>
|
||||
<div class="row">
|
||||
<div class="col-xs-3">
|
||||
|
|
Loading…
Reference in a new issue