Merge branch 'develop' into dane/restore-backups

This commit is contained in:
Dane Everitt 2021-01-25 19:16:40 -08:00
commit 663143de0b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
575 changed files with 6080 additions and 6864 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.3, 7.4]
php: [7.4, 8.0]
name: PHP ${{ matrix.php }}
steps:
- name: checkout
@ -44,14 +44,14 @@ jobs:
with:
php-version: ${{ matrix.php }}
extensions: cli, openssl, gd, mysql, pdo, mbstring, tokenizer, bcmath, xml, curl, zip
tools: composer:v1
tools: composer:v2
coverage: none
- name: configure
run: cp .env.ci .env
- name: install dependencies
run: composer install --prefer-dist --no-interaction --no-progress
- name: run cs-fixer
run: vendor/bin/php-cs-fixer fix --dry-run --diff --diff-format=udiff
run: vendor/bin/php-cs-fixer fix --dry-run --diff --diff-format=udiff --rules=psr_autoloading
continue-on-error: true
- name: execute unit tests
run: vendor/bin/phpunit --bootstrap bootstrap/app.php tests/Unit

5
.gitignore vendored
View file

@ -1,6 +1,9 @@
/vendor
*.DS_Store*
.env
!.env.ci
!.env.dusk
!.env.example
.env*
.vagrant/*
.vscode/*
storage/framework/*

58
.php_cs
View file

@ -1,58 +0,0 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in([
'app',
'bootstrap',
'config',
'database',
'resources/lang',
'routes',
'tests',
]);
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'@PSR1' => true,
'@PSR2' => 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);

33
.php_cs.dist Normal file
View file

@ -0,0 +1,33 @@
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$finder = (new Finder())->in(__DIR__)->exclude(['vendor', 'node_modules', 'storage', 'bootstrap/cache']);
return (new Config())
->setRiskyAllowed(true)
->setFinder($finder)
->setRules([
'@Symfony' => true,
'@PSR1' => true,
'@PSR2' => true,
'@PSR12' => true,
'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'],
'heredoc_to_nowdoc' => true,
'no_alias_functions' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_return' => true,
'ordered_imports' => [
'sortAlgorithm' => 'length',
],
'random_api_migration' => true,
'ternary_to_null_coalescing' => true,
'yoda_style' => [
'equal' => false,
'identical' => false,
'less_and_greater' => false,
],
]);

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,12 +99,14 @@ 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'));
@ -171,7 +170,8 @@ 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;
@ -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,20 +78,24 @@ 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;

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,15 +80,19 @@ 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,15 +107,18 @@ 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(
@ -125,11 +132,13 @@ 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,7 +148,8 @@ 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)
{
@ -104,6 +101,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,7 +63,8 @@ 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();

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

@ -12,21 +12,18 @@ class PruneOrphanedBackupsCommand extends Command
/**
* @var string
*/
protected $signature = 'p:maintenance:prune-backups {--since-minutes=30}';
protected $signature = 'p:maintenance:prune-backups {--prune-age=}';
/**
* @var string
*/
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)) {
throw new InvalidArgumentException('The --since-minutes option must be a valid numeric digit.');
$since = $this->option('prune-age') ?? config('backups.prune_age', 360);
if (!$since || !is_digit($since)) {
throw new InvalidArgumentException('The "--prune-age" argument must be a value greater than 0.');
}
$query = $repository->getBuilder()

View file

@ -1,58 +0,0 @@
<?php
namespace Pterodactyl\Console\Commands\Migration;
use Pterodactyl\Models\ApiKey;
use Illuminate\Console\Command;
use Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface;
class CleanOrphanedApiKeysCommand extends Command
{
/**
* @var \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface
*/
private $repository;
/**
* @var string
*/
protected $signature = 'p:migration:clean-orphaned-keys';
/**
* @var string
*/
protected $description = 'Cleans API keys from the database that are not assigned a specific role.';
/**
* CleanOrphanedApiKeysCommand constructor.
*
* @param \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface $repository
*/
public function __construct(ApiKeyRepositoryInterface $repository)
{
parent::__construct();
$this->repository = $repository;
}
/**
* Delete all orphaned API keys from the database when upgrading from 0.6 to 0.7.
*
* @return void|null
*/
public function handle()
{
$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
);
if (! $continue) {
return null;
}
$this->info('Deleting keys...');
$this->repository->deleteWhere([['key_type', '=', ApiKey::TYPE_NONE]]);
$this->info('Keys were successfully deleted.');
}
}

View file

@ -13,12 +13,12 @@ class KeyGenerateCommand extends BaseKeyGenerateCommand
public function handle()
{
if (!empty(config('app.key')) && $this->input->isInteractive()) {
$this->output->warning(trans('command/messages.key.warning'));
if (! $this->confirm(trans('command/messages.key.confirm'))) {
$this->output->warning('It appears you have already configured an application encryption key. Continuing with this process with overwrite that key and cause data corruption for any existing encrypted data. DO NOT CONTINUE UNLESS YOU KNOW WHAT YOU ARE DOING.');
if (!$this->confirm('I understand the consequences of performing this command and accept all responsibility for the loss of encrypted data.')) {
return;
}
if (! $this->confirm(trans('command/messages.key.final_confirm'))) {
if (!$this->confirm('Are you sure you wish to continue? Changing the application encryption key WILL CAUSE DATA LOSS.')) {
return;
}
}

View file

@ -10,17 +10,17 @@ class SeedCommand extends BaseSeedCommand
use RequiresDatabaseMigrations;
/**
* Block someone from running this seed command if they have not completed the migration
* process.
*
* @return int
* Block someone from running this seed command if they have not completed
* the migration process.
*/
public function handle()
{
if (!$this->hasCompletedMigrations()) {
return $this->showMigrationWarning();
$this->showMigrationWarning();
return;
}
return parent::handle();
parent::handle();
}
}

View file

@ -10,14 +10,17 @@ class UpCommand extends BaseUpCommand
use RequiresDatabaseMigrations;
/**
* @return bool|int
* Block someone from running this up command if they have not completed
* the migration process.
*/
public function handle()
{
if (!$this->hasCompletedMigrations()) {
return $this->showMigrationWarning();
$this->showMigrationWarning();
return;
}
return parent::handle();
parent::handle();
}
}

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)
@ -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)

View file

@ -1,113 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\Server;
use Webmozart\Assert\Assert;
use Illuminate\Console\Command;
use GuzzleHttp\Exception\RequestException;
use Pterodactyl\Repositories\Eloquent\ServerRepository;
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
use Pterodactyl\Services\Servers\ServerConfigurationStructureService;
class BulkReinstallActionCommand extends Command
{
/**
* @var \Pterodactyl\Services\Servers\ServerConfigurationStructureService
*/
private $configurationStructureService;
/**
* @var \Pterodactyl\Repositories\Wings\DaemonServerRepository
*/
private $daemonRepository;
/**
* @var \Pterodactyl\Repositories\Eloquent\ServerRepository
*/
private $repository;
/**
* @var string
*/
protected $description = 'Reinstall a single server, all servers on a node, or all servers on the panel.';
/**
* @var string
*/
protected $signature = 'p:server:reinstall
{server? : The ID of the server to reinstall.}
{--node= : ID of the node to reinstall all servers on. Ignored if server is passed.}';
/**
* 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,
ServerConfigurationStructureService $configurationStructureService,
ServerRepository $repository
) {
parent::__construct();
$this->configurationStructureService = $configurationStructureService;
$this->daemonRepository = $daemonRepository;
$this->repository = $repository;
}
/**
* Handle command execution.
*/
public function handle()
{
$servers = $this->getServersToProcess();
if (! $this->confirm(trans('command/messages.server.reinstall.confirm')) && $this->input->isInteractive()) {
return;
}
$bar = $this->output->createProgressBar(count($servers));
$servers->each(function ($server) use ($bar) {
$bar->clear();
try {
$this->daemonRepository->setServer($server)->reinstall();
} catch (RequestException $exception) {
$this->output->error(trans('command/messages.server.reinstall.failed', [
'name' => $server->name,
'id' => $server->id,
'node' => $server->node->name,
'message' => $exception->getMessage(),
]));
}
$bar->advance();
$bar->display();
});
$this->line('');
}
/**
* Return the servers to be reinstalled.
*
* @return \Illuminate\Support\Collection
*/
private function getServersToProcess()
{
Assert::nullOrIntegerish($this->argument('server'), 'Value passed in server argument must be null or an integer, received %s.');
Assert::nullOrIntegerish($this->option('node'), 'Value passed in node option must be null or integer, received %s.');
return $this->repository->getDataForReinstall($this->argument('server'), $this->option('node'));
}
}

View file

@ -0,0 +1,178 @@
<?php
namespace Pterodactyl\Console\Commands;
use Closure;
use Illuminate\Console\Command;
use Pterodactyl\Console\Kernel;
use Symfony\Component\Process\Process;
use Symfony\Component\Console\Helper\ProgressBar;
class UpgradeCommand extends Command
{
protected const DEFAULT_URL = 'https://github.com/pterodactyl/panel/releases/%s/panel.tar.gz';
/** @var string */
protected $signature = 'p:upgrade
{--user= : The user that PHP runs under. All files will be owned by this user.}
{--url= : The specific archive to download.}
{--release= : A specific Pterodactyl version to download from GitHub. Leave blank to use latest.}
{--skip-download : If set no archive will be downloaded.}';
/** @var string */
protected $description = 'Downloads a new archive for Pterodactyl from GitHub and then executes the normal upgrade commands.';
/**
* Executes an upgrade command which will run through all of our standard
* commands for Pterodactyl and enable users to basically just download
* the archive and execute this and be done.
*
* This places the application in maintenance mode as well while the commands
* are being executed.
*
* @throws \Exception
*/
public function handle()
{
$skipDownload = $this->option('skip-download');
if (!$skipDownload) {
$this->output->warning('This command does not verify the integrity of downloaded assets. Please ensure that you trust the download source before continuing. If you do not wish to download an archive, please indicate that using the --skip-download flag, or answering "no" to the question below.');
$this->output->comment('Download Source (set with --url=):');
$this->line($this->getUrl());
}
if (version_compare(PHP_VERSION, '7.4.0') < 0) {
$this->error('Cannot execute self-upgrade process. The minimum required PHP version required is 7.4.0, you have [' . PHP_VERSION . '].');
}
$user = 'www-data';
if ($this->input->isInteractive()) {
if (!$skipDownload) {
$skipDownload = !$this->confirm('Would you like to download and unpack the archive files for the latest version?', true);
}
if (is_null($this->option('user'))) {
$details = posix_getpwuid(fileowner('public'));
$user = $details['name'] ?? 'www-data';
if (!$this->confirm("Your webserver user has been detected as [{$user}]: is this correct?", true)) {
$user = $this->anticipate(
'Please enter the name of the user running your webserver process. This varies from system to system, but is generally "www-data", "nginx", or "apache".',
[
'www-data',
'apache',
'nginx',
]
);
}
}
if (!$this->confirm('Are you sure you want to run the upgrade process for your Panel?')) {
return;
}
}
ini_set('output_buffering', 0);
$bar = $this->output->createProgressBar($skipDownload ? 9 : 10);
$bar->start();
if (!$skipDownload) {
$this->withProgress($bar, function () {
$this->line("\$upgrader> curl -L \"{$this->getUrl()}\" | tar -xzv");
$process = Process::fromShellCommandline("curl -L \"{$this->getUrl()}\" | tar -xzvf");
$process->run(function ($type, $buffer) {
$this->{$type === Process::ERR ? 'error' : 'line'}($buffer);
});
});
}
$this->withProgress($bar, function () {
$this->line('$upgrader> php artisan down');
$this->call('down');
});
$this->withProgress($bar, function () {
$this->line('$upgrader> chmod -R 755 storage bootstrap/cache');
$process = new Process(['chmod', '-R', '755', 'storage', 'bootstrap/cache']);
$process->run(function ($type, $buffer) {
$this->{$type === Process::ERR ? 'error' : 'line'}($buffer);
});
});
$this->withProgress($bar, function () {
$command = ['composer', 'install', '--no-ansi'];
if (config('app.env') === 'production' && !config('app.debug')) {
$command[] = '--optimize-autoloader';
$command[] = '--no-dev';
}
$this->line('$upgrader> ' . implode(' ', $command));
$process = new Process($command);
$process->setTimeout(10 * 60);
$process->run(function ($type, $buffer) {
$this->line($buffer);
});
});
/** @var \Illuminate\Foundation\Application $app */
$app = require __DIR__ . '/../../../bootstrap/app.php';
/** @var \Pterodactyl\Console\Kernel $kernel */
$kernel = $app->make(Kernel::class);
$kernel->bootstrap();
$this->setLaravel($app);
$this->withProgress($bar, function () {
$this->line('$upgrader> php artisan view:clear');
$this->call('view:clear');
});
$this->withProgress($bar, function () {
$this->line('$upgrader> php artisan config:clear');
$this->call('config:clear');
});
$this->withProgress($bar, function () {
$this->line('$upgrader> php artisan migrate --seed --force');
$this->call('migrate', ['--seed' => '', '--force' => '']);
});
$this->withProgress($bar, function () use ($user) {
$this->line("\$upgrader> chown -R {$user}:{$user} *");
$process = Process::fromShellCommandline("chown -R {$user}:{$user} *", $this->getLaravel()->basePath());
$process->setTimeout(10 * 60);
$process->run(function ($type, $buffer) {
$this->{$type === Process::ERR ? 'error' : 'line'}($buffer);
});
});
$this->withProgress($bar, function () {
$this->line('$upgrader> php artisan queue:restart');
$this->call('queue:restart');
});
$this->withProgress($bar, function () {
$this->line('$upgrader> php artisan up');
$this->call('up');
});
$this->newLine();
$this->info('Finished running upgrade.');
}
protected function withProgress(ProgressBar $bar, Closure $callback)
{
$bar->clear();
$callback();
$bar->advance();
$bar->display();
}
protected function getUrl(): string
{
if ($this->option('url')) {
return $this->option('url');
}
return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v' . $this->option('release') : 'latest/download');
}
}

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()
@ -96,7 +95,5 @@ class DeleteUserCommand extends Command
$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)
{

View file

@ -17,20 +17,15 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*/
protected function schedule(Schedule $schedule)
{
// Execute scheduled commands for servers every minute, as if there was a normal cron running.
$schedule->command('p:schedule:process')->everyMinute()->withoutOverlapping();
if (config('backups.prune_age')) {
// Every 30 minutes, run the backup pruning command so that any abandoned backups can be deleted.
$pruneAge = config('backups.prune_age', 360); // Defaults to 6 hours (time is in minuteS)
if ($pruneAge > 0) {
$schedule->command('p:maintenance:prune-backups', [
'--since-minutes' => $pruneAge,
])->everyThirtyMinutes();
$schedule->command('p:maintenance:prune-backups')->everyThirtyMinutes();
}
// Every day cleanup any internal backups of service files.

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
{
@ -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
protected function showMigrationWarning()
{
$this->getOutput()->writeln("<options=bold>
$this->getOutput()->writeln('<options=bold>
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
| |
| Your database has not been properly migrated! |
@ -52,10 +48,8 @@ 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.");
return 1;
$this->getOutput()->error('You must correct the error above before continuing.');
}
}

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

@ -18,6 +18,7 @@ interface HashidsInterface extends VendorHashidsInterface
*
* @param string $encoded
* @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,7 +25,6 @@ class DisplayException extends PterodactylException
* Exception constructor.
*
* @param string $message
* @param Throwable|null $previous
* @param string $level
* @param int $code
*/
@ -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)

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);
});
$this->reportable(function (Swift_TransportException $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);
}
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

@ -29,9 +29,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)
{

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,7 +141,6 @@ class BackupManager
/**
* Creates a new S3 adapter.
*
* @param array $config
* @return \League\Flysystem\AdapterInterface
*/
public function createS3Adapter(array $config)
@ -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,

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,22 +36,18 @@ 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 string $name
* @param mixed $default
*
* @return string
*/
public static function checked(string $name, $default)

View file

@ -33,10 +33,6 @@ class ApiController extends Controller
/**
* ApplicationApiController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface $repository
* @param \Pterodactyl\Services\Api\KeyCreationService $keyCreationService
*/
public function __construct(
AlertsMessageBag $alert,
@ -50,9 +46,6 @@ class ApiController extends Controller
/**
* Render view showing all of a user's application API keys.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\View\View
*/
public function index(Request $request): View
{
@ -64,7 +57,6 @@ class ApiController extends Controller
/**
* Render view allowing an admin to create a new application API key.
*
* @return \Illuminate\View\View
* @throws \ReflectionException
*/
public function create(): View
@ -85,9 +77,6 @@ class ApiController extends Controller
/**
* Store the new key and redirect the user back to the application key listing.
*
* @param \Pterodactyl\Http\Requests\Admin\Api\StoreApplicationApiKeyRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function store(StoreApplicationApiKeyRequest $request): RedirectResponse
@ -104,10 +93,6 @@ class ApiController extends Controller
/**
* Delete an application API key from the database.
*
* @param \Illuminate\Http\Request $request
* @param string $identifier
* @return \Illuminate\Http\Response
*/
public function delete(Request $request, string $identifier): Response
{

View file

@ -15,8 +15,6 @@ class BaseController extends Controller
/**
* BaseController constructor.
*
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $version
*/
public function __construct(SoftwareVersionService $version)
{
@ -25,8 +23,6 @@ class BaseController extends Controller
/**
* Return the admin index view.
*
* @return \Illuminate\View\View
*/
public function index(): View
{

View file

@ -56,14 +56,6 @@ class DatabaseController extends Controller
/**
* DatabaseController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface $repository
* @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $databaseRepository
* @param \Pterodactyl\Services\Databases\Hosts\HostCreationService $creationService
* @param \Pterodactyl\Services\Databases\Hosts\HostDeletionService $deletionService
* @param \Pterodactyl\Services\Databases\Hosts\HostUpdateService $updateService
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
*/
public function __construct(
AlertsMessageBag $alert,
@ -85,8 +77,6 @@ class DatabaseController extends Controller
/**
* Display database host index.
*
* @return \Illuminate\View\View
*/
public function index(): View
{
@ -99,9 +89,6 @@ class DatabaseController extends Controller
/**
* Display database host to user.
*
* @param int $host
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function view(int $host): View
@ -116,9 +103,6 @@ class DatabaseController extends Controller
/**
* Handle request to create a new database host.
*
* @param \Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
*/
public function create(DatabaseHostFormRequest $request): RedirectResponse
@ -145,10 +129,6 @@ class DatabaseController extends Controller
/**
* Handle updating database host.
*
* @param \Pterodactyl\Http\Requests\Admin\DatabaseHostFormRequest $request
* @param \Pterodactyl\Models\DatabaseHost $host
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
*/
public function update(DatabaseHostFormRequest $request, DatabaseHost $host): RedirectResponse
@ -178,9 +158,6 @@ class DatabaseController extends Controller
/**
* Handle request to delete a database host.
*
* @param int $host
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/
public function delete(int $host): RedirectResponse

View file

@ -48,12 +48,6 @@ class LocationController extends Controller
/**
* LocationController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @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(
AlertsMessageBag $alert,
@ -85,6 +79,7 @@ class LocationController extends Controller
* Return the location view page.
*
* @param int $id
*
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
@ -99,7 +94,6 @@ class LocationController extends Controller
/**
* Handle request to create new location.
*
* @param \Pterodactyl\Http\Requests\Admin\LocationFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
@ -115,8 +109,6 @@ class LocationController extends Controller
/**
* Handle request to update or delete location.
*
* @param \Pterodactyl\Http\Requests\Admin\LocationFormRequest $request
* @param \Pterodactyl\Models\Location $location
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
@ -136,7 +128,6 @@ class LocationController extends Controller
/**
* Delete a location from the system.
*
* @param \Pterodactyl\Models\Location $location
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Exception

View file

@ -3,17 +3,13 @@
namespace Pterodactyl\Http\Controllers\Admin;
use Ramsey\Uuid\Uuid;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Pterodactyl\Models\Nest;
use Pterodactyl\Models\Mount;
use Pterodactyl\Models\Location;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Mounts\MountUpdateService;
use Pterodactyl\Http\Requests\Admin\MountFormRequest;
use Pterodactyl\Services\Mounts\MountCreationService;
use Pterodactyl\Services\Mounts\MountDeletionService;
use Pterodactyl\Repositories\Eloquent\MountRepository;
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
@ -42,11 +38,6 @@ class MountController extends Controller
/**
* MountController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $nestRepository
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
* @param \Pterodactyl\Repositories\Eloquent\MountRepository $repository
*/
public function __construct(
AlertsMessageBag $alert,
@ -76,6 +67,7 @@ class MountController extends Controller
* Return the mount view page.
*
* @param string $id
*
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
@ -95,7 +87,6 @@ class MountController extends Controller
/**
* Handle request to create new mount.
*
* @param \Pterodactyl\Http\Requests\Admin\MountFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
@ -116,8 +107,6 @@ class MountController extends Controller
/**
* Handle request to update or delete location.
*
* @param \Pterodactyl\Http\Requests\Admin\MountFormRequest $request
* @param \Pterodactyl\Models\Mount $mount
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
@ -138,7 +127,6 @@ class MountController extends Controller
/**
* Delete a location from the system.
*
* @param \Pterodactyl\Models\Mount $mount
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Exception
@ -153,8 +141,6 @@ class MountController extends Controller
/**
* Adds eggs to the mount's many to many relation.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Mount $mount
* @return \Illuminate\Http\RedirectResponse
*/
public function addEggs(Request $request, Mount $mount)
@ -176,8 +162,6 @@ class MountController extends Controller
/**
* Adds nodes to the mount's many to many relation.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Mount $mount
* @return \Illuminate\Http\RedirectResponse
*/
public function addNodes(Request $request, Mount $mount)
@ -197,8 +181,6 @@ class MountController extends Controller
/**
* Deletes an egg from the mount's many to many relation.
*
* @param \Pterodactyl\Models\Mount $mount
* @param int $egg_id
* @return \Illuminate\Http\Response
*/
public function deleteEgg(Mount $mount, int $egg_id)
@ -211,8 +193,6 @@ class MountController extends Controller
/**
* Deletes an node from the mount's many to many relation.
*
* @param \Pterodactyl\Models\Mount $mount
* @param int $node_id
* @return \Illuminate\Http\Response
*/
public function deleteNode(Mount $mount, int $node_id)

View file

@ -55,8 +55,6 @@ class EggController extends Controller
/**
* Handle a request to display the Egg creation page.
*
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function create(): View
@ -70,9 +68,6 @@ class EggController extends Controller
/**
* Handle request to store a new Egg.
*
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException
*/
@ -93,9 +88,6 @@ class EggController extends Controller
/**
* Handle request to view a single Egg.
*
* @param \Pterodactyl\Models\Egg $egg
* @return \Illuminate\View\View
*/
public function view(Egg $egg): View
{
@ -105,10 +97,6 @@ class EggController extends Controller
/**
* Handle request to update an Egg.
*
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggFormRequest $request
* @param \Pterodactyl\Models\Egg $egg
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException
@ -131,9 +119,6 @@ class EggController extends Controller
/**
* Handle request to destroy an egg.
*
* @param \Pterodactyl\Models\Egg $egg
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Service\Egg\HasChildrenException
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/

View file

@ -30,10 +30,6 @@ class EggScriptController extends Controller
/**
* EggScriptController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
* @param \Pterodactyl\Services\Eggs\Scripts\InstallScriptService $installScriptService
*/
public function __construct(
AlertsMessageBag $alert,
@ -47,9 +43,6 @@ class EggScriptController extends Controller
/**
* Handle requests to render installation script for an Egg.
*
* @param int $egg
* @return \Illuminate\View\View
*/
public function index(int $egg): View
{
@ -74,10 +67,6 @@ class EggScriptController extends Controller
/**
* Handle a request to update the installation script for an Egg.
*
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggScriptFormRequest $request
* @param \Pterodactyl\Models\Egg $egg
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException

View file

@ -43,11 +43,6 @@ class EggShareController extends Controller
/**
* OptionShareController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Services\Eggs\Sharing\EggExporterService $exporterService
* @param \Pterodactyl\Services\Eggs\Sharing\EggImporterService $importerService
* @param \Pterodactyl\Services\Eggs\Sharing\EggUpdateImporterService $updateImporterService
*/
public function __construct(
AlertsMessageBag $alert,
@ -62,9 +57,6 @@ class EggShareController extends Controller
}
/**
* @param \Pterodactyl\Models\Egg $egg
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function export(Egg $egg): Response
@ -82,9 +74,6 @@ class EggShareController extends Controller
/**
* Import a new service option using an XML file.
*
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggImportFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\Egg\BadJsonFormatException
@ -101,10 +90,6 @@ class EggShareController extends Controller
/**
* Update an existing Egg using a new imported file.
*
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggImportFormRequest $request
* @param \Pterodactyl\Models\Egg $egg
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\Egg\BadJsonFormatException

View file

@ -50,12 +50,6 @@ class EggVariableController extends Controller
/**
* EggVariableController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Services\Eggs\Variables\VariableCreationService $creationService
* @param \Pterodactyl\Services\Eggs\Variables\VariableUpdateService $updateService
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
* @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $variableRepository
*/
public function __construct(
AlertsMessageBag $alert,
@ -74,9 +68,6 @@ class EggVariableController extends Controller
/**
* Handle request to view the variables attached to an Egg.
*
* @param int $egg
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function view(int $egg): View
@ -89,10 +80,6 @@ class EggVariableController extends Controller
/**
* Handle a request to create a new Egg variable.
*
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggVariableFormRequest $request
* @param \Pterodactyl\Models\Egg $egg
*
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\BadValidationRuleException
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException
@ -108,11 +95,6 @@ class EggVariableController extends Controller
/**
* Handle a request to update an existing Egg variable.
*
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggVariableFormRequest $request
* @param \Pterodactyl\Models\Egg $egg
* @param \Pterodactyl\Models\EggVariable $variable
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
@ -130,10 +112,6 @@ class EggVariableController extends Controller
/**
* Handle a request to delete an existing Egg variable from the Panel.
*
* @param int $egg
* @param \Pterodactyl\Models\EggVariable $variable
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(int $egg, EggVariable $variable): RedirectResponse
{

View file

@ -48,12 +48,6 @@ class NestController extends Controller
/**
* NestController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Services\Nests\NestCreationService $nestCreationService
* @param \Pterodactyl\Services\Nests\NestDeletionService $nestDeletionService
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository
* @param \Pterodactyl\Services\Nests\NestUpdateService $nestUpdateService
*/
public function __construct(
AlertsMessageBag $alert,
@ -72,8 +66,6 @@ class NestController extends Controller
/**
* Render nest listing page.
*
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function index(): View
@ -85,8 +77,6 @@ class NestController extends Controller
/**
* Render nest creation page.
*
* @return \Illuminate\View\View
*/
public function create(): View
{
@ -96,9 +86,6 @@ class NestController extends Controller
/**
* Handle the storage of a new nest.
*
* @param \Pterodactyl\Http\Requests\Admin\Nest\StoreNestFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function store(StoreNestFormRequest $request): RedirectResponse
@ -112,9 +99,6 @@ class NestController extends Controller
/**
* Return details about a nest including all of the eggs and servers per egg.
*
* @param int $nest
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function view(int $nest): View
@ -127,10 +111,6 @@ class NestController extends Controller
/**
* Handle request to update a nest.
*
* @param \Pterodactyl\Http\Requests\Admin\Nest\StoreNestFormRequest $request
* @param int $nest
*
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
@ -145,9 +125,6 @@ class NestController extends Controller
/**
* Handle request to delete a nest.
*
* @param int $nest
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/
public function destroy(int $nest): RedirectResponse

View file

@ -30,10 +30,6 @@ class NodeAutoDeployController extends Controller
/**
* NodeAutoDeployController constructor.
*
* @param \Pterodactyl\Repositories\Eloquent\ApiKeyRepository $repository
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
* @param \Pterodactyl\Services\Api\KeyCreationService $keyCreationService
*/
public function __construct(
ApiKeyRepository $repository,
@ -49,8 +45,6 @@ class NodeAutoDeployController extends Controller
* Generates a new API key for the logged in user with only permission to read
* nodes, and returns that as the deployment key for a node.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException

View file

@ -23,9 +23,6 @@ class NodeController extends Controller
/**
* NodeController constructor.
*
* @param \Pterodactyl\Repositories\Eloquent\NodeRepository $repository
* @param \Illuminate\Contracts\View\Factory $view
*/
public function __construct(NodeRepository $repository, Factory $view)
{
@ -36,7 +33,6 @@ class NodeController extends Controller
/**
* Returns a listing of nodes on the system.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\View
*/
public function index(Request $request)

View file

@ -51,13 +51,6 @@ class NodeViewController extends Controller
/**
* NodeViewController constructor.
*
* @param \Pterodactyl\Repositories\Eloquent\AllocationRepository $allocationRepository
* @param \Pterodactyl\Repositories\Eloquent\LocationRepository $locationRepository
* @param \Pterodactyl\Repositories\Eloquent\NodeRepository $repository
* @param \Pterodactyl\Repositories\Eloquent\ServerRepository $serverRepository
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $versionService
* @param \Illuminate\Contracts\View\Factory $view
*/
public function __construct(
AllocationRepository $allocationRepository,
@ -78,8 +71,6 @@ class NodeViewController extends Controller
/**
* Returns index view for a specific node on the system.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\Contracts\View\View
*/
public function index(Request $request, Node $node)
@ -96,8 +87,6 @@ class NodeViewController extends Controller
/**
* Returns the settings page for a specific node.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\Contracts\View\View
*/
public function settings(Request $request, Node $node)
@ -111,8 +100,6 @@ class NodeViewController extends Controller
/**
* Return the node configuration page for a specific node.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\Contracts\View\View
*/
public function configuration(Request $request, Node $node)
@ -123,8 +110,6 @@ class NodeViewController extends Controller
/**
* Return the node allocation management page.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\Contracts\View\View
*/
public function allocations(Request $request, Node $node)
@ -145,8 +130,6 @@ class NodeViewController extends Controller
/**
* Return a listing of servers that exist for this specific node.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\Contracts\View\View
*/
public function servers(Request $request, Node $node)

View file

@ -18,8 +18,6 @@ class SystemInformationController extends Controller
/**
* SystemInformationController constructor.
*
* @param \Pterodactyl\Repositories\Wings\DaemonConfigurationRepository $repository
*/
public function __construct(DaemonConfigurationRepository $repository)
{
@ -29,8 +27,6 @@ class SystemInformationController extends Controller
/**
* Returns system information from the Daemon.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\Http\JsonResponse
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException

View file

@ -94,19 +94,6 @@ class NodesController extends Controller
/**
* NodesController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Services\Allocations\AllocationDeletionService $allocationDeletionService
* @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $allocationRepository
* @param \Pterodactyl\Services\Allocations\AssignmentService $assignmentService
* @param \Illuminate\Cache\Repository $cache
* @param \Pterodactyl\Services\Nodes\NodeCreationService $creationService
* @param \Pterodactyl\Services\Nodes\NodeDeletionService $deletionService
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository
* @param \Pterodactyl\Services\Nodes\NodeUpdateService $updateService
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $versionService
*/
public function __construct(
AlertsMessageBag $alert,
@ -156,7 +143,6 @@ class NodesController extends Controller
/**
* Post controller to create a new node on the system.
*
* @param \Pterodactyl\Http\Requests\Admin\Node\NodeFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
@ -172,8 +158,6 @@ class NodesController extends Controller
/**
* Updates settings for a node.
*
* @param \Pterodactyl\Http\Requests\Admin\Node\NodeFormRequest $request
* @param \Pterodactyl\Models\Node $node
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -191,10 +175,6 @@ class NodesController extends Controller
/**
* Removes a single allocation from a node.
*
* @param int $node
* @param \Pterodactyl\Models\Allocation $allocation
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\Service\Allocation\ServerUsingAllocationException
*/
public function allocationRemoveSingle(int $node, Allocation $allocation): Response
@ -207,10 +187,6 @@ class NodesController extends Controller
/**
* Removes multiple individual allocations from a node.
*
* @param \Illuminate\Http\Request $request
* @param int $node
* @return \Illuminate\Http\Response
*
* @throws \Pterodactyl\Exceptions\Service\Allocation\ServerUsingAllocationException
*/
public function allocationRemoveMultiple(Request $request, int $node): Response
@ -228,8 +204,8 @@ class NodesController extends Controller
/**
* Remove all allocations for a specific IP at once on a node.
*
* @param \Illuminate\Http\Request $request
* @param int $node
*
* @return \Illuminate\Http\RedirectResponse
*/
public function allocationRemoveBlock(Request $request, $node)
@ -249,7 +225,6 @@ class NodesController extends Controller
/**
* Sets an alias for a specific allocation on a node.
*
* @param \Pterodactyl\Http\Requests\Admin\Node\AllocationAliasFormRequest $request
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
@ -267,8 +242,8 @@ class NodesController extends Controller
/**
* Creates new allocations on a node.
*
* @param \Pterodactyl\Http\Requests\Admin\Node\AllocationFormRequest $request
* @param int|\Pterodactyl\Models\Node $node
*
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Service\Allocation\CidrOutOfRangeException
@ -288,6 +263,7 @@ class NodesController extends Controller
* Deletes a node from the system.
*
* @param $node
*
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException

View file

@ -47,13 +47,6 @@ class CreateServerController extends Controller
/**
* CreateServerController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Repositories\Eloquent\NestRepository $nestRepository
* @param \Pterodactyl\Repositories\Eloquent\LocationRepository $locationRepository
* @param \Pterodactyl\Repositories\Eloquent\NodeRepository $nodeRepository
* @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository
* @param \Pterodactyl\Services\Servers\ServerCreationService $creationService
*/
public function __construct(
AlertsMessageBag $alert,
@ -75,6 +68,7 @@ class CreateServerController extends Controller
* Displays the create server page.
*
* @return \Illuminate\Contracts\View\Factory
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function index()
@ -106,7 +100,6 @@ class CreateServerController extends Controller
/**
* Create a new server on the remote system.
*
* @param \Pterodactyl\Http\Requests\Admin\ServerFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException

View file

@ -25,9 +25,6 @@ class ServerController extends Controller
/**
* ServerController constructor.
*
* @param \Illuminate\Contracts\View\Factory $view
* @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository
*/
public function __construct(
Factory $view,
@ -41,7 +38,6 @@ class ServerController extends Controller
* Returns all of the servers that exist on the system using a paginated result set. If
* a query is passed along in the request it is also passed to the repository function.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\View
*/
public function index(Request $request)
@ -49,7 +45,7 @@ class ServerController extends Controller
$servers = QueryBuilder::for(Server::query()->with('node', 'user', 'allocation'))
->allowedFilters([
AllowedFilter::exact('owner_id'),
AllowedFilter::custom('*', new AdminServerFilter),
AllowedFilter::custom('*', new AdminServerFilter()),
])
->paginate(config()->get('pterodactyl.paginate.admin.servers'));

View file

@ -53,14 +53,6 @@ class ServerTransferController extends Controller
/**
* ServerTransferController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $allocationRepository
* @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository
* @param \Pterodactyl\Repositories\Eloquent\LocationRepository $locationRepository
* @param \Pterodactyl\Repositories\Eloquent\NodeRepository $nodeRepository
* @param \Pterodactyl\Services\Servers\TransferService $transferService
* @param \Pterodactyl\Repositories\Wings\DaemonConfigurationRepository $daemonConfigurationRepository
*/
public function __construct(
AlertsMessageBag $alert,
@ -83,13 +75,12 @@ class ServerTransferController extends Controller
/**
* Starts a transfer of a server to a new node.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
*/
public function transfer(Request $request, Server $server) {
public function transfer(Request $request, Server $server)
{
$validatedData = $request->validate([
'node_id' => 'required|exists:nodes,id',
'allocation_id' => 'required|bail|unique:servers|exists:allocations,id',
@ -107,7 +98,7 @@ class ServerTransferController extends Controller
$this->daemonConfigurationRepository->setNode($node)->getSystemInformation();
// Create a new ServerTransfer entry.
$transfer = new ServerTransfer;
$transfer = new ServerTransfer();
$transfer->server_id = $server->id;
$transfer->old_node = $server->node_id;
@ -135,11 +126,6 @@ class ServerTransferController extends Controller
/**
* Assigns the specified allocations to the specified server.
*
* @param Server $server
* @param int $node_id
* @param int $allocation_id
* @param array $additional_allocations
*/
private function assignAllocationsToServer(Server $server, int $node_id, int $allocation_id, array $additional_allocations)
{

View file

@ -64,15 +64,6 @@ class ServerViewController extends Controller
/**
* ServerViewController constructor.
*
* @param \Illuminate\Contracts\View\Factory $view
* @param \Pterodactyl\Repositories\Eloquent\DatabaseHostRepository $databaseHostRepository
* @param \Pterodactyl\Repositories\Eloquent\LocationRepository $locationRepository
* @param \Pterodactyl\Repositories\Eloquent\MountRepository $mountRepository
* @param \Pterodactyl\Repositories\Eloquent\NestRepository $nestRepository
* @param \Pterodactyl\Repositories\Eloquent\NodeRepository $nodeRepository
* @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository
* @param \Pterodactyl\Services\Servers\EnvironmentService $environmentService
*/
public function __construct(
Factory $view,
@ -97,8 +88,6 @@ class ServerViewController extends Controller
/**
* Returns the index view for a server.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Contracts\View\View
*/
public function index(Request $request, Server $server)
@ -109,8 +98,6 @@ class ServerViewController extends Controller
/**
* Returns the server details page.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Contracts\View\View
*/
public function details(Request $request, Server $server)
@ -121,8 +108,6 @@ class ServerViewController extends Controller
/**
* Returns a view of server build settings.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Contracts\View\View
*/
public function build(Request $request, Server $server)
@ -139,8 +124,6 @@ class ServerViewController extends Controller
/**
* Returns the server startup management page.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Contracts\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
@ -166,8 +149,6 @@ class ServerViewController extends Controller
/**
* Returns all of the databases that exist for the server.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Contracts\View\View
*/
public function database(Request $request, Server $server)
@ -181,8 +162,6 @@ class ServerViewController extends Controller
/**
* Returns all of the mounts that exist for the server.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Contracts\View\View
*/
public function mounts(Request $request, Server $server)
@ -199,8 +178,6 @@ class ServerViewController extends Controller
* Returns the base server management page, or an exception if the server
* is in a state that cannot be recovered from.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Contracts\View\View
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -234,8 +211,6 @@ class ServerViewController extends Controller
/**
* Returns the server deletion page.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Contracts\View\View
*/
public function delete(Request $request, Server $server)

View file

@ -9,14 +9,12 @@
namespace Pterodactyl\Http\Controllers\Admin;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Pterodactyl\Models\User;
use Pterodactyl\Models\Mount;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\MountServer;
use Prologue\Alerts\AlertsMessageBag;
use GuzzleHttp\Exception\RequestException;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Illuminate\Validation\ValidationException;
@ -37,7 +35,6 @@ use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
use Pterodactyl\Services\Servers\ServerConfigurationStructureService;
use Pterodactyl\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest;
@ -135,25 +132,6 @@ class ServersController extends Controller
/**
* ServersController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $allocationRepository
* @param \Pterodactyl\Services\Servers\BuildModificationService $buildModificationService
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonServerRepository
* @param \Pterodactyl\Services\Databases\DatabaseManagementService $databaseManagementService
* @param \Pterodactyl\Services\Databases\DatabasePasswordService $databasePasswordService
* @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $databaseRepository
* @param \Pterodactyl\Repositories\Eloquent\DatabaseHostRepository $databaseHostRepository
* @param \Pterodactyl\Services\Servers\ServerDeletionService $deletionService
* @param \Pterodactyl\Services\Servers\DetailsModificationService $detailsModificationService
* @param \Pterodactyl\Services\Servers\ReinstallServerService $reinstallService
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
* @param \Pterodactyl\Repositories\Eloquent\MountRepository $mountRepository
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $nestRepository
* @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $serverConfigurationStructureService
* @param \Pterodactyl\Services\Servers\StartupModificationService $startupModificationService
* @param \Pterodactyl\Services\Servers\SuspensionService $suspensionService
*/
public function __construct(
AlertsMessageBag $alert,
@ -198,8 +176,6 @@ class ServersController extends Controller
/**
* Update the details for a server.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
@ -219,7 +195,6 @@ class ServersController extends Controller
/**
* Toggles the install status for a server.
*
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -244,7 +219,6 @@ class ServersController extends Controller
/**
* Reinstalls the server with the currently assigned service.
*
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -262,8 +236,6 @@ class ServersController extends Controller
/**
* Manage the suspension status for a server.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -283,8 +255,6 @@ class ServersController extends Controller
/**
* Update the build configuration for a server.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -311,8 +281,6 @@ class ServersController extends Controller
/**
* Start the server deletion process.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
@ -329,8 +297,6 @@ class ServersController extends Controller
/**
* Update the startup command as well as variables.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Illuminate\Validation\ValidationException
@ -359,8 +325,6 @@ class ServersController extends Controller
/**
* Creates a new database assigned to a specific server.
*
* @param \Pterodactyl\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest $request
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
@ -380,8 +344,8 @@ class ServersController extends Controller
/**
* Resets the database password for a specific database on this server.
*
* @param \Illuminate\Http\Request $request
* @param int $server
*
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
@ -403,6 +367,7 @@ class ServersController extends Controller
*
* @param int $server
* @param int $database
*
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Exception
@ -423,15 +388,13 @@ class ServersController extends Controller
/**
* Add a mount to a server.
*
* @param Server $server
* @param \Pterodactyl\Models\Mount $mount
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
*/
public function addMount(Server $server, Mount $mount)
{
$mountServer = (new MountServer)->forceFill([
$mountServer = (new MountServer())->forceFill([
'mount_id' => $mount->id,
'server_id' => $server->id,
]);
@ -446,8 +409,6 @@ class ServersController extends Controller
/**
* Remove a mount from a server.
*
* @param Server $server
* @param \Pterodactyl\Models\Mount $mount
* @return \Illuminate\Http\RedirectResponse
*/
public function deleteMount(Server $server, Mount $mount)

View file

@ -35,11 +35,6 @@ class AdvancedController extends Controller
/**
* AdvancedController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Illuminate\Contracts\Console\Kernel $kernel
* @param \Pterodactyl\Contracts\Repository\SettingsRepositoryInterface $settings
*/
public function __construct(
AlertsMessageBag $alert,
@ -55,8 +50,6 @@ class AdvancedController extends Controller
/**
* Render advanced Panel settings UI.
*
* @return \Illuminate\View\View
*/
public function index(): View
{
@ -74,8 +67,6 @@ class AdvancedController extends Controller
}
/**
* @param \Pterodactyl\Http\Requests\Admin\Settings\AdvancedSettingsFormRequest $request
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/

View file

@ -38,18 +38,13 @@ class IndexController extends Controller
/**
* IndexController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Illuminate\Contracts\Console\Kernel $kernel
* @param \Pterodactyl\Contracts\Repository\SettingsRepositoryInterface $settings
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $versionService
*/
public function __construct(
AlertsMessageBag $alert,
Kernel $kernel,
SettingsRepositoryInterface $settings,
SoftwareVersionService $versionService)
{
SoftwareVersionService $versionService
) {
$this->alert = $alert;
$this->kernel = $kernel;
$this->settings = $settings;
@ -58,8 +53,6 @@ class IndexController extends Controller
/**
* Render the UI for basic Panel settings.
*
* @return \Illuminate\View\View
*/
public function index(): View
{
@ -72,8 +65,6 @@ class IndexController extends Controller
/**
* Handle settings update.
*
* @param \Pterodactyl\Http\Requests\Admin\Settings\BaseSettingsFormRequest $request
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/

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