From 59bfc212c9b16e44669082a6b3979d50ec6456d5 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 22 Dec 2019 13:28:51 -0800 Subject: [PATCH] Include all server information in details endpoints for daemon to use --- ...roller.php => ServerDetailsController.php} | 29 ++++++++++++++----- routes/api-remote.php | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) rename app/Http/Controllers/Api/Remote/Servers/{ServerConfigurationController.php => ServerDetailsController.php} (52%) diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerConfigurationController.php b/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php similarity index 52% rename from app/Http/Controllers/Api/Remote/Servers/ServerConfigurationController.php rename to app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php index eeb157542..c9d9f4bc6 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerConfigurationController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerDetailsController.php @@ -7,8 +7,9 @@ use Illuminate\Http\JsonResponse; use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Services\Eggs\EggConfigurationService; use Pterodactyl\Repositories\Eloquent\ServerRepository; +use Pterodactyl\Services\Servers\ServerConfigurationStructureService; -class ServerConfigurationController extends Controller +class ServerDetailsController extends Controller { /** * @var \Pterodactyl\Services\Eggs\EggConfigurationService @@ -20,21 +21,34 @@ class ServerConfigurationController extends Controller */ private $repository; + /** + * @var \Pterodactyl\Services\Servers\ServerConfigurationStructureService + */ + private $configurationStructureService; + /** * ServerConfigurationController constructor. * * @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository + * @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $configurationStructureService * @param \Pterodactyl\Services\Eggs\EggConfigurationService $eggConfigurationService */ - public function __construct(ServerRepository $repository, EggConfigurationService $eggConfigurationService) - { + public function __construct( + ServerRepository $repository, + ServerConfigurationStructureService $configurationStructureService, + EggConfigurationService $eggConfigurationService + ) { $this->eggConfigurationService = $eggConfigurationService; $this->repository = $repository; + $this->configurationStructureService = $configurationStructureService; } /** + * Returns details about the server that allows Wings to self-recover and ensure + * that the state of the server matches the Panel at all times. + * * @param \Illuminate\Http\Request $request - * @param $uuid + * @param string $uuid * @return \Illuminate\Http\JsonResponse * * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException @@ -43,8 +57,9 @@ class ServerConfigurationController extends Controller { $server = $this->repository->getByUuid($uuid); - return JsonResponse::create( - $this->eggConfigurationService->handle($server) - ); + return JsonResponse::create([ + 'settings' => $this->configurationStructureService->handle($server), + 'process_configuration' => $this->eggConfigurationService->handle($server), + ]); } } diff --git a/routes/api-remote.php b/routes/api-remote.php index f35810ac1..476e90512 100644 --- a/routes/api-remote.php +++ b/routes/api-remote.php @@ -12,5 +12,5 @@ Route::group(['prefix' => '/scripts'], function () { // Routes for the Wings daemon. Route::post('/sftp/auth', 'SftpAuthenticationController'); Route::group(['prefix' => '/servers/{uuid}'], function () { - Route::get('/configuration', 'Servers\ServerConfigurationController'); + Route::get('/', 'Servers\ServerDetailsController'); });