From 7ed2be50fdcc40b3ec305229a20393e028394108 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Wed, 14 Dec 2022 18:04:16 -0700 Subject: [PATCH] php-cs-fixer and phpstan --- app/Console/Commands/InfoCommand.php | 8 +- .../Nodes/NodeDeploymentController.php | 2 +- .../Databases/UpdateDatabaseRequest.php | 2 +- .../Locations/UpdateLocationRequest.php | 2 +- .../Application/Mounts/UpdateMountRequest.php | 2 +- .../Application/Nests/UpdateNestRequest.php | 2 +- .../Application/Nodes/StoreNodeRequest.php | 11 +-- .../Application/Nodes/UpdateNodeRequest.php | 2 +- .../Application/Roles/UpdateRoleRequest.php | 2 +- .../UpdateServerBuildConfigurationRequest.php | 2 +- .../Servers/UpdateServerDetailsRequest.php | 2 +- .../Servers/UpdateServerStartupRequest.php | 2 +- .../Application/Users/UpdateUserRequest.php | 2 +- .../Api/Client/Account/UpdateEmailRequest.php | 1 + app/Models/AdminRole.php | 17 +--- app/Models/EggVariable.php | 13 ++- app/Models/Node.php | 92 ++++++++++++------- .../Eggs/Sharing/EggImporterService.php | 2 +- .../Eggs/Variables/VariableUpdateService.php | 3 +- .../Helpers/SoftwareVersionService.php | 2 +- .../Telemetry/TelemetryCollectionService.php | 6 +- .../Application/ServerVariableTransformer.php | 21 ----- ...database_host_id_column_to_nodes_table.php | 4 +- ...658_change_port_columns_on_nodes_table.php | 6 +- phpstan.neon | 3 - 25 files changed, 102 insertions(+), 109 deletions(-) diff --git a/app/Console/Commands/InfoCommand.php b/app/Console/Commands/InfoCommand.php index 25c774405..6648da298 100644 --- a/app/Console/Commands/InfoCommand.php +++ b/app/Console/Commands/InfoCommand.php @@ -15,7 +15,7 @@ class InfoCommand extends Command /** * VersionCommand constructor. */ - public function __construct(private ConfigRepository $config, private SoftwareVersionService $versionService) + public function __construct(private ConfigRepository $config, private SoftwareVersionService $softwareVersionService) { parent::__construct(); } @@ -27,9 +27,9 @@ class InfoCommand extends Command { $this->output->title('Version Information'); $this->table([], [ - ['Panel Version', $this->config->get('app.version')], - ['Latest Version', $this->versionService->getPanel()], - ['Up-to-Date', $this->versionService->isLatestPanel() ? 'Yes' : $this->formatText('No', 'bg=red')], + ['Panel Version', $this->softwareVersionService->getCurrentVersion()], + ['Latest Version', $this->softwareVersionService->getLatestPanel()], + ['Up-to-Date', $this->softwareVersionService->isLatestPanel() ? 'Yes' : $this->formatText('No', 'bg=red')], ['Unique Identifier', $this->config->get('pterodactyl.service.author')], ], 'compact'); diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php b/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php index fa09e9707..c3e9303a7 100644 --- a/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php +++ b/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php @@ -30,7 +30,7 @@ class NodeDeploymentController extends ApplicationApiController $nodes = $this->viableNodesService->setLocations($data['location_ids'] ?? []) ->setMemory($data['memory']) ->setDisk($data['disk']) - ->handle($request->query('per_page'), $request->query('page')); // @phpstan-ignore-line + ->handle($request->query('per_page'), $request->query('page')); return $this->fractal->collection($nodes) ->transformWith(NodeTransformer::class) diff --git a/app/Http/Requests/Api/Application/Databases/UpdateDatabaseRequest.php b/app/Http/Requests/Api/Application/Databases/UpdateDatabaseRequest.php index 476719005..51b9f1a59 100644 --- a/app/Http/Requests/Api/Application/Databases/UpdateDatabaseRequest.php +++ b/app/Http/Requests/Api/Application/Databases/UpdateDatabaseRequest.php @@ -8,6 +8,6 @@ class UpdateDatabaseRequest extends StoreDatabaseRequest { public function rules(array $rules = null): array { - return $rules ?? DatabaseHost::getRulesForUpdate($this->route()->parameter('databaseHost')->id); + return $rules ?? DatabaseHost::getRulesForUpdate($this->route()->parameter('databaseHost')); } } diff --git a/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php b/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php index 91ece11fe..f5d79deb2 100644 --- a/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php +++ b/app/Http/Requests/Api/Application/Locations/UpdateLocationRequest.php @@ -8,7 +8,7 @@ class UpdateLocationRequest extends StoreLocationRequest { public function rules(): array { - $locationId = $this->route()->parameter('location')->id; + $locationId = $this->route()->parameter('location'); return collect(Location::getRulesForUpdate($locationId))->only([ 'short', diff --git a/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php b/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php index b9b51b12c..c1317f784 100644 --- a/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php +++ b/app/Http/Requests/Api/Application/Mounts/UpdateMountRequest.php @@ -8,6 +8,6 @@ class UpdateMountRequest extends StoreMountRequest { public function rules(array $rules = null): array { - return $rules ?? Mount::getRulesForUpdate($this->route()->parameter('mount')->id); + return $rules ?? Mount::getRulesForUpdate($this->route()->parameter('mount')); } } diff --git a/app/Http/Requests/Api/Application/Nests/UpdateNestRequest.php b/app/Http/Requests/Api/Application/Nests/UpdateNestRequest.php index 1c7aaec89..30016cd01 100644 --- a/app/Http/Requests/Api/Application/Nests/UpdateNestRequest.php +++ b/app/Http/Requests/Api/Application/Nests/UpdateNestRequest.php @@ -8,6 +8,6 @@ class UpdateNestRequest extends StoreNestRequest { public function rules(array $rules = null): array { - return $rules ?? Nest::getRulesForUpdate($this->route()->parameter('nest')->id); + return $rules ?? Nest::getRulesForUpdate($this->route()->parameter('nest')); } } diff --git a/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php index 803f0e6a3..6d7629302 100644 --- a/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/StoreNodeRequest.php @@ -42,10 +42,8 @@ class StoreNodeRequest extends ApplicationApiRequest /** * Fields to rename for clarity in the API response. - * - * @return array */ - public function attributes() + public function attributes(): array { return [ 'daemon_base' => 'Daemon Base Path', @@ -58,13 +56,8 @@ class StoreNodeRequest extends ApplicationApiRequest /** * Change the formatting of some data keys in the validated response data * to match what the application expects in the services. - * - * @param string|null $key - * @param string|array|null $default - * - * @return mixed */ - public function validated($key = null, $default = null) + public function validated($key = null, $default = null): array { $response = parent::validated(); $response['daemon_base'] = $response['daemon_base'] ?? Node::DEFAULT_DAEMON_BASE; diff --git a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php index 05daebc2e..ae8aab357 100644 --- a/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php +++ b/app/Http/Requests/Api/Application/Nodes/UpdateNodeRequest.php @@ -8,6 +8,6 @@ class UpdateNodeRequest extends StoreNodeRequest { public function rules(array $rules = null): array { - return parent::rules($rules ?? Node::getRulesForUpdate($this->route()->parameter('node')->id)); + return parent::rules($rules ?? Node::getRulesForUpdate($this->route()->parameter('node'))); } } diff --git a/app/Http/Requests/Api/Application/Roles/UpdateRoleRequest.php b/app/Http/Requests/Api/Application/Roles/UpdateRoleRequest.php index de3221abd..de36ff33e 100644 --- a/app/Http/Requests/Api/Application/Roles/UpdateRoleRequest.php +++ b/app/Http/Requests/Api/Application/Roles/UpdateRoleRequest.php @@ -8,6 +8,6 @@ class UpdateRoleRequest extends StoreRoleRequest { public function rules(array $rules = null): array { - return $rules ?? AdminRole::getRulesForUpdate($this->route()->parameter('role')->id); + return $rules ?? AdminRole::getRulesForUpdate($this->route()->parameter('role')); } } diff --git a/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php b/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php index 1e2f12051..03bbd08ec 100644 --- a/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php +++ b/app/Http/Requests/Api/Application/Servers/UpdateServerBuildConfigurationRequest.php @@ -13,7 +13,7 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest */ public function rules(): array { - $rules = Server::getRulesForUpdate($this->route()->parameter('server')->id); + $rules = Server::getRulesForUpdate($this->route()->parameter('server')); return [ 'allocation' => $rules['allocation_id'], diff --git a/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php b/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php index a4551edcd..ce181bae3 100644 --- a/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php +++ b/app/Http/Requests/Api/Application/Servers/UpdateServerDetailsRequest.php @@ -12,7 +12,7 @@ class UpdateServerDetailsRequest extends ServerWriteRequest */ public function rules(): array { - $rules = Server::getRulesForUpdate($this->route()->parameter('server')->id); + $rules = Server::getRulesForUpdate($this->route()->parameter('server')); return [ 'external_id' => $rules['external_id'], diff --git a/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php b/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php index d8f92a1f8..fb16ffdac 100644 --- a/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php +++ b/app/Http/Requests/Api/Application/Servers/UpdateServerStartupRequest.php @@ -9,7 +9,7 @@ class UpdateServerStartupRequest extends ApplicationApiRequest { public function rules(): array { - $rules = Server::getRulesForUpdate($this->route()->parameter('server')->id); + $rules = Server::getRulesForUpdate($this->route()->parameter('server')); return [ 'startup' => $rules['startup'], diff --git a/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php b/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php index ba6d9da2c..3d7d9f75c 100644 --- a/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php +++ b/app/Http/Requests/Api/Application/Users/UpdateUserRequest.php @@ -8,6 +8,6 @@ class UpdateUserRequest extends StoreUserRequest { public function rules(array $rules = null): array { - return parent::rules($rules ?? User::getRulesForUpdate($this->route()->parameter('user')->id)); + return parent::rules($rules ?? User::getRulesForUpdate($this->route()->parameter('user'))); } } diff --git a/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php b/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php index 6287ba585..083e94058 100644 --- a/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php +++ b/app/Http/Requests/Api/Client/Account/UpdateEmailRequest.php @@ -11,6 +11,7 @@ use Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException; class UpdateEmailRequest extends ClientApiRequest { /** + * @throws \Illuminate\Contracts\Container\BindingResolutionException * @throws \Pterodactyl\Exceptions\Http\Base\InvalidPasswordProvidedException */ public function authorize(): bool diff --git a/app/Models/AdminRole.php b/app/Models/AdminRole.php index 51b485495..f03368392 100644 --- a/app/Models/AdminRole.php +++ b/app/Models/AdminRole.php @@ -2,6 +2,8 @@ namespace Pterodactyl\Models; +use Illuminate\Database\Eloquent\Relations\HasMany; + /** * @property int $id * @property string $name @@ -19,15 +21,11 @@ class AdminRole extends Model /** * The table associated with the model. - * - * @var string */ protected $table = 'admin_roles'; /** * Fields that are mass assignable. - * - * @var array */ protected $fillable = [ 'name', @@ -37,8 +35,6 @@ class AdminRole extends Model /** * Cast values to correct type. - * - * @var array */ protected $casts = [ 'sort_id' => 'int', @@ -51,17 +47,12 @@ class AdminRole extends Model 'sort_id' => 'sometimes|numeric', ]; - /** - * @var bool - */ public $timestamps = false; /** - * Gets the permissions associated with a admin role. - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany + * Gets the permissions associated with an admin role. */ - public function permissions() + public function permissions(): HasMany { return $this->hasMany(Permission::class); } diff --git a/app/Models/EggVariable.php b/app/Models/EggVariable.php index dbbf8e0bd..b0e15bc5c 100644 --- a/app/Models/EggVariable.php +++ b/app/Models/EggVariable.php @@ -2,8 +2,8 @@ namespace Pterodactyl\Models; -use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Database\Eloquent\Relations\BelongsTo; /** * @property int $id @@ -19,7 +19,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany; * @property \Carbon\CarbonImmutable $updated_at * @property bool $required * @property Egg $egg - * @property ServerVariable $serverVariable + * @property ServerVariable $serverVariables * @property string $field_type * * The "server_value" variable is only present on the object if you've loaded this model @@ -81,15 +81,18 @@ class EggVariable extends Model return in_array('required', explode('|', $this->rules)); } - public function egg(): HasOne + /** + * Returns the egg that this variable belongs to. + */ + public function egg(): BelongsTo { - return $this->hasOne(Egg::class); + return $this->belongsTo(Egg::class); } /** * Return server variables associated with this variable. */ - public function serverVariable(): HasMany + public function serverVariables(): HasMany { return $this->hasMany(ServerVariable::class, 'variable_id'); } diff --git a/app/Models/Node.php b/app/Models/Node.php index a1d9688f6..eb7d5cc25 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -19,8 +19,13 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough; * @property string $name * @property string|null $description * @property int $location_id - * @property string $fqdn + * @property int|null $database_host_id * @property string $scheme + * @property string $fqdn + * @property int $listen_port_http + * @property int $listen_port_sftp + * @property int $public_port_http + * @property int $public_port_sftp * @property bool $behind_proxy * @property bool $maintenance_mode * @property int $memory @@ -32,17 +37,16 @@ use Illuminate\Database\Eloquent\Relations\HasManyThrough; * @property int $upload_size * @property string $daemon_token_id * @property string $daemon_token - * @property int $daemonListen - * @property int $daemonSFTP - * @property string $daemonBase + * @property string $daemon_base * @property int $servers_count * @property \Carbon\Carbon $created_at * @property \Carbon\Carbon $updated_at - * @property Location $location - * @property int[]|\Illuminate\Support\Collection $ports - * @property Mount[]|Collection $mounts - * @property Server[]|Collection $servers * @property Allocation[]|Collection $allocations + * @property \Pterodactyl\Models\DatabaseHost|null $databaseHost + * @property Location $location + * @property Mount[]|Collection $mounts + * @property int[]|\Illuminate\Support\Collection $ports + * @property Server[]|Collection $servers */ class Node extends Model { @@ -54,6 +58,11 @@ class Node extends Model */ public const RESOURCE_NAME = 'node'; + /** + * The default location of server files on the Wings instance. + */ + public const DEFAULT_DAEMON_BASE = '/var/lib/pterodactyl/volumes'; + public const DAEMON_TOKEN_ID_LENGTH = 16; public const DAEMON_TOKEN_LENGTH = 64; @@ -72,10 +81,13 @@ class Node extends Model */ protected $casts = [ 'location_id' => 'integer', + 'database_host_id' => 'integer', + 'listen_port_http' => 'integer', + 'listen_port_sftp' => 'integer', + 'public_port_http' => 'integer', + 'public_port_sftp' => 'integer', 'memory' => 'integer', 'disk' => 'integer', - 'daemonListen' => 'integer', - 'daemonSFTP' => 'integer', 'behind_proxy' => 'boolean', 'public' => 'boolean', 'maintenance_mode' => 'boolean', @@ -85,11 +97,11 @@ class Node extends Model * Fields that are mass assignable. */ protected $fillable = [ - 'public', 'name', 'location_id', + 'public', 'name', 'location_id', 'database_host_id', + 'listen_port_http', 'listen_port_sftp', 'public_port_http', 'public_port_sftp', 'fqdn', 'scheme', 'behind_proxy', 'memory', 'memory_overallocate', 'disk', - 'disk_overallocate', 'upload_size', 'daemonBase', - 'daemonSFTP', 'daemonListen', + 'disk_overallocate', 'upload_size', 'daemon_base', 'description', 'maintenance_mode', ]; @@ -97,17 +109,20 @@ class Node extends Model 'name' => 'required|regex:/^([\w .-]{1,100})$/', 'description' => 'string|nullable', 'location_id' => 'required|exists:locations,id', + 'database_host_id' => 'sometimes|nullable|exists:database_hosts,id', 'public' => 'boolean', 'fqdn' => 'required|string', + 'listen_port_http' => 'required|numeric|between:1,65535', + 'listen_port_sftp' => 'required|numeric|between:1,65535', + 'public_port_http' => 'required|numeric|between:1,65535', + 'public_port_sftp' => 'required|numeric|between:1,65535', 'scheme' => 'required', 'behind_proxy' => 'boolean', 'memory' => 'required|numeric|min:1', 'memory_overallocate' => 'required|numeric|min:-1', 'disk' => 'required|numeric|min:1', 'disk_overallocate' => 'required|numeric|min:-1', - 'daemonBase' => 'sometimes|required|regex:/^([\/][\d\w.\-\/]+)$/', - 'daemonSFTP' => 'required|numeric|between:1,65535', - 'daemonListen' => 'required|numeric|between:1,65535', + 'daemon_base' => 'sometimes|required|regex:/^([\/][\d\w.\-\/]+)$/', 'maintenance_mode' => 'boolean', 'upload_size' => 'int|between:1,1024', ]; @@ -116,13 +131,15 @@ class Node extends Model * Default values for specific columns that are generally not changed on base installs. */ protected $attributes = [ + 'listen_port_http' => 8080, + 'listen_port_sftp' => 2022, + 'public_port_http' => 8080, + 'public_port_sftp' => 2022, 'public' => true, 'behind_proxy' => false, 'memory_overallocate' => 0, 'disk_overallocate' => 0, - 'daemonBase' => '/var/lib/pterodactyl/volumes', - 'daemonSFTP' => 2022, - 'daemonListen' => 8080, + 'daemon_base' => self::DEFAULT_DAEMON_BASE, 'maintenance_mode' => false, ]; @@ -146,7 +163,7 @@ class Node extends Model 'token' => Container::getInstance()->make(Encrypter::class)->decrypt($this->daemon_token), 'api' => [ 'host' => '0.0.0.0', - 'port' => $this->daemonListen, + 'port' => $this->listen_port_http, 'ssl' => [ 'enabled' => (!$this->behind_proxy && $this->scheme === 'https'), 'cert' => '/etc/letsencrypt/live/' . Str::lower($this->fqdn) . '/fullchain.pem', @@ -155,9 +172,9 @@ class Node extends Model 'upload_limit' => $this->upload_size, ], 'system' => [ - 'data' => $this->daemonBase, + 'data' => $this->daemon_base, 'sftp' => [ - 'bind_port' => $this->daemonSFTP, + 'bind_port' => $this->listen_port_sftp, ], ], 'allowed_mounts' => $this->mounts->pluck('source')->toArray(), @@ -196,9 +213,20 @@ class Node extends Model return $this->maintenance_mode; } - public function mounts(): HasManyThrough + /** + * Gets the allocations associated with a node. + */ + public function allocations(): HasMany { - return $this->hasManyThrough(Mount::class, MountNode::class, 'node_id', 'id', 'id', 'mount_id'); + return $this->hasMany(Allocation::class); + } + + /** + * Returns the database host associated with a node. + */ + public function databaseHost(): BelongsTo + { + return $this->belongsTo(DatabaseHost::class); } /** @@ -209,6 +237,14 @@ class Node extends Model return $this->belongsTo(Location::class); } + /** + * Returns a HasManyThrough relationship for all the mounts associated with a node. + */ + public function mounts(): HasManyThrough + { + return $this->hasManyThrough(Mount::class, MountNode::class, 'node_id', 'id', 'id', 'mount_id'); + } + /** * Gets the servers associated with a node. */ @@ -217,14 +253,6 @@ class Node extends Model return $this->hasMany(Server::class); } - /** - * Gets the allocations associated with a node. - */ - public function allocations(): HasMany - { - return $this->hasMany(Allocation::class); - } - public function loadServerSums(): self { $this->loadSum('servers as sum_memory', 'memory'); diff --git a/app/Services/Eggs/Sharing/EggImporterService.php b/app/Services/Eggs/Sharing/EggImporterService.php index 8be37f0ab..57dd5c8c9 100644 --- a/app/Services/Eggs/Sharing/EggImporterService.php +++ b/app/Services/Eggs/Sharing/EggImporterService.php @@ -116,7 +116,7 @@ class EggImporterService 'copy_script_from' => null, ]); - $egg = $this->parser->fillFromParsed($egg, $parsed); + $egg = $this->eggParserService->fillFromParsed($egg, $parsed); $egg->save(); foreach ($parsed['variables'] ?? [] as $variable) { diff --git a/app/Services/Eggs/Variables/VariableUpdateService.php b/app/Services/Eggs/Variables/VariableUpdateService.php index 5d380f4ac..0bd87b98e 100644 --- a/app/Services/Eggs/Variables/VariableUpdateService.php +++ b/app/Services/Eggs/Variables/VariableUpdateService.php @@ -8,7 +8,6 @@ use Pterodactyl\Models\EggVariable; use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Traits\Services\ValidatesValidationRules; use Illuminate\Contracts\Validation\Factory as ValidationFactory; -use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface; use Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException; class VariableUpdateService @@ -18,7 +17,7 @@ class VariableUpdateService /** * VariableUpdateService constructor. */ - public function __construct(private EggVariableRepositoryInterface $repository, private ValidationFactory $validator) + public function __construct(private ValidationFactory $validator) { } diff --git a/app/Services/Helpers/SoftwareVersionService.php b/app/Services/Helpers/SoftwareVersionService.php index 5b8a5aa80..ad5ca3789 100644 --- a/app/Services/Helpers/SoftwareVersionService.php +++ b/app/Services/Helpers/SoftwareVersionService.php @@ -122,7 +122,7 @@ class SoftwareVersionService protected function versionData(): array { return $this->cache->remember(self::GIT_VERSION_CACHE_KEY, CarbonImmutable::now()->addSeconds(15), function () { - $configVersion = config()->get('app.version'); + $configVersion = $this->getCurrentVersion(); if (file_exists(base_path('.git/HEAD'))) { $head = explode(' ', file_get_contents(base_path('.git/HEAD'))); diff --git a/app/Services/Telemetry/TelemetryCollectionService.php b/app/Services/Telemetry/TelemetryCollectionService.php index c2fd12830..016cf0817 100644 --- a/app/Services/Telemetry/TelemetryCollectionService.php +++ b/app/Services/Telemetry/TelemetryCollectionService.php @@ -16,6 +16,7 @@ use Pterodactyl\Models\Location; use Illuminate\Support\Facades\DB; use Pterodactyl\Models\Allocation; use Illuminate\Support\Facades\Http; +use Pterodactyl\Services\Helpers\SoftwareVersionService; use Pterodactyl\Repositories\Eloquent\SettingsRepository; use Pterodactyl\Repositories\Wings\DaemonConfigurationRepository; @@ -26,7 +27,8 @@ class TelemetryCollectionService */ public function __construct( private DaemonConfigurationRepository $daemonConfigurationRepository, - private SettingsRepository $settingsRepository + private SettingsRepository $settingsRepository, + private SoftwareVersionService $softwareVersionService ) { } @@ -108,7 +110,7 @@ class TelemetryCollectionService 'id' => $uuid, 'panel' => [ - 'version' => config('app.version'), + 'version' => $this->softwareVersionService->getCurrentVersion(), 'phpVersion' => phpversion(), 'drivers' => [ diff --git a/app/Transformers/Api/Application/ServerVariableTransformer.php b/app/Transformers/Api/Application/ServerVariableTransformer.php index 7c3d1de75..eef631a65 100644 --- a/app/Transformers/Api/Application/ServerVariableTransformer.php +++ b/app/Transformers/Api/Application/ServerVariableTransformer.php @@ -2,20 +2,12 @@ namespace Pterodactyl\Transformers\Api\Application; -use League\Fractal\Resource\Item; use Pterodactyl\Models\EggVariable; use Pterodactyl\Models\ServerVariable; -use League\Fractal\Resource\NullResource; -use Pterodactyl\Services\Acl\Api\AdminAcl; use Pterodactyl\Transformers\Api\Transformer; class ServerVariableTransformer extends Transformer { - /** - * List of resources that can be included. - */ - protected array $availableIncludes = ['parent']; - /** * Return the resource name for the JSONAPI output. */ @@ -31,17 +23,4 @@ class ServerVariableTransformer extends Transformer { return $model->toArray(); } - - /** - * Return the parent service variable data. - */ - public function includeParent(EggVariable $variable): Item|NullResource - { - if (!$this->authorize(AdminAcl::RESOURCE_EGGS)) { - return $this->null(); - } - - // TODO: what the fuck? - return $this->item($variable->variable, new EggVariableTransformer()); - } } diff --git a/database/migrations/2021_01_30_193343_add_database_host_id_column_to_nodes_table.php b/database/migrations/2021_01_30_193343_add_database_host_id_column_to_nodes_table.php index e45ad7618..04ce1640e 100644 --- a/database/migrations/2021_01_30_193343_add_database_host_id_column_to_nodes_table.php +++ b/database/migrations/2021_01_30_193343_add_database_host_id_column_to_nodes_table.php @@ -17,7 +17,7 @@ return new class () extends Migration { Schema::table('nodes', function (Blueprint $table) { $table->integer('database_host_id')->nullable()->unsigned()->after('location_id'); - $table->index('database_host_id')->nullable(); + $table->index('database_host_id'); $table->foreign('database_host_id')->references('id')->on('database_hosts')->onDelete('set null'); }); } @@ -34,7 +34,7 @@ return new class () extends Migration { Schema::table('database_hosts', function (Blueprint $table) { $table->integer('node_id')->nullable()->unsigned()->after('max_databases'); - $table->index('node_id')->nullable(); + $table->index('node_id'); $table->foreign('node_id')->references('id')->on('nodes'); }); } diff --git a/database/migrations/2021_02_23_212658_change_port_columns_on_nodes_table.php b/database/migrations/2021_02_23_212658_change_port_columns_on_nodes_table.php index 2e8010c9b..1a61354b7 100644 --- a/database/migrations/2021_02_23_212658_change_port_columns_on_nodes_table.php +++ b/database/migrations/2021_02_23_212658_change_port_columns_on_nodes_table.php @@ -19,10 +19,10 @@ return new class () extends Migration { Schema::table('nodes', function (Blueprint $table) { $table->integer('listen_port_http')->unsigned()->default(8080)->after('fqdn')->change(); - $table->integer('listen_port_sftp')->unsigned()->default(2022)->after('listen_port_sftp')->change(); + $table->integer('listen_port_sftp')->unsigned()->default(2022)->after('listen_port_http')->change(); - $table->integer('public_port_http')->unsigned()->default(8080)->after('listen_port_http'); - $table->integer('public_port_sftp')->unsigned()->default(2022)->after('listen_port_sftp'); + $table->integer('public_port_http')->unsigned()->default(8080)->after('listen_port_sftp'); + $table->integer('public_port_sftp')->unsigned()->default(2022)->after('public_port_http'); }); DB::transaction(function () { diff --git a/phpstan.neon b/phpstan.neon index e12e72eb5..1a394a28f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -19,9 +19,6 @@ parameters: # Ignore magic spatie calls - '#Call to an undefined method Illuminate\\Database\\Eloquent\\Builder::allowed(\w+)\(\)#' - # This should be replaced with resources instead of a magic transformer factory, robots in disguise - - '#Method Pterodactyl\\Http\\Controllers\\Api\\Client\\ClientApiController::getTransformer\(\) should return T#' - excludePaths: - app/Repositories