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
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue