Merge branch 'develop' into feature/react-admin

This commit is contained in:
Matthew Penner 2021-01-23 14:39:23 -07:00
commit 8feb87de7c
532 changed files with 4262 additions and 5622 deletions

View file

@ -25,6 +25,12 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Bump Version
if: "!contains(github.ref, 'develop')"
env:
REF: ${{ github.ref }}
run: |
sed -i "s/ 'version' => 'canary',/ 'version' => '${REF:11}',/" config/app.php
- name: Release Production Build
uses: docker/build-push-action@v2
if: "!contains(github.ref, 'develop')"

View file

@ -19,9 +19,9 @@ jobs:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: true
fail-fast: false
matrix:
php: [7.4]
php: [7.4, 8.0]
name: PHP ${{ matrix.php }}
steps:
- name: checkout
@ -59,9 +59,9 @@ jobs:
env:
DB_CONNECTION: testing
TESTING_DB_HOST: UNIT_NO_DB
# - name: execute integration tests
# run: vendor/bin/phpunit tests/Integration
# if: ${{ always() }}
# env:
# TESTING_DB_PORT: ${{ job.services.mysql.ports[3306] }}
# TESTING_DB_USERNAME: root
- name: execute integration tests
run: vendor/bin/phpunit tests/Integration
if: ${{ always() }}
env:
TESTING_DB_PORT: ${{ job.services.mysql.ports[3306] }}
TESTING_DB_USERNAME: root

49
.php_cs
View file

@ -1,58 +1,43 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in([
'app',
'bootstrap',
'config',
'database',
'resources/lang',
'routes',
'tests',
]);
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
return PhpCsFixer\Config::create()
$finder = (new Finder)->in([
'app',
'bootstrap',
'config',
'database',
'resources/lang',
'routes',
'tests',
]);
return (new Config)
->setRiskyAllowed(true)
->setFinder($finder)
->setRules([
'@Symfony' => true,
'@PSR1' => true,
'@PSR2' => true,
'@PSR12' => true,
'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
'array_syntax' => ['syntax' => 'short'],
'blank_line_before_return' => true,
'blank_line_before_statement' => false,
'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'single'],
'heredoc_to_nowdoc' => true,
'increment_style' => ['style' => 'post'],
'linebreak_after_opening_tag' => true,
'method_argument_space' => [
'ensure_fully_multiline' => false,
'keep_multiple_spaces_after_comma' => false,
],
'new_with_braces' => false,
'no_alias_functions' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_superfluous_phpdoc_tags' => false,
'no_unreachable_default_argument_value' => true,
'no_useless_return' => true,
'not_operator_with_successor_space' => true,
'ordered_imports' => [
'sortAlgorithm' => 'length',
],
'phpdoc_align' => false,
'phpdoc_separation' => false,
'protected_to_private' => false,
'psr0' => ['dir' => 'app'],
'psr4' => true,
'random_api_migration' => true,
'single_line_throw' => false,
'single_trait_insert_per_statement' => false,
'standardize_not_equals' => true,
'ternary_to_null_coalescing' => true,
'yoda_style' => [
'equal' => false,
'identical' => false,
'less_and_greater' => false,
],
])->setRiskyAllowed(true)->setFinder($finder);
]);

View file

@ -3,6 +3,9 @@ This file is a running track of new features and fixes to each version of the pa
This project follows [Semantic Versioning](http://semver.org) guidelines.
## v1.2.2
* **[security]** Fixes authentication bypass allowing a user to take control of specific server actions such as executing schedules, rotating database passwords, and viewing or deleting a backup.
## v1.2.1
### Fixed
* Fixes URL-encoding of filenames when working in the filemanager to fix issues when moving, renaming, or deleting files.

View file

@ -19,13 +19,13 @@ class AppSettingsCommand extends Command
{
use EnvironmentWriterTrait;
const ALLOWED_CACHE_DRIVERS = [
public const ALLOWED_CACHE_DRIVERS = [
'redis' => 'Redis (recommended)',
'memcached' => 'Memcached',
'file' => 'Filesystem',
];
const ALLOWED_SESSION_DRIVERS = [
public const ALLOWED_SESSION_DRIVERS = [
'redis' => 'Redis (recommended)',
'memcached' => 'Memcached',
'database' => 'MySQL Database',
@ -33,7 +33,7 @@ class AppSettingsCommand extends Command
'cookie' => 'Cookie',
];
const ALLOWED_QUEUE_DRIVERS = [
public const ALLOWED_QUEUE_DRIVERS = [
'redis' => 'Redis (recommended)',
'database' => 'MySQL Database',
'sync' => 'Sync',
@ -77,9 +77,6 @@ class AppSettingsCommand extends Command
/**
* AppSettingsCommand constructor.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Illuminate\Contracts\Console\Kernel $command
*/
public function __construct(ConfigRepository $config, Kernel $command)
{
@ -102,43 +99,45 @@ class AppSettingsCommand extends Command
$this->output->comment(trans('command/messages.environment.app.author_help'));
$this->variables['APP_SERVICE_AUTHOR'] = $this->option('author') ?? $this->ask(
trans('command/messages.environment.app.author'), $this->config->get('pterodactyl.service.author', 'unknown@unknown.com')
);
trans('command/messages.environment.app.author'),
$this->config->get('pterodactyl.service.author', 'unknown@unknown.com')
);
$this->output->comment(trans('command/messages.environment.app.app_url_help'));
$this->variables['APP_URL'] = $this->option('url') ?? $this->ask(
trans('command/messages.environment.app.app_url'), $this->config->get('app.url', 'http://example.org')
);
trans('command/messages.environment.app.app_url'),
$this->config->get('app.url', 'http://example.org')
);
$this->output->comment(trans('command/messages.environment.app.timezone_help'));
$this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
trans('command/messages.environment.app.timezone'),
DateTimeZone::listIdentifiers(DateTimeZone::ALL),
$this->config->get('app.timezone')
);
trans('command/messages.environment.app.timezone'),
DateTimeZone::listIdentifiers(DateTimeZone::ALL),
$this->config->get('app.timezone')
);
$selected = $this->config->get('cache.default', 'redis');
$this->variables['CACHE_DRIVER'] = $this->option('cache') ?? $this->choice(
trans('command/messages.environment.app.cache_driver'),
self::ALLOWED_CACHE_DRIVERS,
array_key_exists($selected, self::ALLOWED_CACHE_DRIVERS) ? $selected : null
);
trans('command/messages.environment.app.cache_driver'),
self::ALLOWED_CACHE_DRIVERS,
array_key_exists($selected, self::ALLOWED_CACHE_DRIVERS) ? $selected : null
);
$selected = $this->config->get('session.driver', 'redis');
$this->variables['SESSION_DRIVER'] = $this->option('session') ?? $this->choice(
trans('command/messages.environment.app.session_driver'),
self::ALLOWED_SESSION_DRIVERS,
array_key_exists($selected, self::ALLOWED_SESSION_DRIVERS) ? $selected : null
);
trans('command/messages.environment.app.session_driver'),
self::ALLOWED_SESSION_DRIVERS,
array_key_exists($selected, self::ALLOWED_SESSION_DRIVERS) ? $selected : null
);
$selected = $this->config->get('queue.default', 'redis');
$this->variables['QUEUE_CONNECTION'] = $this->option('queue') ?? $this->choice(
trans('command/messages.environment.app.queue_driver'),
self::ALLOWED_QUEUE_DRIVERS,
array_key_exists($selected, self::ALLOWED_QUEUE_DRIVERS) ? $selected : null
);
trans('command/messages.environment.app.queue_driver'),
self::ALLOWED_QUEUE_DRIVERS,
array_key_exists($selected, self::ALLOWED_QUEUE_DRIVERS) ? $selected : null
);
if (! is_null($this->option('settings-ui'))) {
if (!is_null($this->option('settings-ui'))) {
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->option('settings-ui') == 'true' ? 'false' : 'true';
} else {
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm(trans('command/messages.environment.app.settings'), true) ? 'false' : 'true';
@ -171,11 +170,12 @@ class AppSettingsCommand extends Command
$this->output->note(trans('command/messages.environment.app.using_redis'));
$this->variables['REDIS_HOST'] = $this->option('redis-host') ?? $this->ask(
trans('command/messages.environment.app.redis_host'), $this->config->get('database.redis.default.host')
);
trans('command/messages.environment.app.redis_host'),
$this->config->get('database.redis.default.host')
);
$askForRedisPassword = true;
if (! empty($this->config->get('database.redis.default.password'))) {
if (!empty($this->config->get('database.redis.default.password'))) {
$this->variables['REDIS_PASSWORD'] = $this->config->get('database.redis.default.password');
$askForRedisPassword = $this->confirm(trans('command/messages.environment.app.redis_pass_defined'));
}
@ -183,8 +183,8 @@ class AppSettingsCommand extends Command
if ($askForRedisPassword) {
$this->output->comment(trans('command/messages.environment.app.redis_pass_help'));
$this->variables['REDIS_PASSWORD'] = $this->option('redis-pass') ?? $this->output->askHidden(
trans('command/messages.environment.app.redis_password')
);
trans('command/messages.environment.app.redis_password')
);
}
if (empty($this->variables['REDIS_PASSWORD'])) {
@ -192,7 +192,8 @@ class AppSettingsCommand extends Command
}
$this->variables['REDIS_PORT'] = $this->option('redis-port') ?? $this->ask(
trans('command/messages.environment.app.redis_port'), $this->config->get('database.redis.default.port')
);
trans('command/messages.environment.app.redis_port'),
$this->config->get('database.redis.default.port')
);
}
}

View file

@ -57,10 +57,6 @@ class DatabaseSettingsCommand extends Command
/**
* DatabaseSettingsCommand constructor.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Illuminate\Database\DatabaseManager $database
* @param \Illuminate\Contracts\Console\Kernel $console
*/
public function __construct(ConfigRepository $config, DatabaseManager $database, Kernel $console)
{
@ -82,24 +78,28 @@ class DatabaseSettingsCommand extends Command
{
$this->output->note(trans('command/messages.environment.database.host_warning'));
$this->variables['DB_HOST'] = $this->option('host') ?? $this->ask(
trans('command/messages.environment.database.host'), $this->config->get('database.connections.mysql.host', '127.0.0.1')
);
trans('command/messages.environment.database.host'),
$this->config->get('database.connections.mysql.host', '127.0.0.1')
);
$this->variables['DB_PORT'] = $this->option('port') ?? $this->ask(
trans('command/messages.environment.database.port'), $this->config->get('database.connections.mysql.port', 3306)
);
trans('command/messages.environment.database.port'),
$this->config->get('database.connections.mysql.port', 3306)
);
$this->variables['DB_DATABASE'] = $this->option('database') ?? $this->ask(
trans('command/messages.environment.database.database'), $this->config->get('database.connections.mysql.database', 'panel')
);
trans('command/messages.environment.database.database'),
$this->config->get('database.connections.mysql.database', 'panel')
);
$this->output->note(trans('command/messages.environment.database.username_warning'));
$this->variables['DB_USERNAME'] = $this->option('username') ?? $this->ask(
trans('command/messages.environment.database.username'), $this->config->get('database.connections.mysql.username', 'pterodactyl')
);
trans('command/messages.environment.database.username'),
$this->config->get('database.connections.mysql.username', 'pterodactyl')
);
$askForMySQLPassword = true;
if (! empty($this->config->get('database.connections.mysql.password')) && $this->input->isInteractive()) {
if (!empty($this->config->get('database.connections.mysql.password')) && $this->input->isInteractive()) {
$this->variables['DB_PASSWORD'] = $this->config->get('database.connections.mysql.password');
$askForMySQLPassword = $this->confirm(trans('command/messages.environment.database.password_defined'));
}

View file

@ -47,8 +47,6 @@ class EmailSettingsCommand extends Command
/**
* EmailSettingsCommand constructor.
*
* @param \Illuminate\Contracts\Config\Repository $config
*/
public function __construct(ConfigRepository $config)
{
@ -65,13 +63,15 @@ class EmailSettingsCommand extends Command
public function handle()
{
$this->variables['MAIL_DRIVER'] = $this->option('driver') ?? $this->choice(
trans('command/messages.environment.mail.ask_driver'), [
trans('command/messages.environment.mail.ask_driver'),
[
'smtp' => 'SMTP Server',
'mail' => 'PHP\'s Internal Mail Function',
'mailgun' => 'Mailgun Transactional Email',
'mandrill' => 'Mandrill Transactional Email',
'postmark' => 'Postmarkapp Transactional Email',
], $this->config->get('mail.driver', 'smtp')
],
$this->config->get('mail.driver', 'smtp')
);
$method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables';
@ -80,16 +80,20 @@ class EmailSettingsCommand extends Command
}
$this->variables['MAIL_FROM'] = $this->option('email') ?? $this->ask(
trans('command/messages.environment.mail.ask_mail_from'), $this->config->get('mail.from.address')
);
trans('command/messages.environment.mail.ask_mail_from'),
$this->config->get('mail.from.address')
);
$this->variables['MAIL_FROM_NAME'] = $this->option('from') ?? $this->ask(
trans('command/messages.environment.mail.ask_mail_name'), $this->config->get('mail.from.name')
);
trans('command/messages.environment.mail.ask_mail_name'),
$this->config->get('mail.from.name')
);
$this->variables['MAIL_ENCRYPTION'] = $this->option('encryption') ?? $this->choice(
trans('command/messages.environment.mail.ask_encryption'), ['tls' => 'TLS', 'ssl' => 'SSL', '' => 'None'], $this->config->get('mail.encryption', 'tls')
);
trans('command/messages.environment.mail.ask_encryption'),
['tls' => 'TLS', 'ssl' => 'SSL', '' => 'None'],
$this->config->get('mail.encryption', 'tls')
);
$this->writeToEnvironment($this->variables);
@ -103,20 +107,23 @@ class EmailSettingsCommand extends Command
private function setupSmtpDriverVariables()
{
$this->variables['MAIL_HOST'] = $this->option('host') ?? $this->ask(
trans('command/messages.environment.mail.ask_smtp_host'), $this->config->get('mail.host')
);
trans('command/messages.environment.mail.ask_smtp_host'),
$this->config->get('mail.host')
);
$this->variables['MAIL_PORT'] = $this->option('port') ?? $this->ask(
trans('command/messages.environment.mail.ask_smtp_port'), $this->config->get('mail.port')
);
trans('command/messages.environment.mail.ask_smtp_port'),
$this->config->get('mail.port')
);
$this->variables['MAIL_USERNAME'] = $this->option('username') ?? $this->ask(
trans('command/messages.environment.mail.ask_smtp_username'), $this->config->get('mail.username')
);
trans('command/messages.environment.mail.ask_smtp_username'),
$this->config->get('mail.username')
);
$this->variables['MAIL_PASSWORD'] = $this->option('password') ?? $this->secret(
trans('command/messages.environment.mail.ask_smtp_password')
);
trans('command/messages.environment.mail.ask_smtp_password')
);
}
/**
@ -125,12 +132,14 @@ class EmailSettingsCommand extends Command
private function setupMailgunDriverVariables()
{
$this->variables['MAILGUN_DOMAIN'] = $this->option('host') ?? $this->ask(
trans('command/messages.environment.mail.ask_mailgun_domain'), $this->config->get('services.mailgun.domain')
);
trans('command/messages.environment.mail.ask_mailgun_domain'),
$this->config->get('services.mailgun.domain')
);
$this->variables['MAILGUN_SECRET'] = $this->option('password') ?? $this->ask(
trans('command/messages.environment.mail.ask_mailgun_secret'), $this->config->get('services.mailgun.secret')
);
trans('command/messages.environment.mail.ask_mailgun_secret'),
$this->config->get('services.mailgun.secret')
);
}
/**
@ -139,8 +148,9 @@ class EmailSettingsCommand extends Command
private function setupMandrillDriverVariables()
{
$this->variables['MANDRILL_SECRET'] = $this->option('password') ?? $this->ask(
trans('command/messages.environment.mail.ask_mandrill_secret'), $this->config->get('services.mandrill.secret')
);
trans('command/messages.environment.mail.ask_mandrill_secret'),
$this->config->get('services.mandrill.secret')
);
}
/**
@ -152,7 +162,8 @@ class EmailSettingsCommand extends Command
$this->variables['MAIL_HOST'] = 'smtp.postmarkapp.com';
$this->variables['MAIL_PORT'] = 587;
$this->variables['MAIL_USERNAME'] = $this->variables['MAIL_PASSWORD'] = $this->option('username') ?? $this->ask(
trans('command/messages.environment.mail.ask_postmark_username'), $this->config->get('mail.username')
);
trans('command/messages.environment.mail.ask_postmark_username'),
$this->config->get('mail.username')
);
}
}

View file

@ -37,9 +37,6 @@ class InfoCommand extends Command
/**
* VersionCommand constructor.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $versionService
*/
public function __construct(ConfigRepository $config, SoftwareVersionService $versionService)
{
@ -65,7 +62,7 @@ class InfoCommand extends Command
$this->output->title('Application Configuration');
$this->table([], [
['Environment', $this->formatText($this->config->get('app.env'), $this->config->get('app.env') === 'production' ?: 'bg=red')],
['Debug Mode', $this->formatText($this->config->get('app.debug') ? 'Yes' : 'No', ! $this->config->get('app.debug') ?: 'bg=red')],
['Debug Mode', $this->formatText($this->config->get('app.debug') ? 'Yes' : 'No', !$this->config->get('app.debug') ?: 'bg=red')],
['Installation URL', $this->config->get('app.url')],
['Installation Directory', base_path()],
['Timezone', $this->config->get('app.timezone')],
@ -103,6 +100,7 @@ class InfoCommand extends Command
*
* @param string $value
* @param string $opts
*
* @return string
*/
private function formatText($value, $opts = '')

View file

@ -42,9 +42,6 @@ class DeleteLocationCommand extends Command
/**
* DeleteLocationCommand constructor.
*
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository
* @param \Pterodactyl\Services\Locations\LocationDeletionService $deletionService
*/
public function __construct(
LocationDeletionService $deletionService,
@ -66,8 +63,9 @@ class DeleteLocationCommand extends Command
{
$this->locations = $this->locations ?? $this->repository->all();
$short = $this->option('short') ?? $this->anticipate(
trans('command/messages.location.ask_short'), $this->locations->pluck('short')->toArray()
);
trans('command/messages.location.ask_short'),
$this->locations->pluck('short')->toArray()
);
$location = $this->locations->where('short', $short)->first();
if (is_null($location)) {

View file

@ -33,8 +33,6 @@ class MakeLocationCommand extends Command
/**
* Create a new command instance.
*
* @param \Pterodactyl\Services\Locations\LocationCreationService $creationService
*/
public function __construct(LocationCreationService $creationService)
{

View file

@ -9,7 +9,7 @@ use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;
class CleanServiceBackupFilesCommand extends Command
{
const BACKUP_THRESHOLD_MINUTES = 5;
public const BACKUP_THRESHOLD_MINUTES = 5;
/**
* @var string
@ -28,8 +28,6 @@ class CleanServiceBackupFilesCommand extends Command
/**
* CleanServiceBackupFilesCommand constructor.
*
* @param \Illuminate\Contracts\Filesystem\Factory $filesystem
*/
public function __construct(FilesystemFactory $filesystem)
{

View file

@ -19,13 +19,10 @@ class PruneOrphanedBackupsCommand extends Command
*/
protected $description = 'Marks all backups that have not completed in the last "n" minutes as being failed.';
/**
* @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository
*/
public function handle(BackupRepository $repository)
{
$since = $this->option('since-minutes');
if (! is_digit($since)) {
if (!is_digit($since)) {
throw new InvalidArgumentException('The --since-minutes option must be a valid numeric digit.');
}
@ -34,7 +31,7 @@ class PruneOrphanedBackupsCommand extends Command
->whereDate('created_at', '<=', CarbonImmutable::now()->subMinutes($since));
$count = $query->count();
if (! $count) {
if (!$count) {
$this->info('There are no orphaned backups to be marked as failed.');
return;

View file

@ -25,8 +25,6 @@ class CleanOrphanedApiKeysCommand extends Command
/**
* CleanOrphanedApiKeysCommand constructor.
*
* @param \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface $repository
*/
public function __construct(ApiKeyRepositoryInterface $repository)
{
@ -44,10 +42,11 @@ class CleanOrphanedApiKeysCommand extends Command
{
$count = $this->repository->findCountWhere([['key_type', '=', ApiKey::TYPE_NONE]]);
$continue = $this->confirm(
'This action will remove ' . $count . ' keys from the database. Are you sure you wish to continue?', false
'This action will remove ' . $count . ' keys from the database. Are you sure you wish to continue?',
false
);
if (! $continue) {
if (!$continue) {
return null;
}

View file

@ -12,13 +12,13 @@ class KeyGenerateCommand extends BaseKeyGenerateCommand
*/
public function handle()
{
if (! empty(config('app.key')) && $this->input->isInteractive()) {
if (!empty(config('app.key')) && $this->input->isInteractive()) {
$this->output->warning(trans('command/messages.key.warning'));
if (! $this->confirm(trans('command/messages.key.confirm'))) {
if (!$this->confirm(trans('command/messages.key.confirm'))) {
return;
}
if (! $this->confirm(trans('command/messages.key.final_confirm'))) {
if (!$this->confirm(trans('command/messages.key.final_confirm'))) {
return;
}
}

View file

@ -2,8 +2,8 @@
namespace Pterodactyl\Console\Commands\Schedule;
use Throwable;
use Exception;
use Throwable;
use Illuminate\Console\Command;
use Pterodactyl\Models\Schedule;
use Illuminate\Support\Facades\Log;
@ -54,7 +54,6 @@ class ProcessRunnableCommand extends Command
* never throw an exception out, otherwise you'll end up killing the entire run group causing
* any other schedules to not process correctly.
*
* @param \Pterodactyl\Models\Schedule $schedule
* @see https://github.com/pterodactyl/panel/issues/2609
*/
protected function processSchedule(Schedule $schedule)

View file

@ -27,8 +27,6 @@ class BulkPowerActionCommand extends Command
/**
* Handle the bulk power request.
*
* @param \Pterodactyl\Repositories\Wings\DaemonPowerRepository $powerRepository
* @param \Illuminate\Validation\Factory $validator
* @throws \Illuminate\Validation\ValidationException
*/
public function handle(DaemonPowerRepository $powerRepository, ValidatorFactory $validator)
@ -58,7 +56,7 @@ class BulkPowerActionCommand extends Command
}
$count = $this->getQueryBuilder($servers, $nodes)->count();
if (! $this->confirm(trans('command/messages.server.power.confirm', ['action' => $action, 'count' => $count])) && $this->input->isInteractive()) {
if (!$this->confirm(trans('command/messages.server.power.confirm', ['action' => $action, 'count' => $count])) && $this->input->isInteractive()) {
return;
}
@ -87,8 +85,6 @@ class BulkPowerActionCommand extends Command
/**
* Returns the query builder instance that will return the servers that should be affected.
*
* @param array $servers
* @param array $nodes
* @return \Illuminate\Database\Eloquent\Builder
*/
protected function getQueryBuilder(array $servers, array $nodes)
@ -97,11 +93,11 @@ class BulkPowerActionCommand extends Command
->where('suspended', false)
->where('installed', Server::STATUS_INSTALLED);
if (! empty($nodes) && ! empty($servers)) {
if (!empty($nodes) && !empty($servers)) {
$instance->whereIn('id', $servers)->orWhereIn('node_id', $nodes);
} else if (empty($nodes) && ! empty($servers)) {
} elseif (empty($nodes) && !empty($servers)) {
$instance->whereIn('id', $servers);
} else if (! empty($nodes) && empty($servers)) {
} elseif (!empty($nodes) && empty($servers)) {
$instance->whereIn('node_id', $nodes);
}

View file

@ -47,10 +47,6 @@ class BulkReinstallActionCommand extends Command
/**
* BulkReinstallActionCommand constructor.
*
* @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonRepository
* @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $configurationStructureService
* @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository
*/
public function __construct(
DaemonServerRepository $daemonRepository,
@ -71,7 +67,7 @@ class BulkReinstallActionCommand extends Command
{
$servers = $this->getServersToProcess();
if (! $this->confirm(trans('command/messages.server.reinstall.confirm')) && $this->input->isInteractive()) {
if (!$this->confirm(trans('command/messages.server.reinstall.confirm')) && $this->input->isInteractive()) {
return;
}

View file

@ -9,11 +9,10 @@
namespace Pterodactyl\Console\Commands\User;
use Webmozart\Assert\Assert;
use Pterodactyl\Models\User;
use Webmozart\Assert\Assert;
use Illuminate\Console\Command;
use Pterodactyl\Services\Users\UserDeletionService;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
class DeleteUserCommand extends Command
{
@ -39,10 +38,9 @@ class DeleteUserCommand extends Command
/**
* DeleteUserCommand constructor.
*
* @param \Pterodactyl\Services\Users\UserDeletionService $deletionService
*/
public function __construct(UserDeletionService $deletionService) {
public function __construct(UserDeletionService $deletionService)
{
parent::__construct();
$this->deletionService = $deletionService;
@ -50,6 +48,7 @@ class DeleteUserCommand extends Command
/**
* @return bool
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function handle()
@ -79,7 +78,7 @@ class DeleteUserCommand extends Command
}
$this->table(['User ID', 'Email', 'Name'], $tableValues);
if (! $deleteUser = $this->ask(trans('command/messages.user.select_search_user'))) {
if (!$deleteUser = $this->ask(trans('command/messages.user.select_search_user'))) {
return $this->handle();
}
} else {
@ -92,11 +91,9 @@ class DeleteUserCommand extends Command
$deleteUser = $results->first();
}
if ($this->confirm(trans('command/messages.user.confirm_delete')) || ! $this->input->isInteractive()) {
if ($this->confirm(trans('command/messages.user.confirm_delete')) || !$this->input->isInteractive()) {
$this->deletionService->handle($deleteUser);
$this->info(trans('command/messages.user.deleted'));
}
return;
}
}

View file

@ -31,8 +31,6 @@ class DisableTwoFactorCommand extends Command
/**
* DisableTwoFactorCommand constructor.
*
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
*/
public function __construct(UserRepositoryInterface $repository)
{

View file

@ -31,8 +31,6 @@ class MakeUserCommand extends Command
/**
* MakeUserCommand constructor.
*
* @param \Pterodactyl\Services\Users\UserCreationService $creationService
*/
public function __construct(UserCreationService $creationService)
{
@ -55,7 +53,7 @@ class MakeUserCommand extends Command
$name_first = $this->option('name-first') ?? $this->ask(trans('command/messages.user.ask_name_first'));
$name_last = $this->option('name-last') ?? $this->ask(trans('command/messages.user.ask_name_last'));
if (is_null($password = $this->option('password')) && ! $this->option('no-password')) {
if (is_null($password = $this->option('password')) && !$this->option('no-password')) {
$this->warn(trans('command/messages.user.ask_password_help'));
$this->line(trans('command/messages.user.ask_password_tip'));
$password = $this->secret(trans('command/messages.user.ask_password'));

View file

@ -17,8 +17,6 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*/
protected function schedule(Schedule $schedule)
{

View file

@ -9,8 +9,6 @@ trait RequiresDatabaseMigrations
{
/**
* Checks if the migrations have finished running by comparing the last migration file.
*
* @return bool
*/
protected function hasCompletedMigrations(): bool
{
@ -19,7 +17,7 @@ trait RequiresDatabaseMigrations
$files = $migrator->getMigrationFiles(database_path('migrations'));
if (! $migrator->repositoryExists()) {
if (!$migrator->repositoryExists()) {
return false;
}
@ -34,12 +32,10 @@ trait RequiresDatabaseMigrations
* Throw a massive error into the console to hopefully catch the users attention and get
* them to properly run the migrations rather than ignoring all of the other previous
* errors...
*
* @return int
*/
protected function showMigrationWarning(): int
{
$this->getOutput()->writeln("<options=bold>
$this->getOutput()->writeln('<options=bold>
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| |
| Your database has not been properly migrated! |
@ -52,9 +48,9 @@ You must run the following command to finish migrating your database:
You will not be able to use Pterodactyl Panel as expected without fixing your
database state by running the command above.
");
');
$this->getOutput()->error("You must correct the error above before continuing.");
$this->getOutput()->error('You must correct the error above before continuing.');
return 1;
}

View file

@ -8,8 +8,6 @@ interface ReceivesEvents
{
/**
* Handles receiving an event from the application.
*
* @param \Pterodactyl\Events\Event $notification
*/
public function handle(Event $notification): void;
}

View file

@ -17,7 +17,7 @@ interface CriteriaInterface
* Apply selected criteria to a repository call.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Pterodactyl\Repositories\Repository $repository
*
* @return mixed
*/
public function apply($model, Repository $repository);

View file

@ -17,7 +17,8 @@ interface HashidsInterface extends VendorHashidsInterface
* Decode an encoded hashid and return the first result.
*
* @param string $encoded
* @param null $default
* @param null $default
*
* @return mixed
*
* @throws \InvalidArgumentException

View file

@ -8,8 +8,6 @@ interface ClientPermissionsRequest
* Returns the permissions string indicating which permission should be used to
* validate that the authenticated user has permission to perform this action aganist
* the given resource (server).
*
* @return string
*/
public function permission(): string;
}

View file

@ -2,25 +2,17 @@
namespace Pterodactyl\Contracts\Repository;
use Illuminate\Support\Collection;
interface AllocationRepositoryInterface extends RepositoryInterface
{
/**
* Return all of the allocations that exist for a node that are not currently
* allocated.
*
* @param int $node
* @return array
*/
public function getUnassignedAllocationIds(int $node): array;
/**
* Return a single allocation from those meeting the requirements.
*
* @param array $nodes
* @param array $ports
* @param bool $dedicated
* @return \Pterodactyl\Models\Allocation|null
*/
public function getRandomAllocation(array $nodes, array $ports, bool $dedicated = false);

View file

@ -9,35 +9,21 @@ interface ApiKeyRepositoryInterface extends RepositoryInterface
{
/**
* Get all of the account API keys that exist for a specific user.
*
* @param \Pterodactyl\Models\User $user
* @return \Illuminate\Support\Collection
*/
public function getAccountKeys(User $user): Collection;
/**
* Get all of the application API keys that exist for a specific user.
*
* @param \Pterodactyl\Models\User $user
* @return \Illuminate\Support\Collection
*/
public function getApplicationKeys(User $user): Collection;
/**
* Delete an account API key from the panel for a specific user.
*
* @param \Pterodactyl\Models\User $user
* @param string $identifier
* @return int
*/
public function deleteAccountKey(User $user, string $identifier): int;
/**
* Delete an application API key from the panel for a specific user.
*
* @param \Pterodactyl\Models\User $user
* @param string $identifier
* @return int
*/
public function deleteApplicationKey(User $user, string $identifier): int;
}

View file

@ -9,8 +9,6 @@ interface DatabaseHostRepositoryInterface extends RepositoryInterface
/**
* Return database hosts with a count of databases and the node
* information for which it is attached.
*
* @return \Illuminate\Support\Collection
*/
public function getWithViewDetails(): Collection;
}

View file

@ -8,89 +8,60 @@ use Illuminate\Contracts\Pagination\LengthAwarePaginator;
interface DatabaseRepositoryInterface extends RepositoryInterface
{
const DEFAULT_CONNECTION_NAME = 'dynamic';
public const DEFAULT_CONNECTION_NAME = 'dynamic';
/**
* Set the connection name to execute statements against.
*
* @param string $connection
* @return $this
*/
public function setConnection(string $connection);
/**
* Return the connection to execute statements against.
*
* @return string
*/
public function getConnection(): string;
/**
* Return all of the databases belonging to a server.
*
* @param int $server
* @return \Illuminate\Support\Collection
*/
public function getDatabasesForServer(int $server): Collection;
/**
* Return all of the databases for a given host with the server relationship loaded.
*
* @param int $host
* @param int $count
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator;
/**
* Create a new database on a given connection.
*
* @param string $database
* @return bool
*/
public function createDatabase(string $database): bool;
/**
* Create a new database user on a given connection.
*
* @param string $username
* @param string $remote
* @param string $password
* @param $max_connections
* @return bool
*/
public function createUser(string $username, string $remote, string $password, string $max_connections): bool;
/**
* Give a specific user access to a given database.
*
* @param string $database
* @param string $username
* @param string $remote
* @return bool
*/
public function assignUserToDatabase(string $database, string $username, string $remote): bool;
/**
* Flush the privileges for a given connection.
*
* @return bool
*/
public function flush(): bool;
/**
* Drop a given database on a specific connection.
*
* @param string $database
* @return bool
*/
public function dropDatabase(string $database): bool;
/**
* Drop a given user on a specific connection.
*
* @param string $username
* @param string $remote
* @return mixed
*/
public function dropUser(string $username, string $remote): bool;

View file

@ -17,17 +17,12 @@ interface EggRepositoryInterface extends RepositoryInterface
/**
* Return an egg with the variables relation attached.
*
* @param int $id
* @return \Pterodactyl\Models\Egg
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithVariables(int $id): Egg;
/**
* Return all eggs and their relations to be used in the daemon API.
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getAllWithCopyAttributes(): Collection;
@ -35,27 +30,18 @@ interface EggRepositoryInterface extends RepositoryInterface
* Return an egg with the scriptFrom and configFrom relations loaded onto the model.
*
* @param int|string $value
* @param string $column
* @return \Pterodactyl\Models\Egg
*/
public function getWithCopyAttributes($value, string $column = 'id'): Egg;
/**
* Return all of the data needed to export a service.
*
* @param int $id
* @return \Pterodactyl\Models\Egg
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithExportAttributes(int $id): Egg;
/**
* Confirm a copy script belongs to the same nest as the item trying to use it.
*
* @param int $copyFromId
* @param int $service
* @return bool
*/
public function isCopyableScript(int $copyFromId, int $service): bool;
}

View file

@ -16,9 +16,6 @@ interface EggVariableRepositoryInterface extends RepositoryInterface
/**
* Return editable variables for a given egg. Editable variables must be set to
* user viewable in order to be picked up by this function.
*
* @param int $egg
* @return \Illuminate\Support\Collection
*/
public function getEditableVariables(int $egg): Collection;
}

View file

@ -9,22 +9,17 @@ interface LocationRepositoryInterface extends RepositoryInterface
{
/**
* Return locations with a count of nodes and servers attached to it.
*
* @return \Illuminate\Support\Collection
*/
public function getAllWithDetails(): Collection;
/**
* Return all of the available locations with the nodes as a relationship.
*
* @return \Illuminate\Support\Collection
*/
public function getAllWithNodes(): Collection;
/**
* Return all of the nodes and their respective count of servers for a location.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
@ -34,7 +29,6 @@ interface LocationRepositoryInterface extends RepositoryInterface
/**
* Return a location and the count of nodes in that location.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException

View file

@ -17,6 +17,7 @@ interface NestRepositoryInterface extends RepositoryInterface
* Return a nest or all nests with their associated eggs and variables.
*
* @param int $id
*
* @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
@ -26,7 +27,6 @@ interface NestRepositoryInterface extends RepositoryInterface
/**
* Return a nest or all nests and the count of eggs and servers for that nest.
*
* @param int|null $id
* @return \Pterodactyl\Models\Nest|\Illuminate\Database\Eloquent\Collection
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
@ -36,9 +36,6 @@ interface NestRepositoryInterface extends RepositoryInterface
/**
* Return a nest along with its associated eggs and the servers relation on those eggs.
*
* @param int $id
* @return \Pterodactyl\Models\Nest
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithEggServers(int $id): Nest;

View file

@ -4,54 +4,35 @@ namespace Pterodactyl\Contracts\Repository;
use Pterodactyl\Models\Node;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
interface NodeRepositoryInterface extends RepositoryInterface
{
const THRESHOLD_PERCENTAGE_LOW = 75;
const THRESHOLD_PERCENTAGE_MEDIUM = 90;
public const THRESHOLD_PERCENTAGE_LOW = 75;
public const THRESHOLD_PERCENTAGE_MEDIUM = 90;
/**
* Return the usage stats for a single node.
*
* @param \Pterodactyl\Models\Node $node
* @return array
*/
public function getUsageStats(Node $node): array;
/**
* Return the usage stats for a single node.
*
* @param \Pterodactyl\Models\Node $node
* @return array
*/
public function getUsageStatsRaw(Node $node): array;
/**
* Return a single node with location and server information.
*
* @param \Pterodactyl\Models\Node $node
* @param bool $refresh
* @return \Pterodactyl\Models\Node
*/
public function loadLocationAndServerCount(Node $node, bool $refresh = false): Node;
/**
* Attach a paginated set of allocations to a node mode including
* any servers that are also attached to those allocations.
*
* @param \Pterodactyl\Models\Node $node
* @param bool $refresh
* @return \Pterodactyl\Models\Node
*/
public function loadNodeAllocations(Node $node, bool $refresh = false): Node;
/**
* Return a collection of nodes for all locations to use in server creation UI.
*
* @return \Illuminate\Support\Collection
*/
public function getNodesForServerCreation(): Collection;
}

View file

@ -39,6 +39,7 @@ interface RepositoryInterface
* An array of columns to filter the response by.
*
* @param array|string $columns
*
* @return $this
*/
public function setColumns($columns = ['*']);
@ -62,7 +63,6 @@ interface RepositoryInterface
* Set whether or not the repository should return a fresh model
* when changes are committed.
*
* @param bool $fresh
* @return $this
*/
public function setFreshModel(bool $fresh = true);
@ -70,9 +70,6 @@ interface RepositoryInterface
/**
* Create a new model instance and persist it to the database.
*
* @param array $fields
* @param bool $validate
* @param bool $force
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
@ -82,7 +79,6 @@ interface RepositoryInterface
/**
* Find a model that has the specific ID passed.
*
* @param int $id
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
@ -91,16 +87,12 @@ interface RepositoryInterface
/**
* Find a model matching an array of where clauses.
*
* @param array $fields
* @return \Illuminate\Support\Collection
*/
public function findWhere(array $fields): Collection;
/**
* Find and return the first matching instance for the given fields.
*
* @param array $fields
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
@ -109,25 +101,16 @@ interface RepositoryInterface
/**
* Return a count of records matching the passed arguments.
*
* @param array $fields
* @return int
*/
public function findCountWhere(array $fields): int;
/**
* Delete a given record from the database.
*
* @param int $id
* @return int
*/
public function delete(int $id): int;
/**
* Delete records matching the given attributes.
*
* @param array $attributes
* @return int
*/
public function deleteWhere(array $attributes): int;
@ -135,9 +118,7 @@ interface RepositoryInterface
* Update a given ID with the passed array of fields.
*
* @param int $id
* @param array $fields
* @param bool $validate
* @param bool $force
*
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
@ -148,21 +129,12 @@ interface RepositoryInterface
/**
* Perform a mass update where matching records are updated using whereIn.
* This does not perform any model data validation.
*
* @param string $column
* @param array $values
* @param array $fields
* @return int
*/
public function updateWhereIn(string $column, array $values, array $fields): int;
/**
* Update a record if it exists in the database, otherwise create it.
*
* @param array $where
* @param array $fields
* @param bool $validate
* @param bool $force
* @return mixed
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
@ -171,40 +143,27 @@ interface RepositoryInterface
/**
* Return all records associated with the given model.
*
* @return Collection
*/
public function all(): Collection;
/**
* Return a paginated result set using a search term if set on the repository.
*
* @param int $perPage
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function paginated(int $perPage): LengthAwarePaginator;
/**
* Insert a single or multiple records into the database at once skipping
* validation and mass assignment checking.
*
* @param array $data
* @return bool
*/
public function insert(array $data): bool;
/**
* Insert multiple records into the database and ignore duplicates.
*
* @param array $values
* @return bool
*/
public function insertIgnore(array $values): bool;
/**
* Get the amount of entries in the database.
*
* @return int
*/
public function count(): int;
}

View file

@ -9,18 +9,12 @@ interface ScheduleRepositoryInterface extends RepositoryInterface
{
/**
* Return all of the schedules for a given server.
*
* @param int $server
* @return \Illuminate\Support\Collection
*/
public function findServerSchedules(int $server): Collection;
/**
* Return a schedule model with all of the associated tasks as a relationship.
*
* @param int $schedule
* @return \Pterodactyl\Models\Schedule
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getScheduleWithTasks(int $schedule): Schedule;

View file

@ -10,37 +10,22 @@ interface ServerRepositoryInterface extends RepositoryInterface
{
/**
* Load the egg relations onto the server model.
*
* @param \Pterodactyl\Models\Server $server
* @param bool $refresh
* @return \Pterodactyl\Models\Server
*/
public function loadEggRelations(Server $server, bool $refresh = false): Server;
/**
* Return a collection of servers with their associated data for rebuild operations.
*
* @param int|null $server
* @param int|null $node
* @return \Illuminate\Support\Collection
*/
public function getDataForRebuild(int $server = null, int $node = null): Collection;
/**
* Return a collection of servers with their associated data for reinstall operations.
*
* @param int|null $server
* @param int|null $node
* @return \Illuminate\Support\Collection
*/
public function getDataForReinstall(int $server = null, int $node = null): Collection;
/**
* Return a server model and all variables associated with the server.
*
* @param int $id
* @return \Pterodactyl\Models\Server
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function findWithVariables(int $id): Server;
@ -49,28 +34,16 @@ interface ServerRepositoryInterface extends RepositoryInterface
* Get the primary allocation for a given server. If a model is passed into
* the function, load the allocation relationship onto it. Otherwise, find and
* return the server from the database.
*
* @param \Pterodactyl\Models\Server $server
* @param bool $refresh
* @return \Pterodactyl\Models\Server
*/
public function getPrimaryAllocation(Server $server, bool $refresh = false): Server;
/**
* Return enough data to be used for the creation of a server via the daemon.
*
* @param \Pterodactyl\Models\Server $server
* @param bool $refresh
* @return \Pterodactyl\Models\Server
*/
public function getDataForCreation(Server $server, bool $refresh = false): Server;
/**
* Load associated databases onto the server model.
*
* @param \Pterodactyl\Models\Server $server
* @param bool $refresh
* @return \Pterodactyl\Models\Server
*/
public function loadDatabaseRelations(Server $server, bool $refresh = false): Server;
@ -78,46 +51,28 @@ interface ServerRepositoryInterface extends RepositoryInterface
* Get data for use when updating a server on the Daemon. Returns an array of
* the egg which is used for build and rebuild. Only loads relations
* if they are missing, or refresh is set to true.
*
* @param \Pterodactyl\Models\Server $server
* @param bool $refresh
* @return array
*/
public function getDaemonServiceData(Server $server, bool $refresh = false): array;
/**
* Return a server by UUID.
*
* @param string $uuid
* @return \Pterodactyl\Models\Server
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getByUuid(string $uuid): Server;
/**
* Check if a given UUID and UUID-Short string are unique to a server.
*
* @param string $uuid
* @param string $short
* @return bool
*/
public function isUniqueUuidCombo(string $uuid, string $short): bool;
/**
* Get the amount of servers that are suspended.
*
* @return int
*/
public function getSuspendedServersCount(): int;
/**
* Returns all of the servers that exist for a given node in a paginated response.
*
* @param int $node
* @param int $limit
*
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function loadAllServersForNode(int $node, int $limit): LengthAwarePaginator;
}

View file

@ -8,17 +8,12 @@ interface SessionRepositoryInterface extends RepositoryInterface
{
/**
* Return all of the active sessions for a user.
*
* @param int $user
* @return \Illuminate\Support\Collection
*/
public function getUserSessions(int $user): Collection;
/**
* Delete a session for a given user.
*
* @param int $user
* @param string $session
* @return int|null
*/
public function deleteUserSession(int $user, string $session);

View file

@ -7,9 +7,6 @@ interface SettingsRepositoryInterface extends RepositoryInterface
/**
* Store a new persistent setting in the database.
*
* @param string $key
* @param string|null $value
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
@ -18,16 +15,14 @@ interface SettingsRepositoryInterface extends RepositoryInterface
/**
* Retrieve a persistent setting from the database.
*
* @param string $key
* @param mixed $default
*
* @return mixed
*/
public function get(string $key, $default);
/**
* Remove a key from the database cache.
*
* @param string $key
*/
public function forget(string $key);
}

View file

@ -8,29 +8,17 @@ interface SubuserRepositoryInterface extends RepositoryInterface
{
/**
* Return a subuser with the associated server relationship.
*
* @param \Pterodactyl\Models\Subuser $subuser
* @param bool $refresh
* @return \Pterodactyl\Models\Subuser
*/
public function loadServerAndUserRelations(Subuser $subuser, bool $refresh = false): Subuser;
/**
* Return a subuser with the associated permissions relationship.
*
* @param \Pterodactyl\Models\Subuser $subuser
* @param bool $refresh
* @return \Pterodactyl\Models\Subuser
*/
public function getWithPermissions(Subuser $subuser, bool $refresh = false): Subuser;
/**
* Return a subuser and associated permissions given a user_id and server_id.
*
* @param int $user
* @param int $server
* @return \Pterodactyl\Models\Subuser
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getWithPermissionsUsingUserAndServer(int $user, int $server): Subuser;

View file

@ -9,9 +9,6 @@ interface TaskRepositoryInterface extends RepositoryInterface
/**
* Get a task and the server relationship for that task.
*
* @param int $id
* @return \Pterodactyl\Models\Task
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function getTaskForJobProcess(int $id): Task;
@ -19,8 +16,6 @@ interface TaskRepositoryInterface extends RepositoryInterface
/**
* Returns the next task in a schedule.
*
* @param int $schedule
* @param int $index
* @return \Pterodactyl\Models\Task|null
*/
public function getNextTask(int $schedule, int $index);

View file

@ -25,8 +25,6 @@ class Created
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
*/
public function __construct(Server $server)
{

View file

@ -25,8 +25,6 @@ class Creating
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
*/
public function __construct(Server $server)
{

View file

@ -25,8 +25,6 @@ class Deleted
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
*/
public function __construct(Server $server)
{

View file

@ -25,8 +25,6 @@ class Deleting
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
*/
public function __construct(Server $server)
{

View file

@ -25,8 +25,6 @@ class Saved
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
*/
public function __construct(Server $server)
{

View file

@ -25,8 +25,6 @@ class Saving
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
*/
public function __construct(Server $server)
{

View file

@ -25,8 +25,6 @@ class Updated
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
*/
public function __construct(Server $server)
{

View file

@ -25,8 +25,6 @@ class Updating
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\Server $server
*/
public function __construct(Server $server)
{

View file

@ -25,8 +25,6 @@ class Created
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\Subuser $subuser
*/
public function __construct(Subuser $subuser)
{

View file

@ -25,8 +25,6 @@ class Creating
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\Subuser $subuser
*/
public function __construct(Subuser $subuser)
{

View file

@ -25,8 +25,6 @@ class Deleted
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\Subuser $subuser
*/
public function __construct(Subuser $subuser)
{

View file

@ -25,8 +25,6 @@ class Deleting
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\Subuser $subuser
*/
public function __construct(Subuser $subuser)
{

View file

@ -25,8 +25,6 @@ class Created
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\User $user
*/
public function __construct(User $user)
{

View file

@ -25,8 +25,6 @@ class Creating
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\User $user
*/
public function __construct(User $user)
{

View file

@ -25,8 +25,6 @@ class Deleted
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\User $user
*/
public function __construct(User $user)
{

View file

@ -25,8 +25,6 @@ class Deleting
/**
* Create a new event instance.
*
* @param \Pterodactyl\Models\User $user
*/
public function __construct(User $user)
{

View file

@ -11,10 +11,10 @@ use Prologue\Alerts\AlertsMessageBag;
class DisplayException extends PterodactylException
{
const LEVEL_DEBUG = 'debug';
const LEVEL_INFO = 'info';
const LEVEL_WARNING = 'warning';
const LEVEL_ERROR = 'error';
public const LEVEL_DEBUG = 'debug';
public const LEVEL_INFO = 'info';
public const LEVEL_WARNING = 'warning';
public const LEVEL_ERROR = 'error';
/**
* @var string
@ -25,9 +25,8 @@ class DisplayException extends PterodactylException
* Exception constructor.
*
* @param string $message
* @param Throwable|null $previous
* @param string $level
* @param int $code
* @param int $code
*/
public function __construct($message, Throwable $previous = null, $level = self::LEVEL_ERROR, $code = 0)
{
@ -58,6 +57,7 @@ class DisplayException extends PterodactylException
* request originated from an API hit, return the error in JSONAPI spec format.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
*/
public function render($request)
@ -83,7 +83,7 @@ class DisplayException extends PterodactylException
*/
public function report()
{
if (! $this->getPrevious() instanceof Exception || ! Handler::isReportable($this->getPrevious())) {
if (!$this->getPrevious() instanceof Exception || !Handler::isReportable($this->getPrevious())) {
return null;
}

View file

@ -5,10 +5,14 @@ namespace Pterodactyl\Exceptions;
use Exception;
use Throwable;
use PDOException;
use Psr\Log\LoggerInterface;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Swift_TransportException;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection;
use Illuminate\Container\Container;
use Illuminate\Database\Connection;
use Illuminate\Foundation\Application;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Validation\ValidationException;
@ -43,17 +47,6 @@ class Handler extends ExceptionHandler
ValidationException::class,
];
/**
* A list of exceptions that should be logged with cleaned stack
* traces to avoid exposing credentials or other sensitive information.
*
* @var array
*/
protected $cleanStacks = [
PDOException::class,
Swift_TransportException::class,
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
@ -67,56 +60,40 @@ class Handler extends ExceptionHandler
];
/**
* Report or log an exception. Skips Laravel's internal reporter since we
* don't need or want the user information in our logs by default.
* Registers the exception handling callbacks for the application. This
* will capture specific exception types that we do not want to include
* the detailed stack traces for since they could reveal credentials to
* whoever can read the logs.
*
* If you want to implement logging in a different format to integrate with
* services such as AWS Cloudwatch or other monitoring you can replace the
* contents of this function with a call to the parent reporter.
*
* @param \Throwable $exception
* @return mixed
*
* @throws \Throwable
* @noinspection PhpUnusedLocalVariableInspection
*/
public function report(Throwable $exception)
public function register()
{
if (! config('app.exceptions.report_all', false) && $this->shouldntReport($exception)) {
return null;
if (config('app.exceptions.report_all', false)) {
$this->dontReport = [];
}
if (method_exists($exception, 'report')) {
return $exception->report();
}
$this->reportable(function (PDOException $ex) {
$ex = $this->generateCleanedExceptionStack($ex);
});
try {
$logger = $this->container->make(LoggerInterface::class);
} catch (Exception $ex) {
throw $exception;
}
foreach ($this->cleanStacks as $class) {
if ($exception instanceof $class) {
$exception = $this->generateCleanedExceptionStack($exception);
break;
}
}
return $logger->error($exception);
$this->reportable(function (Swift_TransportException $ex) {
$ex = $this->generateCleanedExceptionStack($ex);
});
}
private function generateCleanedExceptionStack(Throwable $exception)
private function generateCleanedExceptionStack(Throwable $exception): string
{
$cleanedStack = '';
foreach ($exception->getTrace() as $index => $item) {
$cleanedStack .= sprintf(
"#%d %s(%d): %s%s%s\n",
$index,
array_get($item, 'file'),
array_get($item, 'line'),
array_get($item, 'class'),
array_get($item, 'type'),
array_get($item, 'function')
Arr::get($item, 'file'),
Arr::get($item, 'line'),
Arr::get($item, 'class'),
Arr::get($item, 'type'),
Arr::get($item, 'function')
);
}
@ -135,14 +112,14 @@ class Handler extends ExceptionHandler
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
*
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
*/
public function render($request, Throwable $exception)
{
$connections = Container::getInstance()->make(Connection::class);
$connections = $this->container->make(Connection::class);
// If we are currently wrapped up inside a transaction, we will roll all the way
// back to the beginning. This needs to happen, otherwise session data does not
@ -165,27 +142,28 @@ class Handler extends ExceptionHandler
* calls to the API.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Validation\ValidationException $exception
*
* @return \Illuminate\Http\JsonResponse
*/
public function invalidJson($request, ValidationException $exception)
{
$codes = collect($exception->validator->failed())->mapWithKeys(function ($reasons, $field) {
$codes = Collection::make($exception->validator->failed())->mapWithKeys(function ($reasons, $field) {
$cleaned = [];
foreach ($reasons as $reason => $attrs) {
$cleaned[] = snake_case($reason);
$cleaned[] = Str::snake($reason);
}
return [str_replace('.', '_', $field) => $cleaned];
})->toArray();
$errors = collect($exception->errors())->map(function ($errors, $field) use ($codes, $exception) {
$errors = Collection::make($exception->errors())->map(function ($errors, $field) use ($codes, $exception) {
$response = [];
foreach ($errors as $key => $error) {
$meta = [
'source_field' => $field,
'rule' => str_replace(self::PTERODACTYL_RULE_STRING, 'p_', array_get(
$codes, str_replace('.', '_', $field) . '.' . $key
'rule' => str_replace(self::PTERODACTYL_RULE_STRING, 'p_', Arr::get(
$codes,
str_replace('.', '_', $field) . '.' . $key
)),
];
@ -206,10 +184,6 @@ class Handler extends ExceptionHandler
/**
* Return the exception as a JSONAPI representation for use on API requests.
*
* @param \Throwable $exception
* @param array $override
* @return array
*/
public static function convertToArray(Throwable $exception, array $override = []): array
{
@ -235,7 +209,7 @@ class Handler extends ExceptionHandler
'detail' => $exception->getMessage(),
'source' => [
'line' => $exception->getLine(),
'file' => str_replace(base_path(), '', $exception->getFile()),
'file' => str_replace(Application::getInstance()->basePath(), '', $exception->getFile()),
],
'meta' => [
'trace' => explode("\n", $exception->getTraceAsString()),
@ -248,9 +222,6 @@ class Handler extends ExceptionHandler
/**
* Return an array of exceptions that should not be reported.
*
* @param \Exception $exception
* @return bool
*/
public static function isReportable(Exception $exception): bool
{
@ -261,23 +232,22 @@ class Handler extends ExceptionHandler
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response
*
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(self::convertToArray($exception), 401);
return new JsonResponse(self::convertToArray($exception), JsonResponse::HTTP_UNAUTHORIZED);
}
return redirect()->guest(route('auth.login'));
return $this->container->make('redirect')->guest('/auth/login');
}
/**
* Converts an exception into an array to render in the response. Overrides
* Laravel's built-in converter to output as a JSONAPI spec compliant object.
*
* @param \Throwable $exception
* @return array
*/
protected function convertExceptionToArray(Throwable $exception)

View file

@ -19,9 +19,6 @@ class DaemonConnectionException extends DisplayException
/**
* Throw a displayable exception caused by a daemon connection error.
*
* @param \GuzzleHttp\Exception\GuzzleException $previous
* @param bool $useStatusCode
*/
public function __construct(GuzzleException $previous, bool $useStatusCode = true)
{
@ -38,11 +35,11 @@ class DaemonConnectionException extends DisplayException
// Attempt to pull the actual error message off the response and return that if it is not
// a 500 level error.
if ($this->statusCode < 500 && ! is_null($response)) {
if ($this->statusCode < 500 && !is_null($response)) {
$body = $response->getBody();
if (is_string($body) || (is_object($body) && method_exists($body, '__toString'))) {
$body = json_decode(is_string($body) ? $body : $body->__toString(), true);
$message = "[Wings Error]: " . Arr::get($body, 'error', $message);
$message = '[Wings Error]: ' . Arr::get($body, 'error', $message);
}
}

View file

@ -9,9 +9,6 @@ class HttpForbiddenException extends HttpException
{
/**
* HttpForbiddenException constructor.
*
* @param string|null $message
* @param \Throwable|null $previous
*/
public function __construct(string $message = null, \Throwable $previous = null)
{

View file

@ -11,11 +11,9 @@ class TwoFactorAuthRequiredException extends HttpException implements HttpExcept
{
/**
* TwoFactorAuthRequiredException constructor.
*
* @param \Throwable|null $previous
*/
public function __construct(Throwable $previous = null)
{
parent::__construct(Response::HTTP_BAD_REQUEST, "Two-factor authentication is required on this account in order to access this endpoint.", $previous);
parent::__construct(Response::HTTP_BAD_REQUEST, 'Two-factor authentication is required on this account in order to access this endpoint.', $previous);
}
}

View file

@ -18,8 +18,6 @@ class DataValidationException extends PterodactylException implements HttpExcept
/**
* DataValidationException constructor.
*
* @param \Illuminate\Contracts\Validation\Validator $validator
*/
public function __construct(Validator $validator)
{

View file

@ -8,8 +8,6 @@ class TooManyBackupsException extends DisplayException
{
/**
* TooManyBackupsException constructor.
*
* @param int $backupLimit
*/
public function __construct(int $backupLimit)
{

View file

@ -10,9 +10,6 @@ class ServiceLimitExceededException extends DisplayException
/**
* Exception thrown when something goes over a defined limit, such as allocated
* ports, tasks, databases, etc.
*
* @param string $message
* @param \Throwable|null $previous
*/
public function __construct(string $message, Throwable $previous = null)
{

View file

@ -8,8 +8,8 @@ use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Webmozart\Assert\Assert;
use InvalidArgumentException;
use League\Flysystem\AdapterInterface;
use Illuminate\Foundation\Application;
use League\Flysystem\AdapterInterface;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Memory\MemoryAdapter;
use Illuminate\Contracts\Config\Repository;
@ -42,8 +42,6 @@ class BackupManager
/**
* BackupManager constructor.
*
* @param \Illuminate\Foundation\Application $app
*/
public function __construct(Application $app)
{
@ -54,7 +52,6 @@ class BackupManager
/**
* Returns a backup adapter instance.
*
* @param string|null $name
* @return \League\Flysystem\AdapterInterface
*/
public function adapter(string $name = null)
@ -65,8 +62,8 @@ class BackupManager
/**
* Set the given backup adapter instance.
*
* @param string $name
* @param \League\Flysystem\AdapterInterface $disk
*
* @return $this
*/
public function set(string $name, $disk)
@ -79,7 +76,6 @@ class BackupManager
/**
* Gets a backup adapter.
*
* @param string $name
* @return \League\Flysystem\AdapterInterface
*/
protected function get(string $name)
@ -90,7 +86,6 @@ class BackupManager
/**
* Resolve the given backup disk.
*
* @param string $name
* @return \League\Flysystem\AdapterInterface
*/
protected function resolve(string $name)
@ -98,9 +93,7 @@ class BackupManager
$config = $this->getConfig($name);
if (empty($config['adapter'])) {
throw new InvalidArgumentException(
"Backup disk [{$name}] does not have a configured adapter."
);
throw new InvalidArgumentException("Backup disk [{$name}] does not have a configured adapter.");
}
$adapter = $config['adapter'];
@ -124,7 +117,6 @@ class BackupManager
/**
* Calls a custom creator for a given adapter type.
*
* @param array $config
* @return \League\Flysystem\AdapterInterface
*/
protected function callCustomCreator(array $config)
@ -139,7 +131,6 @@ class BackupManager
/**
* Creates a new wings adapter.
*
* @param array $config
* @return \League\Flysystem\AdapterInterface
*/
public function createWingsAdapter(array $config)
@ -150,14 +141,13 @@ class BackupManager
/**
* Creates a new S3 adapter.
*
* @param array $config
* @return \League\Flysystem\AdapterInterface
*/
public function createS3Adapter(array $config)
{
$config['version'] = 'latest';
if (! empty($config['key']) && ! empty($config['secret'])) {
if (!empty($config['key']) && !empty($config['secret'])) {
$config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
}
@ -169,7 +159,6 @@ class BackupManager
/**
* Returns the configuration associated with a given backup type.
*
* @param string $name
* @return array
*/
protected function getConfig(string $name)
@ -189,8 +178,6 @@ class BackupManager
/**
* Set the default session driver name.
*
* @param string $name
*/
public function setDefaultAdapter(string $name)
{
@ -201,6 +188,7 @@ class BackupManager
* Unset the given adapter instances.
*
* @param string|string[] $adapter
*
* @return $this
*/
public function forget($adapter)
@ -215,8 +203,6 @@ class BackupManager
/**
* Register a custom adapter creator closure.
*
* @param string $adapter
* @param \Closure $callback
* @return $this
*/
public function extend(string $adapter, Closure $callback)

View file

@ -16,9 +16,9 @@ use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
class DynamicDatabaseConnection
{
const DB_CHARSET = 'utf8';
const DB_COLLATION = 'utf8_unicode_ci';
const DB_DRIVER = 'mysql';
public const DB_CHARSET = 'utf8';
public const DB_COLLATION = 'utf8_unicode_ci';
public const DB_DRIVER = 'mysql';
/**
* @var \Illuminate\Config\Repository
@ -37,10 +37,6 @@ class DynamicDatabaseConnection
/**
* DynamicDatabaseConnection constructor.
*
* @param \Illuminate\Config\Repository $config
* @param \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface $repository
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
*/
public function __construct(
ConfigRepository $config,
@ -55,15 +51,15 @@ class DynamicDatabaseConnection
/**
* Adds a dynamic database connection entry to the runtime config.
*
* @param string $connection
* @param string $connection
* @param \Pterodactyl\Models\DatabaseHost|int $host
* @param string $database
* @param string $database
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function set($connection, $host, $database = 'mysql')
{
if (! $host instanceof DatabaseHost) {
if (!$host instanceof DatabaseHost) {
$host = $this->repository->find($host);
}

View file

@ -20,7 +20,7 @@ class Hashids extends VendorHashids implements HashidsInterface
public function decodeFirst($encoded, $default = null)
{
$result = $this->decode($encoded);
if (! is_array($result)) {
if (!is_array($result)) {
return $default;
}

View file

@ -0,0 +1,30 @@
<?php
namespace Pterodactyl\Extensions\Lcobucci\JWT\Encoding;
use DateTimeImmutable;
use Lcobucci\JWT\ClaimsFormatter;
use Lcobucci\JWT\Token\RegisteredClaims;
final class TimestampDates implements ClaimsFormatter
{
/**
* The default time encoder for JWTs using this library is not supported correctly
* by Wings and will cause a flood of errors and panic conditions because the times
* cannot be parsed correctly. The default is time with microseconds, we just need
* to use the normal unix timestamp here.
*/
public function formatClaims(array $claims): array
{
foreach (RegisteredClaims::DATE_CLAIMS as $claim) {
if (!array_key_exists($claim, $claims)) {
continue;
}
assert($claims[$claim] instanceof DateTimeImmutable);
$claims[$claim] = $claims[$claim]->getTimestamp();
}
return $claims;
}
}

View file

@ -10,7 +10,7 @@ class PterodactylSerializer extends ArraySerializer
* Serialize an item.
*
* @param string $resourceKey
* @param array $data
*
* @return array
*/
public function item($resourceKey, array $data)
@ -25,7 +25,7 @@ class PterodactylSerializer extends ArraySerializer
* Serialize a collection.
*
* @param string $resourceKey
* @param array $data
*
* @return array
*/
public function collection($resourceKey, array $data)
@ -59,6 +59,7 @@ class PterodactylSerializer extends ArraySerializer
*
* @param array $transformedData
* @param array $includedData
*
* @return array
*/
public function mergeIncludes($transformedData, $includedData)

View file

@ -22,7 +22,7 @@ class Fractal extends SpatieFractal
{
// Set the serializer by default.
if (is_null($this->serializer)) {
$this->serializer = new PterodactylSerializer;
$this->serializer = new PterodactylSerializer();
}
// Automatically set the paginator on the response object if the

View file

@ -12,9 +12,6 @@ final class Time
* for named timezones in MySQL.
*
* Returns the timezone as a string like +08:00 or -05:00 depending on the app timezone.
*
* @param string $timezone
* @return string
*/
public static function getMySQLTimezoneOffset(string $timezone): string
{

View file

@ -13,9 +13,6 @@ class Utilities
/**
* Generates a random string and injects special characters into it, in addition to
* the randomness of the alpha-numeric default response.
*
* @param int $length
* @return string
*/
public static function randomStringWithSpecialCharacters(int $length = 16): string
{
@ -23,7 +20,7 @@ class Utilities
// Given a random string of characters, randomly loop through the characters and replace some
// with special characters to avoid issues with MySQL password requirements on some servers.
try {
for ($i = 0; $i < random_int(2, 6); $i++) {
for ($i = 0; $i < random_int(2, 6); ++$i) {
$character = ['!', '@', '=', '.', '+', '^'][random_int(0, 5)];
$string = substr_replace($string, $character, random_int(0, $length - 1), 1);
@ -39,16 +36,28 @@ class Utilities
/**
* Converts schedule cron data into a carbon object.
*
* @param string $minute
* @param string $hour
* @param string $dayOfMonth
* @param string $dayOfWeek
* @return \Carbon\Carbon
*/
public static function getScheduleNextRunDate(string $minute, string $hour, string $dayOfMonth, string $dayOfWeek)
public static function getScheduleNextRunDate(string $minute, string $hour, string $dayOfMonth, string $month, string $dayOfWeek)
{
return Carbon::instance(CronExpression::factory(
sprintf('%s %s %s * %s', $minute, $hour, $dayOfMonth, $dayOfWeek)
sprintf('%s %s %s %s %s', $minute, $hour, $dayOfMonth, $month, $dayOfWeek)
)->getNextRunDate());
}
/**
* @param mixed $default
*
* @return string
*/
public static function checked(string $name, $default)
{
$errors = session('errors');
if (isset($errors) && $errors instanceof ViewErrorBag && $errors->any()) {
return old($name) ? 'checked' : '';
}
return ($default) ? 'checked' : '';
}
}

View file

@ -2,6 +2,7 @@
namespace Pterodactyl\Http\Controllers\Api\Application\Locations;
use Illuminate\Http\Response;
use Pterodactyl\Models\Location;
use Illuminate\Http\JsonResponse;
use Spatie\QueryBuilder\QueryBuilder;
@ -42,11 +43,6 @@ class LocationController extends ApplicationApiController
/**
* LocationController constructor.
*
* @param \Pterodactyl\Services\Locations\LocationCreationService $creationService
* @param \Pterodactyl\Services\Locations\LocationDeletionService $deletionService
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository
* @param \Pterodactyl\Services\Locations\LocationUpdateService $updateService
*/
public function __construct(
LocationCreationService $creationService,
@ -64,11 +60,6 @@ class LocationController extends ApplicationApiController
/**
* Return all of the locations currently registered on the Panel.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationsRequest $request
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function index(GetLocationsRequest $request): array
{
@ -91,12 +82,6 @@ class LocationController extends ApplicationApiController
/**
* Return a single location.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationRequest $request
* @param \Pterodactyl\Models\Location $location
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function view(GetLocationRequest $request, Location $location): array
{
@ -110,11 +95,9 @@ class LocationController extends ApplicationApiController
* new location attached.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\StoreLocationRequest $request
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function store(StoreLocationRequest $request): JsonResponse
{
@ -133,11 +116,6 @@ class LocationController extends ApplicationApiController
/**
* Update a location on the Panel and return the updated record to the user.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\UpdateLocationRequest $request
* @param \Pterodactyl\Models\Location $location
*
* @return array
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Illuminate\Contracts\Container\BindingResolutionException
@ -154,11 +132,6 @@ class LocationController extends ApplicationApiController
/**
* Delete a location from the Panel.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\DeleteLocationRequest $request
* @param \Pterodactyl\Models\Location $location
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException
*/
public function delete(DeleteLocationRequest $request, Location $location): JsonResponse

View file

@ -41,11 +41,6 @@ class NestController extends ApplicationApiController
/**
* NestController constructor.
*
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository
* @param \Pterodactyl\Services\Nests\NestCreationService $nestCreationService
* @param \Pterodactyl\Services\Nests\NestDeletionService $nestDeletionService
* @param \Pterodactyl\Services\Nests\NestUpdateService $nestUpdateService
*/
public function __construct(
NestRepositoryInterface $repository,
@ -64,11 +59,6 @@ class NestController extends ApplicationApiController
/**
* Return all Nests that exist on the Panel.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest $request
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function index(GetNestsRequest $request): array
{

View file

@ -14,8 +14,6 @@ class NodeConfigurationController extends ApplicationApiController
* to remote machines so long as an API key is provided to the machine to make the request
* with, and the node is known.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest $request
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\Http\JsonResponse
*/
public function __invoke(GetNodeRequest $request, Node $node)

View file

@ -42,11 +42,6 @@ class NodeController extends ApplicationApiController
/**
* NodeController constructor.
*
* @param \Pterodactyl\Services\Nodes\NodeCreationService $creationService
* @param \Pterodactyl\Services\Nodes\NodeDeletionService $deletionService
* @param \Pterodactyl\Services\Nodes\NodeUpdateService $updateService
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository
*/
public function __construct(
NodeCreationService $creationService,
@ -64,11 +59,6 @@ class NodeController extends ApplicationApiController
/**
* Return all of the nodes currently available on the Panel.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodesRequest $request
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function index(GetNodesRequest $request): array
{
@ -91,12 +81,6 @@ class NodeController extends ApplicationApiController
/**
* Return data for a single instance of a node.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest $request
* @param \Pterodactyl\Models\Node $node
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function view(GetNodeRequest $request, Node $node): array
{
@ -109,11 +93,7 @@ class NodeController extends ApplicationApiController
* Create a new node on the Panel. Returns the created node and a HTTP/201
* status response on success.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\StoreNodeRequest $request
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException*@throws \Illuminate\Contracts\Container\BindingResolutionException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function store(StoreNodeRequest $request): JsonResponse
{
@ -132,17 +112,14 @@ class NodeController extends ApplicationApiController
/**
* Update an existing node on the Panel.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\UpdateNodeRequest $request
* @param \Pterodactyl\Models\Node $node
*
* @return array
*
* @throws \Throwable
*/
public function update(UpdateNodeRequest $request, Node $node): array
{
$node = $this->updateService->handle(
$node, $request->validated(), $request->input('reset_secret') === true
$node,
$request->validated(),
$request->input('reset_secret') === true
);
return $this->fractal->item($node)
@ -154,11 +131,6 @@ class NodeController extends ApplicationApiController
* Deletes a given node from the Panel as long as there are no servers
* currently attached to it.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\DeleteNodeRequest $request
* @param \Pterodactyl\Models\Node $node
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/
public function delete(DeleteNodeRequest $request, Node $node): JsonResponse

View file

@ -16,8 +16,6 @@ class NodeDeploymentController extends ApplicationApiController
/**
* NodeDeploymentController constructor.
*
* @param \Pterodactyl\Services\Deployment\FindViableNodesService $viableNodesService
*/
public function __construct(FindViableNodesService $viableNodesService)
{
@ -31,9 +29,6 @@ class NodeDeploymentController extends ApplicationApiController
* similarly to the server creation process, but allows you to pass the deployment object
* to this endpoint and get back a list of all Nodes satisfying the requirements.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetDeployableNodesRequest $request
* @return array
*
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException
*/
public function __invoke(GetDeployableNodesRequest $request): array

View file

@ -35,17 +35,12 @@ class DatabaseController extends ApplicationApiController
/**
* DatabaseController constructor.
*
* @param \Pterodactyl\Services\Databases\DatabaseManagementService $databaseManagementService
* @param \Pterodactyl\Services\Databases\DatabasePasswordService $databasePasswordService
* @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $repository
*/
public function __construct(
DatabaseManagementService $databaseManagementService,
DatabasePasswordService $databasePasswordService,
DatabaseRepositoryInterface $repository
)
{
) {
parent::__construct();
$this->databaseManagementService = $databaseManagementService;
@ -56,12 +51,6 @@ class DatabaseController extends ApplicationApiController
/**
* Return a listing of all databases currently available to a single
* server.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabasesRequest $request
* @param \Pterodactyl\Models\Server $server
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function index(GetServerDatabasesRequest $request, Server $server): array
{
@ -72,13 +61,6 @@ class DatabaseController extends ApplicationApiController
/**
* Return a single server database.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabaseRequest $request
* @param \Pterodactyl\Models\Server $server
* @param \Pterodactyl\Models\Database $database
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function view(GetServerDatabaseRequest $request, Server $server, Database $database): array
{
@ -90,12 +72,6 @@ class DatabaseController extends ApplicationApiController
/**
* Reset the password for a specific server database.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request
* @param \Pterodactyl\Models\Server $server
* @param \Pterodactyl\Models\Database $database
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function resetPassword(ServerDatabaseWriteRequest $request, Server $server, Database $database): JsonResponse
@ -108,11 +84,6 @@ class DatabaseController extends ApplicationApiController
/**
* Create a new database on the Panel for a given server.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\StoreServerDatabaseRequest $request
* @param \Pterodactyl\Models\Server $server
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
*/
public function store(StoreServerDatabaseRequest $request, Server $server): JsonResponse
@ -135,12 +106,7 @@ class DatabaseController extends ApplicationApiController
/**
* Handle a request to delete a specific server database from the Panel.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request
* @param \Pterodactyl\Models\Database $database
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function delete(ServerDatabaseWriteRequest $request, Database $database): JsonResponse
{

View file

@ -10,11 +10,6 @@ class ExternalServerController extends ApplicationApiController
{
/**
* Retrieve a specific server from the database using its external ID.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetExternalServerRequest $request
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function index(GetExternalServerRequest $request): array
{

View file

@ -30,9 +30,6 @@ class ServerController extends ApplicationApiController
/**
* ServerController constructor.
*
* @param \Pterodactyl\Services\Servers\ServerCreationService $creationService
* @param \Pterodactyl\Services\Servers\ServerDeletionService $deletionService
*/
public function __construct(
ServerCreationService $creationService,
@ -46,11 +43,6 @@ class ServerController extends ApplicationApiController
/**
* Return all of the servers that currently exist on the Panel.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetServersRequest $request
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function index(GetServersRequest $request): array
{
@ -74,10 +66,6 @@ class ServerController extends ApplicationApiController
/**
* Create a new server on the system.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\StoreServerRequest $request
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
* @throws \Illuminate\Validation\ValidationException
* @throws \Pterodactyl\Exceptions\DisplayException
@ -96,12 +84,6 @@ class ServerController extends ApplicationApiController
/**
* Show a single server transformed for the application API.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetServerRequest $request
* @param \Pterodactyl\Models\Server $server
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function view(GetServerRequest $request, Server $server): array
{
@ -111,15 +93,7 @@ class ServerController extends ApplicationApiController
}
/**
* Deletes a server.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
* @param \Pterodactyl\Models\Server $server
* @param string $force
*
* @return \Illuminate\Http\Response
*
* @throws \Throwable
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete(ServerWriteRequest $request, Server $server, string $force = ''): Response
{

View file

@ -24,9 +24,6 @@ class ServerDetailsController extends ApplicationApiController
/**
* ServerDetailsController constructor.
*
* @param \Pterodactyl\Services\Servers\BuildModificationService $buildModificationService
* @param \Pterodactyl\Services\Servers\DetailsModificationService $detailsModificationService
*/
public function __construct(
BuildModificationService $buildModificationService,
@ -41,18 +38,15 @@ class ServerDetailsController extends ApplicationApiController
/**
* Update the details for a specific server.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerDetailsRequest $request
* @param \Pterodactyl\Models\Server $server
*
* @return array
*
* @throws \Illuminate\Contracts\Container\BindingResolutionException
* @throws \Throwable
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function details(UpdateServerDetailsRequest $request, Server $server): array
{
$server = $this->detailsModificationService->returnUpdatedModel()->handle(
$server, $request->validated()
$server,
$request->validated()
);
return $this->fractal->item($server)
@ -65,11 +59,11 @@ class ServerDetailsController extends ApplicationApiController
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigurationRequest $request
* @param \Pterodactyl\Models\Server $server
*
* @return array
*
* @throws \Throwable
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function build(UpdateServerBuildConfigurationRequest $request, Server $server): array
{

View file

@ -23,9 +23,6 @@ class ServerManagementController extends ApplicationApiController
/**
* SuspensionController constructor.
*
* @param \Pterodactyl\Services\Servers\ReinstallServerService $reinstallServerService
* @param \Pterodactyl\Services\Servers\SuspensionService $suspensionService
*/
public function __construct(
ReinstallServerService $reinstallServerService,
@ -40,11 +37,6 @@ class ServerManagementController extends ApplicationApiController
/**
* Suspend a server on the Panel.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
* @param \Pterodactyl\Models\Server $server
*
* @return \Illuminate\Http\Response
*
* @throws \Throwable
*/
public function suspend(ServerWriteRequest $request, Server $server): Response
@ -57,11 +49,6 @@ class ServerManagementController extends ApplicationApiController
/**
* Unsuspend a server on the Panel.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
* @param \Pterodactyl\Models\Server $server
*
* @return \Illuminate\Http\Response
*
* @throws \Throwable
*/
public function unsuspend(ServerWriteRequest $request, Server $server): Response
@ -74,12 +61,9 @@ class ServerManagementController extends ApplicationApiController
/**
* Mark a server as needing to be reinstalled.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
* @param \Pterodactyl\Models\Server $server
*
* @return \Illuminate\Http\Response
*
* @throws \Throwable
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function reinstall(ServerWriteRequest $request, Server $server): Response
{

View file

@ -18,8 +18,6 @@ class StartupController extends ApplicationApiController
/**
* StartupController constructor.
*
* @param \Pterodactyl\Services\Servers\StartupModificationService $modificationService
*/
public function __construct(StartupModificationService $modificationService)
{
@ -31,11 +29,10 @@ class StartupController extends ApplicationApiController
/**
* Update the startup and environment settings for a specific server.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest $request
* @param \Pterodactyl\Models\Server $server
*
* @return array
* @throws \Throwable
* @throws \Illuminate\Validation\ValidationException
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function index(UpdateServerStartupRequest $request, Server $server): array
{

View file

@ -10,11 +10,6 @@ class ExternalUserController extends ApplicationApiController
{
/**
* Retrieve a specific user from the database using their external ID.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetExternalUserRequest $request
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function index(GetExternalUserRequest $request): array
{

View file

@ -42,11 +42,6 @@ class UserController extends ApplicationApiController
/**
* UserController constructor.
*
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
* @param \Pterodactyl\Services\Users\UserCreationService $creationService
* @param \Pterodactyl\Services\Users\UserDeletionService $deletionService
* @param \Pterodactyl\Services\Users\UserUpdateService $updateService
*/
public function __construct(
UserRepositoryInterface $repository,
@ -94,12 +89,6 @@ class UserController extends ApplicationApiController
/**
* Handle a request to view a single user. Includes any relations that
* were defined in the request.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetUserRequest $request
* @param \Pterodactyl\Models\User $user
*
* @return array
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
public function view(GetUserRequest $request, User $user): array
{
@ -116,11 +105,6 @@ class UserController extends ApplicationApiController
* Revocation errors are returned under the 'revocation_errors' key in the response
* meta. If there are no errors this is an empty array.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Users\UpdateUserRequest $request
* @param \Pterodactyl\Models\User $user
*
* @return array
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Illuminate\Contracts\Container\BindingResolutionException
@ -139,10 +123,6 @@ class UserController extends ApplicationApiController
* Store a new user on the system. Returns the created user and a HTTP/201
* header on successful creation.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Users\StoreUserRequest $request
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
@ -164,11 +144,6 @@ class UserController extends ApplicationApiController
* Handle a request to delete a user from the Panel. Returns a HTTP/204 response
* on successful deletion.
*
* @param \Pterodactyl\Http\Requests\Api\Application\Users\DeleteUserRequest $request
* @param \Pterodactyl\Models\User $user
*
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete(DeleteUserRequest $request, User $user): JsonResponse

View file

@ -25,9 +25,6 @@ class AccountController extends ClientApiController
/**
* AccountController constructor.
*
* @param \Illuminate\Auth\AuthManager $sessionGuard
* @param \Pterodactyl\Services\Users\UserUpdateService $updateService
*/
public function __construct(AuthManager $sessionGuard, UserUpdateService $updateService)
{
@ -37,10 +34,6 @@ class AccountController extends ClientApiController
$this->sessionGuard = $sessionGuard;
}
/**
* @param Request $request
* @return array
*/
public function index(Request $request): array
{
return $this->fractal->item($request->user())
@ -51,9 +44,6 @@ class AccountController extends ClientApiController
/**
* Update the authenticated user's email address.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Account\UpdateEmailRequest $request
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
@ -68,9 +58,6 @@ class AccountController extends ClientApiController
* Update the authenticated user's password. All existing sessions will be logged
* out immediately.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Account\UpdatePasswordRequest $request
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/

View file

@ -32,10 +32,6 @@ class ApiKeyController extends ClientApiController
/**
* ApiKeyController constructor.
*
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
* @param \Pterodactyl\Services\Api\KeyCreationService $keyCreationService
* @param \Pterodactyl\Repositories\Eloquent\ApiKeyRepository $repository
*/
public function __construct(
Encrypter $encrypter,
@ -52,7 +48,6 @@ class ApiKeyController extends ClientApiController
/**
* Returns all of the API keys that exist for the given client.
*
* @param \Pterodactyl\Http\Requests\Api\Client\ClientApiRequest $request
* @return array
*/
public function index(ClientApiRequest $request)
@ -65,7 +60,6 @@ class ApiKeyController extends ClientApiController
/**
* Store a new API key for a user's account.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Account\StoreApiKeyRequest $request
* @return array
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -74,9 +68,7 @@ class ApiKeyController extends ClientApiController
public function store(StoreApiKeyRequest $request)
{
if ($request->user()->apiKeys->count() >= 5) {
throw new DisplayException(
'You have reached the account limit for number of API keys.'
);
throw new DisplayException('You have reached the account limit for number of API keys.');
}
$key = $this->keyCreationService->setKeyType(ApiKey::TYPE_ACCOUNT)->handle([
@ -96,8 +88,6 @@ class ApiKeyController extends ClientApiController
/**
* Deletes a given API key.
*
* @param \Pterodactyl\Http\Requests\Api\Client\ClientApiRequest $request
* @param string $identifier
* @return \Illuminate\Http\JsonResponse
*/
public function delete(ClientApiRequest $request, string $identifier)
@ -108,8 +98,8 @@ class ApiKeyController extends ClientApiController
'identifier' => $identifier,
]);
if (! $response) {
throw new NotFoundHttpException;
if (!$response) {
throw new NotFoundHttpException();
}
return JsonResponse::create([], JsonResponse::HTTP_NO_CONTENT);

View file

@ -13,8 +13,6 @@ abstract class ClientApiController extends ApplicationApiController
/**
* Returns only the includes which are valid for the given transformer.
*
* @param \Pterodactyl\Transformers\Api\Client\BaseClientTransformer $transformer
* @param array $merge
* @return string[]
*/
protected function getIncludesForTransformer(BaseClientTransformer $transformer, array $merge = [])
@ -35,7 +33,7 @@ abstract class ClientApiController extends ApplicationApiController
{
$includes = $this->request->query('include') ?? [];
if (! is_string($includes)) {
if (!is_string($includes)) {
return $includes;
}
@ -47,7 +45,6 @@ abstract class ClientApiController extends ApplicationApiController
/**
* Return an instance of an application transformer.
*
* @param string $abstract
* @return \Pterodactyl\Transformers\Api\Client\BaseClientTransformer
*/
public function getTransformer(string $abstract)

View file

@ -20,8 +20,6 @@ class ClientController extends ClientApiController
/**
* ClientController constructor.
*
* @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository
*/
public function __construct(ServerRepository $repository)
{
@ -33,9 +31,6 @@ class ClientController extends ClientApiController
/**
* Return all of the servers available to the client making the API
* request, including servers the user has access to as a subuser.
*
* @param \Pterodactyl\Http\Requests\Api\Client\GetServersRequest $request
* @return array
*/
public function index(GetServersRequest $request): array
{
@ -49,7 +44,7 @@ class ClientController extends ClientApiController
'uuid',
'name',
'external_id',
AllowedFilter::custom('*', new MultiFieldServerFilter),
AllowedFilter::custom('*', new MultiFieldServerFilter()),
]);
$type = $request->input('type');
@ -60,14 +55,14 @@ class ClientController extends ClientApiController
if (in_array($type, ['admin', 'admin-all'])) {
// If they aren't an admin but want all the admin servers don't fail the request, just
// make it a query that will never return any results back.
if (! $user->root_admin) {
if (!$user->root_admin) {
$builder->whereRaw('1 = 2');
} else {
$builder = $type === 'admin-all'
? $builder
: $builder->whereNotIn('servers.id', $user->accessibleServers()->pluck('id')->all());
}
} else if ($type === 'owner') {
} elseif ($type === 'owner') {
$builder = $builder->where('servers.owner_id', $user->id);
} else {
$builder = $builder->whereIn('servers.id', $user->accessibleServers()->pluck('id')->all());

View file

@ -33,10 +33,6 @@ class BackupController extends ClientApiController
/**
* BackupController constructor.
*
* @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository
* @param \Pterodactyl\Services\Backups\DeleteBackupService $deleteBackupService
* @param \Pterodactyl\Services\Backups\InitiateBackupService $initiateBackupService
*/
public function __construct(
BackupRepository $repository,
@ -54,13 +50,12 @@ class BackupController extends ClientApiController
* Returns all of the backups for a given server instance in a paginated
* result set.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\GetBackupsRequest $request
* @param \Pterodactyl\Models\Server $server
* @return array
*/
public function index(GetBackupsRequest $request, Server $server)
{
$limit = min($request->query('per_page') ?? 20, 50);
return $this->fractal->collection($server->backups()->paginate($limit))
->transformWith($this->getTransformer(BackupTransformer::class))
->toArray();
@ -69,8 +64,6 @@ class BackupController extends ClientApiController
/**
* Starts the backup process for a server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest $request
* @param \Pterodactyl\Models\Server $server
* @return array
*
* @throws \Exception|\Throwable
@ -91,9 +84,6 @@ class BackupController extends ClientApiController
/**
* Returns information about a single backup.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\GetBackupsRequest $request
* @param \Pterodactyl\Models\Server $server
* @param \Pterodactyl\Models\Backup $backup
* @return array
*/
public function view(GetBackupsRequest $request, Server $server, Backup $backup)
@ -107,9 +97,6 @@ class BackupController extends ClientApiController
* Deletes a backup from the panel as well as the remote source where it is currently
* being stored.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\DeleteBackupRequest $request
* @param \Pterodactyl\Models\Server $server
* @param \Pterodactyl\Models\Backup $backup
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable

View file

@ -21,8 +21,6 @@ class CommandController extends ClientApiController
/**
* CommandController constructor.
*
* @param \Pterodactyl\Repositories\Wings\DaemonCommandRepository $repository
*/
public function __construct(DaemonCommandRepository $repository)
{
@ -34,10 +32,6 @@ class CommandController extends ClientApiController
/**
* Send a command to a running server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\SendCommandRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function index(SendCommandRequest $request, Server $server): Response
@ -52,9 +46,7 @@ class CommandController extends ClientApiController
$previous->getResponse() instanceof ResponseInterface
&& $previous->getResponse()->getStatusCode() === Response::HTTP_BAD_GATEWAY
) {
throw new HttpException(
Response::HTTP_BAD_GATEWAY, 'Server must be online in order to send commands.', $exception
);
throw new HttpException(Response::HTTP_BAD_GATEWAY, 'Server must be online in order to send commands.', $exception);
}
}

View file

@ -40,11 +40,6 @@ class DatabaseController extends ClientApiController
/**
* DatabaseController constructor.
*
* @param \Pterodactyl\Services\Databases\DatabaseManagementService $managementService
* @param \Pterodactyl\Services\Databases\DatabasePasswordService $passwordService
* @param \Pterodactyl\Repositories\Eloquent\DatabaseRepository $repository
* @param \Pterodactyl\Services\Databases\DeployServerDatabaseService $deployDatabaseService
*/
public function __construct(
DatabaseManagementService $managementService,
@ -62,10 +57,6 @@ class DatabaseController extends ClientApiController
/**
* Return all of the databases that belong to the given server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Databases\GetDatabasesRequest $request
* @param \Pterodactyl\Models\Server $server
* @return array
*/
public function index(GetDatabasesRequest $request, Server $server): array
{
@ -77,10 +68,6 @@ class DatabaseController extends ClientApiController
/**
* Create a new database for the given server and return it.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Databases\StoreDatabaseRequest $request
* @param \Pterodactyl\Models\Server $server
* @return array
*
* @throws \Throwable
* @throws \Pterodactyl\Exceptions\Service\Database\TooManyDatabasesException
* @throws \Pterodactyl\Exceptions\Service\Database\DatabaseClientFeatureNotEnabledException
@ -99,9 +86,6 @@ class DatabaseController extends ClientApiController
* Rotates the password for the given server model and returns a fresh instance to
* the caller.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Databases\RotatePasswordRequest $request
* @param \Pterodactyl\Models\Server $server
* @param \Pterodactyl\Models\Database $database
* @return array
*
* @throws \Throwable
@ -120,11 +104,6 @@ class DatabaseController extends ClientApiController
/**
* Removes a database from the server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Databases\DeleteDatabaseRequest $request
* @param \Pterodactyl\Models\Server $server
* @param \Pterodactyl\Models\Database $database
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function delete(DeleteDatabaseRequest $request, Server $server, Database $database): Response

View file

@ -39,11 +39,6 @@ class DownloadBackupController extends ClientApiController
/**
* DownloadBackupController constructor.
*
* @param \Pterodactyl\Repositories\Wings\DaemonBackupRepository $daemonBackupRepository
* @param \Pterodactyl\Services\Nodes\NodeJWTService $jwtService
* @param \Pterodactyl\Extensions\Backups\BackupManager $backupManager
* @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory
*/
public function __construct(
DaemonBackupRepository $daemonBackupRepository,
@ -64,9 +59,6 @@ class DownloadBackupController extends ClientApiController
* will be streamed back through the Panel. For AWS S3 files, a signed URL will be generated
* which the user is redirected to.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\DownloadBackupRequest $request
* @param \Pterodactyl\Models\Server $server
* @param \Pterodactyl\Models\Backup $backup
* @return \Illuminate\Http\JsonResponse
*/
public function __invoke(DownloadBackupRequest $request, Server $server, Backup $backup)
@ -79,7 +71,7 @@ class DownloadBackupController extends ClientApiController
$url = $this->getS3BackupUrl($backup, $server);
break;
default:
throw new BadRequestHttpException;
throw new BadRequestHttpException();
}
return new JsonResponse([
@ -94,8 +86,6 @@ class DownloadBackupController extends ClientApiController
* Returns a signed URL that allows us to download a file directly out of a non-public
* S3 bucket by using a signed URL.
*
* @param \Pterodactyl\Models\Backup $backup
* @param \Pterodactyl\Models\Server $server
* @return string
*/
protected function getS3BackupUrl(Backup $backup, Server $server)
@ -120,9 +110,6 @@ class DownloadBackupController extends ClientApiController
/**
* Returns a download link a backup stored on a wings instance.
*
* @param \Pterodactyl\Models\Backup $backup
* @param \Pterodactyl\Models\Server $server
* @param \Pterodactyl\Models\User $user
* @return string
*/
protected function getLocalBackupUrl(Backup $backup, Server $server, User $user)
@ -138,7 +125,7 @@ class DownloadBackupController extends ClientApiController
return sprintf(
'%s/download/backup?token=%s',
$server->node->getConnectionAddress(),
$token->__toString()
$token->toString()
);
}
}

View file

@ -6,7 +6,6 @@ use Carbon\CarbonImmutable;
use Illuminate\Http\Response;
use Pterodactyl\Models\Server;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection;
use Pterodactyl\Services\Nodes\NodeJWTService;
use Illuminate\Contracts\Routing\ResponseFactory;
use Pterodactyl\Repositories\Wings\DaemonFileRepository;
@ -15,9 +14,9 @@ use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CopyFileRequest;
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\PullFileRequest;
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\ListFilesRequest;
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\ChmodFilesRequest;
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\DeleteFileRequest;
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\RenameFileRequest;
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\ChmodFilesRequest;
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CreateFolderRequest;
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CompressFilesRequest;
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\DecompressFilesRequest;
@ -43,10 +42,6 @@ class FileController extends ClientApiController
/**
* FileController constructor.
*
* @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory
* @param \Pterodactyl\Services\Nodes\NodeJWTService $jwtService
* @param \Pterodactyl\Repositories\Wings\DaemonFileRepository $fileRepository
*/
public function __construct(
ResponseFactory $responseFactory,
@ -63,10 +58,6 @@ class FileController extends ClientApiController
/**
* Returns a listing of files in a given directory.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\ListFilesRequest $request
* @param \Pterodactyl\Models\Server $server
* @return array
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function directory(ListFilesRequest $request, Server $server): array
@ -83,10 +74,6 @@ class FileController extends ClientApiController
/**
* Return the contents of a specified file for the user.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\GetFileContentsRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
@ -94,7 +81,8 @@ class FileController extends ClientApiController
{
return new Response(
$this->fileRepository->setServer($server)->getContent(
$request->get('file'), config('pterodactyl.files.max_edit_size')
$request->get('file'),
config('pterodactyl.files.max_edit_size')
),
Response::HTTP_OK,
['Content-Type' => 'text/plain']
@ -105,8 +93,6 @@ class FileController extends ClientApiController
* Generates a one-time token with a link that the user can use to
* download a given file.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\GetFileContentsRequest $request
* @param \Pterodactyl\Models\Server $server
* @return array
*
* @throws \Exception
@ -127,7 +113,7 @@ class FileController extends ClientApiController
'url' => sprintf(
'%s/download/file?token=%s',
$server->node->getConnectionAddress(),
$token->__toString()
$token->toString()
),
],
];
@ -136,10 +122,6 @@ class FileController extends ClientApiController
/**
* Writes the contents of the specified file to the server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\WriteFileContentRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function write(WriteFileContentRequest $request, Server $server): JsonResponse
@ -152,10 +134,6 @@ class FileController extends ClientApiController
/**
* Creates a new folder on the server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\CreateFolderRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function create(CreateFolderRequest $request, Server $server): JsonResponse
@ -170,10 +148,6 @@ class FileController extends ClientApiController
/**
* Renames a file on the remote machine.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\RenameFileRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function rename(RenameFileRequest $request, Server $server): JsonResponse
@ -188,10 +162,6 @@ class FileController extends ClientApiController
/**
* Copies a file on the server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\CopyFileRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function copy(CopyFileRequest $request, Server $server): JsonResponse
@ -204,10 +174,6 @@ class FileController extends ClientApiController
}
/**
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\CompressFilesRequest $request
* @param \Pterodactyl\Models\Server $server
* @return array
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function compress(CompressFilesRequest $request, Server $server): array
@ -217,7 +183,8 @@ class FileController extends ClientApiController
$file = $this->fileRepository->setServer($server)
->compressFiles(
$request->input('root'), $request->input('files')
$request->input('root'),
$request->input('files')
);
return $this->fractal->item($file)
@ -226,10 +193,6 @@ class FileController extends ClientApiController
}
/**
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\DecompressFilesRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function decompress(DecompressFilesRequest $request, Server $server): JsonResponse
@ -246,17 +209,14 @@ class FileController extends ClientApiController
/**
* Deletes files or folders for the server in the given root directory.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\DeleteFileRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function delete(DeleteFileRequest $request, Server $server): JsonResponse
{
$this->fileRepository->setServer($server)
->deleteFiles(
$request->input('root'), $request->input('files')
$request->input('root'),
$request->input('files')
);
return new JsonResponse([], Response::HTTP_NO_CONTENT);
@ -265,17 +225,14 @@ class FileController extends ClientApiController
/**
* Updates file permissions for file(s) in the given root directory.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\ChmodFilesRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function chmod(ChmodFilesRequest $request, Server $server): JsonResponse
{
$this->fileRepository->setServer($server)
->chmodFiles(
$request->input('root'), $request->input('files')
$request->input('root'),
$request->input('files')
);
return new JsonResponse([], Response::HTTP_NO_CONTENT);
@ -285,8 +242,6 @@ class FileController extends ClientApiController
* Requests that a file be downloaded from a remote location by Wings.
*
* @param $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/

View file

@ -19,8 +19,6 @@ class FileUploadController extends ClientApiController
/**
* FileUploadController constructor.
*
* @param \Pterodactyl\Services\Nodes\NodeJWTService $jwtService
*/
public function __construct(
NodeJWTService $jwtService
@ -33,9 +31,6 @@ class FileUploadController extends ClientApiController
/**
* Returns a url where files can be uploaded to.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\UploadFileRequest $request
* @param \Pterodactyl\Models\Server $server
*
* @return \Illuminate\Http\JsonResponse
*/
public function __invoke(UploadFileRequest $request, Server $server)
@ -51,8 +46,6 @@ class FileUploadController extends ClientApiController
/**
* Returns a url where files can be uploaded to.
*
* @param \Pterodactyl\Models\Server $server
* @param \Pterodactyl\Models\User $user
* @return string
*/
protected function getUploadUrl(Server $server, User $user)
@ -67,7 +60,7 @@ class FileUploadController extends ClientApiController
return sprintf(
'%s/upload/file?token=%s',
$server->node->getConnectionAddress(),
$token->__toString()
$token->toString()
);
}
}

View file

@ -36,10 +36,6 @@ class NetworkAllocationController extends ClientApiController
/**
* NetworkController constructor.
*
* @param \Pterodactyl\Repositories\Eloquent\AllocationRepository $repository
* @param \Pterodactyl\Repositories\Eloquent\ServerRepository $serverRepository
* @param \Pterodactyl\Services\Allocations\FindAssignableAllocationService $assignableAllocationService
*/
public function __construct(
AllocationRepository $repository,
@ -56,10 +52,6 @@ class NetworkAllocationController extends ClientApiController
/**
* Lists all of the allocations available to a server and wether or
* not they are currently assigned as the primary for this server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\GetNetworkRequest $request
* @param \Pterodactyl\Models\Server $server
* @return array
*/
public function index(GetNetworkRequest $request, Server $server): array
{
@ -71,11 +63,6 @@ class NetworkAllocationController extends ClientApiController
/**
* Set the primary allocation for a server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\UpdateAllocationRequest $request
* @param \Pterodactyl\Models\Server $server
* @param \Pterodactyl\Models\Allocation $allocation
* @return array
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
@ -93,11 +80,6 @@ class NetworkAllocationController extends ClientApiController
/**
* Set the primary allocation for a server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\SetPrimaryAllocationRequest $request
* @param \Pterodactyl\Models\Server $server
* @param \Pterodactyl\Models\Allocation $allocation
* @return array
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
@ -112,20 +94,14 @@ class NetworkAllocationController extends ClientApiController
/**
* Set the notes for the allocation for a server.
*s
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\NewAllocationRequest $request
* @param \Pterodactyl\Models\Server $server
* @return array
*s.
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function store(NewAllocationRequest $request, Server $server): array
{
if ($server->allocations()->count() >= $server->allocation_limit) {
throw new DisplayException(
'Cannot assign additional allocations to this server: limit has been reached.'
);
throw new DisplayException('Cannot assign additional allocations to this server: limit has been reached.');
}
$allocation = $this->assignableAllocationService->handle($server);
@ -138,9 +114,6 @@ class NetworkAllocationController extends ClientApiController
/**
* Delete an allocation from a server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\DeleteAllocationRequest $request
* @param \Pterodactyl\Models\Server $server
* @param \Pterodactyl\Models\Allocation $allocation
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -148,9 +121,7 @@ class NetworkAllocationController extends ClientApiController
public function delete(DeleteAllocationRequest $request, Server $server, Allocation $allocation)
{
if ($allocation->id === $server->allocation_id) {
throw new DisplayException(
'You cannot delete the primary allocation for this server.'
);
throw new DisplayException('You cannot delete the primary allocation for this server.');
}
Allocation::query()->where('id', $allocation->id)->update([

View file

@ -17,8 +17,6 @@ class PowerController extends ClientApiController
/**
* PowerController constructor.
*
* @param \Pterodactyl\Repositories\Wings\DaemonPowerRepository $repository
*/
public function __construct(DaemonPowerRepository $repository)
{
@ -30,10 +28,6 @@ class PowerController extends ClientApiController
/**
* Send a power action to a server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\SendPowerRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function index(SendPowerRequest $request, Server $server): Response

View file

@ -17,8 +17,6 @@ class ResourceUtilizationController extends ClientApiController
/**
* ResourceUtilizationController constructor.
*
* @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $repository
*/
public function __construct(DaemonServerRepository $repository)
{
@ -30,10 +28,6 @@ class ResourceUtilizationController extends ClientApiController
/**
* Return the current resource utilization for a server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\GetServerRequest $request
* @param \Pterodactyl\Models\Server $server
* @return array
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function __invoke(GetServerRequest $request, Server $server): array

Some files were not shown because too many files have changed in this diff Show more