mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-05 13:55:44 -05:00
action docblocks
This commit is contained in:
@@ -24,13 +24,7 @@ use Pterodactyl\Models\User;
|
||||
*/
|
||||
final class IngestActivityLogs implements IngestsActivityLogs
|
||||
{
|
||||
/**
|
||||
* The activity Wings reports, under the field names of its protocol: `data` lists the
|
||||
* events, each naming the server it happened on, the event, its metadata and when it
|
||||
* happened, and optionally the user who caused it and their IP address.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
/** @return NormalizedValidationRules */
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
@@ -46,8 +40,7 @@ final class IngestActivityLogs implements IngestsActivityLogs
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates reported activity and returns the events it lists. Metadata given as null
|
||||
* is empty.
|
||||
* Metadata given as null is empty.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
* @return list<ActivityEvent>
|
||||
@@ -75,11 +68,6 @@ final class IngestActivityLogs implements IngestsActivityLogs
|
||||
return $events;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function ingest(Node $node, array $input): void
|
||||
{
|
||||
$events = self::events($input);
|
||||
|
||||
@@ -10,16 +10,11 @@ use Pterodactyl\Contracts\Allocations\AssignsAvailableAllocations;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Models\Allocation;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Throwable;
|
||||
|
||||
final readonly class AssignAllocation implements AssignsAllocations
|
||||
{
|
||||
public function __construct(private AssignsAvailableAllocations $assignable) {}
|
||||
|
||||
/**
|
||||
* @throws DisplayException
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function assign(Server $server): Allocation
|
||||
{
|
||||
return DB::transaction(function () use ($server): Allocation {
|
||||
|
||||
@@ -8,7 +8,6 @@ use Illuminate\Support\Collection;
|
||||
use Pterodactyl\Contracts\Allocations\AssignsAvailableAllocations;
|
||||
use Pterodactyl\Contracts\Allocations\CreatesAllocations;
|
||||
use Pterodactyl\Data\AllocationRange;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\Service\Allocation\AutoAllocationNotEnabledException;
|
||||
use Pterodactyl\Exceptions\Service\Allocation\NoAutoAllocationSpaceAvailableException;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
@@ -20,7 +19,6 @@ final readonly class AssignAvailableAllocation implements AssignsAvailableAlloca
|
||||
{
|
||||
public function __construct(private CreatesAllocations $allocations) {}
|
||||
|
||||
/** @throws DisplayException */
|
||||
public function assignAvailable(Server $server): Allocation
|
||||
{
|
||||
throw_unless(config('pterodactyl.client_features.allocations.enabled'), AutoAllocationNotEnabledException::class);
|
||||
|
||||
@@ -51,12 +51,7 @@ final readonly class CreateAllocations implements CreatesAllocations
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The fields of the allocations to create on one address: an IP address, CIDR range or
|
||||
* hostname, the ports and port ranges ("25565-25570") to open on it, and an optional alias.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
/** @return NormalizedValidationRules */
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
@@ -67,15 +62,6 @@ final readonly class CreateAllocations implements CreatesAllocations
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws DisplayException
|
||||
* @throws CidrOutOfRangeException
|
||||
* @throws InvalidPortMappingException
|
||||
* @throws PortOutOfRangeException
|
||||
* @throws TooManyPortsInRangeException
|
||||
*/
|
||||
public function create(Node $node, array $input): void
|
||||
{
|
||||
$validated = Validator::make($input, self::rules())->safe();
|
||||
|
||||
@@ -10,11 +10,6 @@ use Pterodactyl\Models\Allocation;
|
||||
|
||||
final class DeleteAllocation implements DeletesAllocations
|
||||
{
|
||||
/**
|
||||
* Delete an allocation, provided no server is attached to it.
|
||||
*
|
||||
* @throws ServerUsingAllocationException
|
||||
*/
|
||||
public function delete(Allocation $allocation): void
|
||||
{
|
||||
if ($allocation->server_id !== null) {
|
||||
|
||||
@@ -12,9 +12,6 @@ use Pterodactyl\Models\Server;
|
||||
|
||||
final class UnassignAllocation implements UnassignsAllocations
|
||||
{
|
||||
/**
|
||||
* @throws DisplayException
|
||||
*/
|
||||
public function unassign(Server $server, Allocation $allocation): Allocation
|
||||
{
|
||||
throw_if(empty($server->allocation_limit), DisplayException::class, 'You cannot delete allocations for this server: no allocation limit is set.');
|
||||
|
||||
@@ -17,12 +17,7 @@ final readonly class CreateAccountApiKey implements CreatesAccountApiKeys
|
||||
{
|
||||
use ValidatesAllowedIps;
|
||||
|
||||
/**
|
||||
* An account API key's fields: its description, held to the rules of an API key's memo,
|
||||
* and the IP addresses or CIDR ranges it may be used from.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
/** @return NormalizedValidationRules */
|
||||
public static function rules(): array
|
||||
{
|
||||
$rules = CreateApiKey::rules();
|
||||
@@ -34,7 +29,6 @@ final readonly class CreateAccountApiKey implements CreatesAccountApiKeys
|
||||
];
|
||||
}
|
||||
|
||||
/** @param list<string>|null $allowedIps */
|
||||
public function create(User $user, ?string $description, ?array $allowedIps): NewAccessToken
|
||||
{
|
||||
$validator = Validator::make(['description' => $description, 'allowed_ips' => $allowedIps], self::rules());
|
||||
|
||||
@@ -17,9 +17,8 @@ final readonly class CreateApiKey implements CreatesApiKeys
|
||||
use ValidatesAllowedIps;
|
||||
|
||||
/**
|
||||
* An API key's fields: its memo, the user it belongs to, and the IP addresses or CIDR
|
||||
* ranges it may be used from. Each allowed IP must also parse as an address or a range
|
||||
* (see ValidatesAllowedIps).
|
||||
* Each allowed IP must also parse as an address or a range, which ValidatesAllowedIps checks
|
||||
* once these rules pass.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -34,8 +33,8 @@ final readonly class CreateApiKey implements CreatesApiKeys
|
||||
}
|
||||
|
||||
/**
|
||||
* The resource permissions of an application key: an r_* column for each AdminAcl
|
||||
* resource, holding AdminAcl::NONE or AdminAcl::READ and AdminAcl::WRITE combined.
|
||||
* An r_* column for each AdminAcl resource, holding AdminAcl::NONE or AdminAcl::READ and
|
||||
* AdminAcl::WRITE combined.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -49,10 +48,6 @@ final readonly class CreateApiKey implements CreatesApiKeys
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
* @param array<string, mixed> $permissions
|
||||
*/
|
||||
public function create(int $keyType, array $input, array $permissions = []): ApiKey
|
||||
{
|
||||
$validator = Validator::make($input, self::rules());
|
||||
|
||||
@@ -10,12 +10,6 @@ use Pterodactyl\Models\ApiKey;
|
||||
|
||||
final readonly class UpdateApiKey implements UpdatesApiKeys
|
||||
{
|
||||
/**
|
||||
* Update an API key's attributes without regenerating its token.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
* @param array<string, mixed> $permissions
|
||||
*/
|
||||
public function update(ApiKey $key, array $input, array $permissions = []): ApiKey
|
||||
{
|
||||
$attributes = Validator::validate($input, ['memo' => ['sometimes', ...CreateApiKey::rules()['memo']]]);
|
||||
|
||||
@@ -8,7 +8,6 @@ use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Pterodactyl\Contracts\Backups\CompletesBackups;
|
||||
use Pterodactyl\Events\Server\OperationCompleted;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
@@ -16,19 +15,12 @@ use Pterodactyl\Extensions\Backups\BackupManager;
|
||||
use Pterodactyl\Extensions\Filesystem\S3Filesystem;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Models\Backup;
|
||||
use Throwable;
|
||||
|
||||
final readonly class CompleteBackup implements CompletesBackups
|
||||
{
|
||||
public function __construct(private BackupManager $backupManager) {}
|
||||
|
||||
/**
|
||||
* The outcome Wings reports for a backup, under the field names of its protocol. A
|
||||
* successful backup carries its checksum, the checksum's type and its size in bytes. An
|
||||
* S3 backup may list the parts of its multipart upload.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
/** @return NormalizedValidationRules */
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
@@ -42,16 +34,6 @@ final readonly class CompleteBackup implements CompletesBackups
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Records the outcome Wings reported for a backup and, for S3 storage, closes the
|
||||
* multipart upload it belongs to.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws DisplayException
|
||||
* @throws ValidationException
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function complete(Backup $backup, array $input): void
|
||||
{
|
||||
$validated = Validator::make($input, self::rules())->safe();
|
||||
@@ -90,9 +72,6 @@ final readonly class CompleteBackup implements CompletesBackups
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a multipart upload in a given S3-compatible instance as failed or successful for
|
||||
* the given backup.
|
||||
*
|
||||
* @param list<MultipartUploadPart>|null $parts
|
||||
*
|
||||
* @throws DisplayException
|
||||
|
||||
@@ -22,12 +22,6 @@ final readonly class DeleteBackup implements DeletesBackups
|
||||
private BackupManager $manager,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Deletes a backup from the system. If the backup is stored in S3 a request
|
||||
* will be made to delete that backup from the disk as well.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function delete(Backup $backup): void
|
||||
{
|
||||
// If the backup is marked as failed it can still be deleted, even if locked
|
||||
@@ -59,11 +53,7 @@ final readonly class DeleteBackup implements DeletesBackups
|
||||
->log();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a backup's archive from an S3 disk.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
/** @throws Throwable */
|
||||
private function deleteFromS3(Backup $backup): void
|
||||
{
|
||||
$adapter = $this->manager->adapter(Backup::ADAPTER_AWS_S3);
|
||||
|
||||
@@ -19,10 +19,6 @@ final readonly class GenerateBackupDownloadLink implements GeneratesBackupDownlo
|
||||
{
|
||||
public function __construct(private BackupManager $backupManager, private NodeJWTService $jwtService) {}
|
||||
|
||||
/**
|
||||
* Returns the URL that allows for a backup to be downloaded by an individual
|
||||
* user, or by the Wings control software.
|
||||
*/
|
||||
public function generate(Backup $backup, User $user): string
|
||||
{
|
||||
throw_if($backup->disk !== Backup::ADAPTER_AWS_S3 && $backup->disk !== Backup::ADAPTER_WINGS, BadRequestHttpException::class, 'The backup requested references an unknown disk driver type and cannot be downloaded.');
|
||||
@@ -44,10 +40,6 @@ final readonly class GenerateBackupDownloadLink implements GeneratesBackupDownlo
|
||||
return sprintf('%s/download/backup?token=%s', $backup->server->node->getConnectionAddress(), $token->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a signed URL that allows us to download a file directly out of a non-public
|
||||
* S3 bucket by using a signed URL.
|
||||
*/
|
||||
private function getS3BackupUrl(Backup $backup): string
|
||||
{
|
||||
$adapter = $this->backupManager->adapter(Backup::ADAPTER_AWS_S3);
|
||||
|
||||
@@ -8,7 +8,6 @@ use Carbon\CarbonImmutable;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Pterodactyl\Contracts\Backups\DeletesBackups;
|
||||
use Pterodactyl\Contracts\Backups\InitiatesBackups;
|
||||
use Pterodactyl\Exceptions\Service\Backup\TooManyBackupsException;
|
||||
@@ -34,12 +33,7 @@ final class InitiateBackup implements InitiatesBackups
|
||||
private readonly BackupManager $backupManager,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* A backup's fields: an optional name, whether it is locked against deletion, and the
|
||||
* files and folders to leave out of it.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
/** @return NormalizedValidationRules */
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
@@ -50,10 +44,6 @@ final class InitiateBackup implements InitiatesBackups
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the backup should be locked once it is created which will prevent
|
||||
* its deletion by users or automated system processes.
|
||||
*/
|
||||
public function setIsLocked(bool $isLocked): InitiatesBackups
|
||||
{
|
||||
$this->isLocked = $isLocked;
|
||||
@@ -61,12 +51,6 @@ final class InitiateBackup implements InitiatesBackups
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the files to be ignored by this backup. They are validated when the backup is
|
||||
* initiated.
|
||||
*
|
||||
* @param list<string>|null $ignored
|
||||
*/
|
||||
public function setIgnoredFiles(?array $ignored): InitiatesBackups
|
||||
{
|
||||
$this->ignoredFiles = $ignored ?? [];
|
||||
@@ -74,19 +58,6 @@ final class InitiateBackup implements InitiatesBackups
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates the backup process for a server on Wings.
|
||||
*
|
||||
* The rows are written in a transaction, but Wings is only asked to start the backup
|
||||
* once that transaction commits, and backups rotated out to make room are deleted only
|
||||
* after Wings accepted the new one. A rejected backup is marked failed and nothing is
|
||||
* rotated out, so the oldest backup survives a failed attempt.
|
||||
*
|
||||
* @throws Throwable
|
||||
* @throws TooManyBackupsException
|
||||
* @throws TooManyRequestsHttpException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function initiate(Server $server, ?string $name = null, bool $override = false): Backup
|
||||
{
|
||||
Validator::validate(['name' => $name, 'is_locked' => $this->isLocked, 'ignored_files' => $this->ignoredFiles], self::rules());
|
||||
@@ -151,6 +122,8 @@ final class InitiateBackup implements InitiatesBackups
|
||||
return [$backup, $rotated];
|
||||
});
|
||||
|
||||
// Wings is only asked once the rows are committed, and backups rotated out to make room
|
||||
// are deleted only after it accepts the new one.
|
||||
try {
|
||||
Daemon::server($server)->backups()->create($backup);
|
||||
} catch (Throwable $throwable) {
|
||||
|
||||
@@ -17,14 +17,6 @@ final readonly class PresignBackupUpload implements PresignsBackupUploads
|
||||
|
||||
public function __construct(private BackupManager $backupManager) {}
|
||||
|
||||
/**
|
||||
* Opens a multipart upload for the backup in S3 and returns one presigned URL per part
|
||||
* Wings needs to upload for an archive of the given size.
|
||||
*
|
||||
* @return BackupUploadParts
|
||||
*
|
||||
* @throws BadRequestHttpException
|
||||
*/
|
||||
public function presign(Backup $backup, int $size): array
|
||||
{
|
||||
$adapter = $this->backupManager->adapter();
|
||||
|
||||
@@ -13,7 +13,6 @@ use Pterodactyl\Models\Backup;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\User;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Throwable;
|
||||
|
||||
final readonly class RestoreBackup implements RestoresBackups
|
||||
{
|
||||
@@ -22,8 +21,7 @@ final readonly class RestoreBackup implements RestoresBackups
|
||||
) {}
|
||||
|
||||
/**
|
||||
* A restore's fields: whether the server's files are deleted before the backup is
|
||||
* unpacked over them. The action takes the flag as a bool, which always meets them.
|
||||
* The action takes `truncate` as a bool, which always meets these rules.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -34,12 +32,6 @@ final readonly class RestoreBackup implements RestoresBackups
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the server as restoring and asks Wings to unpack the backup over its files.
|
||||
* S3 backups are handed to Wings as a signed download link.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function restore(Server $server, Backup $backup, User $user, bool $truncate): void
|
||||
{
|
||||
throw_if(($server->status) !== null, BadRequestHttpException::class, 'This server is not currently in a state that allows for a backup to be restored.');
|
||||
|
||||
@@ -41,7 +41,7 @@ final class CreateDatabase implements CreatesDatabases
|
||||
) {}
|
||||
|
||||
/**
|
||||
* A database's fields. The name is the full one, already prefixed with "s{server_id}_" by
|
||||
* The name is the full one, already prefixed with "s{server_id}_" by
|
||||
* DatabaseName::generateUnique().
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
@@ -63,13 +63,6 @@ final class CreateDatabase implements CreatesDatabases
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws Throwable
|
||||
* @throws TooManyDatabasesException
|
||||
* @throws DatabaseClientFeatureNotEnabledException
|
||||
*/
|
||||
public function create(Server $server, array $input): Database
|
||||
{
|
||||
throw_unless(config('pterodactyl.client_features.databases.enabled'), DatabaseClientFeatureNotEnabledException::class);
|
||||
|
||||
@@ -12,18 +12,12 @@ use Pterodactyl\Extensions\DynamicDatabaseConnection;
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Pterodactyl\Services\Extensions\ExtensionFields;
|
||||
use Pterodactyl\Services\Extensions\ValidatedExtensionValues;
|
||||
use Throwable;
|
||||
|
||||
final readonly class CreateDatabaseHost implements CreatesDatabaseHosts
|
||||
{
|
||||
public function __construct(private DynamicDatabaseConnection $dynamic, private ExtensionFields $extensions) {}
|
||||
|
||||
/**
|
||||
* A database host's fields, for creating one and for updating one. The host is a hostname
|
||||
* or IP address, and the node, when given, must exist.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
/** @return NormalizedValidationRules */
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
@@ -36,13 +30,6 @@ final readonly class CreateDatabaseHost implements CreatesDatabaseHosts
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new database host on the Panel once it accepts the given credentials.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function create(array $input): DatabaseHost
|
||||
{
|
||||
$validated = Validator::validate($input, self::rules());
|
||||
|
||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Pterodactyl\Actions\Databases;
|
||||
|
||||
use Exception;
|
||||
use Pterodactyl\Contracts\Databases\DeletesDatabases;
|
||||
use Pterodactyl\Extensions\DynamicDatabaseConnection;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
@@ -18,7 +17,6 @@ final readonly class DeleteDatabase implements DeletesDatabases
|
||||
private DatabaseHostGateway $gateway,
|
||||
) {}
|
||||
|
||||
/** @throws Exception */
|
||||
public function delete(Database $database): ?bool
|
||||
{
|
||||
$this->dynamic->set('dynamic', $database->relationLoaded('host') ? $database->host : $database->database_host_id);
|
||||
|
||||
@@ -10,11 +10,6 @@ use Pterodactyl\Models\DatabaseHost;
|
||||
|
||||
final readonly class DeleteDatabaseHost implements DeletesDatabaseHosts
|
||||
{
|
||||
/**
|
||||
* Delete a database host, provided no databases are attached to it.
|
||||
*
|
||||
* @throws HasActiveServersException
|
||||
*/
|
||||
public function delete(DatabaseHost $host): void
|
||||
{
|
||||
if ($host->databases()->exists()) {
|
||||
|
||||
@@ -9,22 +9,18 @@ use Illuminate\Support\Facades\Validator;
|
||||
use Pterodactyl\Contracts\Databases\CreatesDatabases;
|
||||
use Pterodactyl\Contracts\Databases\DeploysServerDatabases;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\Service\Database\DatabaseClientFeatureNotEnabledException;
|
||||
use Pterodactyl\Exceptions\Service\Database\NoSuitableDatabaseHostException;
|
||||
use Pterodactyl\Exceptions\Service\Database\TooManyDatabasesException;
|
||||
use Pterodactyl\Models\Database;
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Support\DatabaseName;
|
||||
use Throwable;
|
||||
|
||||
final readonly class DeployServerDatabase implements DeploysServerDatabases
|
||||
{
|
||||
public function __construct(private CreatesDatabases $createDatabase) {}
|
||||
|
||||
/**
|
||||
* The fields of a database to deploy. The name is the one a user picks, before the
|
||||
* "s{server_id}_" prefix is added; with no host given, one is picked for the server.
|
||||
* The name is the one a user picks, before the "s{server_id}_" prefix is added.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -40,15 +36,6 @@ final readonly class DeployServerDatabase implements DeploysServerDatabases
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws Throwable
|
||||
* @throws TooManyDatabasesException
|
||||
* @throws DatabaseClientFeatureNotEnabledException
|
||||
* @throws NoSuitableDatabaseHostException
|
||||
* @throws DisplayException
|
||||
*/
|
||||
public function deploy(Server $server, array $input): Database
|
||||
{
|
||||
$validated = Validator::make($input, self::rules())->safe();
|
||||
|
||||
@@ -12,7 +12,6 @@ use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Helpers\Utilities;
|
||||
use Pterodactyl\Models\Database;
|
||||
use Pterodactyl\Services\Databases\DatabaseHostGateway;
|
||||
use Throwable;
|
||||
|
||||
final readonly class RotateDatabasePassword implements RotatesDatabasePasswords
|
||||
{
|
||||
@@ -21,7 +20,6 @@ final readonly class RotateDatabasePassword implements RotatesDatabasePasswords
|
||||
private DatabaseHostGateway $gateway,
|
||||
) {}
|
||||
|
||||
/** @throws Throwable */
|
||||
public function rotate(Database $database): string
|
||||
{
|
||||
$password = Utilities::randomStringWithSpecialCharacters(24);
|
||||
|
||||
@@ -13,19 +13,11 @@ use Pterodactyl\Extensions\DynamicDatabaseConnection;
|
||||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Pterodactyl\Services\Extensions\ExtensionFields;
|
||||
use Pterodactyl\Services\Extensions\ValidatedExtensionValues;
|
||||
use Throwable;
|
||||
|
||||
final readonly class UpdateDatabaseHost implements UpdatesDatabaseHosts
|
||||
{
|
||||
public function __construct(private DynamicDatabaseConnection $dynamic, private ExtensionFields $extensions) {}
|
||||
|
||||
/**
|
||||
* Update a database host and persist to the database.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function update(DatabaseHost $host, array $input): DatabaseHost
|
||||
{
|
||||
$validated = Validator::validate($input, CreateDatabaseHost::rules());
|
||||
|
||||
@@ -28,10 +28,8 @@ final readonly class CreateEgg implements CreatesEggs
|
||||
public function __construct(private ExtensionFields $extensions) {}
|
||||
|
||||
/**
|
||||
* An egg's fields, for creating one and for updating one. The Docker images are one per
|
||||
* line, each held to DOCKER_IMAGE (see DockerImageList). An egg that copies its config from
|
||||
* another needs none of its own; every config block given must be JSON, apart from the
|
||||
* stop command.
|
||||
* The Docker images are one per line, each held to DOCKER_IMAGE. An egg that copies its
|
||||
* config from another needs none of its own.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -72,11 +70,6 @@ final readonly class CreateEgg implements CreatesEggs
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an egg, stamping the configured service author.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function create(array $input): Egg
|
||||
{
|
||||
// A parent egg of 0 is the legacy "no parent egg" sentinel.
|
||||
|
||||
@@ -12,13 +12,6 @@ use Pterodactyl\Models\Egg;
|
||||
|
||||
final class DeleteEgg implements DeletesEggs
|
||||
{
|
||||
/**
|
||||
* Delete an egg, provided no servers use it and no eggs inherit their
|
||||
* configuration from it.
|
||||
*
|
||||
* @throws HasActiveServersException
|
||||
* @throws HasChildrenException
|
||||
*/
|
||||
public function delete(Egg $egg): void
|
||||
{
|
||||
if ($egg->servers()->exists()) {
|
||||
|
||||
@@ -11,13 +11,7 @@ use Pterodactyl\Models\Egg;
|
||||
|
||||
final class UpdateInstallScript implements UpdatesEggInstallScripts
|
||||
{
|
||||
/**
|
||||
* An egg's install script fields, each of them optional: the script, whether it runs
|
||||
* privileged, the container entrypoint and image it runs in, and the egg to copy the
|
||||
* script from instead.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
/** @return NormalizedValidationRules */
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
@@ -29,13 +23,6 @@ final class UpdateInstallScript implements UpdatesEggInstallScripts
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the install script for a given Egg.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws InvalidCopyFromException
|
||||
*/
|
||||
public function update(Egg $egg, array $input): Egg
|
||||
{
|
||||
$attributes = Validator::validate($input, self::rules());
|
||||
|
||||
@@ -5,17 +5,11 @@ declare(strict_types=1);
|
||||
namespace Pterodactyl\Actions\Eggs\Sharing;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use JsonException;
|
||||
use Pterodactyl\Contracts\Eggs\ExportsEggs;
|
||||
use Pterodactyl\Models\Egg;
|
||||
|
||||
final class ExportEgg implements ExportsEggs
|
||||
{
|
||||
/**
|
||||
* Return a JSON representation of an egg and its variables.
|
||||
*
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function export(Egg $egg): string
|
||||
{
|
||||
$egg->loadMissing('scriptFrom', 'configFrom', 'variables');
|
||||
|
||||
@@ -7,19 +7,16 @@ namespace Pterodactyl\Actions\Eggs\Sharing;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Pterodactyl\Contracts\Eggs\ImportsEggs;
|
||||
use Pterodactyl\Exceptions\Service\InvalidFileUploadException;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Models\EggVariable;
|
||||
use Pterodactyl\Services\Eggs\EggImportData;
|
||||
use Pterodactyl\Services\Eggs\EggParserService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Throwable;
|
||||
|
||||
final readonly class ImportEgg implements ImportsEggs
|
||||
{
|
||||
public function __construct(private EggParserService $parser) {}
|
||||
|
||||
/** @throws InvalidFileUploadException|Throwable */
|
||||
public function import(UploadedFile $file): Egg
|
||||
{
|
||||
return $this->importParsed($this->parser->handle($file));
|
||||
|
||||
@@ -7,18 +7,15 @@ namespace Pterodactyl\Actions\Eggs\Sharing;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Pterodactyl\Contracts\Eggs\UpdatesEggsFromImports;
|
||||
use Pterodactyl\Exceptions\Service\InvalidFileUploadException;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Models\EggVariable;
|
||||
use Pterodactyl\Services\Eggs\EggImportVariable;
|
||||
use Pterodactyl\Services\Eggs\EggParserService;
|
||||
use Throwable;
|
||||
|
||||
final readonly class UpdateEggFromImport implements UpdatesEggsFromImports
|
||||
{
|
||||
public function __construct(private EggParserService $parser) {}
|
||||
|
||||
/** @throws InvalidFileUploadException|Throwable */
|
||||
public function update(Egg $egg, UploadedFile $file): Egg
|
||||
{
|
||||
$parsed = $this->parser->handle($file);
|
||||
|
||||
@@ -16,11 +16,6 @@ final readonly class UpdateEgg implements UpdatesEggs
|
||||
{
|
||||
public function __construct(private ExtensionFields $extensions) {}
|
||||
|
||||
/**
|
||||
* Update an egg with the fields it is created with.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function update(Egg $egg, array $input): Egg
|
||||
{
|
||||
// A parent egg of 0 is the legacy "no parent egg" sentinel.
|
||||
|
||||
@@ -16,10 +16,8 @@ use Pterodactyl\Rules\ValidRuleSet;
|
||||
final class CreateEggVariable implements CreatesEggVariables
|
||||
{
|
||||
/**
|
||||
* An egg variable's fields, whether it is written through the admin API or arrives in an
|
||||
* imported egg, and the options that set whether users can see and edit it. Pass the egg
|
||||
* to hold the environment variable name unique among its variables, and the variable
|
||||
* being updated so its own name is not taken for a duplicate.
|
||||
* Pass the egg to hold the environment variable name unique among its variables, and the
|
||||
* variable being updated so its own name is not taken for a duplicate.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -41,11 +39,6 @@ final class CreateEggVariable implements CreatesEggVariables
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new variable for a given Egg.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function create(Egg $egg, array $input): EggVariable
|
||||
{
|
||||
$validated = Validator::validate($input, self::rules($egg));
|
||||
|
||||
@@ -9,9 +9,6 @@ use Pterodactyl\Models\EggVariable;
|
||||
|
||||
final readonly class DeleteEggVariable implements DeletesEggVariables
|
||||
{
|
||||
/**
|
||||
* Delete an egg variable.
|
||||
*/
|
||||
public function delete(EggVariable $variable): void
|
||||
{
|
||||
$variable->delete();
|
||||
|
||||
@@ -12,12 +12,7 @@ use Pterodactyl\Models\Egg;
|
||||
|
||||
final readonly class ReorderEggVariables implements ReordersEggVariables
|
||||
{
|
||||
/**
|
||||
* The variable ids of an egg in their new order, each once. An id may be an integer or
|
||||
* a numeric string.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
/** @return NormalizedValidationRules */
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
@@ -27,8 +22,6 @@ final readonly class ReorderEggVariables implements ReordersEggVariables
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates variable ids under `order` and returns them as integers.
|
||||
*
|
||||
* @param list<mixed> $order
|
||||
* @return list<int>
|
||||
*/
|
||||
@@ -39,7 +32,6 @@ final readonly class ReorderEggVariables implements ReordersEggVariables
|
||||
return array_map(fn (int|string $key): int => $input->integer('order.'.$key), array_keys($input->array('order')));
|
||||
}
|
||||
|
||||
/** @param list<mixed> $order */
|
||||
public function reorder(Egg $egg, array $order): void
|
||||
{
|
||||
$order = self::order($order);
|
||||
|
||||
@@ -12,11 +12,6 @@ use Pterodactyl\Models\EggVariable;
|
||||
|
||||
final class UpdateEggVariable implements UpdatesEggVariables
|
||||
{
|
||||
/**
|
||||
* Update an egg variable with the fields it is created with.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function update(EggVariable $variable, array $input): EggVariable
|
||||
{
|
||||
$egg = Egg::query()->findOrFail($variable->egg_id);
|
||||
|
||||
@@ -16,9 +16,6 @@ final readonly class ReplaceExtensionSettingFile implements ReplacesExtensionSet
|
||||
{
|
||||
public function __construct(private ExtensionSettingFiles $files) {}
|
||||
|
||||
/**
|
||||
* @return list<ExtensionSettingField>
|
||||
*/
|
||||
public function replace(ExtensionSettingsDefinition $definition, string $input, ?UploadedFile $upload): array
|
||||
{
|
||||
$field = $definition->fileField($input);
|
||||
|
||||
@@ -9,10 +9,6 @@ use Pterodactyl\Services\Extensions\ExtensionSettingsDefinition;
|
||||
|
||||
final readonly class UpdateExtensionSettings implements UpdatesExtensionSettings
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $settings
|
||||
* @return list<ExtensionSettingField>
|
||||
*/
|
||||
public function update(ExtensionSettingsDefinition $definition, array $settings): array
|
||||
{
|
||||
$definition->update($settings);
|
||||
|
||||
@@ -11,7 +11,6 @@ use Pterodactyl\Models\Server;
|
||||
|
||||
final readonly class ChangeFilePermissions implements ChangesFilePermissions
|
||||
{
|
||||
/** @param array<mixed> $files */
|
||||
public function change(Server $server, ?string $root, array $files): void
|
||||
{
|
||||
Daemon::server($server)->files()->chmodFiles($root, $files);
|
||||
|
||||
@@ -11,10 +11,6 @@ use Pterodactyl\Models\Server;
|
||||
|
||||
final readonly class CompressFiles implements CompressesFiles
|
||||
{
|
||||
/**
|
||||
* @param array<mixed> $files
|
||||
* @return DaemonFileObject
|
||||
*/
|
||||
public function compress(Server $server, ?string $root, array $files): array
|
||||
{
|
||||
$archive = Daemon::server($server)->files()->compressFiles($root, $files);
|
||||
|
||||
@@ -11,7 +11,6 @@ use Pterodactyl\Models\Server;
|
||||
|
||||
final readonly class DeleteFiles implements DeletesFiles
|
||||
{
|
||||
/** @param array<mixed> $files */
|
||||
public function delete(Server $server, ?string $root, array $files): void
|
||||
{
|
||||
Daemon::server($server)->files()->deleteFiles($root, $files);
|
||||
|
||||
@@ -11,7 +11,6 @@ use Pterodactyl\Models\Server;
|
||||
|
||||
final readonly class PullFile implements PullsFiles
|
||||
{
|
||||
/** @param array{filename?: string|null, use_header?: bool, foreground?: bool, timeout?: int} $options */
|
||||
public function pull(Server $server, string $url, ?string $directory, array $options): void
|
||||
{
|
||||
Daemon::server($server)->files()->pull($url, $directory, $options);
|
||||
|
||||
@@ -11,7 +11,6 @@ use Pterodactyl\Models\Server;
|
||||
|
||||
final readonly class RenameFiles implements RenamesFiles
|
||||
{
|
||||
/** @param array<mixed> $files */
|
||||
public function rename(Server $server, ?string $root, array $files): void
|
||||
{
|
||||
Daemon::server($server)->files()->renameFiles($root, $files);
|
||||
|
||||
@@ -17,8 +17,7 @@ final readonly class CreateLocation implements CreatesLocations
|
||||
public function __construct(private ExtensionFields $extensions) {}
|
||||
|
||||
/**
|
||||
* A location's fields. Pass the location being updated so its own short code is not
|
||||
* taken for a duplicate.
|
||||
* Pass the location being updated so its own short code is not taken for a duplicate.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -30,9 +29,6 @@ final readonly class CreateLocation implements CreatesLocations
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function create(array $input): Location
|
||||
{
|
||||
$validated = Validator::validate($input, self::rules());
|
||||
|
||||
@@ -10,11 +10,6 @@ use Pterodactyl\Models\Location;
|
||||
|
||||
final class DeleteLocation implements DeletesLocations
|
||||
{
|
||||
/**
|
||||
* Delete a location, provided no nodes are assigned to it.
|
||||
*
|
||||
* @throws HasActiveNodesException
|
||||
*/
|
||||
public function delete(Location $location): void
|
||||
{
|
||||
if ($location->nodes()->exists()) {
|
||||
|
||||
@@ -15,9 +15,6 @@ final readonly class UpdateLocation implements UpdatesLocations
|
||||
{
|
||||
public function __construct(private ExtensionFields $extensions) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function update(Location $location, array $input): Location
|
||||
{
|
||||
$validated = Validator::validate($input, CreateLocation::rules($location));
|
||||
|
||||
@@ -15,11 +15,7 @@ final readonly class AttachEggsToMount implements AttachesEggsToMounts
|
||||
{
|
||||
use ValidatesArrayExistence;
|
||||
|
||||
/**
|
||||
* The eggs to attach: a list of egg ids, each an integer or a numeric string.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
/** @return NormalizedValidationRules */
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
@@ -28,20 +24,14 @@ final readonly class AttachEggsToMount implements AttachesEggsToMounts
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach eggs to a mount, keeping any eggs already attached.
|
||||
*
|
||||
* @param list<mixed> $eggIds
|
||||
*/
|
||||
public function attach(Mount $mount, array $eggIds): void
|
||||
{
|
||||
$mount->eggs()->syncWithoutDetaching($this->eggIds($eggIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the egg ids under `eggs` and returns them as integers. Each id must name an
|
||||
* egg; they are all looked up in one query, and a missing one fails `eggs.N` as an exists
|
||||
* rule would.
|
||||
* The eggs are looked up in one query, and a missing one fails `eggs.N` as an exists rule
|
||||
* would.
|
||||
*
|
||||
* @param list<mixed> $eggIds
|
||||
* @return list<int>
|
||||
|
||||
@@ -15,11 +15,7 @@ final readonly class AttachNodesToMount implements AttachesNodesToMounts
|
||||
{
|
||||
use ValidatesArrayExistence;
|
||||
|
||||
/**
|
||||
* The nodes to attach: a list of node ids, each an integer or a numeric string.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
/** @return NormalizedValidationRules */
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
@@ -28,20 +24,14 @@ final readonly class AttachNodesToMount implements AttachesNodesToMounts
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach nodes to a mount, keeping any nodes already attached.
|
||||
*
|
||||
* @param list<mixed> $nodeIds
|
||||
*/
|
||||
public function attach(Mount $mount, array $nodeIds): void
|
||||
{
|
||||
$mount->nodes()->syncWithoutDetaching($this->nodeIds($nodeIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the node ids under `nodes` and returns them as integers. Each id must name a
|
||||
* node; they are all looked up in one query, and a missing one fails `nodes.N` as an
|
||||
* exists rule would.
|
||||
* The nodes are looked up in one query, and a missing one fails `nodes.N` as an exists rule
|
||||
* would.
|
||||
*
|
||||
* @param list<mixed> $nodeIds
|
||||
* @return list<int>
|
||||
|
||||
@@ -19,10 +19,10 @@ final readonly class CreateMount implements CreatesMounts
|
||||
public function __construct(private ExtensionFields $extensions) {}
|
||||
|
||||
/**
|
||||
* A mount's fields. Pass the mount being updated so its own name is not taken for a
|
||||
* duplicate. Both paths are absolute. Once '.' and '..' are resolved, the source may not
|
||||
* be the Wings configuration directory or anything in it, nor a whole volumes directory,
|
||||
* and the target may not be the container's home directory itself.
|
||||
* Pass the mount being updated so its own name is not taken for a duplicate. Once '.' and
|
||||
* '..' are resolved, the source may not be the Wings configuration directory or anything in
|
||||
* it, nor a whole volumes directory, and the target may not be the container's home
|
||||
* directory itself.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -58,11 +58,6 @@ final readonly class CreateMount implements CreatesMounts
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new mount, assigning it a fresh UUID.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function create(array $input): Mount
|
||||
{
|
||||
$validated = Validator::validate($input, self::rules());
|
||||
|
||||
@@ -9,9 +9,6 @@ use Pterodactyl\Models\Mount;
|
||||
|
||||
final readonly class DeleteMount implements DeletesMounts
|
||||
{
|
||||
/**
|
||||
* Delete a mount.
|
||||
*/
|
||||
public function delete(Mount $mount): void
|
||||
{
|
||||
$mount->delete();
|
||||
|
||||
@@ -10,9 +10,6 @@ use Pterodactyl\Models\Mount;
|
||||
|
||||
final readonly class DetachEggFromMount implements DetachesEggsFromMounts
|
||||
{
|
||||
/**
|
||||
* Remove a single egg attachment from a mount.
|
||||
*/
|
||||
public function detach(Mount $mount, Egg $egg): void
|
||||
{
|
||||
$mount->eggs()->detach($egg->id);
|
||||
|
||||
@@ -10,9 +10,6 @@ use Pterodactyl\Models\Node;
|
||||
|
||||
final readonly class DetachNodeFromMount implements DetachesNodesFromMounts
|
||||
{
|
||||
/**
|
||||
* Remove a single node attachment from a mount.
|
||||
*/
|
||||
public function detach(Mount $mount, Node $node): void
|
||||
{
|
||||
$mount->nodes()->detach($node->id);
|
||||
|
||||
@@ -15,9 +15,6 @@ final readonly class UpdateMount implements UpdatesMounts
|
||||
{
|
||||
public function __construct(private ExtensionFields $extensions) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function update(Mount $mount, array $input): Mount
|
||||
{
|
||||
$validated = Validator::validate($input, CreateMount::rules($mount));
|
||||
|
||||
@@ -19,8 +19,8 @@ final readonly class CreateNode implements CreatesNodes
|
||||
public function __construct(private ExtensionFields $extensions) {}
|
||||
|
||||
/**
|
||||
* A node's fields, for creating one and for updating one. The daemon fields go by their
|
||||
* API names, which map onto the daemonListen, daemonSFTP and daemonBase columns.
|
||||
* The daemon fields go by their API names, which map onto the daemonListen, daemonSFTP and
|
||||
* daemonBase columns.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -46,11 +46,6 @@ final readonly class CreateNode implements CreatesNodes
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a node and mint its daemon token pair.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function create(array $input): Node
|
||||
{
|
||||
$validated = Validator::validate($input, self::rules());
|
||||
|
||||
@@ -11,11 +11,6 @@ use Pterodactyl\Models\Node;
|
||||
|
||||
final class DeleteNode implements DeletesNodes
|
||||
{
|
||||
/**
|
||||
* Delete a node from the panel if no servers are attached to it.
|
||||
*
|
||||
* @throws HasActiveServersException
|
||||
*/
|
||||
public function delete(Node $node): void
|
||||
{
|
||||
if ($node->servers()->exists()) {
|
||||
|
||||
@@ -11,16 +11,9 @@ use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Models\Backup;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Throwable;
|
||||
|
||||
final readonly class ResetServerStates implements ResetsServerStates
|
||||
{
|
||||
/**
|
||||
* Returns every installing or restoring server on the node to a normal state after a
|
||||
* Wings restart, logging a failed restore for each backup that was in progress.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function reset(Node $node): void
|
||||
{
|
||||
$servers = Server::query()
|
||||
|
||||
@@ -17,19 +17,11 @@ use Pterodactyl\Facades\Daemon;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Services\Extensions\ExtensionFields;
|
||||
use Pterodactyl\Services\Extensions\ValidatedExtensionValues;
|
||||
use Throwable;
|
||||
|
||||
final readonly class UpdateNode implements UpdatesNodes
|
||||
{
|
||||
public function __construct(private ExtensionFields $extensions) {}
|
||||
|
||||
/**
|
||||
* Update the configuration values for a given node on the machine.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function update(Node $node, array $input, bool $resetToken = false): Node
|
||||
{
|
||||
$validated = Validator::validate($input, CreateNode::rules());
|
||||
|
||||
@@ -14,11 +14,7 @@ use Throwable;
|
||||
|
||||
final class CreateSchedule implements CreatesSchedules
|
||||
{
|
||||
/**
|
||||
* A schedule's fields, for creating one and for updating one.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
/** @return NormalizedValidationRules */
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
@@ -33,11 +29,6 @@ final class CreateSchedule implements CreatesSchedules
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws DisplayException
|
||||
*/
|
||||
public function create(Server $server, array $input): Schedule
|
||||
{
|
||||
$validated = Validator::validate($input, self::rules());
|
||||
|
||||
@@ -13,13 +13,11 @@ use Pterodactyl\Exceptions\Service\ServiceLimitExceededException;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Models\Schedule;
|
||||
use Pterodactyl\Models\Task;
|
||||
use Throwable;
|
||||
|
||||
final readonly class CreateScheduleTask implements CreatesScheduleTasks
|
||||
{
|
||||
/**
|
||||
* A task's fields, for creating one and for updating one. A power task's payload
|
||||
* must name the power action to send.
|
||||
* A power task's payload must name the power action to send.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -39,16 +37,6 @@ final readonly class CreateScheduleTask implements CreatesScheduleTasks
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a task to the schedule, or slots it into the requested position by
|
||||
* shifting the tasks that follow it.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws HttpForbiddenException
|
||||
* @throws ServiceLimitExceededException
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function create(Schedule $schedule, array $input): Task
|
||||
{
|
||||
$validated = Validator::make($input, self::rules(($input['action'] ?? null) === Task::ACTION_POWER))->safe();
|
||||
|
||||
@@ -9,15 +9,9 @@ use Pterodactyl\Contracts\Schedules\DeletesScheduleTasks;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Models\Schedule;
|
||||
use Pterodactyl\Models\Task;
|
||||
use Throwable;
|
||||
|
||||
final readonly class DeleteScheduleTask implements DeletesScheduleTasks
|
||||
{
|
||||
/**
|
||||
* Deletes the task and closes the gap it leaves in the schedule's sequence.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function delete(Schedule $schedule, Task $task): void
|
||||
{
|
||||
DB::transaction(function () use ($schedule, $task): void {
|
||||
|
||||
@@ -18,11 +18,6 @@ use Throwable;
|
||||
|
||||
final readonly class ProcessSchedule implements ProcessesSchedules
|
||||
{
|
||||
/**
|
||||
* Process a schedule and push the first task onto the queue worker.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function process(Schedule $schedule, bool $now = false): void
|
||||
{
|
||||
$this->run($schedule, $now);
|
||||
|
||||
@@ -13,11 +13,6 @@ use Throwable;
|
||||
|
||||
final class UpdateSchedule implements UpdatesSchedules
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws DisplayException
|
||||
*/
|
||||
public function update(Schedule $schedule, array $input): Schedule
|
||||
{
|
||||
$validated = Validator::validate($input, CreateSchedule::rules());
|
||||
|
||||
@@ -11,19 +11,9 @@ use Pterodactyl\Exceptions\Http\HttpForbiddenException;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Models\Schedule;
|
||||
use Pterodactyl\Models\Task;
|
||||
use Throwable;
|
||||
|
||||
final readonly class UpdateScheduleTask implements UpdatesScheduleTasks
|
||||
{
|
||||
/**
|
||||
* Updates the task and, when its position changes, shifts the tasks between the
|
||||
* old and new positions to keep the sequence contiguous.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws HttpForbiddenException
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function update(Schedule $schedule, Task $task, array $input): Task
|
||||
{
|
||||
$validated = Validator::make($input, CreateScheduleTask::rules(($input['action'] ?? null) === Task::ACTION_POWER))->safe();
|
||||
|
||||
@@ -12,13 +12,9 @@ use Pterodactyl\Contracts\Servers\ChangesServerEgg;
|
||||
use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\ServerVariable;
|
||||
use Throwable;
|
||||
|
||||
final readonly class ChangeServerEgg implements ChangesServerEgg
|
||||
{
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function change(Server $server, Egg $egg, bool $keepVariables = false): Server
|
||||
{
|
||||
return DB::transaction(function () use ($server, $egg, $keepVariables): Server {
|
||||
|
||||
@@ -10,16 +10,12 @@ use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\ValidatedInput;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Pterodactyl\Actions\Allocations\CreateAllocations;
|
||||
use Pterodactyl\Contracts\Servers\CreatesServers;
|
||||
use Pterodactyl\Contracts\Servers\DeletesServers;
|
||||
use Pterodactyl\Data\ValidatedEggVariable;
|
||||
use Pterodactyl\Events\Server\OperationCompleted;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
||||
use Pterodactyl\Exceptions\Service\Deployment\NoViableAllocationException;
|
||||
use Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException;
|
||||
use Pterodactyl\Facades\Daemon;
|
||||
use Pterodactyl\Models\Allocation;
|
||||
use Pterodactyl\Models\Egg;
|
||||
@@ -33,7 +29,6 @@ use Pterodactyl\Services\Extensions\ExtensionFields;
|
||||
use Pterodactyl\Services\Extensions\ValidatedExtensionValues;
|
||||
use Pterodactyl\Services\Servers\VariableValidatorService;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Throwable;
|
||||
use UnexpectedValueException;
|
||||
|
||||
final readonly class CreateServer implements CreatesServers
|
||||
@@ -47,11 +42,9 @@ final readonly class CreateServer implements CreatesServers
|
||||
) {}
|
||||
|
||||
/**
|
||||
* A new server's fields. The default allocation and any additional ones must exist and
|
||||
* belong to no server. Memory, disk, CPU and the feature limits take 0 for unlimited,
|
||||
* and swap takes -1. The CPU threads are a pattern of cores such as "0-1,3", which a
|
||||
* bare number also matches. Pass a server being updated so its own external id is not
|
||||
* taken for a duplicate.
|
||||
* Memory, disk, CPU and the feature limits take 0 for unlimited, and swap takes -1. The CPU
|
||||
* threads are a pattern of cores such as "0-1,3", which a bare number also matches. Pass a
|
||||
* server being updated so its own external id is not taken for a duplicate.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -84,15 +77,6 @@ final readonly class CreateServer implements CreatesServers
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws Throwable
|
||||
* @throws DisplayException
|
||||
* @throws ValidationException
|
||||
* @throws NoViableNodeException
|
||||
* @throws NoViableAllocationException
|
||||
*/
|
||||
public function create(array $input, ?DeploymentObject $deployment = null): Server
|
||||
{
|
||||
$rules = self::rules();
|
||||
|
||||
@@ -12,7 +12,6 @@ use Illuminate\Support\Facades\Log;
|
||||
use Pterodactyl\Contracts\Databases\DeletesDatabases;
|
||||
use Pterodactyl\Contracts\Servers\DeletesServers;
|
||||
use Pterodactyl\Events\Server\OperationCompleted;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
||||
use Pterodactyl\Facades\Daemon;
|
||||
use Pterodactyl\Models\Server;
|
||||
@@ -33,10 +32,6 @@ final class DeleteServer implements DeletesServers
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
* @throws DisplayException
|
||||
*/
|
||||
public function delete(Server $server): void
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -18,9 +18,7 @@ final readonly class RecordServerInstallResult implements RecordsServerInstallRe
|
||||
public function __construct(private ServerInstallService $serverInstallService) {}
|
||||
|
||||
/**
|
||||
* An install report's fields, as Wings sends them: whether the install script
|
||||
* succeeded, and whether it ran as a reinstall. The action takes both as bools, which
|
||||
* always meet them.
|
||||
* The action takes both flags as bools, which always meet these rules.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
|
||||
@@ -10,14 +10,9 @@ use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Facades\Daemon;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Throwable;
|
||||
|
||||
final readonly class ReinstallServer implements ReinstallsServers
|
||||
{
|
||||
/**
|
||||
* @throws DisplayException when the server skips its install script and is installed
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function reinstall(Server $server): Server
|
||||
{
|
||||
throw_unless($server->canBeReinstalled(), DisplayException::class, trans('admin/server.exceptions.skipping_install_script'));
|
||||
|
||||
@@ -10,12 +10,6 @@ use Pterodactyl\Models\Server;
|
||||
|
||||
final readonly class ToggleServerInstallStatus implements TogglesServerInstallStatus
|
||||
{
|
||||
/**
|
||||
* Flip a server between installed and installing. A server whose install
|
||||
* failed must be reinstalled instead.
|
||||
*
|
||||
* @throws DisplayException
|
||||
*/
|
||||
public function toggle(Server $server): void
|
||||
{
|
||||
if ($server->status === Server::STATUS_INSTALL_FAILED) {
|
||||
|
||||
@@ -12,7 +12,6 @@ use Pterodactyl\Events\Server\OperationCompleted;
|
||||
use Pterodactyl\Facades\Daemon;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
||||
use Throwable;
|
||||
|
||||
final readonly class ToggleServerSuspension implements TogglesServerSuspension
|
||||
{
|
||||
@@ -20,7 +19,6 @@ final readonly class ToggleServerSuspension implements TogglesServerSuspension
|
||||
|
||||
public const string ACTION_UNSUSPEND = TogglesServerSuspension::ACTION_UNSUSPEND;
|
||||
|
||||
/** @throws Throwable */
|
||||
public function toggle(Server $server, string $action = self::ACTION_SUSPEND): void
|
||||
{
|
||||
throw_unless(in_array($action, [self::ACTION_SUSPEND, self::ACTION_UNSUSPEND], true), InvalidArgumentException::class, "Unsupported suspension action [$action].");
|
||||
|
||||
@@ -15,7 +15,6 @@ use Pterodactyl\Facades\Daemon;
|
||||
use Pterodactyl\Models\Allocation;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Services\Servers\ServerConfigurationStructureService;
|
||||
use Throwable;
|
||||
|
||||
final readonly class UpdateServerBuild implements UpdatesServerBuild
|
||||
{
|
||||
@@ -24,10 +23,7 @@ final readonly class UpdateServerBuild implements UpdatesServerBuild
|
||||
) {}
|
||||
|
||||
/**
|
||||
* A server's build fields. The default allocation must exist and be no other server's
|
||||
* default; pass the server being updated so its own default is not taken for a clash.
|
||||
* The limits take the values a new server takes, and the allocations to add or remove
|
||||
* are lists of allocation ids.
|
||||
* Pass the server being updated so its own default allocation is not taken for a clash.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -54,12 +50,6 @@ final readonly class UpdateServerBuild implements UpdatesServerBuild
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws Throwable
|
||||
* @throws DisplayException
|
||||
*/
|
||||
public function update(Server $server, array $input): Server
|
||||
{
|
||||
$rules = array_map(fn (array $rules): array => ['sometimes', ...$rules], self::rules($server));
|
||||
|
||||
@@ -13,16 +13,13 @@ use Pterodactyl\Jobs\RevokeSftpAccessJob;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Services\Extensions\ExtensionFields;
|
||||
use Pterodactyl\Services\Extensions\ValidatedExtensionValues;
|
||||
use Throwable;
|
||||
|
||||
final readonly class UpdateServerDetails implements UpdatesServerDetails
|
||||
{
|
||||
public function __construct(private ExtensionFields $extensions) {}
|
||||
|
||||
/**
|
||||
* A server's details: its external id, name, owner and description, checked as they
|
||||
* are when a server is created. Pass the server being updated so its own external id
|
||||
* is not taken for a duplicate.
|
||||
* Pass the server being updated so its own external id is not taken for a duplicate.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -38,11 +35,6 @@ final readonly class UpdateServerDetails implements UpdatesServerDetails
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function update(Server $server, array $input): Server
|
||||
{
|
||||
$validated = Validator::validate($input, self::rules($server));
|
||||
|
||||
@@ -7,17 +7,9 @@ namespace Pterodactyl\Actions\Servers;
|
||||
use Pterodactyl\Contracts\Servers\UpdatesServerDockerImage;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Throwable;
|
||||
|
||||
final readonly class UpdateServerDockerImage implements UpdatesServerDockerImage
|
||||
{
|
||||
/**
|
||||
* Set the Docker image a server runs on without touching its startup command
|
||||
* or install script settings. The image is not checked against the egg, so
|
||||
* authorize and validate it first.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function update(Server $server, string $image): Server
|
||||
{
|
||||
$original = $server->image;
|
||||
|
||||
@@ -15,7 +15,6 @@ use Pterodactyl\Models\Egg;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Services\Servers\VariableValidatorService;
|
||||
use Throwable;
|
||||
use UnexpectedValueException;
|
||||
|
||||
final readonly class UpdateServerStartup implements UpdatesServerStartup
|
||||
@@ -28,10 +27,8 @@ final readonly class UpdateServerStartup implements UpdatesServerStartup
|
||||
) {}
|
||||
|
||||
/**
|
||||
* A server's startup fields at the given user level. The environment maps each egg
|
||||
* variable to its value, which the egg's own variable rules check. Only an administrator
|
||||
* changes the startup command, egg, Docker image and install script flag, so below the
|
||||
* admin level the environment is the only field.
|
||||
* The environment maps each egg variable to its value, which the egg's own variable rules
|
||||
* check. Below the admin level the environment is the only field.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -52,11 +49,6 @@ final readonly class UpdateServerStartup implements UpdatesServerStartup
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function update(Server $server, array $input, int $userLevel = User::USER_LEVEL_USER): Server
|
||||
{
|
||||
// Only the fields given are validated, and fields above the user level are ignored.
|
||||
|
||||
@@ -18,16 +18,13 @@ use Pterodactyl\Models\Subuser;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Rules\UserEmail;
|
||||
use Pterodactyl\Services\Servers\SubuserPermissionCatalog;
|
||||
use Throwable;
|
||||
|
||||
final readonly class CreateSubuser implements CreatesSubusers
|
||||
{
|
||||
public function __construct(private CreatesUsers $users, private SubuserPermissionCatalog $catalog) {}
|
||||
|
||||
/**
|
||||
* A subuser's fields: the email address of the user to give access, who is invited when
|
||||
* no account has it, and the permission keys to grant. Pass the keys that can be granted
|
||||
* to hold each permission to them.
|
||||
* Pass the keys that can be granted to hold each permission to them.
|
||||
*
|
||||
* @param list<string>|null $grantable
|
||||
* @return NormalizedValidationRules
|
||||
@@ -41,18 +38,6 @@ final readonly class CreateSubuser implements CreatesSubusers
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new user on the system and assigns them access to the provided server.
|
||||
* If the email address already belongs to a user on the system a new user will not
|
||||
* be created. The returned subuser's user reports wasRecentlyCreated when one was.
|
||||
*
|
||||
* @param list<string> $permissions The permission keys to grant, deduplicated
|
||||
* before they are stored.
|
||||
*
|
||||
* @throws ServerSubuserExistsException
|
||||
* @throws UserIsServerOwnerException
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function create(Server $server, string $email, array $permissions): Subuser
|
||||
{
|
||||
Validator::validate(['email' => $email, 'permissions' => $permissions], self::rules($this->catalog->keys()));
|
||||
|
||||
@@ -11,15 +11,9 @@ use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Jobs\RevokeSftpAccessJob;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\Subuser;
|
||||
use Throwable;
|
||||
|
||||
final readonly class DeleteSubuser implements DeletesSubusers
|
||||
{
|
||||
/**
|
||||
* Removes the subuser from the server and revokes their outstanding SFTP sessions on Wings.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function delete(Server $server, Subuser $subuser): void
|
||||
{
|
||||
DB::transaction(function () use ($server, $subuser): void {
|
||||
|
||||
@@ -14,20 +14,11 @@ use Pterodactyl\Jobs\RevokeSftpAccessJob;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\Subuser;
|
||||
use Pterodactyl\Services\Servers\SubuserPermissionCatalog;
|
||||
use Throwable;
|
||||
|
||||
final readonly class UpdateSubuser implements UpdatesSubusers
|
||||
{
|
||||
public function __construct(private SubuserPermissionCatalog $catalog) {}
|
||||
|
||||
/**
|
||||
* Replaces the subuser's permissions and revokes their outstanding SFTP sessions on Wings.
|
||||
* Permissions that are already the subuser's, in any order, change nothing.
|
||||
*
|
||||
* @param list<string> $permissions
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function update(Server $server, Subuser $subuser, array $permissions): Subuser
|
||||
{
|
||||
// A permission the subuser already holds stays grantable even once nothing defines
|
||||
|
||||
@@ -13,9 +13,9 @@ use Pterodactyl\Rules\TagSlug;
|
||||
final readonly class CreateTag implements CreatesTags
|
||||
{
|
||||
/**
|
||||
* A tag's fields. Pass the tag being edited so its own slug does not collide with the
|
||||
* uniqueness check. A slug may not be purely numeric, so a leftover legacy nest id can be
|
||||
* told apart from a real tag and a slug can never shadow a tag id (see TagSlug).
|
||||
* Pass the tag being edited so its own slug does not collide with the uniqueness check. A
|
||||
* slug may not be purely numeric, so a leftover legacy nest id can be told apart from a real
|
||||
* tag and a slug can never shadow a tag id (see TagSlug).
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -31,9 +31,6 @@ final readonly class CreateTag implements CreatesTags
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $input
|
||||
*/
|
||||
public function create(array $input): Tag
|
||||
{
|
||||
$validated = Validator::validate($input, self::rules());
|
||||
|
||||
@@ -11,15 +11,10 @@ use Pterodactyl\Models\Tag;
|
||||
|
||||
final readonly class DeleteTag implements DeletesTags
|
||||
{
|
||||
/**
|
||||
* Delete a tag and detach it from every egg and node. Built-in game tags cannot be
|
||||
* deleted because the cascading pivot cleanup would discard every egg and node
|
||||
* assignment, and recreating the tag later cannot restore those associations.
|
||||
*
|
||||
* @throws DisplayException
|
||||
*/
|
||||
public function delete(Tag $tag): void
|
||||
{
|
||||
// The cascading pivot cleanup would discard every egg and node assignment of a built-in
|
||||
// tag, and recreating the tag later cannot restore them.
|
||||
throw_if(EggSpecificTags::isSpecial($tag->slug), DisplayException::class, 'Built-in game tags cannot be deleted.');
|
||||
|
||||
$tag->delete();
|
||||
|
||||
@@ -27,12 +27,7 @@ final readonly class SyncTags implements SyncsTags
|
||||
|
||||
public function __construct(private TagResolutionService $resolver) {}
|
||||
|
||||
/**
|
||||
* The tags to sync, each an existing tag's id or a new tag's name. An id may also be an
|
||||
* integer.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
/** @return NormalizedValidationRules */
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
@@ -45,8 +40,7 @@ final readonly class SyncTags implements SyncsTags
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates tag values under `tags` and returns them as strings for the resolver, an
|
||||
* integer id becoming the numeric string the panel sends.
|
||||
* An integer id becomes the numeric string the panel sends.
|
||||
*
|
||||
* @param list<mixed> $values
|
||||
* @return list<string>
|
||||
@@ -58,19 +52,16 @@ final readonly class SyncTags implements SyncsTags
|
||||
return array_map(fn (int|string $key): string => $input->string('tags.'.$key)->toString(), array_keys($input->array('tags')));
|
||||
}
|
||||
|
||||
/** @param list<mixed> $values */
|
||||
public function syncEgg(Egg $egg, array $values): void
|
||||
{
|
||||
$this->sync($egg, $egg->tags(), self::values($values));
|
||||
}
|
||||
|
||||
/** @param list<mixed> $values */
|
||||
public function syncNodeGames(Node $node, array $values): void
|
||||
{
|
||||
$this->sync($node, $node->eggTags(), self::values($values), $node->deploymentTags());
|
||||
}
|
||||
|
||||
/** @param list<mixed> $values */
|
||||
public function syncNodeDeployments(Node $node, array $values): void
|
||||
{
|
||||
$this->sync($node, $node->deploymentTags(), self::values($values), $node->eggTags());
|
||||
|
||||
@@ -12,17 +12,10 @@ use Pterodactyl\Models\Tag;
|
||||
|
||||
final readonly class UpdateTag implements UpdatesTags
|
||||
{
|
||||
/**
|
||||
* Update an existing tag. A built-in game tag's slug is the key feature gating matches on
|
||||
* and its presentation comes from the EggSpecificTags enum, so it must never be renamed or
|
||||
* relabelled.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws DisplayException
|
||||
*/
|
||||
public function update(Tag $tag, array $input): Tag
|
||||
{
|
||||
// Feature gating matches on a built-in tag's slug and EggSpecificTags owns its
|
||||
// presentation, so it is never renamed or relabelled.
|
||||
throw_if(EggSpecificTags::isSpecial($tag->slug), DisplayException::class, 'Built-in game tags cannot be edited.');
|
||||
|
||||
$validated = Validator::validate($input, CreateTag::rules($tag));
|
||||
|
||||
@@ -16,7 +16,6 @@ final readonly class ApplyTheme implements AppliesThemes
|
||||
{
|
||||
public function __construct(private ThemeService $themes, private FilesystemChanges $files) {}
|
||||
|
||||
/** Publish a theme's tokens.css (and optional assets/ directory). */
|
||||
public function apply(string $id): void
|
||||
{
|
||||
$theme = $this->themes->discovered()[$id] ?? null;
|
||||
|
||||
@@ -12,7 +12,6 @@ final readonly class ResetTheme implements ResetsThemes
|
||||
{
|
||||
public function __construct(private ThemeService $themes, private FilesystemChanges $files) {}
|
||||
|
||||
/** Remove the published theme, restoring the stock look. */
|
||||
public function reset(): void
|
||||
{
|
||||
$this->files->run([
|
||||
|
||||
@@ -14,15 +14,9 @@ use Pterodactyl\Facades\Daemon;
|
||||
use Pterodactyl\Models\Allocation;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Models\ServerTransfer;
|
||||
use Throwable;
|
||||
|
||||
final readonly class CompleteTransfer implements CompletesTransfers
|
||||
{
|
||||
/**
|
||||
* Moves the server onto its new node and allocations, then removes it from the old node.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function complete(ServerTransfer $transfer): Server
|
||||
{
|
||||
$server = DB::transaction(function () use ($transfer): Server {
|
||||
|
||||
@@ -10,15 +10,9 @@ use Pterodactyl\Contracts\Transfers\FailsTransfers;
|
||||
use Pterodactyl\Events\Server\OperationCompleted;
|
||||
use Pterodactyl\Models\Allocation;
|
||||
use Pterodactyl\Models\ServerTransfer;
|
||||
use Throwable;
|
||||
|
||||
final readonly class FailTransfer implements FailsTransfers
|
||||
{
|
||||
/**
|
||||
* Marks the transfer as failed and releases the allocations reserved on the target node.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function fail(ServerTransfer $transfer): void
|
||||
{
|
||||
DB::transaction(function () use ($transfer): void {
|
||||
|
||||
@@ -33,11 +33,7 @@ final readonly class InitiateTransfer implements InitiatesTransfers
|
||||
) {}
|
||||
|
||||
/**
|
||||
* A transfer's fields: a node other than the server's own, the allocation the server
|
||||
* takes as its default there, and any additional ones. The default allocation must
|
||||
* exist and be no server's default; the additional ones are integers or numeric
|
||||
* strings. Once these pass, validateAllocations() checks the allocations are free and
|
||||
* on the node.
|
||||
* Once these pass, validateAllocations() checks the allocations are free and on the node.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -78,17 +74,6 @@ final readonly class InitiateTransfer implements InitiatesTransfers
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Records the transfer, reserves the target allocations, and tells the destination
|
||||
* node to begin pulling the server. Wings is called after the records commit; if it
|
||||
* rejects the transfer, it is marked failed and its allocations are released.
|
||||
*
|
||||
* @param list<int> $additionalAllocations
|
||||
*
|
||||
* @throws DisplayException
|
||||
* @throws ValidationException
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function initiate(Server $server, Node $node, int $allocationId, array $additionalAllocations): ServerTransfer
|
||||
{
|
||||
$additionalAllocations = $this->additionalAllocations($server, $node, $allocationId, $additionalAllocations);
|
||||
@@ -147,9 +132,8 @@ final readonly class InitiateTransfer implements InitiatesTransfers
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the transfer of the server to the node and returns the additional
|
||||
* allocations, as integers. Missing additional allocations fail `allocation_additional.N`
|
||||
* as an exists rule would, all looked up in one query.
|
||||
* Missing additional allocations fail `allocation_additional.N` as an exists rule would, all
|
||||
* looked up in one query.
|
||||
*
|
||||
* @param list<int> $additionalAllocations
|
||||
* @return list<int>
|
||||
|
||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace Pterodactyl\Actions\Users;
|
||||
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Pterodactyl\Contracts\Users\CreatesSshKeys;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Models\User;
|
||||
@@ -37,8 +36,7 @@ final readonly class CreateSshKey implements CreatesSshKeys
|
||||
];
|
||||
|
||||
/**
|
||||
* An SSH key's fields: its name, the public key and the key's fingerprint. A key a
|
||||
* request parses is first held to PUBLIC_KEY_MAX_LENGTH and isSupportedPublicKey().
|
||||
* A key a request parses is first held to PUBLIC_KEY_MAX_LENGTH and isSupportedPublicKey().
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -73,7 +71,6 @@ final readonly class CreateSshKey implements CreatesSshKeys
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @throws ValidationException */
|
||||
public function create(User $user, string $name, string $publicKey, string $fingerprint): UserSSHKey
|
||||
{
|
||||
$attributes = Validator::validate(['name' => $name, 'public_key' => $publicKey, 'fingerprint' => $fingerprint], self::rules());
|
||||
|
||||
@@ -19,7 +19,6 @@ use Pterodactyl\Rules\UserEmail;
|
||||
use Pterodactyl\Rules\Username;
|
||||
use Pterodactyl\Services\Extensions\ExtensionFields;
|
||||
use Pterodactyl\Services\Extensions\ValidatedExtensionValues;
|
||||
use Throwable;
|
||||
|
||||
final readonly class CreateUser implements CreatesUsers
|
||||
{
|
||||
@@ -37,8 +36,8 @@ final readonly class CreateUser implements CreatesUsers
|
||||
}
|
||||
|
||||
/**
|
||||
* A user's fields. Pass the user being updated so its own email, username and external
|
||||
* id are not taken for duplicates.
|
||||
* Pass the user being updated so its own email, username and external id are not taken for
|
||||
* duplicates.
|
||||
*
|
||||
* @return NormalizedValidationRules
|
||||
*/
|
||||
@@ -56,17 +55,6 @@ final readonly class CreateUser implements CreatesUsers
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user on the system. When no password is provided a random one is
|
||||
* set and a password reset token is generated for the account welcome email.
|
||||
*
|
||||
* The UUID and password hash are handled by the model itself (HasVersion4Uuids
|
||||
* and the hashed password cast).
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function create(array $input): User
|
||||
{
|
||||
$attributes = Validator::validate($input, self::rules());
|
||||
|
||||
@@ -10,11 +10,6 @@ use Pterodactyl\Models\User;
|
||||
|
||||
final class DeleteUser implements DeletesUsers
|
||||
{
|
||||
/**
|
||||
* Delete a user from the panel only if they have no servers attached to their account.
|
||||
*
|
||||
* @throws DisplayException
|
||||
*/
|
||||
public function delete(User $user): ?bool
|
||||
{
|
||||
if ($user->servers()->exists()) {
|
||||
|
||||
@@ -14,13 +14,6 @@ final readonly class SetupTwoFactor implements SetsUpTwoFactor
|
||||
{
|
||||
public const string VALID_BASE32_CHARACTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
||||
|
||||
/**
|
||||
* Generate a 2FA token and store it in the database before returning the
|
||||
* QR code URL. This URL will need to be attached to a QR generating service in
|
||||
* order to function.
|
||||
*
|
||||
* @return array{image_url_data: string, secret: string}
|
||||
*/
|
||||
public function setup(User $user): array
|
||||
{
|
||||
$secret = '';
|
||||
|
||||
@@ -8,34 +8,18 @@ use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException;
|
||||
use PragmaRX\Google2FA\Exceptions\InvalidCharactersException;
|
||||
use PragmaRX\Google2FA\Exceptions\SecretKeyTooShortException;
|
||||
use PragmaRX\Google2FA\Google2FA;
|
||||
use Pterodactyl\Contracts\Users\TogglesTwoFactor;
|
||||
use Pterodactyl\Exceptions\Service\User\TwoFactorAuthenticationTokenInvalid;
|
||||
use Pterodactyl\Facades\Activity;
|
||||
use Pterodactyl\Models\RecoveryToken;
|
||||
use Pterodactyl\Models\User;
|
||||
use Throwable;
|
||||
use UnexpectedValueException;
|
||||
|
||||
final readonly class ToggleTwoFactor implements TogglesTwoFactor
|
||||
{
|
||||
public function __construct(private Google2FA $google2FA) {}
|
||||
|
||||
/**
|
||||
* Toggle 2FA on an account only if the token provided is valid.
|
||||
*
|
||||
* @return list<string> The plaintext recovery tokens generated for the account,
|
||||
* empty when 2FA is being turned off.
|
||||
*
|
||||
* @throws Throwable
|
||||
* @throws IncompatibleWithGoogleAuthenticatorException
|
||||
* @throws InvalidCharactersException
|
||||
* @throws SecretKeyTooShortException
|
||||
* @throws TwoFactorAuthenticationTokenInvalid
|
||||
*/
|
||||
public function toggle(User $user, string $token, ?bool $toggleState = null): array
|
||||
{
|
||||
$encryptedSecret = $user->totp_secret;
|
||||
|
||||
@@ -11,20 +11,11 @@ use Pterodactyl\Events\User\PasswordChanged;
|
||||
use Pterodactyl\Models\User;
|
||||
use Pterodactyl\Services\Extensions\ExtensionFields;
|
||||
use Pterodactyl\Services\Extensions\ValidatedExtensionValues;
|
||||
use Throwable;
|
||||
|
||||
final readonly class UpdateUser implements UpdatesUsers
|
||||
{
|
||||
public function __construct(private ExtensionFields $extensions) {}
|
||||
|
||||
/**
|
||||
* Update the user model instance and return the updated model. The hashed
|
||||
* password cast on the model takes care of hashing a new password.
|
||||
*
|
||||
* @param array<string, mixed> $input
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function update(User $user, array $input): User
|
||||
{
|
||||
$rules = array_map(fn (array $rules): array => ['sometimes', ...$rules], CreateUser::rules($user));
|
||||
|
||||
@@ -19,9 +19,6 @@ final readonly class UpdateUserEmail implements UpdatesUserEmails
|
||||
|
||||
public function __construct(private UpdatesUsers $users) {}
|
||||
|
||||
/**
|
||||
* @return array{user: User, original: string, email: string, changed: bool}
|
||||
*/
|
||||
public function update(User $user, string $email): array
|
||||
{
|
||||
throw_if(RateLimiter::tooManyAttempts($key = $this->throttleKey($user), self::THROTTLE_MAX), TooManyRequestsHttpException::class, 'Your email address has been changed too many times today. Please try again later.');
|
||||
|
||||
@@ -15,10 +15,6 @@ final readonly class UpdateUserPassword implements UpdatesUserPasswords
|
||||
{
|
||||
public function __construct(private UpdatesUsers $users) {}
|
||||
|
||||
/**
|
||||
* Changing a password, through the account page or a reset link, also ends every other
|
||||
* session and "remember me" login made with the old one.
|
||||
*/
|
||||
public function update(User $user, string $password): User
|
||||
{
|
||||
$user = $this->users->update($user, ['password' => $password]);
|
||||
|
||||
@@ -10,10 +10,9 @@ use Pterodactyl\Models\Node;
|
||||
interface IngestsActivityLogs
|
||||
{
|
||||
/**
|
||||
* Record the activity a node reported against the servers it runs. The input is the
|
||||
* report Wings sends, validated here under the field names of its protocol, so it can
|
||||
* come straight from any caller. Events for servers on other nodes, and events outside
|
||||
* the `server:` namespace, are dropped.
|
||||
* Record the activity a node reported against the servers it runs. The input is the report
|
||||
* Wings sends, validated here under the field names of its protocol. Events for servers on
|
||||
* other nodes, and events outside the `server:` namespace, are dropped.
|
||||
*
|
||||
* @param array<string, mixed> $input data: the events, each with server, event, metadata and timestamp, and optionally user and ip
|
||||
*
|
||||
|
||||
@@ -14,9 +14,8 @@ use Pterodactyl\Models\Node;
|
||||
interface CreatesAllocations
|
||||
{
|
||||
/**
|
||||
* Create the allocations of one address on a node. The input is validated here, so it can
|
||||
* come straight from any caller. A port that cannot be read, falls outside 1025-65535 or
|
||||
* opens a range of more than 1000 ports is refused with the exceptions below.
|
||||
* The input is validated here. A port that cannot be read, falls outside 1025-65535 or opens
|
||||
* a range of more than 1000 ports is refused with the exceptions below.
|
||||
*
|
||||
* @param array<string, mixed> $input allocation_ip (an IP address, CIDR range or hostname), allocation_ports (port numbers, or ranges such as "25565-25570") and optionally allocation_alias
|
||||
*
|
||||
|
||||
@@ -10,7 +10,7 @@ use Pterodactyl\Models\Allocation;
|
||||
interface DeletesAllocations
|
||||
{
|
||||
/**
|
||||
* Delete an allocation, provided no server is attached to it.
|
||||
* An allocation a server is using is not deleted.
|
||||
*
|
||||
* @throws ServerUsingAllocationException
|
||||
*/
|
||||
|
||||
@@ -11,10 +11,9 @@ use Pterodactyl\Models\User;
|
||||
interface CreatesAccountApiKeys
|
||||
{
|
||||
/**
|
||||
* Create an account API key for the user, who may hold at most 25. The description and
|
||||
* the allowed IPs are validated here, so they can come straight from any caller: the
|
||||
* description is required, and each allowed IP must be an IP address or a CIDR range.
|
||||
* A key given no allowed IPs can be used from any address.
|
||||
* A user holds at most 25 account keys. The description and the allowed IPs are validated
|
||||
* here: the description is required, and each allowed IP must be an IP address or a CIDR
|
||||
* range. A key given no allowed IPs can be used from any address.
|
||||
*
|
||||
* @param list<string>|null $allowedIps
|
||||
*
|
||||
|
||||
@@ -9,11 +9,10 @@ use Pterodactyl\Models\ApiKey;
|
||||
interface CreatesApiKeys
|
||||
{
|
||||
/**
|
||||
* Create an API key of the given type with a fresh identifier and token. The input and
|
||||
* the permissions are validated here, so they can come straight from any caller. Each
|
||||
* allowed IP must be an IP address or a CIDR range. The permissions are only applied to
|
||||
* application keys: each is AdminAcl::NONE or AdminAcl::READ and AdminAcl::WRITE
|
||||
* combined, and a resource left out gets AdminAcl::NONE.
|
||||
* The input and the permissions are validated here, and each allowed IP must be an IP
|
||||
* address or a CIDR range. The permissions only apply to application keys: each is
|
||||
* AdminAcl::NONE or AdminAcl::READ and AdminAcl::WRITE combined, and a resource left out
|
||||
* gets AdminAcl::NONE.
|
||||
*
|
||||
* @param array<string, mixed> $input memo and user_id, and optionally allowed_ips
|
||||
* @param array<string, mixed> $permissions the r_* column of any AdminAcl resource
|
||||
|
||||
@@ -9,9 +9,8 @@ use Pterodactyl\Models\ApiKey;
|
||||
interface UpdatesApiKeys
|
||||
{
|
||||
/**
|
||||
* Update an API key's attributes without regenerating its token. The input and the
|
||||
* permissions are validated here, so they can come straight from any caller. Only what
|
||||
* is given changes, and the permissions are only applied to application keys.
|
||||
* The token is kept. The input and the permissions are validated here, only what is given
|
||||
* changes, and the permissions only apply to application keys.
|
||||
*
|
||||
* @param array<string, mixed> $input optionally memo
|
||||
* @param array<string, mixed> $permissions the r_* column of any AdminAcl resource
|
||||
|
||||
@@ -12,10 +12,10 @@ use Throwable;
|
||||
interface CompletesBackups
|
||||
{
|
||||
/**
|
||||
* Record the outcome Wings reported for a backup. The input is validated here, so it can
|
||||
* come straight from any caller, under the field names of the Wings protocol. A
|
||||
* successful backup needs its checksum, checksum type and size; S3 parts left out are
|
||||
* listed from S3 when the multipart upload is completed.
|
||||
* Record the outcome Wings reported for a backup and complete or abort its S3 multipart
|
||||
* upload. The input is validated here under the field names of the Wings protocol: a
|
||||
* successful backup needs its checksum, checksum type and size, and S3 parts left out are
|
||||
* listed from S3.
|
||||
*
|
||||
* @param array<string, mixed> $input successful, checksum, checksum_type, size and optionally parts, each with an etag and part_number
|
||||
*
|
||||
|
||||
@@ -9,6 +9,10 @@ use Throwable;
|
||||
|
||||
interface DeletesBackups
|
||||
{
|
||||
/** @throws Throwable */
|
||||
/**
|
||||
* An S3 backup's archive is deleted from its bucket as well.
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function delete(Backup $backup): void;
|
||||
}
|
||||
|
||||
@@ -9,5 +9,9 @@ use Pterodactyl\Models\User;
|
||||
|
||||
interface GeneratesBackupDownloadLinks
|
||||
{
|
||||
/**
|
||||
* A short-lived link the user can download the backup from: a presigned S3 URL, or a signed
|
||||
* link to the backup on its node.
|
||||
*/
|
||||
public function generate(Backup $backup, User $user): string;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user