Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
parent
95e15d2c8a
commit
cbcf62086f
573 changed files with 4387 additions and 9411 deletions
|
@ -9,6 +9,7 @@ use Pterodactyl\Models\ApiKey;
|
|||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Pterodactyl\Services\Acl\Api\AdminAcl;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Api\KeyCreationService;
|
||||
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
|
||||
|
@ -17,31 +18,14 @@ use Pterodactyl\Http\Requests\Admin\Api\StoreApplicationApiKeyRequest;
|
|||
class ApiController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
private $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Api\KeyCreationService
|
||||
*/
|
||||
private $keyCreationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ApplicationApiController constructor.
|
||||
* ApiController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
ApiKeyRepositoryInterface $repository,
|
||||
KeyCreationService $keyCreationService
|
||||
private AlertsMessageBag $alert,
|
||||
private ApiKeyRepositoryInterface $repository,
|
||||
private KeyCreationService $keyCreationService,
|
||||
private ViewFactory $view,
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->keyCreationService = $keyCreationService;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,7 +33,7 @@ class ApiController extends Controller
|
|||
*/
|
||||
public function index(Request $request): View
|
||||
{
|
||||
return view('admin.api.index', [
|
||||
return $this->view->make('admin.api.index', [
|
||||
'keys' => $this->repository->getApplicationKeys($request->user()),
|
||||
]);
|
||||
}
|
||||
|
@ -64,7 +48,7 @@ class ApiController extends Controller
|
|||
$resources = AdminAcl::getResourceList();
|
||||
sort($resources);
|
||||
|
||||
return view('admin.api.new', [
|
||||
return $this->view->make('admin.api.new', [
|
||||
'resources' => $resources,
|
||||
'permissions' => [
|
||||
'r' => AdminAcl::READ,
|
||||
|
|
|
@ -3,22 +3,17 @@
|
|||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* BaseController constructor.
|
||||
*/
|
||||
public function __construct(SoftwareVersionService $version)
|
||||
public function __construct(private SoftwareVersionService $version, private ViewFactory $view)
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,6 +21,6 @@ class BaseController extends Controller
|
|||
*/
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.index', ['version' => $this->version]);
|
||||
return $this->view->make('admin.index', ['version' => $this->version]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use Illuminate\View\View;
|
|||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Databases\Hosts\HostUpdateService;
|
||||
use Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest;
|
||||
|
@ -19,60 +20,19 @@ use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
|
|||
|
||||
class DatabaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
private $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\Hosts\HostCreationService
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface
|
||||
*/
|
||||
private $databaseRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\Hosts\HostDeletionService
|
||||
*/
|
||||
private $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
|
||||
*/
|
||||
private $locationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\Hosts\HostUpdateService
|
||||
*/
|
||||
private $updateService;
|
||||
|
||||
/**
|
||||
* DatabaseController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
DatabaseHostRepositoryInterface $repository,
|
||||
DatabaseRepositoryInterface $databaseRepository,
|
||||
HostCreationService $creationService,
|
||||
HostDeletionService $deletionService,
|
||||
HostUpdateService $updateService,
|
||||
LocationRepositoryInterface $locationRepository
|
||||
private AlertsMessageBag $alert,
|
||||
private DatabaseHostRepositoryInterface $repository,
|
||||
private DatabaseRepositoryInterface $databaseRepository,
|
||||
private HostCreationService $creationService,
|
||||
private HostDeletionService $deletionService,
|
||||
private HostUpdateService $updateService,
|
||||
private LocationRepositoryInterface $locationRepository,
|
||||
private ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->creationService = $creationService;
|
||||
$this->databaseRepository = $databaseRepository;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->repository = $repository;
|
||||
$this->locationRepository = $locationRepository;
|
||||
$this->updateService = $updateService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,7 +40,7 @@ class DatabaseController extends Controller
|
|||
*/
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.databases.index', [
|
||||
return $this->view->make('admin.databases.index', [
|
||||
'locations' => $this->locationRepository->getAllWithNodes(),
|
||||
'hosts' => $this->repository->getWithViewDetails(),
|
||||
]);
|
||||
|
@ -93,7 +53,7 @@ class DatabaseController extends Controller
|
|||
*/
|
||||
public function view(int $host): View
|
||||
{
|
||||
return view('admin.databases.view', [
|
||||
return $this->view->make('admin.databases.view', [
|
||||
'locations' => $this->locationRepository->getAllWithNodes(),
|
||||
'host' => $this->repository->find($host),
|
||||
'databases' => $this->databaseRepository->getDatabasesForHost($host),
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Pterodactyl\Models\Location;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Http\Requests\Admin\LocationFormRequest;
|
||||
|
@ -21,56 +17,25 @@ use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
|||
|
||||
class LocationController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Locations\LocationCreationService
|
||||
*/
|
||||
protected $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Locations\LocationDeletionService
|
||||
*/
|
||||
protected $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Locations\LocationUpdateService
|
||||
*/
|
||||
protected $updateService;
|
||||
|
||||
/**
|
||||
* LocationController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
LocationCreationService $creationService,
|
||||
LocationDeletionService $deletionService,
|
||||
LocationRepositoryInterface $repository,
|
||||
LocationUpdateService $updateService
|
||||
protected AlertsMessageBag $alert,
|
||||
protected LocationCreationService $creationService,
|
||||
protected LocationDeletionService $deletionService,
|
||||
protected LocationRepositoryInterface $repository,
|
||||
protected LocationUpdateService $updateService,
|
||||
protected ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->creationService = $creationService;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->repository = $repository;
|
||||
$this->updateService = $updateService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the location overview page.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.locations.index', [
|
||||
return $this->view->make('admin.locations.index', [
|
||||
'locations' => $this->repository->getAllWithDetails(),
|
||||
]);
|
||||
}
|
||||
|
@ -78,15 +43,11 @@ class LocationController extends Controller
|
|||
/**
|
||||
* Return the location view page.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function view($id)
|
||||
public function view(int $id): View
|
||||
{
|
||||
return view('admin.locations.view', [
|
||||
return $this->view->make('admin.locations.view', [
|
||||
'location' => $this->repository->getWithNodes($id),
|
||||
]);
|
||||
}
|
||||
|
@ -94,11 +55,9 @@ class LocationController extends Controller
|
|||
/**
|
||||
* Handle request to create new location.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function create(LocationFormRequest $request)
|
||||
public function create(LocationFormRequest $request): RedirectResponse
|
||||
{
|
||||
$location = $this->creationService->handle($request->normalize());
|
||||
$this->alert->success('Location was created successfully.')->flash();
|
||||
|
@ -109,11 +68,9 @@ class LocationController extends Controller
|
|||
/**
|
||||
* Handle request to update or delete location.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function update(LocationFormRequest $request, Location $location)
|
||||
public function update(LocationFormRequest $request, Location $location): RedirectResponse
|
||||
{
|
||||
if ($request->input('action') === 'delete') {
|
||||
return $this->delete($location);
|
||||
|
@ -128,12 +85,10 @@ class LocationController extends Controller
|
|||
/**
|
||||
* Delete a location from the system.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function delete(Location $location)
|
||||
public function delete(Location $location): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->deletionService->handle($location->id);
|
||||
|
|
|
@ -3,11 +3,15 @@
|
|||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Nest;
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Models\Mount;
|
||||
use Pterodactyl\Models\Location;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Http\Requests\Admin\MountFormRequest;
|
||||
use Pterodactyl\Repositories\Eloquent\MountRepository;
|
||||
|
@ -16,49 +20,24 @@ use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
|||
|
||||
class MountController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
|
||||
*/
|
||||
protected $nestRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
|
||||
*/
|
||||
protected $locationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\MountRepository
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* MountController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
NestRepositoryInterface $nestRepository,
|
||||
LocationRepositoryInterface $locationRepository,
|
||||
MountRepository $repository
|
||||
protected AlertsMessageBag $alert,
|
||||
protected NestRepositoryInterface $nestRepository,
|
||||
protected LocationRepositoryInterface $locationRepository,
|
||||
protected MountRepository $repository,
|
||||
protected ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->nestRepository = $nestRepository;
|
||||
$this->locationRepository = $locationRepository;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mount overview page.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.mounts.index', [
|
||||
return $this->view->make('admin.mounts.index', [
|
||||
'mounts' => $this->repository->getAllWithDetails(),
|
||||
]);
|
||||
}
|
||||
|
@ -66,18 +45,14 @@ class MountController extends Controller
|
|||
/**
|
||||
* Return the mount view page.
|
||||
*
|
||||
* @param string $id
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function view($id)
|
||||
public function view(string $id): View
|
||||
{
|
||||
$nests = Nest::query()->with('eggs')->get();
|
||||
$locations = Location::query()->with('nodes')->get();
|
||||
|
||||
return view('admin.mounts.view', [
|
||||
return $this->view->make('admin.mounts.view', [
|
||||
'mount' => $this->repository->getWithRelations($id),
|
||||
'nests' => $nests,
|
||||
'locations' => $locations,
|
||||
|
@ -87,11 +62,9 @@ class MountController extends Controller
|
|||
/**
|
||||
* Handle request to create new mount.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function create(MountFormRequest $request)
|
||||
public function create(MountFormRequest $request): RedirectResponse
|
||||
{
|
||||
$model = (new Mount())->fill($request->validated());
|
||||
$model->forceFill(['uuid' => Uuid::uuid4()->toString()]);
|
||||
|
@ -107,11 +80,9 @@ class MountController extends Controller
|
|||
/**
|
||||
* Handle request to update or delete location.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function update(MountFormRequest $request, Mount $mount)
|
||||
public function update(MountFormRequest $request, Mount $mount): RedirectResponse
|
||||
{
|
||||
if ($request->input('action') === 'delete') {
|
||||
return $this->delete($mount);
|
||||
|
@ -127,11 +98,9 @@ class MountController extends Controller
|
|||
/**
|
||||
* Delete a location from the system.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(Mount $mount)
|
||||
public function delete(Mount $mount): RedirectResponse
|
||||
{
|
||||
$mount->delete();
|
||||
|
||||
|
@ -139,11 +108,9 @@ class MountController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds eggs to the mount's many to many relation.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* Adds eggs to the mount's many-to-many relation.
|
||||
*/
|
||||
public function addEggs(Request $request, Mount $mount)
|
||||
public function addEggs(Request $request, Mount $mount): RedirectResponse
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'eggs' => 'required|exists:eggs,id',
|
||||
|
@ -160,11 +127,9 @@ class MountController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds nodes to the mount's many to many relation.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* Adds nodes to the mount's many-to-many relation.
|
||||
*/
|
||||
public function addNodes(Request $request, Mount $mount)
|
||||
public function addNodes(Request $request, Mount $mount): RedirectResponse
|
||||
{
|
||||
$data = $request->validate(['nodes' => 'required|exists:nodes,id']);
|
||||
|
||||
|
@ -179,11 +144,9 @@ class MountController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes an egg from the mount's many to many relation.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* Deletes an egg from the mount's many-to-many relation.
|
||||
*/
|
||||
public function deleteEgg(Mount $mount, int $egg_id)
|
||||
public function deleteEgg(Mount $mount, int $egg_id): Response
|
||||
{
|
||||
$mount->eggs()->detach($egg_id);
|
||||
|
||||
|
@ -191,11 +154,9 @@ class MountController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes an node from the mount's many to many relation.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* Deletes a node from the mount's many-to-many relation.
|
||||
*/
|
||||
public function deleteNode(Mount $mount, int $node_id)
|
||||
public function deleteNode(Mount $mount, int $node_id): Response
|
||||
{
|
||||
$mount->nodes()->detach($node_id);
|
||||
|
||||
|
|
|
@ -1,19 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Nests;
|
||||
|
||||
use Javascript;
|
||||
use JavaScript;
|
||||
use Illuminate\View\View;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Eggs\EggUpdateService;
|
||||
use Pterodactyl\Services\Eggs\EggCreationService;
|
||||
|
@ -24,32 +18,18 @@ use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
|||
|
||||
class EggController extends Controller
|
||||
{
|
||||
protected $alert;
|
||||
|
||||
protected $creationService;
|
||||
|
||||
protected $deletionService;
|
||||
|
||||
protected $nestRepository;
|
||||
|
||||
protected $repository;
|
||||
|
||||
protected $updateService;
|
||||
|
||||
/**
|
||||
* EggController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
EggCreationService $creationService,
|
||||
EggDeletionService $deletionService,
|
||||
EggRepositoryInterface $repository,
|
||||
EggUpdateService $updateService,
|
||||
NestRepositoryInterface $nestRepository
|
||||
protected AlertsMessageBag $alert,
|
||||
protected EggCreationService $creationService,
|
||||
protected EggDeletionService $deletionService,
|
||||
protected EggRepositoryInterface $repository,
|
||||
protected EggUpdateService $updateService,
|
||||
protected NestRepositoryInterface $nestRepository,
|
||||
protected ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->creationService = $creationService;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->nestRepository = $nestRepository;
|
||||
$this->repository = $repository;
|
||||
$this->updateService = $updateService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,9 +40,9 @@ class EggController extends Controller
|
|||
public function create(): View
|
||||
{
|
||||
$nests = $this->nestRepository->getWithEggs();
|
||||
Javascript::put(['nests' => $nests->keyBy('id')]);
|
||||
JavaScript::put(['nests' => $nests->keyBy('id')]);
|
||||
|
||||
return view('admin.eggs.new', ['nests' => $nests]);
|
||||
return $this->view->make('admin.eggs.new', ['nests' => $nests]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,7 +67,7 @@ class EggController extends Controller
|
|||
*/
|
||||
public function view(Egg $egg): View
|
||||
{
|
||||
return view('admin.eggs.view', [
|
||||
return $this->view->make('admin.eggs.view', [
|
||||
'egg' => $egg,
|
||||
'images' => array_map(
|
||||
fn ($key, $value) => $key === $value ? $value : "$key|$value",
|
||||
|
|
|
@ -6,6 +6,7 @@ use Illuminate\View\View;
|
|||
use Pterodactyl\Models\Egg;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Eggs\Scripts\InstallScriptService;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
|
@ -13,32 +14,15 @@ use Pterodactyl\Http\Requests\Admin\Egg\EggScriptFormRequest;
|
|||
|
||||
class EggScriptController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Eggs\Scripts\InstallScriptService
|
||||
*/
|
||||
protected $installScriptService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* EggScriptController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
EggRepositoryInterface $repository,
|
||||
InstallScriptService $installScriptService
|
||||
protected AlertsMessageBag $alert,
|
||||
protected EggRepositoryInterface $repository,
|
||||
protected InstallScriptService $installScriptService,
|
||||
protected ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->installScriptService = $installScriptService;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,7 +41,7 @@ class EggScriptController extends Controller
|
|||
['copy_script_from', '=', $egg->id],
|
||||
]);
|
||||
|
||||
return view('admin.eggs.scripts', [
|
||||
return $this->view->make('admin.eggs.scripts', [
|
||||
'copyFromOptions' => $copy,
|
||||
'relyOnScript' => $rely,
|
||||
'egg' => $egg,
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Nests;
|
||||
|
||||
|
@ -22,38 +15,14 @@ use Pterodactyl\Services\Eggs\Sharing\EggUpdateImporterService;
|
|||
class EggShareController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Eggs\Sharing\EggExporterService
|
||||
*/
|
||||
protected $exporterService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Eggs\Sharing\EggImporterService
|
||||
*/
|
||||
protected $importerService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Eggs\Sharing\EggUpdateImporterService
|
||||
*/
|
||||
protected $updateImporterService;
|
||||
|
||||
/**
|
||||
* OptionShareController constructor.
|
||||
* EggShareController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
EggExporterService $exporterService,
|
||||
EggImporterService $importerService,
|
||||
EggUpdateImporterService $updateImporterService
|
||||
protected AlertsMessageBag $alert,
|
||||
protected EggExporterService $exporterService,
|
||||
protected EggImporterService $importerService,
|
||||
protected EggUpdateImporterService $updateImporterService
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->exporterService = $exporterService;
|
||||
$this->importerService = $importerService;
|
||||
$this->updateImporterService = $updateImporterService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +30,7 @@ class EggShareController extends Controller
|
|||
*/
|
||||
public function export(Egg $egg): Response
|
||||
{
|
||||
$filename = trim(preg_replace('/[^\w]/', '-', kebab_case($egg->name)), '-');
|
||||
$filename = trim(preg_replace('/\W/', '-', kebab_case($egg->name)), '-');
|
||||
|
||||
return response($this->exporterService->handle($egg->id), 200, [
|
||||
'Content-Transfer-Encoding' => 'binary',
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Nests;
|
||||
|
||||
|
@ -14,6 +7,7 @@ use Pterodactyl\Models\Egg;
|
|||
use Pterodactyl\Models\EggVariable;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Services\Eggs\Variables\VariableUpdateService;
|
||||
|
@ -23,46 +17,17 @@ use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
|
|||
|
||||
class EggVariableController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Eggs\Variables\VariableCreationService
|
||||
*/
|
||||
protected $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Eggs\Variables\VariableUpdateService
|
||||
*/
|
||||
protected $updateService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface
|
||||
*/
|
||||
protected $variableRepository;
|
||||
|
||||
/**
|
||||
* EggVariableController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
VariableCreationService $creationService,
|
||||
VariableUpdateService $updateService,
|
||||
EggRepositoryInterface $repository,
|
||||
EggVariableRepositoryInterface $variableRepository
|
||||
protected AlertsMessageBag $alert,
|
||||
protected VariableCreationService $creationService,
|
||||
protected VariableUpdateService $updateService,
|
||||
protected EggRepositoryInterface $repository,
|
||||
protected EggVariableRepositoryInterface $variableRepository,
|
||||
protected ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->creationService = $creationService;
|
||||
$this->repository = $repository;
|
||||
$this->updateService = $updateService;
|
||||
$this->variableRepository = $variableRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,7 +39,7 @@ class EggVariableController extends Controller
|
|||
{
|
||||
$egg = $this->repository->getWithVariables($egg);
|
||||
|
||||
return view('admin.eggs.variables', ['egg' => $egg]);
|
||||
return $this->view->make('admin.eggs.variables', ['egg' => $egg]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,17 +1,11 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Nests;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Nests\NestUpdateService;
|
||||
use Pterodactyl\Services\Nests\NestCreationService;
|
||||
|
@ -21,46 +15,17 @@ use Pterodactyl\Http\Requests\Admin\Nest\StoreNestFormRequest;
|
|||
|
||||
class NestController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nests\NestCreationService
|
||||
*/
|
||||
protected $nestCreationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nests\NestDeletionService
|
||||
*/
|
||||
protected $nestDeletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nests\NestUpdateService
|
||||
*/
|
||||
protected $nestUpdateService;
|
||||
|
||||
/**
|
||||
* NestController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
NestCreationService $nestCreationService,
|
||||
NestDeletionService $nestDeletionService,
|
||||
NestRepositoryInterface $repository,
|
||||
NestUpdateService $nestUpdateService
|
||||
protected AlertsMessageBag $alert,
|
||||
protected NestCreationService $nestCreationService,
|
||||
protected NestDeletionService $nestDeletionService,
|
||||
protected NestRepositoryInterface $repository,
|
||||
protected NestUpdateService $nestUpdateService,
|
||||
protected ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->nestDeletionService = $nestDeletionService;
|
||||
$this->nestCreationService = $nestCreationService;
|
||||
$this->nestUpdateService = $nestUpdateService;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +35,7 @@ class NestController extends Controller
|
|||
*/
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.nests.index', [
|
||||
return $this->view->make('admin.nests.index', [
|
||||
'nests' => $this->repository->getWithCounts(),
|
||||
]);
|
||||
}
|
||||
|
@ -80,7 +45,7 @@ class NestController extends Controller
|
|||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('admin.nests.new');
|
||||
return $this->view->make('admin.nests.new');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,13 +62,13 @@ class NestController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Return details about a nest including all of the eggs and servers per egg.
|
||||
* Return details about a nest including all the eggs and servers per egg.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function view(int $nest): View
|
||||
{
|
||||
return view('admin.nests.view', [
|
||||
return $this->view->make('admin.nests.view', [
|
||||
'nest' => $this->repository->getWithEggServers($nest),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -13,43 +13,23 @@ use Pterodactyl\Repositories\Eloquent\ApiKeyRepository;
|
|||
|
||||
class NodeAutoDeployController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Api\KeyCreationService
|
||||
*/
|
||||
private $keyCreationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ApiKeyRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Encryption\Encrypter
|
||||
*/
|
||||
private $encrypter;
|
||||
|
||||
/**
|
||||
* NodeAutoDeployController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ApiKeyRepository $repository,
|
||||
Encrypter $encrypter,
|
||||
KeyCreationService $keyCreationService
|
||||
private ApiKeyRepository $repository,
|
||||
private Encrypter $encrypter,
|
||||
private KeyCreationService $keyCreationService
|
||||
) {
|
||||
$this->keyCreationService = $keyCreationService;
|
||||
$this->repository = $repository;
|
||||
$this->encrypter = $encrypter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new API key for the logged in user with only permission to read
|
||||
* Generates a new API key for the logged-in user with only permission to read
|
||||
* nodes, and returns that as the deployment key for a node.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function __invoke(Request $request, Node $node)
|
||||
public function __invoke(Request $request, Node $node): JsonResponse
|
||||
{
|
||||
/** @var \Pterodactyl\Models\ApiKey|null $key */
|
||||
$key = $this->repository->getApplicationKeys($request->user())
|
||||
|
|
|
@ -2,40 +2,26 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Nodes;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
||||
|
||||
class NodeController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\NodeRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* NodeController constructor.
|
||||
*/
|
||||
public function __construct(NodeRepository $repository, Factory $view)
|
||||
public function __construct(private ViewFactory $view)
|
||||
{
|
||||
$this->view = $view;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a listing of nodes on the system.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request)
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$nodes = QueryBuilder::for(
|
||||
Node::query()->with('location')->withCount('servers')
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Nodes;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Illuminate\Support\Collection;
|
||||
use Pterodactyl\Models\Allocation;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||
use Pterodactyl\Traits\Controllers\JavascriptInjection;
|
||||
|
@ -19,61 +20,23 @@ class NodeViewController extends Controller
|
|||
{
|
||||
use JavascriptInjection;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\NodeRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
|
||||
*/
|
||||
private $versionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\LocationRepository
|
||||
*/
|
||||
private $locationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\AllocationRepository
|
||||
*/
|
||||
private $allocationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
||||
*/
|
||||
private $serverRepository;
|
||||
|
||||
/**
|
||||
* NodeViewController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AllocationRepository $allocationRepository,
|
||||
LocationRepository $locationRepository,
|
||||
NodeRepository $repository,
|
||||
ServerRepository $serverRepository,
|
||||
SoftwareVersionService $versionService,
|
||||
Factory $view
|
||||
private AllocationRepository $allocationRepository,
|
||||
private LocationRepository $locationRepository,
|
||||
private NodeRepository $repository,
|
||||
private ServerRepository $serverRepository,
|
||||
private SoftwareVersionService $versionService,
|
||||
private ViewFactory $view
|
||||
) {
|
||||
$this->repository = $repository;
|
||||
$this->view = $view;
|
||||
$this->versionService = $versionService;
|
||||
$this->locationRepository = $locationRepository;
|
||||
$this->allocationRepository = $allocationRepository;
|
||||
$this->serverRepository = $serverRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns index view for a specific node on the system.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request, Node $node)
|
||||
public function index(Request $request, Node $node): View
|
||||
{
|
||||
$node = $this->repository->loadLocationAndServerCount($node);
|
||||
|
||||
|
@ -86,10 +49,8 @@ class NodeViewController extends Controller
|
|||
|
||||
/**
|
||||
* Returns the settings page for a specific node.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function settings(Request $request, Node $node)
|
||||
public function settings(Request $request, Node $node): View
|
||||
{
|
||||
return $this->view->make('admin.nodes.view.settings', [
|
||||
'node' => $node,
|
||||
|
@ -99,20 +60,16 @@ class NodeViewController extends Controller
|
|||
|
||||
/**
|
||||
* Return the node configuration page for a specific node.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function configuration(Request $request, Node $node)
|
||||
public function configuration(Request $request, Node $node): View
|
||||
{
|
||||
return $this->view->make('admin.nodes.view.configuration', compact('node'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the node allocation management page.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function allocations(Request $request, Node $node)
|
||||
public function allocations(Request $request, Node $node): View
|
||||
{
|
||||
$node = $this->repository->loadNodeAllocations($node);
|
||||
|
||||
|
@ -129,10 +86,8 @@ class NodeViewController extends Controller
|
|||
|
||||
/**
|
||||
* Return a listing of servers that exist for this specific node.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function servers(Request $request, Node $node)
|
||||
public function servers(Request $request, Node $node): View
|
||||
{
|
||||
$this->plainInject([
|
||||
'node' => Collection::wrap($node->makeVisible(['daemon_token_id', 'daemon_token']))
|
||||
|
|
|
@ -11,27 +11,19 @@ use Pterodactyl\Repositories\Wings\DaemonConfigurationRepository;
|
|||
|
||||
class SystemInformationController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Wings\DaemonConfigurationRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* SystemInformationController constructor.
|
||||
*/
|
||||
public function __construct(DaemonConfigurationRepository $repository)
|
||||
public function __construct(private DaemonConfigurationRepository $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns system information from the Daemon.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function __invoke(Request $request, Node $node)
|
||||
public function __invoke(Request $request, Node $node): JsonResponse
|
||||
{
|
||||
$data = $this->repository->setNode($node)->getSystemInformation();
|
||||
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Models\Allocation;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Nodes\NodeUpdateService;
|
||||
use Illuminate\Cache\Repository as CacheRepository;
|
||||
|
@ -32,103 +28,30 @@ use Pterodactyl\Http\Requests\Admin\Node\AllocationAliasFormRequest;
|
|||
|
||||
class NodesController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Allocations\AllocationDeletionService
|
||||
*/
|
||||
protected $allocationDeletionService;
|
||||
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface
|
||||
*/
|
||||
protected $allocationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Allocations\AssignmentService
|
||||
*/
|
||||
protected $assignmentService;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Cache\Repository
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeCreationService
|
||||
*/
|
||||
protected $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeDeletionService
|
||||
*/
|
||||
protected $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
|
||||
*/
|
||||
protected $locationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||
*/
|
||||
protected $serverRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeUpdateService
|
||||
*/
|
||||
protected $updateService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
|
||||
*/
|
||||
protected $versionService;
|
||||
|
||||
/**
|
||||
* NodesController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
AllocationDeletionService $allocationDeletionService,
|
||||
AllocationRepositoryInterface $allocationRepository,
|
||||
AssignmentService $assignmentService,
|
||||
CacheRepository $cache,
|
||||
NodeCreationService $creationService,
|
||||
NodeDeletionService $deletionService,
|
||||
LocationRepositoryInterface $locationRepository,
|
||||
NodeRepositoryInterface $repository,
|
||||
ServerRepositoryInterface $serverRepository,
|
||||
NodeUpdateService $updateService,
|
||||
SoftwareVersionService $versionService
|
||||
protected AlertsMessageBag $alert,
|
||||
protected AllocationDeletionService $allocationDeletionService,
|
||||
protected AllocationRepositoryInterface $allocationRepository,
|
||||
protected AssignmentService $assignmentService,
|
||||
protected CacheRepository $cache,
|
||||
protected NodeCreationService $creationService,
|
||||
protected NodeDeletionService $deletionService,
|
||||
protected LocationRepositoryInterface $locationRepository,
|
||||
protected NodeRepositoryInterface $repository,
|
||||
protected ServerRepositoryInterface $serverRepository,
|
||||
protected NodeUpdateService $updateService,
|
||||
protected SoftwareVersionService $versionService,
|
||||
protected ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->allocationDeletionService = $allocationDeletionService;
|
||||
$this->allocationRepository = $allocationRepository;
|
||||
$this->assignmentService = $assignmentService;
|
||||
$this->cache = $cache;
|
||||
$this->creationService = $creationService;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->locationRepository = $locationRepository;
|
||||
$this->repository = $repository;
|
||||
$this->serverRepository = $serverRepository;
|
||||
$this->updateService = $updateService;
|
||||
$this->versionService = $versionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays create new node page.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
public function create()
|
||||
public function create(): View|RedirectResponse
|
||||
{
|
||||
$locations = $this->locationRepository->all();
|
||||
if (count($locations) < 1) {
|
||||
|
@ -137,17 +60,15 @@ class NodesController extends Controller
|
|||
return redirect()->route('admin.locations');
|
||||
}
|
||||
|
||||
return view('admin.nodes.new', ['locations' => $locations]);
|
||||
return $this->view->make('admin.nodes.new', ['locations' => $locations]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post controller to create a new node on the system.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function store(NodeFormRequest $request)
|
||||
public function store(NodeFormRequest $request): RedirectResponse
|
||||
{
|
||||
$node = $this->creationService->handle($request->normalize());
|
||||
$this->alert->info(trans('admin/node.notices.node_created'))->flash();
|
||||
|
@ -158,13 +79,11 @@ class NodesController extends Controller
|
|||
/**
|
||||
* Updates settings for a node.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function updateSettings(NodeFormRequest $request, Node $node)
|
||||
public function updateSettings(NodeFormRequest $request, Node $node): RedirectResponse
|
||||
{
|
||||
$this->updateService->handle($node, $request->normalize(), $request->input('reset_secret') === 'on');
|
||||
$this->alert->success(trans('admin/node.notices.node_updated'))->flash();
|
||||
|
@ -203,12 +122,8 @@ class NodesController extends Controller
|
|||
|
||||
/**
|
||||
* Remove all allocations for a specific IP at once on a node.
|
||||
*
|
||||
* @param int $node
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function allocationRemoveBlock(Request $request, $node)
|
||||
public function allocationRemoveBlock(Request $request, int $node): RedirectResponse
|
||||
{
|
||||
$this->allocationRepository->deleteWhere([
|
||||
['node_id', '=', $node],
|
||||
|
@ -225,12 +140,10 @@ class NodesController extends Controller
|
|||
/**
|
||||
* Sets an alias for a specific allocation on a node.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function allocationSetAlias(AllocationAliasFormRequest $request)
|
||||
public function allocationSetAlias(AllocationAliasFormRequest $request): \Symfony\Component\HttpFoundation\Response
|
||||
{
|
||||
$this->allocationRepository->update($request->input('allocation_id'), [
|
||||
'ip_alias' => (empty($request->input('alias'))) ? null : $request->input('alias'),
|
||||
|
@ -242,16 +155,12 @@ class NodesController extends Controller
|
|||
/**
|
||||
* Creates new allocations on a node.
|
||||
*
|
||||
* @param int|\Pterodactyl\Models\Node $node
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Service\Allocation\CidrOutOfRangeException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Allocation\InvalidPortMappingException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Allocation\PortOutOfRangeException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Allocation\TooManyPortsInRangeException
|
||||
*/
|
||||
public function createAllocation(AllocationFormRequest $request, Node $node)
|
||||
public function createAllocation(AllocationFormRequest $request, Node $node): RedirectResponse
|
||||
{
|
||||
$this->assignmentService->handle($node, $request->normalize());
|
||||
$this->alert->success(trans('admin/node.notices.allocations_added'))->flash();
|
||||
|
@ -262,13 +171,9 @@ class NodesController extends Controller
|
|||
/**
|
||||
* Deletes a node from the system.
|
||||
*
|
||||
* @param $node
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function delete($node)
|
||||
public function delete(int|Node $node): RedirectResponse
|
||||
{
|
||||
$this->deletionService->handle($node);
|
||||
$this->alert->success(trans('admin/node.notices.node_deleted'))->flash();
|
||||
|
|
|
@ -3,77 +3,40 @@
|
|||
namespace Pterodactyl\Http\Controllers\Admin\Servers;
|
||||
|
||||
use JavaScript;
|
||||
use Illuminate\View\View;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Models\Location;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Repositories\Eloquent\NestRepository;
|
||||
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
||||
use Pterodactyl\Http\Requests\Admin\ServerFormRequest;
|
||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||
use Pterodactyl\Services\Servers\ServerCreationService;
|
||||
use Pterodactyl\Repositories\Eloquent\LocationRepository;
|
||||
|
||||
class CreateServerController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
private $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\NestRepository
|
||||
*/
|
||||
private $nestRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\LocationRepository
|
||||
*/
|
||||
private $locationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ServerCreationService
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* CreateServerController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
NestRepository $nestRepository,
|
||||
LocationRepository $locationRepository,
|
||||
NodeRepository $nodeRepository,
|
||||
ServerRepository $repository,
|
||||
ServerCreationService $creationService
|
||||
private AlertsMessageBag $alert,
|
||||
private NestRepository $nestRepository,
|
||||
private NodeRepository $nodeRepository,
|
||||
private ServerCreationService $creationService,
|
||||
private ViewFactory $view
|
||||
) {
|
||||
$this->repository = $repository;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
$this->alert = $alert;
|
||||
$this->nestRepository = $nestRepository;
|
||||
$this->locationRepository = $locationRepository;
|
||||
$this->creationService = $creationService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the create server page.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
public function index(): View|RedirectResponse
|
||||
{
|
||||
$nodes = $this->nodeRepository->all();
|
||||
$nodes = Node::all();
|
||||
if (count($nodes) < 1) {
|
||||
$this->alert->warning(trans('admin/server.alerts.node_required'))->flash();
|
||||
|
||||
|
@ -82,7 +45,7 @@ class CreateServerController extends Controller
|
|||
|
||||
$nests = $this->nestRepository->getWithEggs();
|
||||
|
||||
Javascript::put([
|
||||
JavaScript::put([
|
||||
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
|
||||
'nests' => $nests->map(function ($item) {
|
||||
return array_merge($item->toArray(), [
|
||||
|
@ -91,8 +54,8 @@ class CreateServerController extends Controller
|
|||
})->keyBy('id'),
|
||||
]);
|
||||
|
||||
return view('admin.servers.new', [
|
||||
'locations' => $this->locationRepository->all(),
|
||||
return $this->view->make('admin.servers.new', [
|
||||
'locations' => Location::all(),
|
||||
'nests' => $nests,
|
||||
]);
|
||||
}
|
||||
|
@ -100,15 +63,13 @@ class CreateServerController extends Controller
|
|||
/**
|
||||
* Create a new server on the remote system.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableAllocationException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function store(ServerFormRequest $request)
|
||||
public function store(ServerFormRequest $request): RedirectResponse
|
||||
{
|
||||
$data = $request->except(['_token']);
|
||||
if (!empty($data['custom_image'])) {
|
||||
|
@ -118,10 +79,8 @@ class CreateServerController extends Controller
|
|||
|
||||
$server = $this->creationService->handle($data);
|
||||
|
||||
$this->alert->success(
|
||||
trans('admin/server.alerts.server_created')
|
||||
)->flash();
|
||||
$this->alert->success(trans('admin/server.alerts.server_created'))->flash();
|
||||
|
||||
return RedirectResponse::create('/admin/servers/view/' . $server->id);
|
||||
return new RedirectResponse('/admin/servers/view/' . $server->id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,45 +2,29 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Admin\Servers;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Spatie\QueryBuilder\AllowedFilter;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Models\Filters\AdminServerFilter;
|
||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
||||
|
||||
class ServerController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ServerController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
Factory $view,
|
||||
ServerRepository $repository
|
||||
) {
|
||||
$this->view = $view;
|
||||
$this->repository = $repository;
|
||||
public function __construct(private ViewFactory $view)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all of the servers that exist on the system using a paginated result set. If
|
||||
* Returns all the servers that exist on the system using a paginated result set. If
|
||||
* a query is passed along in the request it is also passed to the repository function.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request)
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$servers = QueryBuilder::for(Server::query()->with('node', 'user', 'allocation'))
|
||||
->allowedFilters([
|
||||
|
|
|
@ -5,81 +5,34 @@ namespace Pterodactyl\Http\Controllers\Admin\Servers;
|
|||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Pterodactyl\Models\ServerTransfer;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Servers\TransferService;
|
||||
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||
use Pterodactyl\Repositories\Eloquent\LocationRepository;
|
||||
use Pterodactyl\Repositories\Wings\DaemonConfigurationRepository;
|
||||
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
|
||||
|
||||
class ServerTransferController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
private $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface
|
||||
*/
|
||||
private $allocationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\LocationRepository
|
||||
*/
|
||||
private $locationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\TransferService
|
||||
*/
|
||||
private $transferService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Wings\DaemonConfigurationRepository
|
||||
*/
|
||||
private $daemonConfigurationRepository;
|
||||
|
||||
/**
|
||||
* ServerTransferController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
AllocationRepositoryInterface $allocationRepository,
|
||||
ServerRepository $repository,
|
||||
LocationRepository $locationRepository,
|
||||
NodeRepository $nodeRepository,
|
||||
TransferService $transferService,
|
||||
DaemonConfigurationRepository $daemonConfigurationRepository
|
||||
private AlertsMessageBag $alert,
|
||||
private AllocationRepositoryInterface $allocationRepository,
|
||||
private NodeRepository $nodeRepository,
|
||||
private TransferService $transferService,
|
||||
private DaemonConfigurationRepository $daemonConfigurationRepository
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->allocationRepository = $allocationRepository;
|
||||
$this->repository = $repository;
|
||||
$this->locationRepository = $locationRepository;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
$this->transferService = $transferService;
|
||||
$this->daemonConfigurationRepository = $daemonConfigurationRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a transfer of a server to a new node.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function transfer(Request $request, Server $server)
|
||||
public function transfer(Request $request, Server $server): RedirectResponse
|
||||
{
|
||||
$validatedData = $request->validate([
|
||||
'node_id' => 'required|exists:nodes,id',
|
||||
|
@ -112,7 +65,7 @@ class ServerTransferController extends Controller
|
|||
|
||||
$transfer->save();
|
||||
|
||||
// Add the allocations to the server so they cannot be automatically assigned while the transfer is in progress.
|
||||
// Add the allocations to the server, so they cannot be automatically assigned while the transfer is in progress.
|
||||
$this->assignAllocationsToServer($server, $node_id, $allocation_id, $additional_allocations);
|
||||
|
||||
// Request an archive from the server's current daemon. (this also checks if the daemon is online)
|
||||
|
@ -132,7 +85,7 @@ class ServerTransferController extends Controller
|
|||
private function assignAllocationsToServer(Server $server, int $node_id, int $allocation_id, array $additional_allocations)
|
||||
{
|
||||
$allocations = $additional_allocations;
|
||||
array_push($allocations, $allocation_id);
|
||||
$allocations[] = $allocation_id;
|
||||
|
||||
$unassigned = $this->allocationRepository->getUnassignedAllocationIds($node_id);
|
||||
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
namespace Pterodactyl\Http\Controllers\Admin\Servers;
|
||||
|
||||
use JavaScript;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Nest;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Servers\EnvironmentService;
|
||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Repositories\Eloquent\NestRepository;
|
||||
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
||||
use Pterodactyl\Repositories\Eloquent\MountRepository;
|
||||
|
@ -22,95 +23,41 @@ class ServerViewController extends Controller
|
|||
{
|
||||
use JavascriptInjection;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\DatabaseHostRepository
|
||||
*/
|
||||
private $databaseHostRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\MountRepository
|
||||
*/
|
||||
protected $mountRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\NestRepository
|
||||
*/
|
||||
private $nestRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\LocationRepository
|
||||
*/
|
||||
private $locationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\NodeRepository
|
||||
*/
|
||||
private $nodeRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\EnvironmentService
|
||||
*/
|
||||
private $environmentService;
|
||||
|
||||
/**
|
||||
* ServerViewController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
Factory $view,
|
||||
DatabaseHostRepository $databaseHostRepository,
|
||||
LocationRepository $locationRepository,
|
||||
MountRepository $mountRepository,
|
||||
NestRepository $nestRepository,
|
||||
NodeRepository $nodeRepository,
|
||||
ServerRepository $repository,
|
||||
EnvironmentService $environmentService
|
||||
private DatabaseHostRepository $databaseHostRepository,
|
||||
private LocationRepository $locationRepository,
|
||||
private MountRepository $mountRepository,
|
||||
private NestRepository $nestRepository,
|
||||
private NodeRepository $nodeRepository,
|
||||
private ServerRepository $repository,
|
||||
private EnvironmentService $environmentService,
|
||||
private ViewFactory $view
|
||||
) {
|
||||
$this->view = $view;
|
||||
$this->databaseHostRepository = $databaseHostRepository;
|
||||
$this->locationRepository = $locationRepository;
|
||||
$this->mountRepository = $mountRepository;
|
||||
$this->nestRepository = $nestRepository;
|
||||
$this->nodeRepository = $nodeRepository;
|
||||
$this->repository = $repository;
|
||||
$this->environmentService = $environmentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index view for a server.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index(Request $request, Server $server)
|
||||
public function index(Request $request, Server $server): View
|
||||
{
|
||||
return $this->view->make('admin.servers.view.index', compact('server'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server details page.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function details(Request $request, Server $server)
|
||||
public function details(Request $request, Server $server): View
|
||||
{
|
||||
return $this->view->make('admin.servers.view.details', compact('server'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view of server build settings.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function build(Request $request, Server $server)
|
||||
public function build(Request $request, Server $server): View
|
||||
{
|
||||
$allocations = $server->node->allocations->toBase();
|
||||
|
||||
|
@ -124,11 +71,9 @@ class ServerViewController extends Controller
|
|||
/**
|
||||
* Returns the server startup management page.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function startup(Request $request, Server $server)
|
||||
public function startup(Request $request, Server $server): View
|
||||
{
|
||||
$nests = $this->nestRepository->getWithEggs();
|
||||
$variables = $this->environmentService->handle($server);
|
||||
|
@ -147,11 +92,9 @@ class ServerViewController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns all of the databases that exist for the server.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
* Returns all the databases that exist for the server.
|
||||
*/
|
||||
public function database(Request $request, Server $server)
|
||||
public function database(Request $request, Server $server): View
|
||||
{
|
||||
return $this->view->make('admin.servers.view.database', [
|
||||
'hosts' => $this->databaseHostRepository->all(),
|
||||
|
@ -160,11 +103,9 @@ class ServerViewController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns all of the mounts that exist for the server.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
* Returns all the mounts that exist for the server.
|
||||
*/
|
||||
public function mounts(Request $request, Server $server)
|
||||
public function mounts(Request $request, Server $server): View
|
||||
{
|
||||
$server->load('mounts');
|
||||
|
||||
|
@ -178,11 +119,9 @@ class ServerViewController extends Controller
|
|||
* Returns the base server management page, or an exception if the server
|
||||
* is in a state that cannot be recovered from.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function manage(Request $request, Server $server)
|
||||
public function manage(Request $request, Server $server): View
|
||||
{
|
||||
if ($server->status === Server::STATUS_INSTALL_FAILED) {
|
||||
throw new DisplayException('This server is in a failed install state and cannot be recovered. Please delete and re-create the server.');
|
||||
|
@ -195,7 +134,7 @@ class ServerViewController extends Controller
|
|||
$canTransfer = true;
|
||||
}
|
||||
|
||||
Javascript::put([
|
||||
JavaScript::put([
|
||||
'nodeData' => $this->nodeRepository->getNodesForServerCreation(),
|
||||
]);
|
||||
|
||||
|
@ -208,10 +147,8 @@ class ServerViewController extends Controller
|
|||
|
||||
/**
|
||||
* Returns the server deletion page.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function delete(Request $request, Server $server)
|
||||
public function delete(Request $request, Server $server): View
|
||||
{
|
||||
return $this->view->make('admin.servers.view.delete', compact('server'));
|
||||
}
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\User;
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Models\Mount;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\Database;
|
||||
use Pterodactyl\Models\MountServer;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
|
@ -41,148 +36,38 @@ use Pterodactyl\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest
|
|||
|
||||
class ServersController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface
|
||||
*/
|
||||
protected $allocationRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\BuildModificationService
|
||||
*/
|
||||
protected $buildModificationService;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Wings\DaemonServerRepository
|
||||
*/
|
||||
private $daemonServerRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface
|
||||
*/
|
||||
protected $databaseRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\DatabaseManagementService
|
||||
*/
|
||||
protected $databaseManagementService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\DatabasePasswordService
|
||||
*/
|
||||
protected $databasePasswordService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface
|
||||
*/
|
||||
protected $databaseHostRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ServerDeletionService
|
||||
*/
|
||||
protected $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\DetailsModificationService
|
||||
*/
|
||||
protected $detailsModificationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\MountRepository
|
||||
*/
|
||||
protected $mountRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
|
||||
*/
|
||||
protected $nestRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ReinstallServerService
|
||||
*/
|
||||
protected $reinstallService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ServerConfigurationStructureService
|
||||
*/
|
||||
private $serverConfigurationStructureService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\StartupModificationService
|
||||
*/
|
||||
private $startupModificationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\SuspensionService
|
||||
*/
|
||||
protected $suspensionService;
|
||||
|
||||
/**
|
||||
* ServersController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
AllocationRepositoryInterface $allocationRepository,
|
||||
BuildModificationService $buildModificationService,
|
||||
ConfigRepository $config,
|
||||
DaemonServerRepository $daemonServerRepository,
|
||||
DatabaseManagementService $databaseManagementService,
|
||||
DatabasePasswordService $databasePasswordService,
|
||||
DatabaseRepositoryInterface $databaseRepository,
|
||||
DatabaseHostRepository $databaseHostRepository,
|
||||
ServerDeletionService $deletionService,
|
||||
DetailsModificationService $detailsModificationService,
|
||||
ReinstallServerService $reinstallService,
|
||||
ServerRepositoryInterface $repository,
|
||||
MountRepository $mountRepository,
|
||||
NestRepositoryInterface $nestRepository,
|
||||
ServerConfigurationStructureService $serverConfigurationStructureService,
|
||||
StartupModificationService $startupModificationService,
|
||||
SuspensionService $suspensionService
|
||||
protected AlertsMessageBag $alert,
|
||||
protected AllocationRepositoryInterface $allocationRepository,
|
||||
protected BuildModificationService $buildModificationService,
|
||||
protected ConfigRepository $config,
|
||||
protected DaemonServerRepository $daemonServerRepository,
|
||||
protected DatabaseManagementService $databaseManagementService,
|
||||
protected DatabasePasswordService $databasePasswordService,
|
||||
protected DatabaseRepositoryInterface $databaseRepository,
|
||||
protected DatabaseHostRepository $databaseHostRepository,
|
||||
protected ServerDeletionService $deletionService,
|
||||
protected DetailsModificationService $detailsModificationService,
|
||||
protected ReinstallServerService $reinstallService,
|
||||
protected ServerRepositoryInterface $repository,
|
||||
protected MountRepository $mountRepository,
|
||||
protected NestRepositoryInterface $nestRepository,
|
||||
protected ServerConfigurationStructureService $serverConfigurationStructureService,
|
||||
protected StartupModificationService $startupModificationService,
|
||||
protected SuspensionService $suspensionService
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->allocationRepository = $allocationRepository;
|
||||
$this->buildModificationService = $buildModificationService;
|
||||
$this->config = $config;
|
||||
$this->daemonServerRepository = $daemonServerRepository;
|
||||
$this->databaseHostRepository = $databaseHostRepository;
|
||||
$this->databaseManagementService = $databaseManagementService;
|
||||
$this->databasePasswordService = $databasePasswordService;
|
||||
$this->databaseRepository = $databaseRepository;
|
||||
$this->detailsModificationService = $detailsModificationService;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->nestRepository = $nestRepository;
|
||||
$this->reinstallService = $reinstallService;
|
||||
$this->repository = $repository;
|
||||
$this->mountRepository = $mountRepository;
|
||||
$this->serverConfigurationStructureService = $serverConfigurationStructureService;
|
||||
$this->startupModificationService = $startupModificationService;
|
||||
$this->suspensionService = $suspensionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the details for a server.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function setDetails(Request $request, Server $server)
|
||||
public function setDetails(Request $request, Server $server): RedirectResponse
|
||||
{
|
||||
$this->detailsModificationService->handle($server, $request->only([
|
||||
'owner_id', 'external_id', 'name', 'description',
|
||||
|
@ -194,15 +79,13 @@ class ServersController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Toggles the install status for a server.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* Toggles the installation status for a server.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function toggleInstall(Server $server)
|
||||
public function toggleInstall(Server $server): RedirectResponse
|
||||
{
|
||||
if ($server->status === Server::STATUS_INSTALL_FAILED) {
|
||||
throw new DisplayException(trans('admin/server.exceptions.marked_as_failed'));
|
||||
|
@ -220,13 +103,11 @@ class ServersController extends Controller
|
|||
/**
|
||||
* Reinstalls the server with the currently assigned service.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function reinstallServer(Server $server)
|
||||
public function reinstallServer(Server $server): RedirectResponse
|
||||
{
|
||||
$this->reinstallService->handle($server);
|
||||
$this->alert->success(trans('admin/server.alerts.server_reinstalled'))->flash();
|
||||
|
@ -237,13 +118,11 @@ class ServersController extends Controller
|
|||
/**
|
||||
* Manage the suspension status for a server.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function manageSuspension(Request $request, Server $server)
|
||||
public function manageSuspension(Request $request, Server $server): RedirectResponse
|
||||
{
|
||||
$this->suspensionService->toggle($server, $request->input('action'));
|
||||
$this->alert->success(trans('admin/server.alerts.suspension_toggled', [
|
||||
|
@ -256,13 +135,11 @@ class ServersController extends Controller
|
|||
/**
|
||||
* Update the build configuration for a server.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function updateBuild(Request $request, Server $server)
|
||||
public function updateBuild(Request $request, Server $server): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$this->buildModificationService->handle($server, $request->only([
|
||||
|
@ -282,12 +159,10 @@ class ServersController extends Controller
|
|||
/**
|
||||
* Start the server deletion process.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function delete(Request $request, Server $server)
|
||||
public function delete(Request $request, Server $server): RedirectResponse
|
||||
{
|
||||
$this->deletionService->withForce($request->filled('force_delete'))->handle($server);
|
||||
$this->alert->success(trans('admin/server.alerts.server_deleted'))->flash();
|
||||
|
@ -298,11 +173,9 @@ class ServersController extends Controller
|
|||
/**
|
||||
* Update the startup command as well as variables.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function saveStartup(Request $request, Server $server)
|
||||
public function saveStartup(Request $request, Server $server): RedirectResponse
|
||||
{
|
||||
$data = $request->except('_token');
|
||||
if (!empty($data['custom_docker_image'])) {
|
||||
|
@ -326,11 +199,9 @@ class ServersController extends Controller
|
|||
/**
|
||||
* Creates a new database assigned to a specific server.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function newDatabase(StoreServerDatabaseRequest $request, Server $server)
|
||||
public function newDatabase(StoreServerDatabaseRequest $request, Server $server): RedirectResponse
|
||||
{
|
||||
$this->databaseManagementService->create($server, [
|
||||
'database' => DatabaseManagementService::generateUniqueDatabaseName($request->input('database'), $server->id),
|
||||
|
@ -345,13 +216,12 @@ class ServersController extends Controller
|
|||
/**
|
||||
* Resets the database password for a specific database on this server.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function resetDatabasePassword(Request $request, Server $server)
|
||||
public function resetDatabasePassword(Request $request, Server $server): Response
|
||||
{
|
||||
$database = $server->databases()->where('id', $request->input('database'))->findOrFail();
|
||||
/** @var \Pterodactyl\Models\Database $database */
|
||||
$database = $server->databases()->findOrFail($request->input('database'));
|
||||
|
||||
$this->databasePasswordService->handle($database);
|
||||
|
||||
|
@ -361,11 +231,9 @@ class ServersController extends Controller
|
|||
/**
|
||||
* Deletes a database from a server.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function deleteDatabase(Server $server, Database $database)
|
||||
public function deleteDatabase(Server $server, Database $database): Response
|
||||
{
|
||||
$this->databaseManagementService->delete($database);
|
||||
|
||||
|
@ -375,11 +243,9 @@ class ServersController extends Controller
|
|||
/**
|
||||
* Add a mount to a server.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function addMount(Request $request, Server $server)
|
||||
public function addMount(Request $request, Server $server): RedirectResponse
|
||||
{
|
||||
$mountServer = (new MountServer())->forceFill([
|
||||
'mount_id' => $request->input('mount_id'),
|
||||
|
@ -395,10 +261,8 @@ class ServersController extends Controller
|
|||
|
||||
/**
|
||||
* Remove a mount from a server.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function deleteMount(Server $server, Mount $mount)
|
||||
public function deleteMount(Server $server, Mount $mount): RedirectResponse
|
||||
{
|
||||
MountServer::where('mount_id', $mount->id)->where('server_id', $server->id)->delete();
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use Illuminate\View\View;
|
|||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
||||
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
||||
|
@ -13,39 +14,16 @@ use Pterodactyl\Http\Requests\Admin\Settings\AdvancedSettingsFormRequest;
|
|||
|
||||
class AdvancedController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
private $alert;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Console\Kernel
|
||||
*/
|
||||
private $kernel;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\SettingsRepositoryInterface
|
||||
*/
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* AdvancedController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
ConfigRepository $config,
|
||||
Kernel $kernel,
|
||||
SettingsRepositoryInterface $settings
|
||||
private AlertsMessageBag $alert,
|
||||
private ConfigRepository $config,
|
||||
private Kernel $kernel,
|
||||
private SettingsRepositoryInterface $settings,
|
||||
private ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->config = $config;
|
||||
$this->kernel = $kernel;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +39,7 @@ class AdvancedController extends Controller
|
|||
$showRecaptchaWarning = true;
|
||||
}
|
||||
|
||||
return view('admin.settings.advanced', [
|
||||
return $this->view->make('admin.settings.advanced', [
|
||||
'showRecaptchaWarning' => $showRecaptchaWarning,
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ use Illuminate\View\View;
|
|||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Traits\Helpers\AvailableLanguages;
|
||||
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
||||
|
@ -16,39 +17,16 @@ class IndexController extends Controller
|
|||
{
|
||||
use AvailableLanguages;
|
||||
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
private $alert;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Console\Kernel
|
||||
*/
|
||||
private $kernel;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\SettingsRepositoryInterface
|
||||
*/
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
|
||||
*/
|
||||
private $versionService;
|
||||
|
||||
/**
|
||||
* IndexController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
Kernel $kernel,
|
||||
SettingsRepositoryInterface $settings,
|
||||
SoftwareVersionService $versionService
|
||||
private AlertsMessageBag $alert,
|
||||
private Kernel $kernel,
|
||||
private SettingsRepositoryInterface $settings,
|
||||
private SoftwareVersionService $versionService,
|
||||
private ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->kernel = $kernel;
|
||||
$this->settings = $settings;
|
||||
$this->versionService = $versionService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,7 +34,7 @@ class IndexController extends Controller
|
|||
*/
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.settings.index', [
|
||||
return $this->view->make('admin.settings.index', [
|
||||
'version' => $this->versionService,
|
||||
'languages' => $this->getAvailableLanguages(true),
|
||||
]);
|
||||
|
|
|
@ -6,9 +6,9 @@ use Exception;
|
|||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Pterodactyl\Notifications\MailTested;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
|
@ -20,46 +20,16 @@ use Pterodactyl\Http\Requests\Admin\Settings\MailSettingsFormRequest;
|
|||
|
||||
class MailController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
private $alert;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Encryption\Encrypter
|
||||
*/
|
||||
private $encrypter;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Console\Kernel
|
||||
*/
|
||||
private $kernel;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\SettingsRepositoryInterface
|
||||
*/
|
||||
private $settings;
|
||||
|
||||
/**
|
||||
* MailController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
ConfigRepository $config,
|
||||
Encrypter $encrypter,
|
||||
Kernel $kernel,
|
||||
SettingsRepositoryInterface $settings
|
||||
private ConfigRepository $config,
|
||||
private Encrypter $encrypter,
|
||||
private Kernel $kernel,
|
||||
private SettingsRepositoryInterface $settings,
|
||||
private ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->config = $config;
|
||||
$this->encrypter = $encrypter;
|
||||
$this->kernel = $kernel;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,7 +38,7 @@ class MailController extends Controller
|
|||
*/
|
||||
public function index(): View
|
||||
{
|
||||
return view('admin.settings.mail', [
|
||||
return $this->view->make('admin.settings.mail', [
|
||||
'disabled' => $this->config->get('mail.driver') !== 'smtp',
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -2,10 +2,15 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Models\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Prologue\Alerts\AlertsMessageBag;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Translation\Translator;
|
||||
|
@ -20,61 +25,24 @@ class UserController extends Controller
|
|||
{
|
||||
use AvailableLanguages;
|
||||
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
*/
|
||||
protected $alert;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\UserCreationService
|
||||
*/
|
||||
protected $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\UserDeletionService
|
||||
*/
|
||||
protected $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Translation\Translator
|
||||
*/
|
||||
protected $translator;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\UserUpdateService
|
||||
*/
|
||||
protected $updateService;
|
||||
|
||||
/**
|
||||
* UserController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AlertsMessageBag $alert,
|
||||
UserCreationService $creationService,
|
||||
UserDeletionService $deletionService,
|
||||
Translator $translator,
|
||||
UserUpdateService $updateService,
|
||||
UserRepositoryInterface $repository
|
||||
protected AlertsMessageBag $alert,
|
||||
protected UserCreationService $creationService,
|
||||
protected UserDeletionService $deletionService,
|
||||
protected Translator $translator,
|
||||
protected UserUpdateService $updateService,
|
||||
protected UserRepositoryInterface $repository,
|
||||
protected ViewFactory $view
|
||||
) {
|
||||
$this->alert = $alert;
|
||||
$this->creationService = $creationService;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->repository = $repository;
|
||||
$this->translator = $translator;
|
||||
$this->updateService = $updateService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display user index page.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(Request $request)
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$users = QueryBuilder::for(
|
||||
User::query()->select('users.*')
|
||||
|
@ -88,29 +56,25 @@ class UserController extends Controller
|
|||
->allowedSorts(['id', 'uuid'])
|
||||
->paginate(50);
|
||||
|
||||
return view('admin.users.index', ['users' => $users]);
|
||||
return $this->view->make('admin.users.index', ['users' => $users]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display new user page.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function create()
|
||||
public function create(): View
|
||||
{
|
||||
return view('admin.users.new', [
|
||||
return $this->view->make('admin.users.new', [
|
||||
'languages' => $this->getAvailableLanguages(true),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display user view page.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function view(User $user)
|
||||
public function view(User $user): View
|
||||
{
|
||||
return view('admin.users.view', [
|
||||
return $this->view->make('admin.users.view', [
|
||||
'user' => $user,
|
||||
'languages' => $this->getAvailableLanguages(true),
|
||||
]);
|
||||
|
@ -119,12 +83,10 @@ class UserController extends Controller
|
|||
/**
|
||||
* Delete a user from the system.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function delete(Request $request, User $user)
|
||||
public function delete(Request $request, User $user): RedirectResponse
|
||||
{
|
||||
if ($request->user()->id === $user->id) {
|
||||
throw new DisplayException($this->translator->get('admin/user.exceptions.user_has_servers'));
|
||||
|
@ -138,12 +100,10 @@ class UserController extends Controller
|
|||
/**
|
||||
* Create a user.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function store(UserFormRequest $request)
|
||||
public function store(UserFormRequest $request): RedirectResponse
|
||||
{
|
||||
$user = $this->creationService->handle($request->normalize());
|
||||
$this->alert->success($this->translator->get('admin/user.notices.account_created'))->flash();
|
||||
|
@ -154,12 +114,10 @@ class UserController extends Controller
|
|||
/**
|
||||
* Update a user on the system.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function update(UserFormRequest $request, User $user)
|
||||
public function update(UserFormRequest $request, User $user): RedirectResponse
|
||||
{
|
||||
$this->updateService
|
||||
->setUserLevel(User::USER_LEVEL_ADMIN)
|
||||
|
@ -172,10 +130,8 @@ class UserController extends Controller
|
|||
|
||||
/**
|
||||
* Get a JSON response of users on the system.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection|\Pterodactyl\Models\Model
|
||||
*/
|
||||
public function json(Request $request)
|
||||
public function json(Request $request): Model|Collection
|
||||
{
|
||||
$users = QueryBuilder::for(User::query())->allowedFilters(['email'])->paginate(25);
|
||||
|
||||
|
|
|
@ -13,15 +13,9 @@ use Pterodactyl\Transformers\Api\Application\BaseTransformer;
|
|||
|
||||
abstract class ApplicationApiController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Http\Request
|
||||
*/
|
||||
protected $request;
|
||||
protected Request $request;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Extensions\Spatie\Fractalistic\Fractal
|
||||
*/
|
||||
protected $fractal;
|
||||
protected Fractal $fractal;
|
||||
|
||||
/**
|
||||
* ApplicationApiController constructor.
|
||||
|
@ -30,7 +24,7 @@ abstract class ApplicationApiController extends Controller
|
|||
{
|
||||
Container::getInstance()->call([$this, 'loadDependencies']);
|
||||
|
||||
// Parse all of the includes to use on this request.
|
||||
// Parse all the includes to use on this request.
|
||||
$input = $this->request->input('include', []);
|
||||
$input = is_array($input) ? $input : explode(',', $input);
|
||||
|
||||
|
@ -62,7 +56,6 @@ abstract class ApplicationApiController extends Controller
|
|||
* @return T
|
||||
*
|
||||
* @noinspection PhpDocSignatureInspection
|
||||
* @noinspection PhpUndefinedClassInspection
|
||||
*/
|
||||
public function getTransformer(string $abstract)
|
||||
{
|
||||
|
@ -72,7 +65,7 @@ abstract class ApplicationApiController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Return a HTTP/204 response for the API.
|
||||
* Return an HTTP/204 response for the API.
|
||||
*/
|
||||
protected function returnNoContent(): Response
|
||||
{
|
||||
|
|
|
@ -9,7 +9,6 @@ use Spatie\QueryBuilder\QueryBuilder;
|
|||
use Pterodactyl\Services\Locations\LocationUpdateService;
|
||||
use Pterodactyl\Services\Locations\LocationCreationService;
|
||||
use Pterodactyl\Services\Locations\LocationDeletionService;
|
||||
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
||||
use Pterodactyl\Transformers\Api\Application\LocationTransformer;
|
||||
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationRequest;
|
||||
|
@ -20,45 +19,19 @@ use Pterodactyl\Http\Requests\Api\Application\Locations\UpdateLocationRequest;
|
|||
|
||||
class LocationController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Locations\LocationCreationService
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Locations\LocationDeletionService
|
||||
*/
|
||||
private $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Locations\LocationUpdateService
|
||||
*/
|
||||
private $updateService;
|
||||
|
||||
/**
|
||||
* LocationController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
LocationCreationService $creationService,
|
||||
LocationDeletionService $deletionService,
|
||||
LocationRepositoryInterface $repository,
|
||||
LocationUpdateService $updateService
|
||||
private LocationCreationService $creationService,
|
||||
private LocationDeletionService $deletionService,
|
||||
private LocationUpdateService $updateService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->creationService = $creationService;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->repository = $repository;
|
||||
$this->updateService = $updateService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the locations currently registered on the Panel.
|
||||
* Return all the locations currently registered on the Panel.
|
||||
*/
|
||||
public function index(GetLocationsRequest $request): array
|
||||
{
|
||||
|
@ -83,7 +56,7 @@ class LocationController extends ApplicationApiController
|
|||
}
|
||||
|
||||
/**
|
||||
* Store a new location on the Panel and return a HTTP/201 response code with the
|
||||
* Store a new location on the Panel and return an HTTP/201 response code with the
|
||||
* new location attached.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
|
|
|
@ -10,19 +10,12 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
|||
|
||||
class NestController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* NestController constructor.
|
||||
*/
|
||||
public function __construct(NestRepositoryInterface $repository)
|
||||
public function __construct(private NestRepositoryInterface $repository)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,31 +18,18 @@ use Pterodactyl\Http\Requests\Api\Application\Allocations\DeleteAllocationReques
|
|||
|
||||
class AllocationController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Allocations\AssignmentService
|
||||
*/
|
||||
private $assignmentService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Allocations\AllocationDeletionService
|
||||
*/
|
||||
private $deletionService;
|
||||
|
||||
/**
|
||||
* AllocationController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AssignmentService $assignmentService,
|
||||
AllocationDeletionService $deletionService
|
||||
private AssignmentService $assignmentService,
|
||||
private AllocationDeletionService $deletionService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->assignmentService = $assignmentService;
|
||||
$this->deletionService = $deletionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the allocations that exist for a given node.
|
||||
* Return all the allocations that exist for a given node.
|
||||
*/
|
||||
public function index(GetAllocationsRequest $request, Node $node): array
|
||||
{
|
||||
|
|
|
@ -13,10 +13,8 @@ class NodeConfigurationController extends ApplicationApiController
|
|||
* Returns the configuration information for a node. This allows for automated deployments
|
||||
* to remote machines so long as an API key is provided to the machine to make the request
|
||||
* with, and the node is known.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function __invoke(GetNodeRequest $request, Node $node)
|
||||
public function __invoke(GetNodeRequest $request, Node $node): JsonResponse
|
||||
{
|
||||
return new JsonResponse($node->getConfiguration());
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ use Spatie\QueryBuilder\QueryBuilder;
|
|||
use Pterodactyl\Services\Nodes\NodeUpdateService;
|
||||
use Pterodactyl\Services\Nodes\NodeCreationService;
|
||||
use Pterodactyl\Services\Nodes\NodeDeletionService;
|
||||
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
||||
use Pterodactyl\Transformers\Api\Application\NodeTransformer;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodesRequest;
|
||||
|
@ -19,45 +18,19 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
|||
|
||||
class NodeController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeCreationService
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeDeletionService
|
||||
*/
|
||||
private $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeUpdateService
|
||||
*/
|
||||
private $updateService;
|
||||
|
||||
/**
|
||||
* NodeController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
NodeCreationService $creationService,
|
||||
NodeDeletionService $deletionService,
|
||||
NodeUpdateService $updateService,
|
||||
NodeRepositoryInterface $repository
|
||||
private NodeCreationService $creationService,
|
||||
private NodeDeletionService $deletionService,
|
||||
private NodeUpdateService $updateService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
$this->creationService = $creationService;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->updateService = $updateService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the nodes currently available on the Panel.
|
||||
* Return all the nodes currently available on the Panel.
|
||||
*/
|
||||
public function index(GetNodesRequest $request): array
|
||||
{
|
||||
|
@ -82,7 +55,7 @@ class NodeController extends ApplicationApiController
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new node on the Panel. Returns the created node and a HTTP/201
|
||||
* Create a new node on the Panel. Returns the created node and an HTTP/201
|
||||
* status response on success.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
|
|
|
@ -9,19 +9,12 @@ use Pterodactyl\Http\Requests\Api\Application\Nodes\GetDeployableNodesRequest;
|
|||
|
||||
class NodeDeploymentController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Deployment\FindViableNodesService
|
||||
*/
|
||||
private $viableNodesService;
|
||||
|
||||
/**
|
||||
* NodeDeploymentController constructor.
|
||||
*/
|
||||
public function __construct(FindViableNodesService $viableNodesService)
|
||||
public function __construct(private FindViableNodesService $viableNodesService)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->viableNodesService = $viableNodesService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,6 @@ use Pterodactyl\Models\Database;
|
|||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Services\Databases\DatabasePasswordService;
|
||||
use Pterodactyl\Services\Databases\DatabaseManagementService;
|
||||
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
|
||||
use Pterodactyl\Transformers\Api\Application\ServerDatabaseTransformer;
|
||||
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabaseRequest;
|
||||
|
@ -18,34 +17,14 @@ use Pterodactyl\Http\Requests\Api\Application\Servers\Databases\StoreServerDatab
|
|||
|
||||
class DatabaseController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\DatabaseManagementService
|
||||
*/
|
||||
private $databaseManagementService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\DatabasePasswordService
|
||||
*/
|
||||
private $databasePasswordService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* DatabaseController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
DatabaseManagementService $databaseManagementService,
|
||||
DatabasePasswordService $databasePasswordService,
|
||||
DatabaseRepositoryInterface $repository
|
||||
private DatabaseManagementService $databaseManagementService,
|
||||
private DatabasePasswordService $databasePasswordService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->databaseManagementService = $databaseManagementService;
|
||||
$this->databasePasswordService = $databasePasswordService;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,6 @@ use Illuminate\Http\JsonResponse;
|
|||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Pterodactyl\Services\Servers\ServerCreationService;
|
||||
use Pterodactyl\Services\Servers\ServerDeletionService;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Pterodactyl\Transformers\Api\Application\ServerTransformer;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Servers\GetServerRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Servers\GetServersRequest;
|
||||
|
@ -18,38 +17,18 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
|||
|
||||
class ServerController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ServerCreationService
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ServerDeletionService
|
||||
*/
|
||||
private $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ServerController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ServerCreationService $creationService,
|
||||
ServerDeletionService $deletionService,
|
||||
ServerRepositoryInterface $repository
|
||||
private ServerCreationService $creationService,
|
||||
private ServerDeletionService $deletionService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->creationService = $creationService;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the servers that currently exist on the Panel.
|
||||
* Return all the servers that currently exist on the Panel.
|
||||
*/
|
||||
public function index(GetServersRequest $request): array
|
||||
{
|
||||
|
@ -94,6 +73,8 @@ class ServerController extends ApplicationApiController
|
|||
}
|
||||
|
||||
/**
|
||||
* Deletes a server.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function delete(ServerWriteRequest $request, Server $server, string $force = ''): Response
|
||||
|
|
|
@ -12,27 +12,14 @@ use Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigura
|
|||
|
||||
class ServerDetailsController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\BuildModificationService
|
||||
*/
|
||||
private $buildModificationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\DetailsModificationService
|
||||
*/
|
||||
private $detailsModificationService;
|
||||
|
||||
/**
|
||||
* ServerDetailsController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
BuildModificationService $buildModificationService,
|
||||
DetailsModificationService $detailsModificationService
|
||||
private BuildModificationService $buildModificationService,
|
||||
private DetailsModificationService $detailsModificationService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->buildModificationService = $buildModificationService;
|
||||
$this->detailsModificationService = $detailsModificationService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,26 +12,13 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
|||
class ServerManagementController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ReinstallServerService
|
||||
*/
|
||||
private $reinstallServerService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\SuspensionService
|
||||
*/
|
||||
private $suspensionService;
|
||||
|
||||
/**
|
||||
* SuspensionController constructor.
|
||||
* ServerManagementController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ReinstallServerService $reinstallServerService,
|
||||
SuspensionService $suspensionService
|
||||
private ReinstallServerService $reinstallServerService,
|
||||
private SuspensionService $suspensionService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->reinstallServerService = $reinstallServerService;
|
||||
$this->suspensionService = $suspensionService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,7 +28,7 @@ class ServerManagementController extends ApplicationApiController
|
|||
*/
|
||||
public function suspend(ServerWriteRequest $request, Server $server): Response
|
||||
{
|
||||
$this->suspensionService->toggle($server, SuspensionService::ACTION_SUSPEND);
|
||||
$this->suspensionService->toggle($server);
|
||||
|
||||
return $this->returnNoContent();
|
||||
}
|
||||
|
|
|
@ -11,19 +11,12 @@ use Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest
|
|||
|
||||
class StartupController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\StartupModificationService
|
||||
*/
|
||||
private $modificationService;
|
||||
|
||||
/**
|
||||
* StartupController constructor.
|
||||
*/
|
||||
public function __construct(StartupModificationService $modificationService)
|
||||
public function __construct(private StartupModificationService $modificationService)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->modificationService = $modificationService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Application\Users;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Pterodactyl\Services\Users\UserUpdateService;
|
||||
use Pterodactyl\Services\Users\UserCreationService;
|
||||
use Pterodactyl\Services\Users\UserDeletionService;
|
||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
||||
use Pterodactyl\Transformers\Api\Application\UserTransformer;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Users\GetUsersRequest;
|
||||
use Pterodactyl\Http\Requests\Api\Application\Users\StoreUserRequest;
|
||||
|
@ -19,41 +17,15 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
|
|||
|
||||
class UserController extends ApplicationApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\UserCreationService
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\UserDeletionService
|
||||
*/
|
||||
private $deletionService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\UserUpdateService
|
||||
*/
|
||||
private $updateService;
|
||||
|
||||
/**
|
||||
* UserController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
UserRepositoryInterface $repository,
|
||||
UserCreationService $creationService,
|
||||
UserDeletionService $deletionService,
|
||||
UserUpdateService $updateService
|
||||
private UserCreationService $creationService,
|
||||
private UserDeletionService $deletionService,
|
||||
private UserUpdateService $updateService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->creationService = $creationService;
|
||||
$this->deletionService = $deletionService;
|
||||
$this->repository = $repository;
|
||||
$this->updateService = $updateService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,7 +79,7 @@ class UserController extends ApplicationApiController
|
|||
}
|
||||
|
||||
/**
|
||||
* Store a new user on the system. Returns the created user and a HTTP/201
|
||||
* Store a new user on the system. Returns the created user and an HTTP/201
|
||||
* header on successful creation.
|
||||
*
|
||||
* @throws \Exception
|
||||
|
|
|
@ -14,25 +14,12 @@ use Pterodactyl\Http\Requests\Api\Client\Account\UpdatePasswordRequest;
|
|||
|
||||
class AccountController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\UserUpdateService
|
||||
*/
|
||||
private $updateService;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Auth\AuthManager
|
||||
*/
|
||||
private $manager;
|
||||
|
||||
/**
|
||||
* AccountController constructor.
|
||||
*/
|
||||
public function __construct(AuthManager $manager, UserUpdateService $updateService)
|
||||
public function __construct(private AuthManager $manager, private UserUpdateService $updateService)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->updateService = $updateService;
|
||||
$this->manager = $manager;
|
||||
}
|
||||
|
||||
public function index(Request $request): array
|
||||
|
|
|
@ -13,11 +13,9 @@ use Pterodactyl\Http\Requests\Api\Client\Account\StoreApiKeyRequest;
|
|||
class ApiKeyController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* Returns all of the API keys that exist for the given client.
|
||||
*
|
||||
* @return array
|
||||
* Returns all the API keys that exist for the given client.
|
||||
*/
|
||||
public function index(ClientApiRequest $request)
|
||||
public function index(ClientApiRequest $request): array
|
||||
{
|
||||
return $this->fractal->collection($request->user()->apiKeys)
|
||||
->transformWith($this->getTransformer(ApiKeyTransformer::class))
|
||||
|
@ -26,6 +24,8 @@ class ApiKeyController extends ClientApiController
|
|||
|
||||
/**
|
||||
* Store a new API key for a user's account.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function store(StoreApiKeyRequest $request): array
|
||||
{
|
||||
|
@ -51,10 +51,8 @@ class ApiKeyController extends ClientApiController
|
|||
|
||||
/**
|
||||
* Deletes a given API key.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function delete(ClientApiRequest $request, string $identifier)
|
||||
public function delete(ClientApiRequest $request, string $identifier): JsonResponse
|
||||
{
|
||||
/** @var \Pterodactyl\Models\ApiKey $key */
|
||||
$key = $request->user()->apiKeys()
|
||||
|
|
|
@ -10,10 +10,8 @@ abstract class ClientApiController extends ApplicationApiController
|
|||
{
|
||||
/**
|
||||
* Returns only the includes which are valid for the given transformer.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getIncludesForTransformer(BaseClientTransformer $transformer, array $merge = [])
|
||||
protected function getIncludesForTransformer(BaseClientTransformer $transformer, array $merge = []): array
|
||||
{
|
||||
$filtered = array_filter($this->parseIncludes(), function ($datum) use ($transformer) {
|
||||
return in_array($datum, $transformer->getAvailableIncludes());
|
||||
|
@ -24,10 +22,8 @@ abstract class ClientApiController extends ApplicationApiController
|
|||
|
||||
/**
|
||||
* Returns the parsed includes for this request.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
protected function parseIncludes()
|
||||
protected function parseIncludes(): array
|
||||
{
|
||||
$includes = $this->request->query('include') ?? [];
|
||||
|
||||
|
@ -49,7 +45,6 @@ abstract class ClientApiController extends ApplicationApiController
|
|||
*
|
||||
* @return T
|
||||
*
|
||||
* @noinspection PhpUndefinedClassInspection
|
||||
* @noinspection PhpDocSignatureInspection
|
||||
*/
|
||||
public function getTransformer(string $abstract)
|
||||
|
|
|
@ -7,29 +7,21 @@ use Pterodactyl\Models\Permission;
|
|||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use Spatie\QueryBuilder\AllowedFilter;
|
||||
use Pterodactyl\Models\Filters\MultiFieldServerFilter;
|
||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||
use Pterodactyl\Transformers\Api\Client\ServerTransformer;
|
||||
use Pterodactyl\Http\Requests\Api\Client\GetServersRequest;
|
||||
|
||||
class ClientController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ClientController constructor.
|
||||
*/
|
||||
public function __construct(ServerRepository $repository)
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the servers available to the client making the API
|
||||
* Return all the servers available to the client making the API
|
||||
* request, including servers the user has access to as a subuser.
|
||||
*/
|
||||
public function index(GetServersRequest $request): array
|
||||
|
@ -49,8 +41,8 @@ class ClientController extends ClientApiController
|
|||
]);
|
||||
|
||||
$type = $request->input('type');
|
||||
// Either return all of the servers the user has access to because they are an admin `?type=admin` or
|
||||
// just return all of the servers the user has access to because they are the owner or a subuser of the
|
||||
// Either return all the servers the user has access to because they are an admin `?type=admin` or
|
||||
// just return all the servers the user has access to because they are the owner or a subuser of the
|
||||
// server. If ?type=admin-all is passed all servers on the system will be returned to the user, rather
|
||||
// than only servers they can see because they are an admin.
|
||||
if (in_array($type, ['admin', 'admin-all'])) {
|
||||
|
@ -75,11 +67,9 @@ class ClientController extends ClientApiController
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns all of the subuser permissions available on the system.
|
||||
*
|
||||
* @return array
|
||||
* Returns all the subuser permissions available on the system.
|
||||
*/
|
||||
public function permissions()
|
||||
public function permissions(): array
|
||||
{
|
||||
return [
|
||||
'object' => 'system_permissions',
|
||||
|
|
|
@ -11,7 +11,7 @@ use Pterodactyl\Http\Requests\Api\Client\Account\StoreSSHKeyRequest;
|
|||
class SSHKeyController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* Returns all of the SSH keys that have been configured for the logged in
|
||||
* Returns all the SSH keys that have been configured for the logged-in
|
||||
* user account.
|
||||
*/
|
||||
public function index(ClientApiRequest $request): array
|
||||
|
|
|
@ -21,29 +21,17 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest;
|
|||
|
||||
class BackupController extends ClientApiController
|
||||
{
|
||||
private InitiateBackupService $initiateBackupService;
|
||||
private DeleteBackupService $deleteBackupService;
|
||||
private DownloadLinkService $downloadLinkService;
|
||||
private DaemonBackupRepository $daemonRepository;
|
||||
private BackupRepository $repository;
|
||||
|
||||
/**
|
||||
* BackupController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
DaemonBackupRepository $daemonRepository,
|
||||
DeleteBackupService $deleteBackupService,
|
||||
InitiateBackupService $initiateBackupService,
|
||||
DownloadLinkService $downloadLinkService,
|
||||
BackupRepository $repository
|
||||
private DaemonBackupRepository $daemonRepository,
|
||||
private DeleteBackupService $deleteBackupService,
|
||||
private InitiateBackupService $initiateBackupService,
|
||||
private DownloadLinkService $downloadLinkService,
|
||||
private BackupRepository $repository
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
$this->initiateBackupService = $initiateBackupService;
|
||||
$this->deleteBackupService = $deleteBackupService;
|
||||
$this->downloadLinkService = $downloadLinkService;
|
||||
$this->daemonRepository = $daemonRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,9 +182,9 @@ class BackupController extends ClientApiController
|
|||
* to begin the process of finding (or downloading) the backup and unpacking it
|
||||
* over the server files.
|
||||
*
|
||||
* If the "truncate" flag is passed through in this request then all of the
|
||||
* If the "truncate" flag is passed through in this request then all the
|
||||
* files that currently exist on the server will be deleted before restoring.
|
||||
* Otherwise the archive will simply be unpacked over the existing files.
|
||||
* Otherwise, the archive will simply be unpacked over the existing files.
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
|
|
|
@ -15,19 +15,12 @@ use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
|||
|
||||
class CommandController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Wings\DaemonCommandRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* CommandController constructor.
|
||||
*/
|
||||
public function __construct(DaemonCommandRepository $repository)
|
||||
public function __construct(private DaemonCommandRepository $repository)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,6 @@ use Illuminate\Http\Response;
|
|||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\Database;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Repositories\Eloquent\DatabaseRepository;
|
||||
use Pterodactyl\Services\Databases\DatabasePasswordService;
|
||||
use Pterodactyl\Transformers\Api\Client\DatabaseTransformer;
|
||||
use Pterodactyl\Services\Databases\DatabaseManagementService;
|
||||
|
@ -19,45 +18,19 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Databases\RotatePasswordRequest
|
|||
|
||||
class DatabaseController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\DeployServerDatabaseService
|
||||
*/
|
||||
private $deployDatabaseService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\DatabaseRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\DatabaseManagementService
|
||||
*/
|
||||
private $managementService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Databases\DatabasePasswordService
|
||||
*/
|
||||
private $passwordService;
|
||||
|
||||
/**
|
||||
* DatabaseController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
DatabaseManagementService $managementService,
|
||||
DatabasePasswordService $passwordService,
|
||||
DatabaseRepository $repository,
|
||||
DeployServerDatabaseService $deployDatabaseService
|
||||
private DeployServerDatabaseService $deployDatabaseService,
|
||||
private DatabaseManagementService $managementService,
|
||||
private DatabasePasswordService $passwordService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->deployDatabaseService = $deployDatabaseService;
|
||||
$this->repository = $repository;
|
||||
$this->managementService = $managementService;
|
||||
$this->passwordService = $passwordService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all of the databases that belong to the given server.
|
||||
* Return all the databases that belong to the given server.
|
||||
*/
|
||||
public function index(GetDatabasesRequest $request, Server $server): array
|
||||
{
|
||||
|
@ -92,11 +65,9 @@ class DatabaseController extends ClientApiController
|
|||
* Rotates the password for the given server model and returns a fresh instance to
|
||||
* the caller.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function rotatePassword(RotatePasswordRequest $request, Server $server, Database $database)
|
||||
public function rotatePassword(RotatePasswordRequest $request, Server $server, Database $database): array
|
||||
{
|
||||
$this->passwordService->handle($database);
|
||||
$database->refresh();
|
||||
|
@ -126,6 +97,6 @@ class DatabaseController extends ClientApiController
|
|||
->property('name', $database->database)
|
||||
->log();
|
||||
|
||||
return Response::create('', Response::HTTP_NO_CONTENT);
|
||||
return new Response('', Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,27 +25,14 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Files\WriteFileContentRequest;
|
|||
|
||||
class FileController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Wings\DaemonFileRepository
|
||||
*/
|
||||
private $fileRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeJWTService
|
||||
*/
|
||||
private $jwtService;
|
||||
|
||||
/**
|
||||
* FileController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
NodeJWTService $jwtService,
|
||||
DaemonFileRepository $fileRepository
|
||||
private NodeJWTService $jwtService,
|
||||
private DaemonFileRepository $fileRepository
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->fileRepository = $fileRepository;
|
||||
$this->jwtService = $jwtService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,11 +72,9 @@ class FileController extends ClientApiController
|
|||
* Generates a one-time token with a link that the user can use to
|
||||
* download a given file.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function download(GetFileContentsRequest $request, Server $server)
|
||||
public function download(GetFileContentsRequest $request, Server $server): array
|
||||
{
|
||||
$token = $this->jwtService
|
||||
->setExpiresAt(CarbonImmutable::now()->addMinutes(15))
|
||||
|
|
|
@ -12,28 +12,19 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Files\UploadFileRequest;
|
|||
|
||||
class FileUploadController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeJWTService
|
||||
*/
|
||||
private $jwtService;
|
||||
|
||||
/**
|
||||
* FileUploadController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
NodeJWTService $jwtService
|
||||
private NodeJWTService $jwtService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->jwtService = $jwtService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a url where files can be uploaded to.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* Returns an url where files can be uploaded to.
|
||||
*/
|
||||
public function __invoke(UploadFileRequest $request, Server $server)
|
||||
public function __invoke(UploadFileRequest $request, Server $server): JsonResponse
|
||||
{
|
||||
return new JsonResponse([
|
||||
'object' => 'signed_url',
|
||||
|
@ -44,11 +35,9 @@ class FileUploadController extends ClientApiController
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a url where files can be uploaded to.
|
||||
*
|
||||
* @return string
|
||||
* Returns an url where files can be uploaded to.
|
||||
*/
|
||||
protected function getUploadUrl(Server $server, User $user)
|
||||
protected function getUploadUrl(Server $server, User $user): string
|
||||
{
|
||||
$token = $this->jwtService
|
||||
->setExpiresAt(CarbonImmutable::now()->addMinutes(15))
|
||||
|
|
|
@ -8,7 +8,6 @@ use Pterodactyl\Facades\Activity;
|
|||
use Pterodactyl\Models\Allocation;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||
use Pterodactyl\Repositories\Eloquent\AllocationRepository;
|
||||
use Pterodactyl\Transformers\Api\Client\AllocationTransformer;
|
||||
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
|
||||
use Pterodactyl\Services\Allocations\FindAssignableAllocationService;
|
||||
|
@ -21,38 +20,18 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Network\SetPrimaryAllocationReq
|
|||
class NetworkAllocationController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\AllocationRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
||||
*/
|
||||
private $serverRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Allocations\FindAssignableAllocationService
|
||||
*/
|
||||
private $assignableAllocationService;
|
||||
|
||||
/**
|
||||
* NetworkController constructor.
|
||||
* NetworkAllocationController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
AllocationRepository $repository,
|
||||
ServerRepository $serverRepository,
|
||||
FindAssignableAllocationService $assignableAllocationService
|
||||
private FindAssignableAllocationService $assignableAllocationService,
|
||||
private ServerRepository $serverRepository
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
$this->serverRepository = $serverRepository;
|
||||
$this->assignableAllocationService = $assignableAllocationService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all of the allocations available to a server and wether or
|
||||
* not they are currently assigned as the primary for this server.
|
||||
* Lists all the allocations available to a server and whether
|
||||
* they are currently assigned as the primary for this server.
|
||||
*/
|
||||
public function index(GetNetworkRequest $request, Server $server): array
|
||||
{
|
||||
|
@ -132,11 +111,9 @@ class NetworkAllocationController extends ClientApiController
|
|||
/**
|
||||
* Delete an allocation from a server.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function delete(DeleteAllocationRequest $request, Server $server, Allocation $allocation)
|
||||
public function delete(DeleteAllocationRequest $request, Server $server, Allocation $allocation): JsonResponse
|
||||
{
|
||||
// Don't allow the deletion of allocations if the server does not have an
|
||||
// allocation limit set.
|
||||
|
|
|
@ -11,19 +11,12 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\SendPowerRequest;
|
|||
|
||||
class PowerController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Wings\DaemonPowerRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* PowerController constructor.
|
||||
*/
|
||||
public function __construct(DaemonPowerRepository $repository)
|
||||
public function __construct(private DaemonPowerRepository $repository)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,19 +12,12 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\GetServerRequest;
|
|||
|
||||
class ResourceUtilizationController extends ClientApiController
|
||||
{
|
||||
private DaemonServerRepository $repository;
|
||||
|
||||
private Repository $cache;
|
||||
|
||||
/**
|
||||
* ResourceUtilizationController constructor.
|
||||
*/
|
||||
public function __construct(Repository $cache, DaemonServerRepository $repository)
|
||||
public function __construct(private Repository $cache, private DaemonServerRepository $repository)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->cache = $cache;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,7 +29,7 @@ class ResourceUtilizationController extends ClientApiController
|
|||
*/
|
||||
public function __invoke(GetServerRequest $request, Server $server): array
|
||||
{
|
||||
$key = "resources:{$server->uuid}";
|
||||
$key = "resources:$server->uuid";
|
||||
$stats = $this->cache->remember($key, Carbon::now()->addSeconds(20), function () use ($server) {
|
||||
return $this->repository->setServer($server)->getDetails();
|
||||
});
|
||||
|
|
|
@ -25,33 +25,18 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Schedules\TriggerScheduleReques
|
|||
|
||||
class ScheduleController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ScheduleRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Schedules\ProcessScheduleService
|
||||
*/
|
||||
private $service;
|
||||
|
||||
/**
|
||||
* ScheduleController constructor.
|
||||
*/
|
||||
public function __construct(ScheduleRepository $repository, ProcessScheduleService $service)
|
||||
public function __construct(private ScheduleRepository $repository, private ProcessScheduleService $service)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all of the schedules belonging to a given server.
|
||||
*
|
||||
* @return array
|
||||
* Returns all the schedules belonging to a given server.
|
||||
*/
|
||||
public function index(ViewScheduleRequest $request, Server $server)
|
||||
public function index(ViewScheduleRequest $request, Server $server): array
|
||||
{
|
||||
$schedules = $server->schedules->loadMissing('tasks');
|
||||
|
||||
|
@ -63,12 +48,10 @@ class ScheduleController extends ClientApiController
|
|||
/**
|
||||
* Store a new schedule for a server.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function store(StoreScheduleRequest $request, Server $server)
|
||||
public function store(StoreScheduleRequest $request, Server $server): array
|
||||
{
|
||||
/** @var \Pterodactyl\Models\Schedule $model */
|
||||
$model = $this->repository->create([
|
||||
|
@ -96,10 +79,8 @@ class ScheduleController extends ClientApiController
|
|||
|
||||
/**
|
||||
* Returns a specific schedule for the server.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function view(ViewScheduleRequest $request, Server $server, Schedule $schedule)
|
||||
public function view(ViewScheduleRequest $request, Server $server, Schedule $schedule): array
|
||||
{
|
||||
if ($schedule->server_id !== $server->id) {
|
||||
throw new NotFoundHttpException();
|
||||
|
@ -115,13 +96,11 @@ class ScheduleController extends ClientApiController
|
|||
/**
|
||||
* Updates a given schedule with the new data provided.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function update(UpdateScheduleRequest $request, Server $server, Schedule $schedule)
|
||||
public function update(UpdateScheduleRequest $request, Server $server, Schedule $schedule): array
|
||||
{
|
||||
$active = (bool) $request->input('is_active');
|
||||
|
||||
|
@ -161,11 +140,9 @@ class ScheduleController extends ClientApiController
|
|||
* Executes a given schedule immediately rather than waiting on it's normally scheduled time
|
||||
* to pass. This does not care about the schedule state.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function execute(TriggerScheduleRequest $request, Server $server, Schedule $schedule)
|
||||
public function execute(TriggerScheduleRequest $request, Server $server, Schedule $schedule): JsonResponse
|
||||
{
|
||||
$this->service->handle($schedule, true);
|
||||
|
||||
|
@ -176,10 +153,8 @@ class ScheduleController extends ClientApiController
|
|||
|
||||
/**
|
||||
* Deletes a schedule and it's associated tasks.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function delete(DeleteScheduleRequest $request, Server $server, Schedule $schedule)
|
||||
public function delete(DeleteScheduleRequest $request, Server $server, Schedule $schedule): JsonResponse
|
||||
{
|
||||
$this->repository->delete($schedule->id);
|
||||
|
||||
|
|
|
@ -20,35 +20,25 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Schedules\StoreTaskRequest;
|
|||
|
||||
class ScheduleTaskController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\TaskRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* ScheduleTaskController constructor.
|
||||
*/
|
||||
public function __construct(TaskRepository $repository)
|
||||
public function __construct(private TaskRepository $repository)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new task for a given schedule and store it in the database.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\HttpForbiddenException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Service\ServiceLimitExceededException
|
||||
*/
|
||||
public function store(StoreTaskRequest $request, Server $server, Schedule $schedule)
|
||||
public function store(StoreTaskRequest $request, Server $server, Schedule $schedule): array
|
||||
{
|
||||
$limit = config('pterodactyl.client_features.schedules.per_schedule_task_limit', 10);
|
||||
if ($schedule->tasks()->count() >= $limit) {
|
||||
throw new ServiceLimitExceededException("Schedules may not have more than {$limit} tasks associated with them. Creating this task would put this schedule over the limit.");
|
||||
throw new ServiceLimitExceededException("Schedules may not have more than $limit tasks associated with them. Creating this task would put this schedule over the limit.");
|
||||
}
|
||||
|
||||
if ($server->backup_limit === 0 && $request->action === 'backup') {
|
||||
|
@ -81,13 +71,10 @@ class ScheduleTaskController extends ClientApiController
|
|||
/**
|
||||
* Updates a given task for a server.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\HttpForbiddenException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function update(StoreTaskRequest $request, Server $server, Schedule $schedule, Task $task)
|
||||
public function update(StoreTaskRequest $request, Server $server, Schedule $schedule, Task $task): array
|
||||
{
|
||||
if ($schedule->id !== $task->schedule_id || $server->id !== $schedule->server_id) {
|
||||
throw new NotFoundHttpException();
|
||||
|
@ -118,11 +105,9 @@ class ScheduleTaskController extends ClientApiController
|
|||
* Delete a given task for a schedule. If there are subsequent tasks stored in the database
|
||||
* for this schedule their sequence IDs are decremented properly.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function delete(ClientApiRequest $request, Server $server, Schedule $schedule, Task $task)
|
||||
public function delete(ClientApiRequest $request, Server $server, Schedule $schedule, Task $task): JsonResponse
|
||||
{
|
||||
if ($task->schedule_id !== $schedule->id || $schedule->server_id !== $server->id) {
|
||||
throw new NotFoundHttpException();
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
|
||||
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Repositories\Eloquent\SubuserRepository;
|
||||
use Pterodactyl\Transformers\Api\Client\ServerTransformer;
|
||||
use Pterodactyl\Services\Servers\GetUserPermissionsService;
|
||||
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
|
||||
|
@ -11,25 +10,12 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\GetServerRequest;
|
|||
|
||||
class ServerController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\SubuserRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\GetUserPermissionsService
|
||||
*/
|
||||
private $permissionsService;
|
||||
|
||||
/**
|
||||
* ServerController constructor.
|
||||
*/
|
||||
public function __construct(GetUserPermissionsService $permissionsService, SubuserRepository $repository)
|
||||
public function __construct(private GetUserPermissionsService $permissionsService)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
$this->permissionsService = $permissionsService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,38 +16,23 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Settings\ReinstallServerRequest
|
|||
|
||||
class SettingsController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ReinstallServerService
|
||||
*/
|
||||
private $reinstallServerService;
|
||||
|
||||
/**
|
||||
* SettingsController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ServerRepository $repository,
|
||||
ReinstallServerService $reinstallServerService
|
||||
private ServerRepository $repository,
|
||||
private ReinstallServerService $reinstallServerService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
$this->reinstallServerService = $reinstallServerService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames a server.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function rename(RenameServerRequest $request, Server $server)
|
||||
public function rename(RenameServerRequest $request, Server $server): JsonResponse
|
||||
{
|
||||
$this->repository->update($server->id, [
|
||||
'name' => $request->input('name'),
|
||||
|
@ -65,11 +50,9 @@ class SettingsController extends ClientApiController
|
|||
/**
|
||||
* Reinstalls the server on the daemon.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function reinstall(ReinstallServerRequest $request, Server $server)
|
||||
public function reinstall(ReinstallServerRequest $request, Server $server): JsonResponse
|
||||
{
|
||||
$this->reinstallServerService->handle($server);
|
||||
|
||||
|
@ -81,11 +64,9 @@ class SettingsController extends ClientApiController
|
|||
/**
|
||||
* Changes the Docker image in use by the server.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function dockerImage(SetDockerImageRequest $request, Server $server)
|
||||
public function dockerImage(SetDockerImageRequest $request, Server $server): JsonResponse
|
||||
{
|
||||
if (!in_array($server->image, array_values($server->egg->docker_images))) {
|
||||
throw new BadRequestHttpException('This server\'s Docker image has been manually set by an administrator and cannot be updated.');
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
|
|||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Services\Servers\StartupCommandService;
|
||||
use Pterodactyl\Services\Servers\VariableValidatorService;
|
||||
use Pterodactyl\Repositories\Eloquent\ServerVariableRepository;
|
||||
use Pterodactyl\Transformers\Api\Client\EggVariableTransformer;
|
||||
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
|
||||
|
@ -15,41 +14,22 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Startup\UpdateStartupVariableRe
|
|||
|
||||
class StartupController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\VariableValidatorService
|
||||
*/
|
||||
private $service;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerVariableRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\StartupCommandService
|
||||
*/
|
||||
private $startupCommandService;
|
||||
|
||||
/**
|
||||
* StartupController constructor.
|
||||
*/
|
||||
public function __construct(VariableValidatorService $service, StartupCommandService $startupCommandService, ServerVariableRepository $repository)
|
||||
{
|
||||
public function __construct(
|
||||
private StartupCommandService $startupCommandService,
|
||||
private ServerVariableRepository $repository
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->service = $service;
|
||||
$this->repository = $repository;
|
||||
$this->startupCommandService = $startupCommandService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the startup information for the server including all of the variables.
|
||||
*
|
||||
* @return array
|
||||
* Returns the startup information for the server including all the variables.
|
||||
*/
|
||||
public function index(GetStartupRequest $request, Server $server)
|
||||
public function index(GetStartupRequest $request, Server $server): array
|
||||
{
|
||||
$startup = $this->startupCommandService->handle($server, false);
|
||||
$startup = $this->startupCommandService->handle($server);
|
||||
|
||||
return $this->fractal->collection(
|
||||
$server->variables()->where('user_viewable', true)->get()
|
||||
|
@ -66,13 +46,11 @@ class StartupController extends ClientApiController
|
|||
/**
|
||||
* Updates a single variable for a server.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function update(UpdateStartupVariableRequest $request, Server $server)
|
||||
public function update(UpdateStartupVariableRequest $request, Server $server): array
|
||||
{
|
||||
/** @var \Pterodactyl\Models\EggVariable $variable */
|
||||
$variable = $server->variables()->where('env_variable', $request->input('key'))->first();
|
||||
|
@ -97,7 +75,7 @@ class StartupController extends ClientApiController
|
|||
$variable = $variable->refresh();
|
||||
$variable->server_value = $request->input('value');
|
||||
|
||||
$startup = $this->startupCommandService->handle($server, false);
|
||||
$startup = $this->startupCommandService->handle($server);
|
||||
|
||||
if ($variable->env_variable !== $request->input('value')) {
|
||||
Activity::event('server:startup.edit')
|
||||
|
|
|
@ -21,42 +21,21 @@ use Pterodactyl\Http\Requests\Api\Client\Servers\Subusers\UpdateSubuserRequest;
|
|||
|
||||
class SubuserController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\SubuserRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Subusers\SubuserCreationService
|
||||
*/
|
||||
private $creationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Wings\DaemonServerRepository
|
||||
*/
|
||||
private $serverRepository;
|
||||
|
||||
/**
|
||||
* SubuserController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
SubuserRepository $repository,
|
||||
SubuserCreationService $creationService,
|
||||
DaemonServerRepository $serverRepository
|
||||
private SubuserRepository $repository,
|
||||
private SubuserCreationService $creationService,
|
||||
private DaemonServerRepository $serverRepository
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->repository = $repository;
|
||||
$this->creationService = $creationService;
|
||||
$this->serverRepository = $serverRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the users associated with this server instance.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function index(GetSubuserRequest $request, Server $server)
|
||||
public function index(GetSubuserRequest $request, Server $server): array
|
||||
{
|
||||
return $this->fractal->collection($server->subusers)
|
||||
->transformWith($this->getTransformer(SubuserTransformer::class))
|
||||
|
@ -65,10 +44,8 @@ class SubuserController extends ClientApiController
|
|||
|
||||
/**
|
||||
* Returns a single subuser associated with this server instance.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function view(GetSubuserRequest $request)
|
||||
public function view(GetSubuserRequest $request): array
|
||||
{
|
||||
$subuser = $request->attributes->get('subuser');
|
||||
|
||||
|
@ -80,14 +57,12 @@ class SubuserController extends ClientApiController
|
|||
/**
|
||||
* Create a new subuser for the given server.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Subuser\ServerSubuserExistsException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Subuser\UserIsServerOwnerException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function store(StoreSubuserRequest $request, Server $server)
|
||||
public function store(StoreSubuserRequest $request, Server $server): array
|
||||
{
|
||||
$response = $this->creationService->handle(
|
||||
$server,
|
||||
|
@ -143,7 +118,7 @@ class SubuserController extends ClientApiController
|
|||
$this->serverRepository->setServer($server)->revokeUserJTI($subuser->user_id);
|
||||
} catch (DaemonConnectionException $exception) {
|
||||
// Don't block this request if we can't connect to the Wings instance. Chances are it is
|
||||
// offline in this event and the token will be invalid anyways once Wings boots back.
|
||||
// offline and the token will be invalid once Wings boots back.
|
||||
Log::warning($exception, ['user_id' => $subuser->user_id, 'server_id' => $server->id]);
|
||||
|
||||
$instance->property('revoked', false);
|
||||
|
@ -160,10 +135,8 @@ class SubuserController extends ClientApiController
|
|||
|
||||
/**
|
||||
* Removes a subusers from a server's assignment.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function delete(DeleteSubuserRequest $request, Server $server)
|
||||
public function delete(DeleteSubuserRequest $request, Server $server): JsonResponse
|
||||
{
|
||||
/** @var \Pterodactyl\Models\Subuser $subuser */
|
||||
$subuser = $request->attributes->get('subuser');
|
||||
|
|
|
@ -14,38 +14,23 @@ use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
|
|||
|
||||
class WebsocketController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeJWTService
|
||||
*/
|
||||
private $jwtService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\GetUserPermissionsService
|
||||
*/
|
||||
private $permissionsService;
|
||||
|
||||
/**
|
||||
* WebsocketController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
NodeJWTService $jwtService,
|
||||
GetUserPermissionsService $permissionsService
|
||||
private NodeJWTService $jwtService,
|
||||
private GetUserPermissionsService $permissionsService
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->jwtService = $jwtService;
|
||||
$this->permissionsService = $permissionsService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a one-time token that is sent along in every websocket call to the Daemon.
|
||||
* This is a signed JWT that the Daemon then uses the verify the user's identity, and
|
||||
* allows us to continually renew this token and avoid users mainitaining sessions wrongly,
|
||||
* This is a signed JWT that the Daemon then uses to verify the user's identity, and
|
||||
* allows us to continually renew this token and avoid users maintaining sessions wrongly,
|
||||
* as well as ensure that user's only perform actions they're allowed to.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function __invoke(ClientApiRequest $request, Server $server)
|
||||
public function __invoke(ClientApiRequest $request, Server $server): JsonResponse
|
||||
{
|
||||
$user = $request->user();
|
||||
if ($user->cannot(Permission::ACTION_WEBSOCKET_CONNECT, $server)) {
|
||||
|
|
|
@ -7,41 +7,22 @@ use Illuminate\Http\Request;
|
|||
use Illuminate\Http\Response;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use Illuminate\Contracts\Validation\Factory;
|
||||
use Pterodactyl\Services\Users\TwoFactorSetupService;
|
||||
use Pterodactyl\Services\Users\ToggleTwoFactorService;
|
||||
use Illuminate\Contracts\Validation\Factory as ValidationFactory;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
class TwoFactorController extends ClientApiController
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\TwoFactorSetupService
|
||||
*/
|
||||
private $setupService;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Validation\Factory
|
||||
*/
|
||||
private $validation;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Users\ToggleTwoFactorService
|
||||
*/
|
||||
private $toggleTwoFactorService;
|
||||
|
||||
/**
|
||||
* TwoFactorController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ToggleTwoFactorService $toggleTwoFactorService,
|
||||
TwoFactorSetupService $setupService,
|
||||
Factory $validation
|
||||
private ToggleTwoFactorService $toggleTwoFactorService,
|
||||
private TwoFactorSetupService $setupService,
|
||||
private ValidationFactory $validation
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->setupService = $setupService;
|
||||
$this->validation = $validation;
|
||||
$this->toggleTwoFactorService = $toggleTwoFactorService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,12 +30,10 @@ class TwoFactorController extends ClientApiController
|
|||
* it on their account. If two-factor is already enabled this endpoint
|
||||
* will return a 400 error.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function index(Request $request)
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
if ($request->user()->use_totp) {
|
||||
throw new BadRequestHttpException('Two-factor authentication is already enabled on this account.');
|
||||
|
@ -68,12 +47,10 @@ class TwoFactorController extends ClientApiController
|
|||
/**
|
||||
* Updates a user's account to have two-factor enabled.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store(Request $request): JsonResponse
|
||||
{
|
||||
$validator = $this->validation->make($request->all(), [
|
||||
'code' => ['required', 'string', 'size:6'],
|
||||
|
@ -101,10 +78,9 @@ class TwoFactorController extends ClientApiController
|
|||
* Disables two-factor authentication on an account if the password provided
|
||||
* is valid.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function delete(Request $request)
|
||||
public function delete(Request $request): JsonResponse
|
||||
{
|
||||
if (!password_verify($request->input('password') ?? '', $request->user()->password)) {
|
||||
throw new BadRequestHttpException('The password provided was not valid.');
|
||||
|
|
|
@ -4,12 +4,13 @@ namespace Pterodactyl\Http\Controllers\Api\Remote;
|
|||
|
||||
use Exception;
|
||||
use Carbon\Carbon;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Support\Str;
|
||||
use Pterodactyl\Models\User;
|
||||
use Webmozart\Assert\Assert;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\ActivityLog;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Pterodactyl\Models\ActivityLog;
|
||||
use Pterodactyl\Models\ActivityLogSubject;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Http\Requests\Api\Remote\ActivityEventRequest;
|
||||
|
@ -36,7 +37,7 @@ class ActivityProcessingController extends Controller
|
|||
|
||||
try {
|
||||
$when = Carbon::createFromFormat(
|
||||
Carbon::RFC3339,
|
||||
DateTimeInterface::RFC3339,
|
||||
preg_replace('/(\.\d+)Z$/', 'Z', $datum['timestamp']),
|
||||
'UTC'
|
||||
);
|
||||
|
|
|
@ -6,10 +6,9 @@ use Carbon\CarbonImmutable;
|
|||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Backup;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use League\Flysystem\AwsS3v3\AwsS3Adapter;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Extensions\Backups\BackupManager;
|
||||
use Pterodactyl\Repositories\Eloquent\BackupRepository;
|
||||
use Pterodactyl\Extensions\Filesystem\S3Filesystem;
|
||||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
|
||||
|
@ -17,35 +16,21 @@ class BackupRemoteUploadController extends Controller
|
|||
{
|
||||
public const DEFAULT_MAX_PART_SIZE = 5 * 1024 * 1024 * 1024;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\BackupRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Extensions\Backups\BackupManager
|
||||
*/
|
||||
private $backupManager;
|
||||
|
||||
/**
|
||||
* BackupRemoteUploadController constructor.
|
||||
*/
|
||||
public function __construct(BackupRepository $repository, BackupManager $backupManager)
|
||||
public function __construct(private BackupManager $backupManager)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->backupManager = $backupManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the required presigned urls to upload a backup to S3 cloud storage.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Throwable
|
||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
|
||||
*/
|
||||
public function __invoke(Request $request, string $backup)
|
||||
public function __invoke(Request $request, string $backup): JsonResponse
|
||||
{
|
||||
// Get the size query parameter.
|
||||
$size = (int) $request->query('size');
|
||||
|
@ -64,7 +49,7 @@ class BackupRemoteUploadController extends Controller
|
|||
|
||||
// Ensure we are using the S3 adapter.
|
||||
$adapter = $this->backupManager->adapter();
|
||||
if (!$adapter instanceof AwsS3Adapter) {
|
||||
if (!$adapter instanceof S3Filesystem) {
|
||||
throw new BadRequestHttpException('The configured backup adapter is not an S3 compatible adapter.');
|
||||
}
|
||||
|
||||
|
@ -116,7 +101,7 @@ class BackupRemoteUploadController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the configured maximum size of a single part in the multipart uplaod.
|
||||
* Get the configured maximum size of a single part in the multipart upload.
|
||||
*
|
||||
* The function tries to retrieve a configured value from the configuration.
|
||||
* If no value is specified, a fallback value will be used.
|
||||
|
@ -125,10 +110,8 @@ class BackupRemoteUploadController extends Controller
|
|||
* the fallback value will be used too.
|
||||
*
|
||||
* The fallback value is {@see BackupRemoteUploadController::DEFAULT_MAX_PART_SIZE}.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getConfiguredMaxPartSize()
|
||||
private function getConfiguredMaxPartSize(): int
|
||||
{
|
||||
$maxPartSize = (int) config('backups.max_part_size', self::DEFAULT_MAX_PART_SIZE);
|
||||
if ($maxPartSize <= 0) {
|
||||
|
|
|
@ -7,36 +7,28 @@ use Illuminate\Http\Request;
|
|||
use Pterodactyl\Models\Backup;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use League\Flysystem\AwsS3v3\AwsS3Adapter;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Extensions\Backups\BackupManager;
|
||||
use Pterodactyl\Extensions\Filesystem\S3Filesystem;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Pterodactyl\Http\Requests\Api\Remote\ReportBackupCompleteRequest;
|
||||
|
||||
class BackupStatusController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Extensions\Backups\BackupManager
|
||||
*/
|
||||
private $backupManager;
|
||||
|
||||
/**
|
||||
* BackupStatusController constructor.
|
||||
*/
|
||||
public function __construct(BackupManager $backupManager)
|
||||
public function __construct(private BackupManager $backupManager)
|
||||
{
|
||||
$this->backupManager = $backupManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles updating the state of a backup.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function index(ReportBackupCompleteRequest $request, string $backup)
|
||||
public function index(ReportBackupCompleteRequest $request, string $backup): JsonResponse
|
||||
{
|
||||
/** @var \Pterodactyl\Models\Backup $model */
|
||||
$model = Backup::query()->where('uuid', $backup)->firstOrFail();
|
||||
|
@ -65,7 +57,7 @@ class BackupStatusController extends Controller
|
|||
// Check if we are using the s3 backup adapter. If so, make sure we mark the backup as
|
||||
// being completed in S3 correctly.
|
||||
$adapter = $this->backupManager->adapter();
|
||||
if ($adapter instanceof AwsS3Adapter) {
|
||||
if ($adapter instanceof S3Filesystem) {
|
||||
$this->completeMultipartUpload($model, $adapter, $successful, $request->input('parts'));
|
||||
}
|
||||
});
|
||||
|
@ -81,8 +73,6 @@ class BackupStatusController extends Controller
|
|||
* The only thing the successful field does is update the entry value for the audit logs
|
||||
* table tracking for this restoration.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function restore(Request $request, string $backup): JsonResponse
|
||||
|
@ -107,7 +97,7 @@ class BackupStatusController extends Controller
|
|||
* @throws \Exception
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
protected function completeMultipartUpload(Backup $backup, AwsS3Adapter $adapter, bool $successful, ?array $parts): void
|
||||
protected function completeMultipartUpload(Backup $backup, S3Filesystem $adapter, bool $successful, ?array $parts): void
|
||||
{
|
||||
// This should never really happen, but if it does don't let us fall victim to Amazon's
|
||||
// wildly fun error messaging. Just stop the process right here.
|
||||
|
|
|
@ -10,23 +10,11 @@ use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
|||
|
||||
class EggInstallController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\EnvironmentService
|
||||
*/
|
||||
private $environment;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* EggInstallController constructor.
|
||||
*/
|
||||
public function __construct(EnvironmentService $environment, ServerRepositoryInterface $repository)
|
||||
public function __construct(private EnvironmentService $environment, private ServerRepositoryInterface $repository)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,49 +15,24 @@ use Pterodactyl\Services\Servers\ServerConfigurationStructureService;
|
|||
|
||||
class ServerDetailsController extends Controller
|
||||
{
|
||||
protected ConnectionInterface $connection;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Eggs\EggConfigurationService
|
||||
*/
|
||||
private $eggConfigurationService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ServerConfigurationStructureService
|
||||
*/
|
||||
private $configurationStructureService;
|
||||
|
||||
/**
|
||||
* ServerConfigurationController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ConnectionInterface $connection,
|
||||
ServerRepository $repository,
|
||||
ServerConfigurationStructureService $configurationStructureService,
|
||||
EggConfigurationService $eggConfigurationService
|
||||
protected ConnectionInterface $connection,
|
||||
private ServerRepository $repository,
|
||||
private ServerConfigurationStructureService $configurationStructureService,
|
||||
private EggConfigurationService $eggConfigurationService
|
||||
) {
|
||||
$this->eggConfigurationService = $eggConfigurationService;
|
||||
$this->repository = $repository;
|
||||
$this->configurationStructureService = $configurationStructureService;
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 string $uuid
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function __invoke(Request $request, $uuid)
|
||||
public function __invoke(Request $request, string $uuid): JsonResponse
|
||||
{
|
||||
$server = $this->repository->getByUuid($uuid);
|
||||
|
||||
|
@ -69,15 +44,13 @@ class ServerDetailsController extends Controller
|
|||
|
||||
/**
|
||||
* Lists all servers with their configurations that are assigned to the requesting node.
|
||||
*
|
||||
* @return \Pterodactyl\Http\Resources\Wings\ServerConfigurationCollection
|
||||
*/
|
||||
public function list(Request $request)
|
||||
public function list(Request $request): ServerConfigurationCollection
|
||||
{
|
||||
/** @var \Pterodactyl\Models\Node $node */
|
||||
$node = $request->attributes->get('node');
|
||||
|
||||
// Avoid run-away N+1 SQL queries by pre-loading the relationships that are used
|
||||
// Avoid run-away N+1 SQL queries by preloading the relationships that are used
|
||||
// within each of the services called below.
|
||||
$servers = Server::query()->with('allocations', 'egg', 'mounts', 'variables', 'location')
|
||||
->where('node_id', $node->id)
|
||||
|
@ -94,15 +67,13 @@ class ServerDetailsController extends Controller
|
|||
* do not get incorrectly stuck in installing/restoring from backup states since
|
||||
* a Wings reboot would completely stop those processes.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function resetState(Request $request)
|
||||
public function resetState(Request $request): JsonResponse
|
||||
{
|
||||
$node = $request->attributes->get('node');
|
||||
|
||||
// Get all of the servers that are currently marked as restoring from a backup
|
||||
// Get all the servers that are currently marked as restoring from a backup
|
||||
// on this node that do not have a failed backup tracked in the audit logs table
|
||||
// as well.
|
||||
//
|
||||
|
|
|
@ -15,30 +15,16 @@ use Pterodactyl\Http\Requests\Api\Remote\InstallationDataRequest;
|
|||
|
||||
class ServerInstallController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Events\Dispatcher
|
||||
*/
|
||||
private $eventDispatcher;
|
||||
|
||||
/**
|
||||
* ServerInstallController constructor.
|
||||
*/
|
||||
public function __construct(ServerRepository $repository, EventDispatcher $eventDispatcher)
|
||||
public function __construct(private ServerRepository $repository, private EventDispatcher $eventDispatcher)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns installation information for a server.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function index(Request $request, string $uuid): JsonResponse
|
||||
|
@ -56,8 +42,6 @@ class ServerInstallController extends Controller
|
|||
/**
|
||||
* Updates the installation state of a server.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
|
@ -77,7 +61,7 @@ class ServerInstallController extends Controller
|
|||
$isInitialInstall = is_null($server->installed_at);
|
||||
if ($isInitialInstall && config()->get('pterodactyl.email.send_install_notification', true)) {
|
||||
$this->eventDispatcher->dispatch(new ServerInstalled($server));
|
||||
} elseif (! $isInitialInstall && config()->get('pterodactyl.email.send_reinstall_notification', true)) {
|
||||
} elseif (!$isInitialInstall && config()->get('pterodactyl.email.send_reinstall_notification', true)) {
|
||||
$this->eventDispatcher->dispatch(new ServerInstalled($server));
|
||||
}
|
||||
|
||||
|
|
|
@ -16,68 +16,28 @@ use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
|||
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
||||
use Pterodactyl\Repositories\Wings\DaemonTransferRepository;
|
||||
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
||||
use Pterodactyl\Services\Servers\ServerConfigurationStructureService;
|
||||
|
||||
class ServerTransferController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Wings\DaemonServerRepository
|
||||
*/
|
||||
private $daemonServerRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Wings\DaemonTransferRepository
|
||||
*/
|
||||
private $daemonTransferRepository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ServerConfigurationStructureService
|
||||
*/
|
||||
private $configurationStructureService;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Nodes\NodeJWTService
|
||||
*/
|
||||
private $jwtService;
|
||||
|
||||
/**
|
||||
* ServerTransferController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ConnectionInterface $connection,
|
||||
ServerRepository $repository,
|
||||
DaemonServerRepository $daemonServerRepository,
|
||||
DaemonTransferRepository $daemonTransferRepository,
|
||||
ServerConfigurationStructureService $configurationStructureService,
|
||||
NodeJWTService $jwtService
|
||||
private ConnectionInterface $connection,
|
||||
private ServerRepository $repository,
|
||||
private DaemonServerRepository $daemonServerRepository,
|
||||
private DaemonTransferRepository $daemonTransferRepository,
|
||||
private NodeJWTService $jwtService
|
||||
) {
|
||||
$this->connection = $connection;
|
||||
$this->repository = $repository;
|
||||
$this->daemonServerRepository = $daemonServerRepository;
|
||||
$this->daemonTransferRepository = $daemonTransferRepository;
|
||||
$this->configurationStructureService = $configurationStructureService;
|
||||
$this->jwtService = $jwtService;
|
||||
}
|
||||
|
||||
/**
|
||||
* The daemon notifies us about the archive status.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function archive(Request $request, string $uuid)
|
||||
public function archive(Request $request, string $uuid): JsonResponse
|
||||
{
|
||||
$server = $this->repository->getByUuid($uuid);
|
||||
|
||||
|
@ -114,11 +74,9 @@ class ServerTransferController extends Controller
|
|||
/**
|
||||
* The daemon notifies us about a transfer failure.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function failure(string $uuid)
|
||||
public function failure(string $uuid): JsonResponse
|
||||
{
|
||||
$server = $this->repository->getByUuid($uuid);
|
||||
|
||||
|
@ -168,14 +126,12 @@ class ServerTransferController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Release all of the reserved allocations for this transfer and mark it as failed in
|
||||
* Release all the reserved allocations for this transfer and mark it as failed in
|
||||
* the database.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Throwable
|
||||
*/
|
||||
protected function processFailedTransfer(ServerTransfer $transfer)
|
||||
protected function processFailedTransfer(ServerTransfer $transfer): JsonResponse
|
||||
{
|
||||
$this->connection->transaction(function () use (&$transfer) {
|
||||
$transfer->forceFill(['successful' => false])->saveOrFail();
|
||||
|
|
|
@ -22,11 +22,8 @@ class SftpAuthenticationController extends Controller
|
|||
{
|
||||
use ThrottlesLogins;
|
||||
|
||||
protected GetUserPermissionsService $permissions;
|
||||
|
||||
public function __construct(GetUserPermissionsService $permissions)
|
||||
public function __construct(protected GetUserPermissionsService $permissions)
|
||||
{
|
||||
$this->permissions = $permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,7 +41,7 @@ class SftpAuthenticationController extends Controller
|
|||
if ($this->hasTooManyLoginAttempts($request)) {
|
||||
$seconds = $this->limiter()->availableIn($this->throttleKey($request));
|
||||
|
||||
throw new TooManyRequestsHttpException($seconds, "Too many login attempts for this account, please try again in {$seconds} seconds.");
|
||||
throw new TooManyRequestsHttpException($seconds, "Too many login attempts for this account, please try again in $seconds seconds.");
|
||||
}
|
||||
|
||||
$user = $this->getUser($request, $connection['username']);
|
||||
|
@ -60,7 +57,7 @@ class SftpAuthenticationController extends Controller
|
|||
$key = null;
|
||||
try {
|
||||
$key = PublicKeyLoader::loadPublicKey(trim($request->input('password')));
|
||||
} catch (NoKeyLoadedException $exception) {
|
||||
} catch (NoKeyLoadedException) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ use Illuminate\Auth\AuthManager;
|
|||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Auth\Events\Failed;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Pterodactyl\Events\Auth\DirectLogin;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
|
@ -21,24 +23,18 @@ abstract class AbstractLoginController extends Controller
|
|||
|
||||
/**
|
||||
* Lockout time for failed login requests.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $lockoutTime;
|
||||
protected int $lockoutTime;
|
||||
|
||||
/**
|
||||
* After how many attempts should logins be throttled and locked.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $maxLoginAttempts;
|
||||
protected int $maxLoginAttempts;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login / registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
protected string $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* LoginController constructor.
|
||||
|
@ -81,6 +77,8 @@ abstract class AbstractLoginController extends Controller
|
|||
|
||||
$this->auth->guard()->login($user, true);
|
||||
|
||||
Event::dispatch(new DirectLogin($user, true));
|
||||
|
||||
return new JsonResponse([
|
||||
'data' => [
|
||||
'complete' => true,
|
||||
|
@ -91,7 +89,7 @@ abstract class AbstractLoginController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is logging in using an email or username,.
|
||||
* Determine if the user is logging in using an email or username.
|
||||
*/
|
||||
protected function getField(string $input = null): string
|
||||
{
|
||||
|
@ -103,6 +101,6 @@ abstract class AbstractLoginController extends Controller
|
|||
*/
|
||||
protected function fireFailedLoginEvent(Authenticatable $user = null, array $credentials = [])
|
||||
{
|
||||
event(new Failed('auth', $user, $credentials));
|
||||
Event::dispatch(new Failed('auth', $user, $credentials));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,6 @@ class ForgotPasswordController extends Controller
|
|||
|
||||
/**
|
||||
* Get the response for a failed password reset link.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @param string $response
|
||||
*/
|
||||
protected function sendResetLinkFailedResponse(Request $request, $response): JsonResponse
|
||||
{
|
||||
|
|
|
@ -18,22 +18,15 @@ class LoginCheckpointController extends AbstractLoginController
|
|||
{
|
||||
private const TOKEN_EXPIRED_MESSAGE = 'The authentication token provided has expired, please refresh the page and try again.';
|
||||
|
||||
private ValidationFactory $validation;
|
||||
|
||||
private Google2FA $google2FA;
|
||||
|
||||
private Encrypter $encrypter;
|
||||
|
||||
/**
|
||||
* LoginCheckpointController constructor.
|
||||
*/
|
||||
public function __construct(Encrypter $encrypter, Google2FA $google2FA, ValidationFactory $validation)
|
||||
{
|
||||
public function __construct(
|
||||
private Encrypter $encrypter,
|
||||
private Google2FA $google2FA,
|
||||
private ValidationFactory $validation
|
||||
) {
|
||||
parent::__construct();
|
||||
|
||||
$this->google2FA = $google2FA;
|
||||
$this->encrypter = $encrypter;
|
||||
$this->validation = $validation;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,8 +34,6 @@ class LoginCheckpointController extends AbstractLoginController
|
|||
* token. Once a user has reached this stage it is assumed that they have already
|
||||
* provided a valid username and password.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse|void
|
||||
*
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException
|
||||
|
@ -67,7 +58,7 @@ class LoginCheckpointController extends AbstractLoginController
|
|||
try {
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = User::query()->findOrFail($details['user_id']);
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
} catch (ModelNotFoundException) {
|
||||
$this->sendFailedLoginResponse($request, null, self::TOKEN_EXPIRED_MESSAGE);
|
||||
}
|
||||
|
||||
|
@ -95,11 +86,9 @@ class LoginCheckpointController extends AbstractLoginController
|
|||
* Determines if a given recovery token is valid for the user account. If we find a matching token
|
||||
* it will be deleted from the database.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function isValidRecoveryToken(User $user, string $value)
|
||||
protected function isValidRecoveryToken(User $user, string $value): bool
|
||||
{
|
||||
foreach ($user->recoveryTokens as $token) {
|
||||
if (password_verify($value, $token->token)) {
|
||||
|
|
|
@ -14,22 +14,18 @@ use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|||
|
||||
class LoginController extends AbstractLoginController
|
||||
{
|
||||
private ViewFactory $view;
|
||||
|
||||
/**
|
||||
* LoginController constructor.
|
||||
*/
|
||||
public function __construct(ViewFactory $view)
|
||||
public function __construct(private ViewFactory $view)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle all incoming requests for the authentication routes and render the
|
||||
* base authentication view component. Vuejs will take over at this point and
|
||||
* turn the login area into a SPA.
|
||||
* base authentication view component. React will take over at this point and
|
||||
* turn the login area into an SPA.
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
|
@ -39,8 +35,6 @@ class LoginController extends AbstractLoginController
|
|||
/**
|
||||
* Handle a login request to the application.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse|void
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
|
@ -56,14 +50,14 @@ class LoginController extends AbstractLoginController
|
|||
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = User::query()->where($this->getField($username), $username)->firstOrFail();
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
} catch (ModelNotFoundException) {
|
||||
$this->sendFailedLoginResponse($request);
|
||||
}
|
||||
|
||||
// Ensure that the account is using a valid username and password before trying to
|
||||
// continue. Previously this was handled in the 2FA checkpoint, however that has
|
||||
// a flaw in which you can discover if an account exists simply by seeing if you
|
||||
// can proceede to the next step in the login process.
|
||||
// can proceed to the next step in the login process.
|
||||
if (!password_verify($request->input('password'), $user->password)) {
|
||||
$this->sendFailedLoginResponse($request, $user);
|
||||
}
|
||||
|
|
|
@ -20,39 +20,19 @@ class ResetPasswordController extends Controller
|
|||
|
||||
/**
|
||||
* The URL to redirect users to after password reset.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $redirectTo = '/';
|
||||
public string $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $hasTwoFactor = false;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Events\Dispatcher
|
||||
*/
|
||||
private $dispatcher;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
private $hasher;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
|
||||
*/
|
||||
private $userRepository;
|
||||
protected bool $hasTwoFactor = false;
|
||||
|
||||
/**
|
||||
* ResetPasswordController constructor.
|
||||
*/
|
||||
public function __construct(Dispatcher $dispatcher, Hasher $hasher, UserRepositoryInterface $userRepository)
|
||||
{
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->hasher = $hasher;
|
||||
$this->userRepository = $userRepository;
|
||||
public function __construct(
|
||||
private Dispatcher $dispatcher,
|
||||
private Hasher $hasher,
|
||||
private UserRepositoryInterface $userRepository
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,7 +44,7 @@ class ResetPasswordController extends Controller
|
|||
{
|
||||
// Here we will attempt to reset the user's password. If it is successful we
|
||||
// will update the password on an actual user model and persist it to the
|
||||
// database. Otherwise we will parse the error and return the response.
|
||||
// database. Otherwise, we will parse the error and return the response.
|
||||
$response = $this->broker()->reset(
|
||||
$this->credentials($request),
|
||||
function ($user, $password) {
|
||||
|
|
|
@ -2,31 +2,27 @@
|
|||
|
||||
namespace Pterodactyl\Http\Controllers\Base;
|
||||
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\View\Factory as ViewFactory;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
|
||||
class IndexController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* IndexController constructor.
|
||||
*/
|
||||
public function __construct(ServerRepositoryInterface $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
public function __construct(
|
||||
protected ServerRepositoryInterface $repository,
|
||||
protected ViewFactory $view
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns listing of user's servers.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
public function index(): View
|
||||
{
|
||||
return view('templates/base.core');
|
||||
return $this->view->make('templates/base.core');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,8 @@ class LocaleController extends Controller
|
|||
|
||||
/**
|
||||
* Returns translation data given a specific locale and namespace.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function __invoke(Request $request)
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$locales = explode(' ', $request->input('locale') ?? '');
|
||||
$namespaces = explode(' ', $request->input('namespace') ?? '');
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Pterodactyl\Http;
|
||||
|
||||
use Fruitcake\Cors\HandleCors;
|
||||
use Illuminate\Auth\Middleware\Authorize;
|
||||
use Illuminate\Http\Middleware\HandleCors;
|
||||
use Illuminate\Auth\Middleware\Authenticate;
|
||||
use Illuminate\Http\Middleware\TrustProxies;
|
||||
use Pterodactyl\Http\Middleware\TrimStrings;
|
||||
|
@ -38,8 +38,6 @@ class Kernel extends HttpKernel
|
|||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
TrustProxies::class,
|
||||
|
@ -52,8 +50,6 @@ class Kernel extends HttpKernel
|
|||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
|
@ -89,8 +85,6 @@ class Kernel extends HttpKernel
|
|||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => Authenticate::class,
|
||||
|
|
|
@ -14,10 +14,8 @@ class TrackAPIKey
|
|||
* API key, or it is just a cookie authenticated session. This data is set in a
|
||||
* request singleton so that all tracked activity log events are properly associated
|
||||
* with the given API key.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
if ($request->user()) {
|
||||
$token = $request->user()->currentAccessToken();
|
||||
|
|
|
@ -13,10 +13,8 @@ class ServerInstalled
|
|||
{
|
||||
/**
|
||||
* Checks that the server is installed before allowing access through the route.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
/** @var \Pterodactyl\Models\Server|null $server */
|
||||
$server = $request->route()->parameter('server');
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
|
@ -18,11 +11,9 @@ class AdminAuthenticate
|
|||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
if (!$request->user() || !$request->user()->root_admin) {
|
||||
throw new AccessDeniedHttpException();
|
||||
|
|
|
@ -11,10 +11,8 @@ class AuthenticateApplicationUser
|
|||
/**
|
||||
* Authenticate that the currently authenticated user is an administrator
|
||||
* and should be allowed to proceed through the application API.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User|null $user */
|
||||
$user = $request->user();
|
||||
|
|
|
@ -15,12 +15,10 @@ class AuthenticateIPAccess
|
|||
/**
|
||||
* Determine if a request IP has permission to access the API.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
/** @var \Laravel\Sanctum\TransientToken|\Pterodactyl\Models\ApiKey $token */
|
||||
$token = $request->user()->currentAccessToken();
|
||||
|
|
|
@ -11,10 +11,8 @@ class RequireClientApiKey
|
|||
/**
|
||||
* Blocks a request to the Client API endpoints if the user is providing an API token
|
||||
* that was created for the application API.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
public function handle(Request $request, \Closure $next): mixed
|
||||
{
|
||||
$token = $request->user()->currentAccessToken();
|
||||
|
||||
|
|
|
@ -5,40 +5,29 @@ namespace Pterodactyl\Http\Middleware\Api\Client\Server;
|
|||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Pterodactyl\Exceptions\Http\Server\ServerStateConflictException;
|
||||
|
||||
class AuthenticateServerAccess
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* Routes that this middleware should not apply to if the user is an admin.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $except = [
|
||||
protected array $except = [
|
||||
'api:client:server.ws',
|
||||
];
|
||||
|
||||
/**
|
||||
* AuthenticateServerAccess constructor.
|
||||
*/
|
||||
public function __construct(ServerRepositoryInterface $repository)
|
||||
public function __construct()
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate that this server exists and is not suspended or marked as installing.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = $request->user();
|
||||
|
|
|
@ -25,10 +25,8 @@ class ResourceBelongsToServer
|
|||
* This is critical to ensuring that all subsequent logic is using exactly the
|
||||
* server that is expected, and that we're not accessing a resource completely
|
||||
* unrelated to the server provided in the request.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
$params = $request->route()->parameters();
|
||||
if (is_null($params) || !$params['server'] instanceof Server) {
|
||||
|
@ -59,8 +57,8 @@ class ResourceBelongsToServer
|
|||
throw $exception;
|
||||
}
|
||||
break;
|
||||
// Regular users are a special case here as we need to make sure they're
|
||||
// currently assigned as a subuser on the server.
|
||||
// Regular users are a special case here as we need to make sure they're
|
||||
// currently assigned as a subuser on the server.
|
||||
case User::class:
|
||||
$subuser = $server->subusers()->where('user_id', $model->id)->first();
|
||||
if (is_null($subuser)) {
|
||||
|
@ -70,8 +68,8 @@ class ResourceBelongsToServer
|
|||
// in the underlying logic.
|
||||
$request->attributes->set('subuser', $subuser);
|
||||
break;
|
||||
// Tasks are special since they're (currently) the only item in the API
|
||||
// that requires something in addition to the server in order to be accessed.
|
||||
// Tasks are special since they're (currently) the only item in the API
|
||||
// that requires something in addition to the server in order to be accessed.
|
||||
case Task::class:
|
||||
$schedule = $request->route()->parameter('schedule');
|
||||
if ($model->schedule_id !== $schedule->id || $schedule->server_id !== $server->id) {
|
||||
|
|
|
@ -10,10 +10,8 @@ class SubstituteClientBindings extends SubstituteBindings
|
|||
{
|
||||
/**
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
public function handle($request, Closure $next): mixed
|
||||
{
|
||||
// Override default behavior of the model binding to use a specific table
|
||||
// column rather than the default 'id'.
|
||||
|
|
|
@ -13,42 +13,26 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
|||
|
||||
class DaemonAuthenticate
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\NodeRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Encryption\Encrypter
|
||||
*/
|
||||
private $encrypter;
|
||||
|
||||
/**
|
||||
* Daemon routes that this middleware should be skipped on.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
protected array $except = [
|
||||
'daemon.configuration',
|
||||
];
|
||||
|
||||
/**
|
||||
* DaemonAuthenticate constructor.
|
||||
*/
|
||||
public function __construct(Encrypter $encrypter, NodeRepository $repository)
|
||||
public function __construct(private Encrypter $encrypter, private NodeRepository $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->encrypter = $encrypter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a request from the daemon can be properly attributed back to a single node instance.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
if (in_array($request->route()->getName(), $this->except)) {
|
||||
return $next($request);
|
||||
|
|
|
@ -13,10 +13,8 @@ class IsValidJson
|
|||
* Throw an exception if the request should be valid JSON data but there is an error while
|
||||
* parsing the data. This avoids confusing validation errors where every field is flagged and
|
||||
* it is not immediately clear that there is an issue with the JSON being passed.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
if ($request->isJson() && !empty($request->getContent())) {
|
||||
try {
|
||||
|
|
|
@ -8,8 +8,6 @@ class EncryptCookies extends BaseEncrypter
|
|||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [];
|
||||
}
|
||||
|
|
|
@ -8,25 +8,17 @@ use Illuminate\Foundation\Application;
|
|||
|
||||
class LanguageMiddleware
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Foundation\Application
|
||||
*/
|
||||
private $app;
|
||||
|
||||
/**
|
||||
* LanguageMiddleware constructor.
|
||||
*/
|
||||
public function __construct(Application $app)
|
||||
public function __construct(private Application $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request and set the user's preferred language.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
$this->app->setLocale($request->user()->language ?? config('app.locale', 'en'));
|
||||
|
||||
|
|
|
@ -3,31 +3,22 @@
|
|||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
|
||||
class MaintenanceMiddleware
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Routing\ResponseFactory
|
||||
*/
|
||||
private $response;
|
||||
|
||||
/**
|
||||
* MaintenanceMiddleware constructor.
|
||||
*/
|
||||
public function __construct(ResponseFactory $response)
|
||||
public function __construct(private ResponseFactory $response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
/** @var \Pterodactyl\Models\Server $server */
|
||||
$server = $request->attributes->get('server');
|
||||
|
|
|
@ -8,25 +8,17 @@ use Illuminate\Auth\AuthManager;
|
|||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Auth\AuthManager
|
||||
*/
|
||||
private $authManager;
|
||||
|
||||
/**
|
||||
* RedirectIfAuthenticated constructor.
|
||||
*/
|
||||
public function __construct(AuthManager $authManager)
|
||||
public function __construct(private AuthManager $authManager)
|
||||
{
|
||||
$this->authManager = $authManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, string $guard = null)
|
||||
public function handle(Request $request, Closure $next, string $guard = null): mixed
|
||||
{
|
||||
if ($this->authManager->guard($guard)->check()) {
|
||||
return redirect()->route('index');
|
||||
|
|
|
@ -15,23 +15,15 @@ class RequireTwoFactorAuthentication
|
|||
public const LEVEL_ALL = 2;
|
||||
|
||||
/**
|
||||
* @var \Prologue\Alerts\AlertsMessageBag
|
||||
* The route to redirect a user to enable 2FA.
|
||||
*/
|
||||
private $alert;
|
||||
|
||||
/**
|
||||
* The route to redirect a user to to enable 2FA.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectRoute = '/account';
|
||||
protected string $redirectRoute = '/account';
|
||||
|
||||
/**
|
||||
* RequireTwoFactorAuthentication constructor.
|
||||
*/
|
||||
public function __construct(AlertsMessageBag $alert)
|
||||
public function __construct(private AlertsMessageBag $alert)
|
||||
{
|
||||
$this->alert = $alert;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,11 +32,9 @@ class RequireTwoFactorAuthentication
|
|||
* order to perform actions. If so, we check the level at which it is required (all users
|
||||
* or just admins) and then check if the user has enabled it for their account.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\TwoFactorAuthRequiredException
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
/** @var \Pterodactyl\Models\User $user */
|
||||
$user = $request->user();
|
||||
|
|
|
@ -8,8 +8,6 @@ class TrimStrings extends BaseTrimmer
|
|||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'password',
|
||||
|
|
|
@ -10,8 +10,6 @@ class VerifyCsrfToken extends BaseVerifier
|
|||
* The URIs that should be excluded from CSRF verification. These are
|
||||
* never hit by the front-end, and require specific token validation
|
||||
* to work.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $except = ['remote/*', 'daemon/*'];
|
||||
}
|
||||
|
|
|
@ -14,33 +14,17 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
|
|||
|
||||
class VerifyReCaptcha
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Events\Dispatcher
|
||||
*/
|
||||
private $dispatcher;
|
||||
|
||||
/**
|
||||
* VerifyReCaptcha constructor.
|
||||
*/
|
||||
public function __construct(Dispatcher $dispatcher, Repository $config)
|
||||
public function __construct(private Dispatcher $dispatcher, private Repository $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
if (!$this->config->get('recaptcha.enabled')) {
|
||||
return $next($request);
|
||||
|
|
|
@ -8,18 +8,14 @@ abstract class AdminFormRequest extends FormRequest
|
|||
{
|
||||
/**
|
||||
* The rules to apply to the incoming form request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract public function rules();
|
||||
abstract public function rules(): array;
|
||||
|
||||
/**
|
||||
* Determine if the user is an admin and has permission to access this
|
||||
* form controller in the first place.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
public function authorize(): bool
|
||||
{
|
||||
if (is_null($this->user())) {
|
||||
return false;
|
||||
|
@ -31,10 +27,8 @@ abstract class AdminFormRequest extends FormRequest
|
|||
/**
|
||||
* Return only the fields that we are interested in from the request.
|
||||
* This will include empty fields as a null value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function normalize(array $only = null)
|
||||
public function normalize(array $only = null): array
|
||||
{
|
||||
return $this->only($only ?? array_keys($this->rules()));
|
||||
}
|
||||
|
|
|
@ -9,12 +9,10 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|||
class StoreApplicationApiKeyRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
$modelRules = ApiKey::getRules();
|
||||
|
||||
|
@ -23,10 +21,7 @@ class StoreApplicationApiKeyRequest extends AdminFormRequest
|
|||
})->merge(['memo' => $modelRules['memo']])->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'memo' => 'Description',
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin;
|
||||
|
||||
class BaseFormRequest extends AdminFormRequest
|
||||
{
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'company' => 'required|between:1,256',
|
||||
|
|
|
@ -3,13 +3,11 @@
|
|||
namespace Pterodactyl\Http\Requests\Admin;
|
||||
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
|
||||
class DatabaseHostFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
if ($this->method() !== 'POST') {
|
||||
return DatabaseHost::getRulesForUpdate($this->route()->parameter('host'));
|
||||
|
@ -20,10 +18,8 @@ class DatabaseHostFormRequest extends AdminFormRequest
|
|||
|
||||
/**
|
||||
* Modify submitted data before it is passed off to the validator.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function getValidatorInstance()
|
||||
protected function getValidatorInstance(): Validator
|
||||
{
|
||||
if (!$this->filled('node_id')) {
|
||||
$this->merge(['node_id' => null]);
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Egg;
|
||||
|
||||
|
@ -13,10 +6,7 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|||
|
||||
class EggFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|max:191',
|
||||
|
@ -39,9 +29,6 @@ class EggFormRequest extends AdminFormRequest
|
|||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Illuminate\Contracts\Validation\Validator $validator
|
||||
*/
|
||||
public function withValidator($validator)
|
||||
{
|
||||
$validator->sometimes('config_from', 'exists:eggs,id', function () {
|
||||
|
@ -49,7 +36,7 @@ class EggFormRequest extends AdminFormRequest
|
|||
});
|
||||
}
|
||||
|
||||
public function validated(): array
|
||||
public function validated($key = null, $default = null): array
|
||||
{
|
||||
$data = parent::validated();
|
||||
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Egg;
|
||||
|
||||
|
@ -13,10 +6,7 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|||
|
||||
class EggImportFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'import_file' => 'bail|required|file|max:1000|mimetypes:application/json,text/plain',
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Admin\Egg;
|
||||
|
||||
|
@ -14,11 +7,9 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
|||
class EggScriptFormRequest extends AdminFormRequest
|
||||
{
|
||||
/**
|
||||
* Return the rules to be used when validating the sent data in the request.
|
||||
*
|
||||
* @return array
|
||||
* Return the rules to be used when validating the data sent in the request.
|
||||
*/
|
||||
public function rules()
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'script_install' => 'sometimes|nullable|string',
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue