Merge branch 'develop' into feature/react-admin
This commit is contained in:
commit
8feb87de7c
532 changed files with 4262 additions and 5622 deletions
6
.github/workflows/docker.yml
vendored
6
.github/workflows/docker.yml
vendored
|
@ -25,6 +25,12 @@ jobs:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
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
|
- name: Release Production Build
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
if: "!contains(github.ref, 'develop')"
|
if: "!contains(github.ref, 'develop')"
|
||||||
|
|
16
.github/workflows/tests.yml
vendored
16
.github/workflows/tests.yml
vendored
|
@ -19,9 +19,9 @@ jobs:
|
||||||
- 3306
|
- 3306
|
||||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
php: [7.4]
|
php: [7.4, 8.0]
|
||||||
name: PHP ${{ matrix.php }}
|
name: PHP ${{ matrix.php }}
|
||||||
steps:
|
steps:
|
||||||
- name: checkout
|
- name: checkout
|
||||||
|
@ -59,9 +59,9 @@ jobs:
|
||||||
env:
|
env:
|
||||||
DB_CONNECTION: testing
|
DB_CONNECTION: testing
|
||||||
TESTING_DB_HOST: UNIT_NO_DB
|
TESTING_DB_HOST: UNIT_NO_DB
|
||||||
# - name: execute integration tests
|
- name: execute integration tests
|
||||||
# run: vendor/bin/phpunit tests/Integration
|
run: vendor/bin/phpunit tests/Integration
|
||||||
# if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
# env:
|
env:
|
||||||
# TESTING_DB_PORT: ${{ job.services.mysql.ports[3306] }}
|
TESTING_DB_PORT: ${{ job.services.mysql.ports[3306] }}
|
||||||
# TESTING_DB_USERNAME: root
|
TESTING_DB_USERNAME: root
|
||||||
|
|
49
.php_cs
49
.php_cs
|
@ -1,58 +1,43 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$finder = PhpCsFixer\Finder::create()
|
use PhpCsFixer\Config;
|
||||||
->in([
|
use PhpCsFixer\Finder;
|
||||||
'app',
|
|
||||||
'bootstrap',
|
|
||||||
'config',
|
|
||||||
'database',
|
|
||||||
'resources/lang',
|
|
||||||
'routes',
|
|
||||||
'tests',
|
|
||||||
]);
|
|
||||||
|
|
||||||
return PhpCsFixer\Config::create()
|
$finder = (new Finder)->in([
|
||||||
|
'app',
|
||||||
|
'bootstrap',
|
||||||
|
'config',
|
||||||
|
'database',
|
||||||
|
'resources/lang',
|
||||||
|
'routes',
|
||||||
|
'tests',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return (new Config)
|
||||||
|
->setRiskyAllowed(true)
|
||||||
|
->setFinder($finder)
|
||||||
->setRules([
|
->setRules([
|
||||||
'@Symfony' => true,
|
'@Symfony' => true,
|
||||||
'@PSR1' => true,
|
'@PSR1' => true,
|
||||||
'@PSR2' => true,
|
'@PSR2' => true,
|
||||||
|
'@PSR12' => true,
|
||||||
'align_multiline_comment' => ['comment_type' => 'phpdocs_like'],
|
'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,
|
'combine_consecutive_unsets' => true,
|
||||||
'concat_space' => ['spacing' => 'one'],
|
'concat_space' => ['spacing' => 'one'],
|
||||||
'declare_equal_normalize' => ['space' => 'single'],
|
|
||||||
'heredoc_to_nowdoc' => true,
|
'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_alias_functions' => true,
|
||||||
'no_multiline_whitespace_before_semicolons' => true,
|
|
||||||
'no_superfluous_phpdoc_tags' => false,
|
|
||||||
'no_unreachable_default_argument_value' => true,
|
'no_unreachable_default_argument_value' => true,
|
||||||
'no_useless_return' => true,
|
'no_useless_return' => true,
|
||||||
'not_operator_with_successor_space' => true,
|
|
||||||
'ordered_imports' => [
|
'ordered_imports' => [
|
||||||
'sortAlgorithm' => 'length',
|
'sortAlgorithm' => 'length',
|
||||||
],
|
],
|
||||||
'phpdoc_align' => false,
|
|
||||||
'phpdoc_separation' => false,
|
|
||||||
'protected_to_private' => false,
|
|
||||||
'psr0' => ['dir' => 'app'],
|
'psr0' => ['dir' => 'app'],
|
||||||
'psr4' => true,
|
'psr4' => true,
|
||||||
'random_api_migration' => true,
|
'random_api_migration' => true,
|
||||||
'single_line_throw' => false,
|
|
||||||
'single_trait_insert_per_statement' => false,
|
|
||||||
'standardize_not_equals' => true,
|
|
||||||
'ternary_to_null_coalescing' => true,
|
'ternary_to_null_coalescing' => true,
|
||||||
'yoda_style' => [
|
'yoda_style' => [
|
||||||
'equal' => false,
|
'equal' => false,
|
||||||
'identical' => false,
|
'identical' => false,
|
||||||
'less_and_greater' => false,
|
'less_and_greater' => false,
|
||||||
],
|
],
|
||||||
])->setRiskyAllowed(true)->setFinder($finder);
|
]);
|
||||||
|
|
|
@ -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.
|
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
|
## v1.2.1
|
||||||
### Fixed
|
### Fixed
|
||||||
* Fixes URL-encoding of filenames when working in the filemanager to fix issues when moving, renaming, or deleting files.
|
* Fixes URL-encoding of filenames when working in the filemanager to fix issues when moving, renaming, or deleting files.
|
||||||
|
|
|
@ -19,13 +19,13 @@ class AppSettingsCommand extends Command
|
||||||
{
|
{
|
||||||
use EnvironmentWriterTrait;
|
use EnvironmentWriterTrait;
|
||||||
|
|
||||||
const ALLOWED_CACHE_DRIVERS = [
|
public const ALLOWED_CACHE_DRIVERS = [
|
||||||
'redis' => 'Redis (recommended)',
|
'redis' => 'Redis (recommended)',
|
||||||
'memcached' => 'Memcached',
|
'memcached' => 'Memcached',
|
||||||
'file' => 'Filesystem',
|
'file' => 'Filesystem',
|
||||||
];
|
];
|
||||||
|
|
||||||
const ALLOWED_SESSION_DRIVERS = [
|
public const ALLOWED_SESSION_DRIVERS = [
|
||||||
'redis' => 'Redis (recommended)',
|
'redis' => 'Redis (recommended)',
|
||||||
'memcached' => 'Memcached',
|
'memcached' => 'Memcached',
|
||||||
'database' => 'MySQL Database',
|
'database' => 'MySQL Database',
|
||||||
|
@ -33,7 +33,7 @@ class AppSettingsCommand extends Command
|
||||||
'cookie' => 'Cookie',
|
'cookie' => 'Cookie',
|
||||||
];
|
];
|
||||||
|
|
||||||
const ALLOWED_QUEUE_DRIVERS = [
|
public const ALLOWED_QUEUE_DRIVERS = [
|
||||||
'redis' => 'Redis (recommended)',
|
'redis' => 'Redis (recommended)',
|
||||||
'database' => 'MySQL Database',
|
'database' => 'MySQL Database',
|
||||||
'sync' => 'Sync',
|
'sync' => 'Sync',
|
||||||
|
@ -77,9 +77,6 @@ class AppSettingsCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AppSettingsCommand constructor.
|
* AppSettingsCommand constructor.
|
||||||
*
|
|
||||||
* @param \Illuminate\Contracts\Config\Repository $config
|
|
||||||
* @param \Illuminate\Contracts\Console\Kernel $command
|
|
||||||
*/
|
*/
|
||||||
public function __construct(ConfigRepository $config, Kernel $command)
|
public function __construct(ConfigRepository $config, Kernel $command)
|
||||||
{
|
{
|
||||||
|
@ -102,43 +99,45 @@ class AppSettingsCommand extends Command
|
||||||
|
|
||||||
$this->output->comment(trans('command/messages.environment.app.author_help'));
|
$this->output->comment(trans('command/messages.environment.app.author_help'));
|
||||||
$this->variables['APP_SERVICE_AUTHOR'] = $this->option('author') ?? $this->ask(
|
$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->output->comment(trans('command/messages.environment.app.app_url_help'));
|
||||||
$this->variables['APP_URL'] = $this->option('url') ?? $this->ask(
|
$this->variables['APP_URL'] = $this->option('url') ?? $this->ask(
|
||||||
trans('command/messages.environment.app.app_url'), $this->config->get('app.url', 'http://example.org')
|
trans('command/messages.environment.app.app_url'),
|
||||||
);
|
$this->config->get('app.url', 'http://example.org')
|
||||||
|
);
|
||||||
|
|
||||||
$this->output->comment(trans('command/messages.environment.app.timezone_help'));
|
$this->output->comment(trans('command/messages.environment.app.timezone_help'));
|
||||||
$this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
|
$this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
|
||||||
trans('command/messages.environment.app.timezone'),
|
trans('command/messages.environment.app.timezone'),
|
||||||
DateTimeZone::listIdentifiers(DateTimeZone::ALL),
|
DateTimeZone::listIdentifiers(DateTimeZone::ALL),
|
||||||
$this->config->get('app.timezone')
|
$this->config->get('app.timezone')
|
||||||
);
|
);
|
||||||
|
|
||||||
$selected = $this->config->get('cache.default', 'redis');
|
$selected = $this->config->get('cache.default', 'redis');
|
||||||
$this->variables['CACHE_DRIVER'] = $this->option('cache') ?? $this->choice(
|
$this->variables['CACHE_DRIVER'] = $this->option('cache') ?? $this->choice(
|
||||||
trans('command/messages.environment.app.cache_driver'),
|
trans('command/messages.environment.app.cache_driver'),
|
||||||
self::ALLOWED_CACHE_DRIVERS,
|
self::ALLOWED_CACHE_DRIVERS,
|
||||||
array_key_exists($selected, self::ALLOWED_CACHE_DRIVERS) ? $selected : null
|
array_key_exists($selected, self::ALLOWED_CACHE_DRIVERS) ? $selected : null
|
||||||
);
|
);
|
||||||
|
|
||||||
$selected = $this->config->get('session.driver', 'redis');
|
$selected = $this->config->get('session.driver', 'redis');
|
||||||
$this->variables['SESSION_DRIVER'] = $this->option('session') ?? $this->choice(
|
$this->variables['SESSION_DRIVER'] = $this->option('session') ?? $this->choice(
|
||||||
trans('command/messages.environment.app.session_driver'),
|
trans('command/messages.environment.app.session_driver'),
|
||||||
self::ALLOWED_SESSION_DRIVERS,
|
self::ALLOWED_SESSION_DRIVERS,
|
||||||
array_key_exists($selected, self::ALLOWED_SESSION_DRIVERS) ? $selected : null
|
array_key_exists($selected, self::ALLOWED_SESSION_DRIVERS) ? $selected : null
|
||||||
);
|
);
|
||||||
|
|
||||||
$selected = $this->config->get('queue.default', 'redis');
|
$selected = $this->config->get('queue.default', 'redis');
|
||||||
$this->variables['QUEUE_CONNECTION'] = $this->option('queue') ?? $this->choice(
|
$this->variables['QUEUE_CONNECTION'] = $this->option('queue') ?? $this->choice(
|
||||||
trans('command/messages.environment.app.queue_driver'),
|
trans('command/messages.environment.app.queue_driver'),
|
||||||
self::ALLOWED_QUEUE_DRIVERS,
|
self::ALLOWED_QUEUE_DRIVERS,
|
||||||
array_key_exists($selected, self::ALLOWED_QUEUE_DRIVERS) ? $selected : null
|
array_key_exists($selected, self::ALLOWED_QUEUE_DRIVERS) ? $selected : null
|
||||||
);
|
);
|
||||||
|
|
||||||
if (! is_null($this->option('settings-ui'))) {
|
if (!is_null($this->option('settings-ui'))) {
|
||||||
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->option('settings-ui') == 'true' ? 'false' : 'true';
|
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->option('settings-ui') == 'true' ? 'false' : 'true';
|
||||||
} else {
|
} else {
|
||||||
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm(trans('command/messages.environment.app.settings'), true) ? 'false' : 'true';
|
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm(trans('command/messages.environment.app.settings'), true) ? 'false' : 'true';
|
||||||
|
@ -171,11 +170,12 @@ class AppSettingsCommand extends Command
|
||||||
|
|
||||||
$this->output->note(trans('command/messages.environment.app.using_redis'));
|
$this->output->note(trans('command/messages.environment.app.using_redis'));
|
||||||
$this->variables['REDIS_HOST'] = $this->option('redis-host') ?? $this->ask(
|
$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;
|
$askForRedisPassword = true;
|
||||||
if (! empty($this->config->get('database.redis.default.password'))) {
|
if (!empty($this->config->get('database.redis.default.password'))) {
|
||||||
$this->variables['REDIS_PASSWORD'] = $this->config->get('database.redis.default.password');
|
$this->variables['REDIS_PASSWORD'] = $this->config->get('database.redis.default.password');
|
||||||
$askForRedisPassword = $this->confirm(trans('command/messages.environment.app.redis_pass_defined'));
|
$askForRedisPassword = $this->confirm(trans('command/messages.environment.app.redis_pass_defined'));
|
||||||
}
|
}
|
||||||
|
@ -183,8 +183,8 @@ class AppSettingsCommand extends Command
|
||||||
if ($askForRedisPassword) {
|
if ($askForRedisPassword) {
|
||||||
$this->output->comment(trans('command/messages.environment.app.redis_pass_help'));
|
$this->output->comment(trans('command/messages.environment.app.redis_pass_help'));
|
||||||
$this->variables['REDIS_PASSWORD'] = $this->option('redis-pass') ?? $this->output->askHidden(
|
$this->variables['REDIS_PASSWORD'] = $this->option('redis-pass') ?? $this->output->askHidden(
|
||||||
trans('command/messages.environment.app.redis_password')
|
trans('command/messages.environment.app.redis_password')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->variables['REDIS_PASSWORD'])) {
|
if (empty($this->variables['REDIS_PASSWORD'])) {
|
||||||
|
@ -192,7 +192,8 @@ class AppSettingsCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->variables['REDIS_PORT'] = $this->option('redis-port') ?? $this->ask(
|
$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')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,10 +57,6 @@ class DatabaseSettingsCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DatabaseSettingsCommand constructor.
|
* 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)
|
public function __construct(ConfigRepository $config, DatabaseManager $database, Kernel $console)
|
||||||
{
|
{
|
||||||
|
@ -82,24 +78,28 @@ class DatabaseSettingsCommand extends Command
|
||||||
{
|
{
|
||||||
$this->output->note(trans('command/messages.environment.database.host_warning'));
|
$this->output->note(trans('command/messages.environment.database.host_warning'));
|
||||||
$this->variables['DB_HOST'] = $this->option('host') ?? $this->ask(
|
$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(
|
$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(
|
$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->output->note(trans('command/messages.environment.database.username_warning'));
|
||||||
$this->variables['DB_USERNAME'] = $this->option('username') ?? $this->ask(
|
$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;
|
$askForMySQLPassword = true;
|
||||||
if (! empty($this->config->get('database.connections.mysql.password')) && $this->input->isInteractive()) {
|
if (!empty($this->config->get('database.connections.mysql.password')) && $this->input->isInteractive()) {
|
||||||
$this->variables['DB_PASSWORD'] = $this->config->get('database.connections.mysql.password');
|
$this->variables['DB_PASSWORD'] = $this->config->get('database.connections.mysql.password');
|
||||||
$askForMySQLPassword = $this->confirm(trans('command/messages.environment.database.password_defined'));
|
$askForMySQLPassword = $this->confirm(trans('command/messages.environment.database.password_defined'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,6 @@ class EmailSettingsCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EmailSettingsCommand constructor.
|
* EmailSettingsCommand constructor.
|
||||||
*
|
|
||||||
* @param \Illuminate\Contracts\Config\Repository $config
|
|
||||||
*/
|
*/
|
||||||
public function __construct(ConfigRepository $config)
|
public function __construct(ConfigRepository $config)
|
||||||
{
|
{
|
||||||
|
@ -65,13 +63,15 @@ class EmailSettingsCommand extends Command
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$this->variables['MAIL_DRIVER'] = $this->option('driver') ?? $this->choice(
|
$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',
|
'smtp' => 'SMTP Server',
|
||||||
'mail' => 'PHP\'s Internal Mail Function',
|
'mail' => 'PHP\'s Internal Mail Function',
|
||||||
'mailgun' => 'Mailgun Transactional Email',
|
'mailgun' => 'Mailgun Transactional Email',
|
||||||
'mandrill' => 'Mandrill Transactional Email',
|
'mandrill' => 'Mandrill Transactional Email',
|
||||||
'postmark' => 'Postmarkapp 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';
|
$method = 'setup' . studly_case($this->variables['MAIL_DRIVER']) . 'DriverVariables';
|
||||||
|
@ -80,16 +80,20 @@ class EmailSettingsCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->variables['MAIL_FROM'] = $this->option('email') ?? $this->ask(
|
$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(
|
$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(
|
$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);
|
$this->writeToEnvironment($this->variables);
|
||||||
|
|
||||||
|
@ -103,20 +107,23 @@ class EmailSettingsCommand extends Command
|
||||||
private function setupSmtpDriverVariables()
|
private function setupSmtpDriverVariables()
|
||||||
{
|
{
|
||||||
$this->variables['MAIL_HOST'] = $this->option('host') ?? $this->ask(
|
$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(
|
$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(
|
$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(
|
$this->variables['MAIL_PASSWORD'] = $this->option('password') ?? $this->secret(
|
||||||
trans('command/messages.environment.mail.ask_smtp_password')
|
trans('command/messages.environment.mail.ask_smtp_password')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,12 +132,14 @@ class EmailSettingsCommand extends Command
|
||||||
private function setupMailgunDriverVariables()
|
private function setupMailgunDriverVariables()
|
||||||
{
|
{
|
||||||
$this->variables['MAILGUN_DOMAIN'] = $this->option('host') ?? $this->ask(
|
$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(
|
$this->variables['MAILGUN_SECRET'] = $this->option('password') ?? $this->ask(
|
||||||
trans('command/messages.environment.mail.ask_mailgun_secret'), $this->config->get('services.mailgun.secret')
|
trans('command/messages.environment.mail.ask_mailgun_secret'),
|
||||||
);
|
$this->config->get('services.mailgun.secret')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,8 +148,9 @@ class EmailSettingsCommand extends Command
|
||||||
private function setupMandrillDriverVariables()
|
private function setupMandrillDriverVariables()
|
||||||
{
|
{
|
||||||
$this->variables['MANDRILL_SECRET'] = $this->option('password') ?? $this->ask(
|
$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_HOST'] = 'smtp.postmarkapp.com';
|
||||||
$this->variables['MAIL_PORT'] = 587;
|
$this->variables['MAIL_PORT'] = 587;
|
||||||
$this->variables['MAIL_USERNAME'] = $this->variables['MAIL_PASSWORD'] = $this->option('username') ?? $this->ask(
|
$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')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,6 @@ class InfoCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VersionCommand constructor.
|
* VersionCommand constructor.
|
||||||
*
|
|
||||||
* @param \Illuminate\Contracts\Config\Repository $config
|
|
||||||
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $versionService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(ConfigRepository $config, SoftwareVersionService $versionService)
|
public function __construct(ConfigRepository $config, SoftwareVersionService $versionService)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +62,7 @@ class InfoCommand extends Command
|
||||||
$this->output->title('Application Configuration');
|
$this->output->title('Application Configuration');
|
||||||
$this->table([], [
|
$this->table([], [
|
||||||
['Environment', $this->formatText($this->config->get('app.env'), $this->config->get('app.env') === 'production' ?: 'bg=red')],
|
['Environment', $this->formatText($this->config->get('app.env'), $this->config->get('app.env') === 'production' ?: 'bg=red')],
|
||||||
['Debug Mode', $this->formatText($this->config->get('app.debug') ? 'Yes' : 'No', ! $this->config->get('app.debug') ?: 'bg=red')],
|
['Debug Mode', $this->formatText($this->config->get('app.debug') ? 'Yes' : 'No', !$this->config->get('app.debug') ?: 'bg=red')],
|
||||||
['Installation URL', $this->config->get('app.url')],
|
['Installation URL', $this->config->get('app.url')],
|
||||||
['Installation Directory', base_path()],
|
['Installation Directory', base_path()],
|
||||||
['Timezone', $this->config->get('app.timezone')],
|
['Timezone', $this->config->get('app.timezone')],
|
||||||
|
@ -103,6 +100,7 @@ class InfoCommand extends Command
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param string $opts
|
* @param string $opts
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function formatText($value, $opts = '')
|
private function formatText($value, $opts = '')
|
||||||
|
|
|
@ -42,9 +42,6 @@ class DeleteLocationCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeleteLocationCommand constructor.
|
* DeleteLocationCommand constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository
|
|
||||||
* @param \Pterodactyl\Services\Locations\LocationDeletionService $deletionService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
LocationDeletionService $deletionService,
|
LocationDeletionService $deletionService,
|
||||||
|
@ -66,8 +63,9 @@ class DeleteLocationCommand extends Command
|
||||||
{
|
{
|
||||||
$this->locations = $this->locations ?? $this->repository->all();
|
$this->locations = $this->locations ?? $this->repository->all();
|
||||||
$short = $this->option('short') ?? $this->anticipate(
|
$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();
|
$location = $this->locations->where('short', $short)->first();
|
||||||
if (is_null($location)) {
|
if (is_null($location)) {
|
||||||
|
|
|
@ -33,8 +33,6 @@ class MakeLocationCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new command instance.
|
* Create a new command instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Locations\LocationCreationService $creationService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(LocationCreationService $creationService)
|
public function __construct(LocationCreationService $creationService)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;
|
||||||
|
|
||||||
class CleanServiceBackupFilesCommand extends Command
|
class CleanServiceBackupFilesCommand extends Command
|
||||||
{
|
{
|
||||||
const BACKUP_THRESHOLD_MINUTES = 5;
|
public const BACKUP_THRESHOLD_MINUTES = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -28,8 +28,6 @@ class CleanServiceBackupFilesCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CleanServiceBackupFilesCommand constructor.
|
* CleanServiceBackupFilesCommand constructor.
|
||||||
*
|
|
||||||
* @param \Illuminate\Contracts\Filesystem\Factory $filesystem
|
|
||||||
*/
|
*/
|
||||||
public function __construct(FilesystemFactory $filesystem)
|
public function __construct(FilesystemFactory $filesystem)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,13 +19,10 @@ class PruneOrphanedBackupsCommand extends Command
|
||||||
*/
|
*/
|
||||||
protected $description = 'Marks all backups that have not completed in the last "n" minutes as being failed.';
|
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)
|
public function handle(BackupRepository $repository)
|
||||||
{
|
{
|
||||||
$since = $this->option('since-minutes');
|
$since = $this->option('since-minutes');
|
||||||
if (! is_digit($since)) {
|
if (!is_digit($since)) {
|
||||||
throw new InvalidArgumentException('The --since-minutes option must be a valid numeric digit.');
|
throw new InvalidArgumentException('The --since-minutes option must be a valid numeric digit.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +31,7 @@ class PruneOrphanedBackupsCommand extends Command
|
||||||
->whereDate('created_at', '<=', CarbonImmutable::now()->subMinutes($since));
|
->whereDate('created_at', '<=', CarbonImmutable::now()->subMinutes($since));
|
||||||
|
|
||||||
$count = $query->count();
|
$count = $query->count();
|
||||||
if (! $count) {
|
if (!$count) {
|
||||||
$this->info('There are no orphaned backups to be marked as failed.');
|
$this->info('There are no orphaned backups to be marked as failed.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -25,8 +25,6 @@ class CleanOrphanedApiKeysCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CleanOrphanedApiKeysCommand constructor.
|
* CleanOrphanedApiKeysCommand constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Contracts\Repository\ApiKeyRepositoryInterface $repository
|
|
||||||
*/
|
*/
|
||||||
public function __construct(ApiKeyRepositoryInterface $repository)
|
public function __construct(ApiKeyRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
|
@ -44,10 +42,11 @@ class CleanOrphanedApiKeysCommand extends Command
|
||||||
{
|
{
|
||||||
$count = $this->repository->findCountWhere([['key_type', '=', ApiKey::TYPE_NONE]]);
|
$count = $this->repository->findCountWhere([['key_type', '=', ApiKey::TYPE_NONE]]);
|
||||||
$continue = $this->confirm(
|
$continue = $this->confirm(
|
||||||
'This action will remove ' . $count . ' keys from the database. Are you sure you wish to continue?', false
|
'This action will remove ' . $count . ' keys from the database. Are you sure you wish to continue?',
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
if (! $continue) {
|
if (!$continue) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,13 @@ class KeyGenerateCommand extends BaseKeyGenerateCommand
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
if (! empty(config('app.key')) && $this->input->isInteractive()) {
|
if (!empty(config('app.key')) && $this->input->isInteractive()) {
|
||||||
$this->output->warning(trans('command/messages.key.warning'));
|
$this->output->warning(trans('command/messages.key.warning'));
|
||||||
if (! $this->confirm(trans('command/messages.key.confirm'))) {
|
if (!$this->confirm(trans('command/messages.key.confirm'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->confirm(trans('command/messages.key.final_confirm'))) {
|
if (!$this->confirm(trans('command/messages.key.final_confirm'))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace Pterodactyl\Console\Commands\Schedule;
|
namespace Pterodactyl\Console\Commands\Schedule;
|
||||||
|
|
||||||
use Throwable;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Throwable;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Pterodactyl\Models\Schedule;
|
use Pterodactyl\Models\Schedule;
|
||||||
use Illuminate\Support\Facades\Log;
|
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
|
* never throw an exception out, otherwise you'll end up killing the entire run group causing
|
||||||
* any other schedules to not process correctly.
|
* any other schedules to not process correctly.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Schedule $schedule
|
|
||||||
* @see https://github.com/pterodactyl/panel/issues/2609
|
* @see https://github.com/pterodactyl/panel/issues/2609
|
||||||
*/
|
*/
|
||||||
protected function processSchedule(Schedule $schedule)
|
protected function processSchedule(Schedule $schedule)
|
||||||
|
|
|
@ -27,8 +27,6 @@ class BulkPowerActionCommand extends Command
|
||||||
/**
|
/**
|
||||||
* Handle the bulk power request.
|
* Handle the bulk power request.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Repositories\Wings\DaemonPowerRepository $powerRepository
|
|
||||||
* @param \Illuminate\Validation\Factory $validator
|
|
||||||
* @throws \Illuminate\Validation\ValidationException
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
*/
|
*/
|
||||||
public function handle(DaemonPowerRepository $powerRepository, ValidatorFactory $validator)
|
public function handle(DaemonPowerRepository $powerRepository, ValidatorFactory $validator)
|
||||||
|
@ -58,7 +56,7 @@ class BulkPowerActionCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
$count = $this->getQueryBuilder($servers, $nodes)->count();
|
$count = $this->getQueryBuilder($servers, $nodes)->count();
|
||||||
if (! $this->confirm(trans('command/messages.server.power.confirm', ['action' => $action, 'count' => $count])) && $this->input->isInteractive()) {
|
if (!$this->confirm(trans('command/messages.server.power.confirm', ['action' => $action, 'count' => $count])) && $this->input->isInteractive()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +85,6 @@ class BulkPowerActionCommand extends Command
|
||||||
/**
|
/**
|
||||||
* Returns the query builder instance that will return the servers that should be affected.
|
* 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
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
*/
|
*/
|
||||||
protected function getQueryBuilder(array $servers, array $nodes)
|
protected function getQueryBuilder(array $servers, array $nodes)
|
||||||
|
@ -97,11 +93,11 @@ class BulkPowerActionCommand extends Command
|
||||||
->where('suspended', false)
|
->where('suspended', false)
|
||||||
->where('installed', Server::STATUS_INSTALLED);
|
->where('installed', Server::STATUS_INSTALLED);
|
||||||
|
|
||||||
if (! empty($nodes) && ! empty($servers)) {
|
if (!empty($nodes) && !empty($servers)) {
|
||||||
$instance->whereIn('id', $servers)->orWhereIn('node_id', $nodes);
|
$instance->whereIn('id', $servers)->orWhereIn('node_id', $nodes);
|
||||||
} else if (empty($nodes) && ! empty($servers)) {
|
} elseif (empty($nodes) && !empty($servers)) {
|
||||||
$instance->whereIn('id', $servers);
|
$instance->whereIn('id', $servers);
|
||||||
} else if (! empty($nodes) && empty($servers)) {
|
} elseif (!empty($nodes) && empty($servers)) {
|
||||||
$instance->whereIn('node_id', $nodes);
|
$instance->whereIn('node_id', $nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,6 @@ class BulkReinstallActionCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BulkReinstallActionCommand constructor.
|
* BulkReinstallActionCommand constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonRepository
|
|
||||||
* @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $configurationStructureService
|
|
||||||
* @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
DaemonServerRepository $daemonRepository,
|
DaemonServerRepository $daemonRepository,
|
||||||
|
@ -71,7 +67,7 @@ class BulkReinstallActionCommand extends Command
|
||||||
{
|
{
|
||||||
$servers = $this->getServersToProcess();
|
$servers = $this->getServersToProcess();
|
||||||
|
|
||||||
if (! $this->confirm(trans('command/messages.server.reinstall.confirm')) && $this->input->isInteractive()) {
|
if (!$this->confirm(trans('command/messages.server.reinstall.confirm')) && $this->input->isInteractive()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,10 @@
|
||||||
|
|
||||||
namespace Pterodactyl\Console\Commands\User;
|
namespace Pterodactyl\Console\Commands\User;
|
||||||
|
|
||||||
use Webmozart\Assert\Assert;
|
|
||||||
use Pterodactyl\Models\User;
|
use Pterodactyl\Models\User;
|
||||||
|
use Webmozart\Assert\Assert;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Pterodactyl\Services\Users\UserDeletionService;
|
use Pterodactyl\Services\Users\UserDeletionService;
|
||||||
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
|
||||||
|
|
||||||
class DeleteUserCommand extends Command
|
class DeleteUserCommand extends Command
|
||||||
{
|
{
|
||||||
|
@ -39,10 +38,9 @@ class DeleteUserCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeleteUserCommand constructor.
|
* DeleteUserCommand constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Users\UserDeletionService $deletionService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(UserDeletionService $deletionService) {
|
public function __construct(UserDeletionService $deletionService)
|
||||||
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->deletionService = $deletionService;
|
$this->deletionService = $deletionService;
|
||||||
|
@ -50,6 +48,7 @@ class DeleteUserCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
|
@ -79,7 +78,7 @@ class DeleteUserCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->table(['User ID', 'Email', 'Name'], $tableValues);
|
$this->table(['User ID', 'Email', 'Name'], $tableValues);
|
||||||
if (! $deleteUser = $this->ask(trans('command/messages.user.select_search_user'))) {
|
if (!$deleteUser = $this->ask(trans('command/messages.user.select_search_user'))) {
|
||||||
return $this->handle();
|
return $this->handle();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -92,11 +91,9 @@ class DeleteUserCommand extends Command
|
||||||
$deleteUser = $results->first();
|
$deleteUser = $results->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->confirm(trans('command/messages.user.confirm_delete')) || ! $this->input->isInteractive()) {
|
if ($this->confirm(trans('command/messages.user.confirm_delete')) || !$this->input->isInteractive()) {
|
||||||
$this->deletionService->handle($deleteUser);
|
$this->deletionService->handle($deleteUser);
|
||||||
$this->info(trans('command/messages.user.deleted'));
|
$this->info(trans('command/messages.user.deleted'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,6 @@ class DisableTwoFactorCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DisableTwoFactorCommand constructor.
|
* DisableTwoFactorCommand constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
|
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepositoryInterface $repository)
|
public function __construct(UserRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,8 +31,6 @@ class MakeUserCommand extends Command
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MakeUserCommand constructor.
|
* MakeUserCommand constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Users\UserCreationService $creationService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(UserCreationService $creationService)
|
public function __construct(UserCreationService $creationService)
|
||||||
{
|
{
|
||||||
|
@ -55,7 +53,7 @@ class MakeUserCommand extends Command
|
||||||
$name_first = $this->option('name-first') ?? $this->ask(trans('command/messages.user.ask_name_first'));
|
$name_first = $this->option('name-first') ?? $this->ask(trans('command/messages.user.ask_name_first'));
|
||||||
$name_last = $this->option('name-last') ?? $this->ask(trans('command/messages.user.ask_name_last'));
|
$name_last = $this->option('name-last') ?? $this->ask(trans('command/messages.user.ask_name_last'));
|
||||||
|
|
||||||
if (is_null($password = $this->option('password')) && ! $this->option('no-password')) {
|
if (is_null($password = $this->option('password')) && !$this->option('no-password')) {
|
||||||
$this->warn(trans('command/messages.user.ask_password_help'));
|
$this->warn(trans('command/messages.user.ask_password_help'));
|
||||||
$this->line(trans('command/messages.user.ask_password_tip'));
|
$this->line(trans('command/messages.user.ask_password_tip'));
|
||||||
$password = $this->secret(trans('command/messages.user.ask_password'));
|
$password = $this->secret(trans('command/messages.user.ask_password'));
|
||||||
|
|
|
@ -17,8 +17,6 @@ class Kernel extends ConsoleKernel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the application's command schedule.
|
* Define the application's command schedule.
|
||||||
*
|
|
||||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
|
||||||
*/
|
*/
|
||||||
protected function schedule(Schedule $schedule)
|
protected function schedule(Schedule $schedule)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,8 +9,6 @@ trait RequiresDatabaseMigrations
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Checks if the migrations have finished running by comparing the last migration file.
|
* Checks if the migrations have finished running by comparing the last migration file.
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
protected function hasCompletedMigrations(): bool
|
protected function hasCompletedMigrations(): bool
|
||||||
{
|
{
|
||||||
|
@ -19,7 +17,7 @@ trait RequiresDatabaseMigrations
|
||||||
|
|
||||||
$files = $migrator->getMigrationFiles(database_path('migrations'));
|
$files = $migrator->getMigrationFiles(database_path('migrations'));
|
||||||
|
|
||||||
if (! $migrator->repositoryExists()) {
|
if (!$migrator->repositoryExists()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +32,10 @@ trait RequiresDatabaseMigrations
|
||||||
* Throw a massive error into the console to hopefully catch the users attention and get
|
* 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
|
* them to properly run the migrations rather than ignoring all of the other previous
|
||||||
* errors...
|
* errors...
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
protected function showMigrationWarning(): int
|
protected function showMigrationWarning(): int
|
||||||
{
|
{
|
||||||
$this->getOutput()->writeln("<options=bold>
|
$this->getOutput()->writeln('<options=bold>
|
||||||
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
|
||||||
| |
|
| |
|
||||||
| Your database has not been properly migrated! |
|
| Your database has not been properly migrated! |
|
||||||
|
@ -52,9 +48,9 @@ You must run the following command to finish migrating your database:
|
||||||
|
|
||||||
You will not be able to use Pterodactyl Panel as expected without fixing your
|
You will not be able to use Pterodactyl Panel as expected without fixing your
|
||||||
database state by running the command above.
|
database state by running the command above.
|
||||||
");
|
');
|
||||||
|
|
||||||
$this->getOutput()->error("You must correct the error above before continuing.");
|
$this->getOutput()->error('You must correct the error above before continuing.');
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,6 @@ interface ReceivesEvents
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Handles receiving an event from the application.
|
* Handles receiving an event from the application.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Events\Event $notification
|
|
||||||
*/
|
*/
|
||||||
public function handle(Event $notification): void;
|
public function handle(Event $notification): void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ interface CriteriaInterface
|
||||||
* Apply selected criteria to a repository call.
|
* Apply selected criteria to a repository call.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Database\Eloquent\Model $model
|
* @param \Illuminate\Database\Eloquent\Model $model
|
||||||
* @param \Pterodactyl\Repositories\Repository $repository
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function apply($model, Repository $repository);
|
public function apply($model, Repository $repository);
|
||||||
|
|
|
@ -17,7 +17,8 @@ interface HashidsInterface extends VendorHashidsInterface
|
||||||
* Decode an encoded hashid and return the first result.
|
* Decode an encoded hashid and return the first result.
|
||||||
*
|
*
|
||||||
* @param string $encoded
|
* @param string $encoded
|
||||||
* @param null $default
|
* @param null $default
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
|
|
|
@ -8,8 +8,6 @@ interface ClientPermissionsRequest
|
||||||
* Returns the permissions string indicating which permission should be used to
|
* Returns the permissions string indicating which permission should be used to
|
||||||
* validate that the authenticated user has permission to perform this action aganist
|
* validate that the authenticated user has permission to perform this action aganist
|
||||||
* the given resource (server).
|
* the given resource (server).
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function permission(): string;
|
public function permission(): string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,25 +2,17 @@
|
||||||
|
|
||||||
namespace Pterodactyl\Contracts\Repository;
|
namespace Pterodactyl\Contracts\Repository;
|
||||||
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
|
|
||||||
interface AllocationRepositoryInterface extends RepositoryInterface
|
interface AllocationRepositoryInterface extends RepositoryInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Return all of the allocations that exist for a node that are not currently
|
* Return all of the allocations that exist for a node that are not currently
|
||||||
* allocated.
|
* allocated.
|
||||||
*
|
|
||||||
* @param int $node
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function getUnassignedAllocationIds(int $node): array;
|
public function getUnassignedAllocationIds(int $node): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a single allocation from those meeting the requirements.
|
* Return a single allocation from those meeting the requirements.
|
||||||
*
|
*
|
||||||
* @param array $nodes
|
|
||||||
* @param array $ports
|
|
||||||
* @param bool $dedicated
|
|
||||||
* @return \Pterodactyl\Models\Allocation|null
|
* @return \Pterodactyl\Models\Allocation|null
|
||||||
*/
|
*/
|
||||||
public function getRandomAllocation(array $nodes, array $ports, bool $dedicated = false);
|
public function getRandomAllocation(array $nodes, array $ports, bool $dedicated = false);
|
||||||
|
|
|
@ -9,35 +9,21 @@ interface ApiKeyRepositoryInterface extends RepositoryInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get all of the account API keys that exist for a specific user.
|
* 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;
|
public function getAccountKeys(User $user): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all of the application API keys that exist for a specific user.
|
* 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;
|
public function getApplicationKeys(User $user): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an account API key from the panel for a specific user.
|
* 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;
|
public function deleteAccountKey(User $user, string $identifier): int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an application API key from the panel for a specific user.
|
* 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;
|
public function deleteApplicationKey(User $user, string $identifier): int;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@ interface DatabaseHostRepositoryInterface extends RepositoryInterface
|
||||||
/**
|
/**
|
||||||
* Return database hosts with a count of databases and the node
|
* Return database hosts with a count of databases and the node
|
||||||
* information for which it is attached.
|
* information for which it is attached.
|
||||||
*
|
|
||||||
* @return \Illuminate\Support\Collection
|
|
||||||
*/
|
*/
|
||||||
public function getWithViewDetails(): Collection;
|
public function getWithViewDetails(): Collection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,89 +8,60 @@ use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||||
|
|
||||||
interface DatabaseRepositoryInterface extends RepositoryInterface
|
interface DatabaseRepositoryInterface extends RepositoryInterface
|
||||||
{
|
{
|
||||||
const DEFAULT_CONNECTION_NAME = 'dynamic';
|
public const DEFAULT_CONNECTION_NAME = 'dynamic';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the connection name to execute statements against.
|
* Set the connection name to execute statements against.
|
||||||
*
|
*
|
||||||
* @param string $connection
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setConnection(string $connection);
|
public function setConnection(string $connection);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the connection to execute statements against.
|
* Return the connection to execute statements against.
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function getConnection(): string;
|
public function getConnection(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all of the databases belonging to a server.
|
* Return all of the databases belonging to a server.
|
||||||
*
|
|
||||||
* @param int $server
|
|
||||||
* @return \Illuminate\Support\Collection
|
|
||||||
*/
|
*/
|
||||||
public function getDatabasesForServer(int $server): Collection;
|
public function getDatabasesForServer(int $server): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all of the databases for a given host with the server relationship loaded.
|
* 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;
|
public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new database on a given connection.
|
* Create a new database on a given connection.
|
||||||
*
|
|
||||||
* @param string $database
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function createDatabase(string $database): bool;
|
public function createDatabase(string $database): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new database user on a given connection.
|
* Create a new database user on a given connection.
|
||||||
*
|
*
|
||||||
* @param string $username
|
|
||||||
* @param string $remote
|
|
||||||
* @param string $password
|
|
||||||
* @param $max_connections
|
* @param $max_connections
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function createUser(string $username, string $remote, string $password, string $max_connections): bool;
|
public function createUser(string $username, string $remote, string $password, string $max_connections): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Give a specific user access to a given database.
|
* 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;
|
public function assignUserToDatabase(string $database, string $username, string $remote): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flush the privileges for a given connection.
|
* Flush the privileges for a given connection.
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function flush(): bool;
|
public function flush(): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drop a given database on a specific connection.
|
* Drop a given database on a specific connection.
|
||||||
*
|
|
||||||
* @param string $database
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function dropDatabase(string $database): bool;
|
public function dropDatabase(string $database): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drop a given user on a specific connection.
|
* Drop a given user on a specific connection.
|
||||||
*
|
*
|
||||||
* @param string $username
|
|
||||||
* @param string $remote
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function dropUser(string $username, string $remote): bool;
|
public function dropUser(string $username, string $remote): bool;
|
||||||
|
|
|
@ -17,17 +17,12 @@ interface EggRepositoryInterface extends RepositoryInterface
|
||||||
/**
|
/**
|
||||||
* Return an egg with the variables relation attached.
|
* Return an egg with the variables relation attached.
|
||||||
*
|
*
|
||||||
* @param int $id
|
|
||||||
* @return \Pterodactyl\Models\Egg
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getWithVariables(int $id): Egg;
|
public function getWithVariables(int $id): Egg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all eggs and their relations to be used in the daemon API.
|
* Return all eggs and their relations to be used in the daemon API.
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Collection
|
|
||||||
*/
|
*/
|
||||||
public function getAllWithCopyAttributes(): 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.
|
* Return an egg with the scriptFrom and configFrom relations loaded onto the model.
|
||||||
*
|
*
|
||||||
* @param int|string $value
|
* @param int|string $value
|
||||||
* @param string $column
|
|
||||||
* @return \Pterodactyl\Models\Egg
|
|
||||||
*/
|
*/
|
||||||
public function getWithCopyAttributes($value, string $column = 'id'): Egg;
|
public function getWithCopyAttributes($value, string $column = 'id'): Egg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all of the data needed to export a service.
|
* Return all of the data needed to export a service.
|
||||||
*
|
*
|
||||||
* @param int $id
|
|
||||||
* @return \Pterodactyl\Models\Egg
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getWithExportAttributes(int $id): Egg;
|
public function getWithExportAttributes(int $id): Egg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Confirm a copy script belongs to the same nest as the item trying to use it.
|
* 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;
|
public function isCopyableScript(int $copyFromId, int $service): bool;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,6 @@ interface EggVariableRepositoryInterface extends RepositoryInterface
|
||||||
/**
|
/**
|
||||||
* Return editable variables for a given egg. Editable variables must be set to
|
* Return editable variables for a given egg. Editable variables must be set to
|
||||||
* user viewable in order to be picked up by this function.
|
* user viewable in order to be picked up by this function.
|
||||||
*
|
|
||||||
* @param int $egg
|
|
||||||
* @return \Illuminate\Support\Collection
|
|
||||||
*/
|
*/
|
||||||
public function getEditableVariables(int $egg): Collection;
|
public function getEditableVariables(int $egg): Collection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,22 +9,17 @@ interface LocationRepositoryInterface extends RepositoryInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Return locations with a count of nodes and servers attached to it.
|
* Return locations with a count of nodes and servers attached to it.
|
||||||
*
|
|
||||||
* @return \Illuminate\Support\Collection
|
|
||||||
*/
|
*/
|
||||||
public function getAllWithDetails(): Collection;
|
public function getAllWithDetails(): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all of the available locations with the nodes as a relationship.
|
* Return all of the available locations with the nodes as a relationship.
|
||||||
*
|
|
||||||
* @return \Illuminate\Support\Collection
|
|
||||||
*/
|
*/
|
||||||
public function getAllWithNodes(): Collection;
|
public function getAllWithNodes(): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all of the nodes and their respective count of servers for a location.
|
* Return all of the nodes and their respective count of servers for a location.
|
||||||
*
|
*
|
||||||
* @param int $id
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
|
@ -34,7 +29,6 @@ interface LocationRepositoryInterface extends RepositoryInterface
|
||||||
/**
|
/**
|
||||||
* Return a location and the count of nodes in that location.
|
* Return a location and the count of nodes in that location.
|
||||||
*
|
*
|
||||||
* @param int $id
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
|
|
|
@ -17,6 +17,7 @@ interface NestRepositoryInterface extends RepositoryInterface
|
||||||
* Return a nest or all nests with their associated eggs and variables.
|
* Return a nest or all nests with their associated eggs and variables.
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest
|
* @return \Illuminate\Database\Eloquent\Collection|\Pterodactyl\Models\Nest
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @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.
|
* 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
|
* @return \Pterodactyl\Models\Nest|\Illuminate\Database\Eloquent\Collection
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @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.
|
* 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
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getWithEggServers(int $id): Nest;
|
public function getWithEggServers(int $id): Nest;
|
||||||
|
|
|
@ -4,54 +4,35 @@ namespace Pterodactyl\Contracts\Repository;
|
||||||
|
|
||||||
use Pterodactyl\Models\Node;
|
use Pterodactyl\Models\Node;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\LazyCollection;
|
|
||||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
|
||||||
use Pterodactyl\Contracts\Repository\Attributes\SearchableInterface;
|
|
||||||
|
|
||||||
interface NodeRepositoryInterface extends RepositoryInterface
|
interface NodeRepositoryInterface extends RepositoryInterface
|
||||||
{
|
{
|
||||||
const THRESHOLD_PERCENTAGE_LOW = 75;
|
public const THRESHOLD_PERCENTAGE_LOW = 75;
|
||||||
const THRESHOLD_PERCENTAGE_MEDIUM = 90;
|
public const THRESHOLD_PERCENTAGE_MEDIUM = 90;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the usage stats for a single node.
|
* Return the usage stats for a single node.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Node $node
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function getUsageStats(Node $node): array;
|
public function getUsageStats(Node $node): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the usage stats for a single node.
|
* Return the usage stats for a single node.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Node $node
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function getUsageStatsRaw(Node $node): array;
|
public function getUsageStatsRaw(Node $node): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a single node with location and server information.
|
* 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;
|
public function loadLocationAndServerCount(Node $node, bool $refresh = false): Node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attach a paginated set of allocations to a node mode including
|
* Attach a paginated set of allocations to a node mode including
|
||||||
* any servers that are also attached to those allocations.
|
* 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;
|
public function loadNodeAllocations(Node $node, bool $refresh = false): Node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a collection of nodes for all locations to use in server creation UI.
|
* Return a collection of nodes for all locations to use in server creation UI.
|
||||||
*
|
|
||||||
* @return \Illuminate\Support\Collection
|
|
||||||
*/
|
*/
|
||||||
public function getNodesForServerCreation(): Collection;
|
public function getNodesForServerCreation(): Collection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ interface RepositoryInterface
|
||||||
* An array of columns to filter the response by.
|
* An array of columns to filter the response by.
|
||||||
*
|
*
|
||||||
* @param array|string $columns
|
* @param array|string $columns
|
||||||
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setColumns($columns = ['*']);
|
public function setColumns($columns = ['*']);
|
||||||
|
@ -62,7 +63,6 @@ interface RepositoryInterface
|
||||||
* Set whether or not the repository should return a fresh model
|
* Set whether or not the repository should return a fresh model
|
||||||
* when changes are committed.
|
* when changes are committed.
|
||||||
*
|
*
|
||||||
* @param bool $fresh
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setFreshModel(bool $fresh = true);
|
public function setFreshModel(bool $fresh = true);
|
||||||
|
@ -70,9 +70,6 @@ interface RepositoryInterface
|
||||||
/**
|
/**
|
||||||
* Create a new model instance and persist it to the database.
|
* Create a new model instance and persist it to the database.
|
||||||
*
|
*
|
||||||
* @param array $fields
|
|
||||||
* @param bool $validate
|
|
||||||
* @param bool $force
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
|
@ -82,7 +79,6 @@ interface RepositoryInterface
|
||||||
/**
|
/**
|
||||||
* Find a model that has the specific ID passed.
|
* Find a model that has the specific ID passed.
|
||||||
*
|
*
|
||||||
* @param int $id
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
|
@ -91,16 +87,12 @@ interface RepositoryInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a model matching an array of where clauses.
|
* Find a model matching an array of where clauses.
|
||||||
*
|
|
||||||
* @param array $fields
|
|
||||||
* @return \Illuminate\Support\Collection
|
|
||||||
*/
|
*/
|
||||||
public function findWhere(array $fields): Collection;
|
public function findWhere(array $fields): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find and return the first matching instance for the given fields.
|
* Find and return the first matching instance for the given fields.
|
||||||
*
|
*
|
||||||
* @param array $fields
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
|
@ -109,25 +101,16 @@ interface RepositoryInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a count of records matching the passed arguments.
|
* Return a count of records matching the passed arguments.
|
||||||
*
|
|
||||||
* @param array $fields
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public function findCountWhere(array $fields): int;
|
public function findCountWhere(array $fields): int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a given record from the database.
|
* Delete a given record from the database.
|
||||||
*
|
|
||||||
* @param int $id
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public function delete(int $id): int;
|
public function delete(int $id): int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete records matching the given attributes.
|
* Delete records matching the given attributes.
|
||||||
*
|
|
||||||
* @param array $attributes
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public function deleteWhere(array $attributes): int;
|
public function deleteWhere(array $attributes): int;
|
||||||
|
|
||||||
|
@ -135,9 +118,7 @@ interface RepositoryInterface
|
||||||
* Update a given ID with the passed array of fields.
|
* Update a given ID with the passed array of fields.
|
||||||
*
|
*
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @param array $fields
|
*
|
||||||
* @param bool $validate
|
|
||||||
* @param bool $force
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
|
@ -148,21 +129,12 @@ interface RepositoryInterface
|
||||||
/**
|
/**
|
||||||
* Perform a mass update where matching records are updated using whereIn.
|
* Perform a mass update where matching records are updated using whereIn.
|
||||||
* This does not perform any model data validation.
|
* 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;
|
public function updateWhereIn(string $column, array $values, array $fields): int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a record if it exists in the database, otherwise create it.
|
* 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
|
* @return mixed
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
|
@ -171,40 +143,27 @@ interface RepositoryInterface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all records associated with the given model.
|
* Return all records associated with the given model.
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
*/
|
||||||
public function all(): Collection;
|
public function all(): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a paginated result set using a search term if set on the repository.
|
* 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;
|
public function paginated(int $perPage): LengthAwarePaginator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert a single or multiple records into the database at once skipping
|
* Insert a single or multiple records into the database at once skipping
|
||||||
* validation and mass assignment checking.
|
* validation and mass assignment checking.
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function insert(array $data): bool;
|
public function insert(array $data): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert multiple records into the database and ignore duplicates.
|
* Insert multiple records into the database and ignore duplicates.
|
||||||
*
|
|
||||||
* @param array $values
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public function insertIgnore(array $values): bool;
|
public function insertIgnore(array $values): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of entries in the database.
|
* Get the amount of entries in the database.
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public function count(): int;
|
public function count(): int;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,18 +9,12 @@ interface ScheduleRepositoryInterface extends RepositoryInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Return all of the schedules for a given server.
|
* Return all of the schedules for a given server.
|
||||||
*
|
|
||||||
* @param int $server
|
|
||||||
* @return \Illuminate\Support\Collection
|
|
||||||
*/
|
*/
|
||||||
public function findServerSchedules(int $server): Collection;
|
public function findServerSchedules(int $server): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a schedule model with all of the associated tasks as a relationship.
|
* 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
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getScheduleWithTasks(int $schedule): Schedule;
|
public function getScheduleWithTasks(int $schedule): Schedule;
|
||||||
|
|
|
@ -10,37 +10,22 @@ interface ServerRepositoryInterface extends RepositoryInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Load the egg relations onto the server model.
|
* 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;
|
public function loadEggRelations(Server $server, bool $refresh = false): Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a collection of servers with their associated data for rebuild operations.
|
* 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;
|
public function getDataForRebuild(int $server = null, int $node = null): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a collection of servers with their associated data for reinstall operations.
|
* 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;
|
public function getDataForReinstall(int $server = null, int $node = null): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a server model and all variables associated with the server.
|
* Return a server model and all variables associated with the server.
|
||||||
*
|
*
|
||||||
* @param int $id
|
|
||||||
* @return \Pterodactyl\Models\Server
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function findWithVariables(int $id): Server;
|
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
|
* 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
|
* the function, load the allocation relationship onto it. Otherwise, find and
|
||||||
* return the server from the database.
|
* 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;
|
public function getPrimaryAllocation(Server $server, bool $refresh = false): Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return enough data to be used for the creation of a server via the daemon.
|
* 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;
|
public function getDataForCreation(Server $server, bool $refresh = false): Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load associated databases onto the server model.
|
* 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;
|
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
|
* 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
|
* the egg which is used for build and rebuild. Only loads relations
|
||||||
* if they are missing, or refresh is set to true.
|
* 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;
|
public function getDaemonServiceData(Server $server, bool $refresh = false): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a server by UUID.
|
* Return a server by UUID.
|
||||||
*
|
*
|
||||||
* @param string $uuid
|
|
||||||
* @return \Pterodactyl\Models\Server
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getByUuid(string $uuid): Server;
|
public function getByUuid(string $uuid): Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a given UUID and UUID-Short string are unique to a 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;
|
public function isUniqueUuidCombo(string $uuid, string $short): bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of servers that are suspended.
|
* Get the amount of servers that are suspended.
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public function getSuspendedServersCount(): int;
|
public function getSuspendedServersCount(): int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all of the servers that exist for a given node in a paginated response.
|
* 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;
|
public function loadAllServersForNode(int $node, int $limit): LengthAwarePaginator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,17 +8,12 @@ interface SessionRepositoryInterface extends RepositoryInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Return all of the active sessions for a user.
|
* Return all of the active sessions for a user.
|
||||||
*
|
|
||||||
* @param int $user
|
|
||||||
* @return \Illuminate\Support\Collection
|
|
||||||
*/
|
*/
|
||||||
public function getUserSessions(int $user): Collection;
|
public function getUserSessions(int $user): Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a session for a given user.
|
* Delete a session for a given user.
|
||||||
*
|
*
|
||||||
* @param int $user
|
|
||||||
* @param string $session
|
|
||||||
* @return int|null
|
* @return int|null
|
||||||
*/
|
*/
|
||||||
public function deleteUserSession(int $user, string $session);
|
public function deleteUserSession(int $user, string $session);
|
||||||
|
|
|
@ -7,9 +7,6 @@ interface SettingsRepositoryInterface extends RepositoryInterface
|
||||||
/**
|
/**
|
||||||
* Store a new persistent setting in the database.
|
* Store a new persistent setting in the database.
|
||||||
*
|
*
|
||||||
* @param string $key
|
|
||||||
* @param string|null $value
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
|
@ -18,16 +15,14 @@ interface SettingsRepositoryInterface extends RepositoryInterface
|
||||||
/**
|
/**
|
||||||
* Retrieve a persistent setting from the database.
|
* Retrieve a persistent setting from the database.
|
||||||
*
|
*
|
||||||
* @param string $key
|
|
||||||
* @param mixed $default
|
* @param mixed $default
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get(string $key, $default);
|
public function get(string $key, $default);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a key from the database cache.
|
* Remove a key from the database cache.
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
*/
|
*/
|
||||||
public function forget(string $key);
|
public function forget(string $key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,29 +8,17 @@ interface SubuserRepositoryInterface extends RepositoryInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Return a subuser with the associated server relationship.
|
* 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;
|
public function loadServerAndUserRelations(Subuser $subuser, bool $refresh = false): Subuser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a subuser with the associated permissions relationship.
|
* 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;
|
public function getWithPermissions(Subuser $subuser, bool $refresh = false): Subuser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a subuser and associated permissions given a user_id and server_id.
|
* 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
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getWithPermissionsUsingUserAndServer(int $user, int $server): Subuser;
|
public function getWithPermissionsUsingUserAndServer(int $user, int $server): Subuser;
|
||||||
|
|
|
@ -9,9 +9,6 @@ interface TaskRepositoryInterface extends RepositoryInterface
|
||||||
/**
|
/**
|
||||||
* Get a task and the server relationship for that task.
|
* Get a task and the server relationship for that task.
|
||||||
*
|
*
|
||||||
* @param int $id
|
|
||||||
* @return \Pterodactyl\Models\Task
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function getTaskForJobProcess(int $id): Task;
|
public function getTaskForJobProcess(int $id): Task;
|
||||||
|
@ -19,8 +16,6 @@ interface TaskRepositoryInterface extends RepositoryInterface
|
||||||
/**
|
/**
|
||||||
* Returns the next task in a schedule.
|
* Returns the next task in a schedule.
|
||||||
*
|
*
|
||||||
* @param int $schedule
|
|
||||||
* @param int $index
|
|
||||||
* @return \Pterodactyl\Models\Task|null
|
* @return \Pterodactyl\Models\Task|null
|
||||||
*/
|
*/
|
||||||
public function getNextTask(int $schedule, int $index);
|
public function getNextTask(int $schedule, int $index);
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Created
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Server $server)
|
public function __construct(Server $server)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Creating
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Server $server)
|
public function __construct(Server $server)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Deleted
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Server $server)
|
public function __construct(Server $server)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Deleting
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Server $server)
|
public function __construct(Server $server)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Saved
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Server $server)
|
public function __construct(Server $server)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Saving
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Server $server)
|
public function __construct(Server $server)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Updated
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Server $server)
|
public function __construct(Server $server)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Updating
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Server $server)
|
public function __construct(Server $server)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Created
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Subuser $subuser
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Subuser $subuser)
|
public function __construct(Subuser $subuser)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Creating
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Subuser $subuser
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Subuser $subuser)
|
public function __construct(Subuser $subuser)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Deleted
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Subuser $subuser
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Subuser $subuser)
|
public function __construct(Subuser $subuser)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Deleting
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\Subuser $subuser
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Subuser $subuser)
|
public function __construct(Subuser $subuser)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Created
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\User $user
|
|
||||||
*/
|
*/
|
||||||
public function __construct(User $user)
|
public function __construct(User $user)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Creating
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\User $user
|
|
||||||
*/
|
*/
|
||||||
public function __construct(User $user)
|
public function __construct(User $user)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Deleted
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\User $user
|
|
||||||
*/
|
*/
|
||||||
public function __construct(User $user)
|
public function __construct(User $user)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Deleting
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Models\User $user
|
|
||||||
*/
|
*/
|
||||||
public function __construct(User $user)
|
public function __construct(User $user)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,10 +11,10 @@ use Prologue\Alerts\AlertsMessageBag;
|
||||||
|
|
||||||
class DisplayException extends PterodactylException
|
class DisplayException extends PterodactylException
|
||||||
{
|
{
|
||||||
const LEVEL_DEBUG = 'debug';
|
public const LEVEL_DEBUG = 'debug';
|
||||||
const LEVEL_INFO = 'info';
|
public const LEVEL_INFO = 'info';
|
||||||
const LEVEL_WARNING = 'warning';
|
public const LEVEL_WARNING = 'warning';
|
||||||
const LEVEL_ERROR = 'error';
|
public const LEVEL_ERROR = 'error';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -25,9 +25,8 @@ class DisplayException extends PterodactylException
|
||||||
* Exception constructor.
|
* Exception constructor.
|
||||||
*
|
*
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param Throwable|null $previous
|
|
||||||
* @param string $level
|
* @param string $level
|
||||||
* @param int $code
|
* @param int $code
|
||||||
*/
|
*/
|
||||||
public function __construct($message, Throwable $previous = null, $level = self::LEVEL_ERROR, $code = 0)
|
public function __construct($message, Throwable $previous = null, $level = self::LEVEL_ERROR, $code = 0)
|
||||||
{
|
{
|
||||||
|
@ -58,6 +57,7 @@ class DisplayException extends PterodactylException
|
||||||
* request originated from an API hit, return the error in JSONAPI spec format.
|
* request originated from an API hit, return the error in JSONAPI spec format.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function render($request)
|
public function render($request)
|
||||||
|
@ -83,7 +83,7 @@ class DisplayException extends PterodactylException
|
||||||
*/
|
*/
|
||||||
public function report()
|
public function report()
|
||||||
{
|
{
|
||||||
if (! $this->getPrevious() instanceof Exception || ! Handler::isReportable($this->getPrevious())) {
|
if (!$this->getPrevious() instanceof Exception || !Handler::isReportable($this->getPrevious())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,14 @@ namespace Pterodactyl\Exceptions;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use PDOException;
|
use PDOException;
|
||||||
use Psr\Log\LoggerInterface;
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Swift_TransportException;
|
use Swift_TransportException;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Container\Container;
|
use Illuminate\Container\Container;
|
||||||
use Illuminate\Database\Connection;
|
use Illuminate\Database\Connection;
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Auth\AuthenticationException;
|
use Illuminate\Auth\AuthenticationException;
|
||||||
use Illuminate\Session\TokenMismatchException;
|
use Illuminate\Session\TokenMismatchException;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
@ -43,17 +47,6 @@ class Handler extends ExceptionHandler
|
||||||
ValidationException::class,
|
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.
|
* 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
|
* Registers the exception handling callbacks for the application. This
|
||||||
* don't need or want the user information in our logs by default.
|
* 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
|
* @noinspection PhpUnusedLocalVariableInspection
|
||||||
* 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
|
|
||||||
*/
|
*/
|
||||||
public function report(Throwable $exception)
|
public function register()
|
||||||
{
|
{
|
||||||
if (! config('app.exceptions.report_all', false) && $this->shouldntReport($exception)) {
|
if (config('app.exceptions.report_all', false)) {
|
||||||
return null;
|
$this->dontReport = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method_exists($exception, 'report')) {
|
$this->reportable(function (PDOException $ex) {
|
||||||
return $exception->report();
|
$ex = $this->generateCleanedExceptionStack($ex);
|
||||||
}
|
});
|
||||||
|
|
||||||
try {
|
$this->reportable(function (Swift_TransportException $ex) {
|
||||||
$logger = $this->container->make(LoggerInterface::class);
|
$ex = $this->generateCleanedExceptionStack($ex);
|
||||||
} 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 = '';
|
$cleanedStack = '';
|
||||||
foreach ($exception->getTrace() as $index => $item) {
|
foreach ($exception->getTrace() as $index => $item) {
|
||||||
$cleanedStack .= sprintf(
|
$cleanedStack .= sprintf(
|
||||||
"#%d %s(%d): %s%s%s\n",
|
"#%d %s(%d): %s%s%s\n",
|
||||||
$index,
|
$index,
|
||||||
array_get($item, 'file'),
|
Arr::get($item, 'file'),
|
||||||
array_get($item, 'line'),
|
Arr::get($item, 'line'),
|
||||||
array_get($item, 'class'),
|
Arr::get($item, 'class'),
|
||||||
array_get($item, 'type'),
|
Arr::get($item, 'type'),
|
||||||
array_get($item, 'function')
|
Arr::get($item, 'function')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,14 +112,14 @@ class Handler extends ExceptionHandler
|
||||||
* Render an exception into an HTTP response.
|
* Render an exception into an HTTP response.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @param \Throwable $exception
|
*
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
*
|
*
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function render($request, Throwable $exception)
|
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
|
// 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
|
// 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.
|
* calls to the API.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @param \Illuminate\Validation\ValidationException $exception
|
*
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function invalidJson($request, ValidationException $exception)
|
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 = [];
|
$cleaned = [];
|
||||||
foreach ($reasons as $reason => $attrs) {
|
foreach ($reasons as $reason => $attrs) {
|
||||||
$cleaned[] = snake_case($reason);
|
$cleaned[] = Str::snake($reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [str_replace('.', '_', $field) => $cleaned];
|
return [str_replace('.', '_', $field) => $cleaned];
|
||||||
})->toArray();
|
})->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 = [];
|
$response = [];
|
||||||
foreach ($errors as $key => $error) {
|
foreach ($errors as $key => $error) {
|
||||||
$meta = [
|
$meta = [
|
||||||
'source_field' => $field,
|
'source_field' => $field,
|
||||||
'rule' => str_replace(self::PTERODACTYL_RULE_STRING, 'p_', array_get(
|
'rule' => str_replace(self::PTERODACTYL_RULE_STRING, 'p_', Arr::get(
|
||||||
$codes, str_replace('.', '_', $field) . '.' . $key
|
$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.
|
* 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
|
public static function convertToArray(Throwable $exception, array $override = []): array
|
||||||
{
|
{
|
||||||
|
@ -235,7 +209,7 @@ class Handler extends ExceptionHandler
|
||||||
'detail' => $exception->getMessage(),
|
'detail' => $exception->getMessage(),
|
||||||
'source' => [
|
'source' => [
|
||||||
'line' => $exception->getLine(),
|
'line' => $exception->getLine(),
|
||||||
'file' => str_replace(base_path(), '', $exception->getFile()),
|
'file' => str_replace(Application::getInstance()->basePath(), '', $exception->getFile()),
|
||||||
],
|
],
|
||||||
'meta' => [
|
'meta' => [
|
||||||
'trace' => explode("\n", $exception->getTraceAsString()),
|
'trace' => explode("\n", $exception->getTraceAsString()),
|
||||||
|
@ -248,9 +222,6 @@ class Handler extends ExceptionHandler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an array of exceptions that should not be reported.
|
* Return an array of exceptions that should not be reported.
|
||||||
*
|
|
||||||
* @param \Exception $exception
|
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
public static function isReportable(Exception $exception): bool
|
public static function isReportable(Exception $exception): bool
|
||||||
{
|
{
|
||||||
|
@ -261,23 +232,22 @@ class Handler extends ExceptionHandler
|
||||||
* Convert an authentication exception into an unauthenticated response.
|
* Convert an authentication exception into an unauthenticated response.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @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)
|
protected function unauthenticated($request, AuthenticationException $exception)
|
||||||
{
|
{
|
||||||
if ($request->expectsJson()) {
|
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
|
* 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.
|
* Laravel's built-in converter to output as a JSONAPI spec compliant object.
|
||||||
*
|
*
|
||||||
* @param \Throwable $exception
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function convertExceptionToArray(Throwable $exception)
|
protected function convertExceptionToArray(Throwable $exception)
|
||||||
|
|
|
@ -19,9 +19,6 @@ class DaemonConnectionException extends DisplayException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throw a displayable exception caused by a daemon connection error.
|
* 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)
|
public function __construct(GuzzleException $previous, bool $useStatusCode = true)
|
||||||
{
|
{
|
||||||
|
@ -38,11 +35,11 @@ class DaemonConnectionException extends DisplayException
|
||||||
|
|
||||||
// Attempt to pull the actual error message off the response and return that if it is not
|
// Attempt to pull the actual error message off the response and return that if it is not
|
||||||
// a 500 level error.
|
// a 500 level error.
|
||||||
if ($this->statusCode < 500 && ! is_null($response)) {
|
if ($this->statusCode < 500 && !is_null($response)) {
|
||||||
$body = $response->getBody();
|
$body = $response->getBody();
|
||||||
if (is_string($body) || (is_object($body) && method_exists($body, '__toString'))) {
|
if (is_string($body) || (is_object($body) && method_exists($body, '__toString'))) {
|
||||||
$body = json_decode(is_string($body) ? $body : $body->__toString(), true);
|
$body = json_decode(is_string($body) ? $body : $body->__toString(), true);
|
||||||
$message = "[Wings Error]: " . Arr::get($body, 'error', $message);
|
$message = '[Wings Error]: ' . Arr::get($body, 'error', $message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,6 @@ class HttpForbiddenException extends HttpException
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* HttpForbiddenException constructor.
|
* HttpForbiddenException constructor.
|
||||||
*
|
|
||||||
* @param string|null $message
|
|
||||||
* @param \Throwable|null $previous
|
|
||||||
*/
|
*/
|
||||||
public function __construct(string $message = null, \Throwable $previous = null)
|
public function __construct(string $message = null, \Throwable $previous = null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,11 +11,9 @@ class TwoFactorAuthRequiredException extends HttpException implements HttpExcept
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* TwoFactorAuthRequiredException constructor.
|
* TwoFactorAuthRequiredException constructor.
|
||||||
*
|
|
||||||
* @param \Throwable|null $previous
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Throwable $previous = null)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ class DataValidationException extends PterodactylException implements HttpExcept
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DataValidationException constructor.
|
* DataValidationException constructor.
|
||||||
*
|
|
||||||
* @param \Illuminate\Contracts\Validation\Validator $validator
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Validator $validator)
|
public function __construct(Validator $validator)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,8 +8,6 @@ class TooManyBackupsException extends DisplayException
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* TooManyBackupsException constructor.
|
* TooManyBackupsException constructor.
|
||||||
*
|
|
||||||
* @param int $backupLimit
|
|
||||||
*/
|
*/
|
||||||
public function __construct(int $backupLimit)
|
public function __construct(int $backupLimit)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,9 +10,6 @@ class ServiceLimitExceededException extends DisplayException
|
||||||
/**
|
/**
|
||||||
* Exception thrown when something goes over a defined limit, such as allocated
|
* Exception thrown when something goes over a defined limit, such as allocated
|
||||||
* ports, tasks, databases, etc.
|
* ports, tasks, databases, etc.
|
||||||
*
|
|
||||||
* @param string $message
|
|
||||||
* @param \Throwable|null $previous
|
|
||||||
*/
|
*/
|
||||||
public function __construct(string $message, Throwable $previous = null)
|
public function __construct(string $message, Throwable $previous = null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,8 +8,8 @@ use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use League\Flysystem\AdapterInterface;
|
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
|
use League\Flysystem\AdapterInterface;
|
||||||
use League\Flysystem\AwsS3v3\AwsS3Adapter;
|
use League\Flysystem\AwsS3v3\AwsS3Adapter;
|
||||||
use League\Flysystem\Memory\MemoryAdapter;
|
use League\Flysystem\Memory\MemoryAdapter;
|
||||||
use Illuminate\Contracts\Config\Repository;
|
use Illuminate\Contracts\Config\Repository;
|
||||||
|
@ -42,8 +42,6 @@ class BackupManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BackupManager constructor.
|
* BackupManager constructor.
|
||||||
*
|
|
||||||
* @param \Illuminate\Foundation\Application $app
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Application $app)
|
public function __construct(Application $app)
|
||||||
{
|
{
|
||||||
|
@ -54,7 +52,6 @@ class BackupManager
|
||||||
/**
|
/**
|
||||||
* Returns a backup adapter instance.
|
* Returns a backup adapter instance.
|
||||||
*
|
*
|
||||||
* @param string|null $name
|
|
||||||
* @return \League\Flysystem\AdapterInterface
|
* @return \League\Flysystem\AdapterInterface
|
||||||
*/
|
*/
|
||||||
public function adapter(string $name = null)
|
public function adapter(string $name = null)
|
||||||
|
@ -65,8 +62,8 @@ class BackupManager
|
||||||
/**
|
/**
|
||||||
* Set the given backup adapter instance.
|
* Set the given backup adapter instance.
|
||||||
*
|
*
|
||||||
* @param string $name
|
|
||||||
* @param \League\Flysystem\AdapterInterface $disk
|
* @param \League\Flysystem\AdapterInterface $disk
|
||||||
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function set(string $name, $disk)
|
public function set(string $name, $disk)
|
||||||
|
@ -79,7 +76,6 @@ class BackupManager
|
||||||
/**
|
/**
|
||||||
* Gets a backup adapter.
|
* Gets a backup adapter.
|
||||||
*
|
*
|
||||||
* @param string $name
|
|
||||||
* @return \League\Flysystem\AdapterInterface
|
* @return \League\Flysystem\AdapterInterface
|
||||||
*/
|
*/
|
||||||
protected function get(string $name)
|
protected function get(string $name)
|
||||||
|
@ -90,7 +86,6 @@ class BackupManager
|
||||||
/**
|
/**
|
||||||
* Resolve the given backup disk.
|
* Resolve the given backup disk.
|
||||||
*
|
*
|
||||||
* @param string $name
|
|
||||||
* @return \League\Flysystem\AdapterInterface
|
* @return \League\Flysystem\AdapterInterface
|
||||||
*/
|
*/
|
||||||
protected function resolve(string $name)
|
protected function resolve(string $name)
|
||||||
|
@ -98,9 +93,7 @@ class BackupManager
|
||||||
$config = $this->getConfig($name);
|
$config = $this->getConfig($name);
|
||||||
|
|
||||||
if (empty($config['adapter'])) {
|
if (empty($config['adapter'])) {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException("Backup disk [{$name}] does not have a configured adapter.");
|
||||||
"Backup disk [{$name}] does not have a configured adapter."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$adapter = $config['adapter'];
|
$adapter = $config['adapter'];
|
||||||
|
@ -124,7 +117,6 @@ class BackupManager
|
||||||
/**
|
/**
|
||||||
* Calls a custom creator for a given adapter type.
|
* Calls a custom creator for a given adapter type.
|
||||||
*
|
*
|
||||||
* @param array $config
|
|
||||||
* @return \League\Flysystem\AdapterInterface
|
* @return \League\Flysystem\AdapterInterface
|
||||||
*/
|
*/
|
||||||
protected function callCustomCreator(array $config)
|
protected function callCustomCreator(array $config)
|
||||||
|
@ -139,7 +131,6 @@ class BackupManager
|
||||||
/**
|
/**
|
||||||
* Creates a new wings adapter.
|
* Creates a new wings adapter.
|
||||||
*
|
*
|
||||||
* @param array $config
|
|
||||||
* @return \League\Flysystem\AdapterInterface
|
* @return \League\Flysystem\AdapterInterface
|
||||||
*/
|
*/
|
||||||
public function createWingsAdapter(array $config)
|
public function createWingsAdapter(array $config)
|
||||||
|
@ -150,14 +141,13 @@ class BackupManager
|
||||||
/**
|
/**
|
||||||
* Creates a new S3 adapter.
|
* Creates a new S3 adapter.
|
||||||
*
|
*
|
||||||
* @param array $config
|
|
||||||
* @return \League\Flysystem\AdapterInterface
|
* @return \League\Flysystem\AdapterInterface
|
||||||
*/
|
*/
|
||||||
public function createS3Adapter(array $config)
|
public function createS3Adapter(array $config)
|
||||||
{
|
{
|
||||||
$config['version'] = 'latest';
|
$config['version'] = 'latest';
|
||||||
|
|
||||||
if (! empty($config['key']) && ! empty($config['secret'])) {
|
if (!empty($config['key']) && !empty($config['secret'])) {
|
||||||
$config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
|
$config['credentials'] = Arr::only($config, ['key', 'secret', 'token']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +159,6 @@ class BackupManager
|
||||||
/**
|
/**
|
||||||
* Returns the configuration associated with a given backup type.
|
* Returns the configuration associated with a given backup type.
|
||||||
*
|
*
|
||||||
* @param string $name
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getConfig(string $name)
|
protected function getConfig(string $name)
|
||||||
|
@ -189,8 +178,6 @@ class BackupManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the default session driver name.
|
* Set the default session driver name.
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
*/
|
*/
|
||||||
public function setDefaultAdapter(string $name)
|
public function setDefaultAdapter(string $name)
|
||||||
{
|
{
|
||||||
|
@ -201,6 +188,7 @@ class BackupManager
|
||||||
* Unset the given adapter instances.
|
* Unset the given adapter instances.
|
||||||
*
|
*
|
||||||
* @param string|string[] $adapter
|
* @param string|string[] $adapter
|
||||||
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function forget($adapter)
|
public function forget($adapter)
|
||||||
|
@ -215,8 +203,6 @@ class BackupManager
|
||||||
/**
|
/**
|
||||||
* Register a custom adapter creator closure.
|
* Register a custom adapter creator closure.
|
||||||
*
|
*
|
||||||
* @param string $adapter
|
|
||||||
* @param \Closure $callback
|
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function extend(string $adapter, Closure $callback)
|
public function extend(string $adapter, Closure $callback)
|
||||||
|
|
|
@ -16,9 +16,9 @@ use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
|
||||||
|
|
||||||
class DynamicDatabaseConnection
|
class DynamicDatabaseConnection
|
||||||
{
|
{
|
||||||
const DB_CHARSET = 'utf8';
|
public const DB_CHARSET = 'utf8';
|
||||||
const DB_COLLATION = 'utf8_unicode_ci';
|
public const DB_COLLATION = 'utf8_unicode_ci';
|
||||||
const DB_DRIVER = 'mysql';
|
public const DB_DRIVER = 'mysql';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Illuminate\Config\Repository
|
* @var \Illuminate\Config\Repository
|
||||||
|
@ -37,10 +37,6 @@ class DynamicDatabaseConnection
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DynamicDatabaseConnection constructor.
|
* DynamicDatabaseConnection constructor.
|
||||||
*
|
|
||||||
* @param \Illuminate\Config\Repository $config
|
|
||||||
* @param \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface $repository
|
|
||||||
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ConfigRepository $config,
|
ConfigRepository $config,
|
||||||
|
@ -55,15 +51,15 @@ class DynamicDatabaseConnection
|
||||||
/**
|
/**
|
||||||
* Adds a dynamic database connection entry to the runtime config.
|
* Adds a dynamic database connection entry to the runtime config.
|
||||||
*
|
*
|
||||||
* @param string $connection
|
* @param string $connection
|
||||||
* @param \Pterodactyl\Models\DatabaseHost|int $host
|
* @param \Pterodactyl\Models\DatabaseHost|int $host
|
||||||
* @param string $database
|
* @param string $database
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function set($connection, $host, $database = 'mysql')
|
public function set($connection, $host, $database = 'mysql')
|
||||||
{
|
{
|
||||||
if (! $host instanceof DatabaseHost) {
|
if (!$host instanceof DatabaseHost) {
|
||||||
$host = $this->repository->find($host);
|
$host = $this->repository->find($host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class Hashids extends VendorHashids implements HashidsInterface
|
||||||
public function decodeFirst($encoded, $default = null)
|
public function decodeFirst($encoded, $default = null)
|
||||||
{
|
{
|
||||||
$result = $this->decode($encoded);
|
$result = $this->decode($encoded);
|
||||||
if (! is_array($result)) {
|
if (!is_array($result)) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
30
app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php
Normal file
30
app/Extensions/Lcobucci/JWT/Encoding/TimestampDates.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ class PterodactylSerializer extends ArraySerializer
|
||||||
* Serialize an item.
|
* Serialize an item.
|
||||||
*
|
*
|
||||||
* @param string $resourceKey
|
* @param string $resourceKey
|
||||||
* @param array $data
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function item($resourceKey, array $data)
|
public function item($resourceKey, array $data)
|
||||||
|
@ -25,7 +25,7 @@ class PterodactylSerializer extends ArraySerializer
|
||||||
* Serialize a collection.
|
* Serialize a collection.
|
||||||
*
|
*
|
||||||
* @param string $resourceKey
|
* @param string $resourceKey
|
||||||
* @param array $data
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function collection($resourceKey, array $data)
|
public function collection($resourceKey, array $data)
|
||||||
|
@ -59,6 +59,7 @@ class PterodactylSerializer extends ArraySerializer
|
||||||
*
|
*
|
||||||
* @param array $transformedData
|
* @param array $transformedData
|
||||||
* @param array $includedData
|
* @param array $includedData
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function mergeIncludes($transformedData, $includedData)
|
public function mergeIncludes($transformedData, $includedData)
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Fractal extends SpatieFractal
|
||||||
{
|
{
|
||||||
// Set the serializer by default.
|
// Set the serializer by default.
|
||||||
if (is_null($this->serializer)) {
|
if (is_null($this->serializer)) {
|
||||||
$this->serializer = new PterodactylSerializer;
|
$this->serializer = new PterodactylSerializer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatically set the paginator on the response object if the
|
// Automatically set the paginator on the response object if the
|
||||||
|
|
|
@ -12,9 +12,6 @@ final class Time
|
||||||
* for named timezones in MySQL.
|
* for named timezones in MySQL.
|
||||||
*
|
*
|
||||||
* Returns the timezone as a string like +08:00 or -05:00 depending on the app timezone.
|
* 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
|
public static function getMySQLTimezoneOffset(string $timezone): string
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,9 +13,6 @@ class Utilities
|
||||||
/**
|
/**
|
||||||
* Generates a random string and injects special characters into it, in addition to
|
* Generates a random string and injects special characters into it, in addition to
|
||||||
* the randomness of the alpha-numeric default response.
|
* the randomness of the alpha-numeric default response.
|
||||||
*
|
|
||||||
* @param int $length
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public static function randomStringWithSpecialCharacters(int $length = 16): 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
|
// 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.
|
// with special characters to avoid issues with MySQL password requirements on some servers.
|
||||||
try {
|
try {
|
||||||
for ($i = 0; $i < random_int(2, 6); $i++) {
|
for ($i = 0; $i < random_int(2, 6); ++$i) {
|
||||||
$character = ['!', '@', '=', '.', '+', '^'][random_int(0, 5)];
|
$character = ['!', '@', '=', '.', '+', '^'][random_int(0, 5)];
|
||||||
|
|
||||||
$string = substr_replace($string, $character, random_int(0, $length - 1), 1);
|
$string = substr_replace($string, $character, random_int(0, $length - 1), 1);
|
||||||
|
@ -39,16 +36,28 @@ class Utilities
|
||||||
/**
|
/**
|
||||||
* Converts schedule cron data into a carbon object.
|
* Converts schedule cron data into a carbon object.
|
||||||
*
|
*
|
||||||
* @param string $minute
|
|
||||||
* @param string $hour
|
|
||||||
* @param string $dayOfMonth
|
|
||||||
* @param string $dayOfWeek
|
|
||||||
* @return \Carbon\Carbon
|
* @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(
|
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());
|
)->getNextRunDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mixed $default
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function checked(string $name, $default)
|
||||||
|
{
|
||||||
|
$errors = session('errors');
|
||||||
|
|
||||||
|
if (isset($errors) && $errors instanceof ViewErrorBag && $errors->any()) {
|
||||||
|
return old($name) ? 'checked' : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($default) ? 'checked' : '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Pterodactyl\Http\Controllers\Api\Application\Locations;
|
namespace Pterodactyl\Http\Controllers\Api\Application\Locations;
|
||||||
|
|
||||||
|
use Illuminate\Http\Response;
|
||||||
use Pterodactyl\Models\Location;
|
use Pterodactyl\Models\Location;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Spatie\QueryBuilder\QueryBuilder;
|
use Spatie\QueryBuilder\QueryBuilder;
|
||||||
|
@ -42,11 +43,6 @@ class LocationController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LocationController constructor.
|
* LocationController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Locations\LocationCreationService $creationService
|
|
||||||
* @param \Pterodactyl\Services\Locations\LocationDeletionService $deletionService
|
|
||||||
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $repository
|
|
||||||
* @param \Pterodactyl\Services\Locations\LocationUpdateService $updateService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
LocationCreationService $creationService,
|
LocationCreationService $creationService,
|
||||||
|
@ -64,11 +60,6 @@ class LocationController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all of the locations currently registered on the Panel.
|
* Return all of the locations currently registered on the Panel.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationsRequest $request
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function index(GetLocationsRequest $request): array
|
public function index(GetLocationsRequest $request): array
|
||||||
{
|
{
|
||||||
|
@ -91,12 +82,6 @@ class LocationController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a single location.
|
* Return a single location.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\GetLocationRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Location $location
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function view(GetLocationRequest $request, Location $location): array
|
public function view(GetLocationRequest $request, Location $location): array
|
||||||
{
|
{
|
||||||
|
@ -110,11 +95,9 @@ class LocationController extends ApplicationApiController
|
||||||
* new location attached.
|
* new location attached.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\StoreLocationRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\StoreLocationRequest $request
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function store(StoreLocationRequest $request): JsonResponse
|
public function store(StoreLocationRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
@ -133,11 +116,6 @@ class LocationController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Update a location on the Panel and return the updated record to the user.
|
* Update a location on the Panel and return the updated record to the user.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\UpdateLocationRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Location $location
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
|
@ -154,11 +132,6 @@ class LocationController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Delete a location from the Panel.
|
* Delete a location from the Panel.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Locations\DeleteLocationRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Location $location
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException
|
* @throws \Pterodactyl\Exceptions\Service\Location\HasActiveNodesException
|
||||||
*/
|
*/
|
||||||
public function delete(DeleteLocationRequest $request, Location $location): JsonResponse
|
public function delete(DeleteLocationRequest $request, Location $location): JsonResponse
|
||||||
|
|
|
@ -41,11 +41,6 @@ class NestController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NestController constructor.
|
* NestController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository
|
|
||||||
* @param \Pterodactyl\Services\Nests\NestCreationService $nestCreationService
|
|
||||||
* @param \Pterodactyl\Services\Nests\NestDeletionService $nestDeletionService
|
|
||||||
* @param \Pterodactyl\Services\Nests\NestUpdateService $nestUpdateService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
NestRepositoryInterface $repository,
|
NestRepositoryInterface $repository,
|
||||||
|
@ -64,11 +59,6 @@ class NestController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all Nests that exist on the Panel.
|
* Return all Nests that exist on the Panel.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nests\GetNestsRequest $request
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function index(GetNestsRequest $request): array
|
public function index(GetNestsRequest $request): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,8 +14,6 @@ class NodeConfigurationController extends ApplicationApiController
|
||||||
* to remote machines so long as an API key is provided to the machine to make the request
|
* to remote machines so long as an API key is provided to the machine to make the request
|
||||||
* with, and the node is known.
|
* with, and the node is known.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Node $node
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function __invoke(GetNodeRequest $request, Node $node)
|
public function __invoke(GetNodeRequest $request, Node $node)
|
||||||
|
|
|
@ -42,11 +42,6 @@ class NodeController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NodeController constructor.
|
* NodeController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Nodes\NodeCreationService $creationService
|
|
||||||
* @param \Pterodactyl\Services\Nodes\NodeDeletionService $deletionService
|
|
||||||
* @param \Pterodactyl\Services\Nodes\NodeUpdateService $updateService
|
|
||||||
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
NodeCreationService $creationService,
|
NodeCreationService $creationService,
|
||||||
|
@ -64,11 +59,6 @@ class NodeController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all of the nodes currently available on the Panel.
|
* Return all of the nodes currently available on the Panel.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodesRequest $request
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function index(GetNodesRequest $request): array
|
public function index(GetNodesRequest $request): array
|
||||||
{
|
{
|
||||||
|
@ -91,12 +81,6 @@ class NodeController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return data for a single instance of a node.
|
* Return data for a single instance of a node.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Node $node
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function view(GetNodeRequest $request, Node $node): array
|
public function view(GetNodeRequest $request, Node $node): array
|
||||||
{
|
{
|
||||||
|
@ -109,11 +93,7 @@ class NodeController extends ApplicationApiController
|
||||||
* Create a new node on the Panel. Returns the created node and a HTTP/201
|
* Create a new node on the Panel. Returns the created node and a HTTP/201
|
||||||
* status response on success.
|
* status response on success.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\StoreNodeRequest $request
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException*@throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function store(StoreNodeRequest $request): JsonResponse
|
public function store(StoreNodeRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
@ -132,17 +112,14 @@ class NodeController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Update an existing node on the Panel.
|
* Update an existing node on the Panel.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\UpdateNodeRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Node $node
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function update(UpdateNodeRequest $request, Node $node): array
|
public function update(UpdateNodeRequest $request, Node $node): array
|
||||||
{
|
{
|
||||||
$node = $this->updateService->handle(
|
$node = $this->updateService->handle(
|
||||||
$node, $request->validated(), $request->input('reset_secret') === true
|
$node,
|
||||||
|
$request->validated(),
|
||||||
|
$request->input('reset_secret') === true
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->fractal->item($node)
|
return $this->fractal->item($node)
|
||||||
|
@ -154,11 +131,6 @@ class NodeController extends ApplicationApiController
|
||||||
* Deletes a given node from the Panel as long as there are no servers
|
* Deletes a given node from the Panel as long as there are no servers
|
||||||
* currently attached to it.
|
* currently attached to it.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\DeleteNodeRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Node $node
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
|
||||||
*/
|
*/
|
||||||
public function delete(DeleteNodeRequest $request, Node $node): JsonResponse
|
public function delete(DeleteNodeRequest $request, Node $node): JsonResponse
|
||||||
|
|
|
@ -16,8 +16,6 @@ class NodeDeploymentController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NodeDeploymentController constructor.
|
* NodeDeploymentController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Deployment\FindViableNodesService $viableNodesService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(FindViableNodesService $viableNodesService)
|
public function __construct(FindViableNodesService $viableNodesService)
|
||||||
{
|
{
|
||||||
|
@ -31,9 +29,6 @@ class NodeDeploymentController extends ApplicationApiController
|
||||||
* similarly to the server creation process, but allows you to pass the deployment object
|
* similarly to the server creation process, but allows you to pass the deployment object
|
||||||
* to this endpoint and get back a list of all Nodes satisfying the requirements.
|
* to this endpoint and get back a list of all Nodes satisfying the requirements.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Nodes\GetDeployableNodesRequest $request
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException
|
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException
|
||||||
*/
|
*/
|
||||||
public function __invoke(GetDeployableNodesRequest $request): array
|
public function __invoke(GetDeployableNodesRequest $request): array
|
||||||
|
|
|
@ -35,17 +35,12 @@ class DatabaseController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DatabaseController constructor.
|
* DatabaseController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Databases\DatabaseManagementService $databaseManagementService
|
|
||||||
* @param \Pterodactyl\Services\Databases\DatabasePasswordService $databasePasswordService
|
|
||||||
* @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $repository
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
DatabaseManagementService $databaseManagementService,
|
DatabaseManagementService $databaseManagementService,
|
||||||
DatabasePasswordService $databasePasswordService,
|
DatabasePasswordService $databasePasswordService,
|
||||||
DatabaseRepositoryInterface $repository
|
DatabaseRepositoryInterface $repository
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->databaseManagementService = $databaseManagementService;
|
$this->databaseManagementService = $databaseManagementService;
|
||||||
|
@ -56,12 +51,6 @@ class DatabaseController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Return a listing of all databases currently available to a single
|
* Return a listing of all databases currently available to a single
|
||||||
* server.
|
* server.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabasesRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function index(GetServerDatabasesRequest $request, Server $server): array
|
public function index(GetServerDatabasesRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
|
@ -72,13 +61,6 @@ class DatabaseController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a single server database.
|
* Return a single server database.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\GetServerDatabaseRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param \Pterodactyl\Models\Database $database
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function view(GetServerDatabaseRequest $request, Server $server, Database $database): array
|
public function view(GetServerDatabaseRequest $request, Server $server, Database $database): array
|
||||||
{
|
{
|
||||||
|
@ -90,12 +72,6 @@ class DatabaseController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Reset the password for a specific server database.
|
* Reset the password for a specific server database.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param \Pterodactyl\Models\Database $database
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function resetPassword(ServerDatabaseWriteRequest $request, Server $server, Database $database): JsonResponse
|
public function resetPassword(ServerDatabaseWriteRequest $request, Server $server, Database $database): JsonResponse
|
||||||
|
@ -108,11 +84,6 @@ class DatabaseController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Create a new database on the Panel for a given server.
|
* Create a new database on the Panel for a given server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\StoreServerDatabaseRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function store(StoreServerDatabaseRequest $request, Server $server): JsonResponse
|
public function store(StoreServerDatabaseRequest $request, Server $server): JsonResponse
|
||||||
|
@ -135,12 +106,7 @@ class DatabaseController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Handle a request to delete a specific server database from the Panel.
|
* Handle a request to delete a specific server database from the Panel.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\Databases\ServerDatabaseWriteRequest $request
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
* @param \Pterodactyl\Models\Database $database
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function delete(ServerDatabaseWriteRequest $request, Database $database): JsonResponse
|
public function delete(ServerDatabaseWriteRequest $request, Database $database): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,11 +10,6 @@ class ExternalServerController extends ApplicationApiController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Retrieve a specific server from the database using its external ID.
|
* Retrieve a specific server from the database using its external ID.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetExternalServerRequest $request
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function index(GetExternalServerRequest $request): array
|
public function index(GetExternalServerRequest $request): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,9 +30,6 @@ class ServerController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ServerController constructor.
|
* ServerController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Servers\ServerCreationService $creationService
|
|
||||||
* @param \Pterodactyl\Services\Servers\ServerDeletionService $deletionService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ServerCreationService $creationService,
|
ServerCreationService $creationService,
|
||||||
|
@ -46,11 +43,6 @@ class ServerController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all of the servers that currently exist on the Panel.
|
* Return all of the servers that currently exist on the Panel.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetServersRequest $request
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function index(GetServersRequest $request): array
|
public function index(GetServersRequest $request): array
|
||||||
{
|
{
|
||||||
|
@ -74,10 +66,6 @@ class ServerController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Create a new server on the system.
|
* Create a new server on the system.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\StoreServerRequest $request
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
* @throws \Illuminate\Validation\ValidationException
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
|
@ -96,12 +84,6 @@ class ServerController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a single server transformed for the application API.
|
* Show a single server transformed for the application API.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\GetServerRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function view(GetServerRequest $request, Server $server): array
|
public function view(GetServerRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
|
@ -111,15 +93,7 @@ class ServerController extends ApplicationApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a server.
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param string $force
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*
|
|
||||||
* @throws \Throwable
|
|
||||||
*/
|
*/
|
||||||
public function delete(ServerWriteRequest $request, Server $server, string $force = ''): Response
|
public function delete(ServerWriteRequest $request, Server $server, string $force = ''): Response
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,9 +24,6 @@ class ServerDetailsController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ServerDetailsController constructor.
|
* ServerDetailsController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Servers\BuildModificationService $buildModificationService
|
|
||||||
* @param \Pterodactyl\Services\Servers\DetailsModificationService $detailsModificationService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
BuildModificationService $buildModificationService,
|
BuildModificationService $buildModificationService,
|
||||||
|
@ -41,18 +38,15 @@ class ServerDetailsController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Update the details for a specific server.
|
* Update the details for a specific server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerDetailsRequest $request
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
*
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
* @throws \Throwable
|
|
||||||
*/
|
*/
|
||||||
public function details(UpdateServerDetailsRequest $request, Server $server): array
|
public function details(UpdateServerDetailsRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
$server = $this->detailsModificationService->returnUpdatedModel()->handle(
|
$server = $this->detailsModificationService->returnUpdatedModel()->handle(
|
||||||
$server, $request->validated()
|
$server,
|
||||||
|
$request->validated()
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->fractal->item($server)
|
return $this->fractal->item($server)
|
||||||
|
@ -65,11 +59,11 @@ class ServerDetailsController extends ApplicationApiController
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigurationRequest $request
|
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerBuildConfigurationRequest $request
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @param \Pterodactyl\Models\Server $server
|
||||||
*
|
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws \Throwable
|
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function build(UpdateServerBuildConfigurationRequest $request, Server $server): array
|
public function build(UpdateServerBuildConfigurationRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,9 +23,6 @@ class ServerManagementController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SuspensionController constructor.
|
* SuspensionController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Servers\ReinstallServerService $reinstallServerService
|
|
||||||
* @param \Pterodactyl\Services\Servers\SuspensionService $suspensionService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ReinstallServerService $reinstallServerService,
|
ReinstallServerService $reinstallServerService,
|
||||||
|
@ -40,11 +37,6 @@ class ServerManagementController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Suspend a server on the Panel.
|
* Suspend a server on the Panel.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*
|
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function suspend(ServerWriteRequest $request, Server $server): Response
|
public function suspend(ServerWriteRequest $request, Server $server): Response
|
||||||
|
@ -57,11 +49,6 @@ class ServerManagementController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Unsuspend a server on the Panel.
|
* Unsuspend a server on the Panel.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*
|
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function unsuspend(ServerWriteRequest $request, Server $server): Response
|
public function unsuspend(ServerWriteRequest $request, Server $server): Response
|
||||||
|
@ -74,12 +61,9 @@ class ServerManagementController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Mark a server as needing to be reinstalled.
|
* Mark a server as needing to be reinstalled.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
*
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*
|
|
||||||
* @throws \Throwable
|
|
||||||
*/
|
*/
|
||||||
public function reinstall(ServerWriteRequest $request, Server $server): Response
|
public function reinstall(ServerWriteRequest $request, Server $server): Response
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,8 +18,6 @@ class StartupController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* StartupController constructor.
|
* StartupController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Servers\StartupModificationService $modificationService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(StartupModificationService $modificationService)
|
public function __construct(StartupModificationService $modificationService)
|
||||||
{
|
{
|
||||||
|
@ -31,11 +29,10 @@ class StartupController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Update the startup and environment settings for a specific server.
|
* Update the startup and environment settings for a specific server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Servers\UpdateServerStartupRequest $request
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
* @param \Pterodactyl\Models\Server $server
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
* @return array
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
* @throws \Throwable
|
|
||||||
*/
|
*/
|
||||||
public function index(UpdateServerStartupRequest $request, Server $server): array
|
public function index(UpdateServerStartupRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,11 +10,6 @@ class ExternalUserController extends ApplicationApiController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Retrieve a specific user from the database using their external ID.
|
* Retrieve a specific user from the database using their external ID.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetExternalUserRequest $request
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function index(GetExternalUserRequest $request): array
|
public function index(GetExternalUserRequest $request): array
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,11 +42,6 @@ class UserController extends ApplicationApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UserController constructor.
|
* UserController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
|
|
||||||
* @param \Pterodactyl\Services\Users\UserCreationService $creationService
|
|
||||||
* @param \Pterodactyl\Services\Users\UserDeletionService $deletionService
|
|
||||||
* @param \Pterodactyl\Services\Users\UserUpdateService $updateService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
UserRepositoryInterface $repository,
|
UserRepositoryInterface $repository,
|
||||||
|
@ -94,12 +89,6 @@ class UserController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Handle a request to view a single user. Includes any relations that
|
* Handle a request to view a single user. Includes any relations that
|
||||||
* were defined in the request.
|
* were defined in the request.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\GetUserRequest $request
|
|
||||||
* @param \Pterodactyl\Models\User $user
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
|
||||||
*/
|
*/
|
||||||
public function view(GetUserRequest $request, User $user): array
|
public function view(GetUserRequest $request, User $user): array
|
||||||
{
|
{
|
||||||
|
@ -116,11 +105,6 @@ class UserController extends ApplicationApiController
|
||||||
* Revocation errors are returned under the 'revocation_errors' key in the response
|
* Revocation errors are returned under the 'revocation_errors' key in the response
|
||||||
* meta. If there are no errors this is an empty array.
|
* meta. If there are no errors this is an empty array.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\UpdateUserRequest $request
|
|
||||||
* @param \Pterodactyl\Models\User $user
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
* @throws \Illuminate\Contracts\Container\BindingResolutionException
|
||||||
|
@ -139,10 +123,6 @@ class UserController extends ApplicationApiController
|
||||||
* Store a new user on the system. Returns the created user and a HTTP/201
|
* Store a new user on the system. Returns the created user and a HTTP/201
|
||||||
* header on successful creation.
|
* header on successful creation.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\StoreUserRequest $request
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
*/
|
*/
|
||||||
|
@ -164,11 +144,6 @@ class UserController extends ApplicationApiController
|
||||||
* Handle a request to delete a user from the Panel. Returns a HTTP/204 response
|
* Handle a request to delete a user from the Panel. Returns a HTTP/204 response
|
||||||
* on successful deletion.
|
* on successful deletion.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Application\Users\DeleteUserRequest $request
|
|
||||||
* @param \Pterodactyl\Models\User $user
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
*/
|
*/
|
||||||
public function delete(DeleteUserRequest $request, User $user): JsonResponse
|
public function delete(DeleteUserRequest $request, User $user): JsonResponse
|
||||||
|
|
|
@ -25,9 +25,6 @@ class AccountController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AccountController constructor.
|
* AccountController constructor.
|
||||||
*
|
|
||||||
* @param \Illuminate\Auth\AuthManager $sessionGuard
|
|
||||||
* @param \Pterodactyl\Services\Users\UserUpdateService $updateService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(AuthManager $sessionGuard, UserUpdateService $updateService)
|
public function __construct(AuthManager $sessionGuard, UserUpdateService $updateService)
|
||||||
{
|
{
|
||||||
|
@ -37,10 +34,6 @@ class AccountController extends ClientApiController
|
||||||
$this->sessionGuard = $sessionGuard;
|
$this->sessionGuard = $sessionGuard;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function index(Request $request): array
|
public function index(Request $request): array
|
||||||
{
|
{
|
||||||
return $this->fractal->item($request->user())
|
return $this->fractal->item($request->user())
|
||||||
|
@ -51,9 +44,6 @@ class AccountController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Update the authenticated user's email address.
|
* Update the authenticated user's email address.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Account\UpdateEmailRequest $request
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
|
@ -68,9 +58,6 @@ class AccountController extends ClientApiController
|
||||||
* Update the authenticated user's password. All existing sessions will be logged
|
* Update the authenticated user's password. All existing sessions will be logged
|
||||||
* out immediately.
|
* out immediately.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Account\UpdatePasswordRequest $request
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,10 +32,6 @@ class ApiKeyController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ApiKeyController constructor.
|
* ApiKeyController constructor.
|
||||||
*
|
|
||||||
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
|
|
||||||
* @param \Pterodactyl\Services\Api\KeyCreationService $keyCreationService
|
|
||||||
* @param \Pterodactyl\Repositories\Eloquent\ApiKeyRepository $repository
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Encrypter $encrypter,
|
Encrypter $encrypter,
|
||||||
|
@ -52,7 +48,6 @@ class ApiKeyController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Returns all of the API keys that exist for the given client.
|
* Returns all of the API keys that exist for the given client.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\ClientApiRequest $request
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function index(ClientApiRequest $request)
|
public function index(ClientApiRequest $request)
|
||||||
|
@ -65,7 +60,6 @@ class ApiKeyController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Store a new API key for a user's account.
|
* Store a new API key for a user's account.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Account\StoreApiKeyRequest $request
|
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
|
@ -74,9 +68,7 @@ class ApiKeyController extends ClientApiController
|
||||||
public function store(StoreApiKeyRequest $request)
|
public function store(StoreApiKeyRequest $request)
|
||||||
{
|
{
|
||||||
if ($request->user()->apiKeys->count() >= 5) {
|
if ($request->user()->apiKeys->count() >= 5) {
|
||||||
throw new DisplayException(
|
throw new DisplayException('You have reached the account limit for number of API keys.');
|
||||||
'You have reached the account limit for number of API keys.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$key = $this->keyCreationService->setKeyType(ApiKey::TYPE_ACCOUNT)->handle([
|
$key = $this->keyCreationService->setKeyType(ApiKey::TYPE_ACCOUNT)->handle([
|
||||||
|
@ -96,8 +88,6 @@ class ApiKeyController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Deletes a given API key.
|
* Deletes a given API key.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\ClientApiRequest $request
|
|
||||||
* @param string $identifier
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function delete(ClientApiRequest $request, string $identifier)
|
public function delete(ClientApiRequest $request, string $identifier)
|
||||||
|
@ -108,8 +98,8 @@ class ApiKeyController extends ClientApiController
|
||||||
'identifier' => $identifier,
|
'identifier' => $identifier,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (! $response) {
|
if (!$response) {
|
||||||
throw new NotFoundHttpException;
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return JsonResponse::create([], JsonResponse::HTTP_NO_CONTENT);
|
return JsonResponse::create([], JsonResponse::HTTP_NO_CONTENT);
|
||||||
|
|
|
@ -13,8 +13,6 @@ abstract class ClientApiController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Returns only the includes which are valid for the given transformer.
|
* Returns only the includes which are valid for the given transformer.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Transformers\Api\Client\BaseClientTransformer $transformer
|
|
||||||
* @param array $merge
|
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
protected function getIncludesForTransformer(BaseClientTransformer $transformer, array $merge = [])
|
protected function getIncludesForTransformer(BaseClientTransformer $transformer, array $merge = [])
|
||||||
|
@ -35,7 +33,7 @@ abstract class ClientApiController extends ApplicationApiController
|
||||||
{
|
{
|
||||||
$includes = $this->request->query('include') ?? [];
|
$includes = $this->request->query('include') ?? [];
|
||||||
|
|
||||||
if (! is_string($includes)) {
|
if (!is_string($includes)) {
|
||||||
return $includes;
|
return $includes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +45,6 @@ abstract class ClientApiController extends ApplicationApiController
|
||||||
/**
|
/**
|
||||||
* Return an instance of an application transformer.
|
* Return an instance of an application transformer.
|
||||||
*
|
*
|
||||||
* @param string $abstract
|
|
||||||
* @return \Pterodactyl\Transformers\Api\Client\BaseClientTransformer
|
* @return \Pterodactyl\Transformers\Api\Client\BaseClientTransformer
|
||||||
*/
|
*/
|
||||||
public function getTransformer(string $abstract)
|
public function getTransformer(string $abstract)
|
||||||
|
|
|
@ -20,8 +20,6 @@ class ClientController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClientController constructor.
|
* ClientController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Repositories\Eloquent\ServerRepository $repository
|
|
||||||
*/
|
*/
|
||||||
public function __construct(ServerRepository $repository)
|
public function __construct(ServerRepository $repository)
|
||||||
{
|
{
|
||||||
|
@ -33,9 +31,6 @@ class ClientController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Return all of the servers available to the client making the API
|
* Return all of the servers available to the client making the API
|
||||||
* request, including servers the user has access to as a subuser.
|
* request, including servers the user has access to as a subuser.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\GetServersRequest $request
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function index(GetServersRequest $request): array
|
public function index(GetServersRequest $request): array
|
||||||
{
|
{
|
||||||
|
@ -49,7 +44,7 @@ class ClientController extends ClientApiController
|
||||||
'uuid',
|
'uuid',
|
||||||
'name',
|
'name',
|
||||||
'external_id',
|
'external_id',
|
||||||
AllowedFilter::custom('*', new MultiFieldServerFilter),
|
AllowedFilter::custom('*', new MultiFieldServerFilter()),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$type = $request->input('type');
|
$type = $request->input('type');
|
||||||
|
@ -60,14 +55,14 @@ class ClientController extends ClientApiController
|
||||||
if (in_array($type, ['admin', 'admin-all'])) {
|
if (in_array($type, ['admin', 'admin-all'])) {
|
||||||
// If they aren't an admin but want all the admin servers don't fail the request, just
|
// If they aren't an admin but want all the admin servers don't fail the request, just
|
||||||
// make it a query that will never return any results back.
|
// make it a query that will never return any results back.
|
||||||
if (! $user->root_admin) {
|
if (!$user->root_admin) {
|
||||||
$builder->whereRaw('1 = 2');
|
$builder->whereRaw('1 = 2');
|
||||||
} else {
|
} else {
|
||||||
$builder = $type === 'admin-all'
|
$builder = $type === 'admin-all'
|
||||||
? $builder
|
? $builder
|
||||||
: $builder->whereNotIn('servers.id', $user->accessibleServers()->pluck('id')->all());
|
: $builder->whereNotIn('servers.id', $user->accessibleServers()->pluck('id')->all());
|
||||||
}
|
}
|
||||||
} else if ($type === 'owner') {
|
} elseif ($type === 'owner') {
|
||||||
$builder = $builder->where('servers.owner_id', $user->id);
|
$builder = $builder->where('servers.owner_id', $user->id);
|
||||||
} else {
|
} else {
|
||||||
$builder = $builder->whereIn('servers.id', $user->accessibleServers()->pluck('id')->all());
|
$builder = $builder->whereIn('servers.id', $user->accessibleServers()->pluck('id')->all());
|
||||||
|
|
|
@ -33,10 +33,6 @@ class BackupController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BackupController constructor.
|
* BackupController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository
|
|
||||||
* @param \Pterodactyl\Services\Backups\DeleteBackupService $deleteBackupService
|
|
||||||
* @param \Pterodactyl\Services\Backups\InitiateBackupService $initiateBackupService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
BackupRepository $repository,
|
BackupRepository $repository,
|
||||||
|
@ -54,13 +50,12 @@ class BackupController extends ClientApiController
|
||||||
* Returns all of the backups for a given server instance in a paginated
|
* Returns all of the backups for a given server instance in a paginated
|
||||||
* result set.
|
* result set.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\GetBackupsRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function index(GetBackupsRequest $request, Server $server)
|
public function index(GetBackupsRequest $request, Server $server)
|
||||||
{
|
{
|
||||||
$limit = min($request->query('per_page') ?? 20, 50);
|
$limit = min($request->query('per_page') ?? 20, 50);
|
||||||
|
|
||||||
return $this->fractal->collection($server->backups()->paginate($limit))
|
return $this->fractal->collection($server->backups()->paginate($limit))
|
||||||
->transformWith($this->getTransformer(BackupTransformer::class))
|
->transformWith($this->getTransformer(BackupTransformer::class))
|
||||||
->toArray();
|
->toArray();
|
||||||
|
@ -69,8 +64,6 @@ class BackupController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Starts the backup process for a server.
|
* Starts the backup process for a server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws \Exception|\Throwable
|
* @throws \Exception|\Throwable
|
||||||
|
@ -91,9 +84,6 @@ class BackupController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Returns information about a single backup.
|
* Returns information about a single backup.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\GetBackupsRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param \Pterodactyl\Models\Backup $backup
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function view(GetBackupsRequest $request, Server $server, Backup $backup)
|
public function view(GetBackupsRequest $request, Server $server, Backup $backup)
|
||||||
|
@ -107,9 +97,6 @@ class BackupController extends ClientApiController
|
||||||
* Deletes a backup from the panel as well as the remote source where it is currently
|
* Deletes a backup from the panel as well as the remote source where it is currently
|
||||||
* being stored.
|
* being stored.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\DeleteBackupRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param \Pterodactyl\Models\Backup $backup
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
|
|
|
@ -21,8 +21,6 @@ class CommandController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CommandController constructor.
|
* CommandController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Repositories\Wings\DaemonCommandRepository $repository
|
|
||||||
*/
|
*/
|
||||||
public function __construct(DaemonCommandRepository $repository)
|
public function __construct(DaemonCommandRepository $repository)
|
||||||
{
|
{
|
||||||
|
@ -34,10 +32,6 @@ class CommandController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Send a command to a running server.
|
* Send a command to a running server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\SendCommandRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
public function index(SendCommandRequest $request, Server $server): Response
|
public function index(SendCommandRequest $request, Server $server): Response
|
||||||
|
@ -52,9 +46,7 @@ class CommandController extends ClientApiController
|
||||||
$previous->getResponse() instanceof ResponseInterface
|
$previous->getResponse() instanceof ResponseInterface
|
||||||
&& $previous->getResponse()->getStatusCode() === Response::HTTP_BAD_GATEWAY
|
&& $previous->getResponse()->getStatusCode() === Response::HTTP_BAD_GATEWAY
|
||||||
) {
|
) {
|
||||||
throw new HttpException(
|
throw new HttpException(Response::HTTP_BAD_GATEWAY, 'Server must be online in order to send commands.', $exception);
|
||||||
Response::HTTP_BAD_GATEWAY, 'Server must be online in order to send commands.', $exception
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,6 @@ class DatabaseController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DatabaseController constructor.
|
* DatabaseController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Databases\DatabaseManagementService $managementService
|
|
||||||
* @param \Pterodactyl\Services\Databases\DatabasePasswordService $passwordService
|
|
||||||
* @param \Pterodactyl\Repositories\Eloquent\DatabaseRepository $repository
|
|
||||||
* @param \Pterodactyl\Services\Databases\DeployServerDatabaseService $deployDatabaseService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
DatabaseManagementService $managementService,
|
DatabaseManagementService $managementService,
|
||||||
|
@ -62,10 +57,6 @@ class DatabaseController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all of the databases that belong to the given server.
|
* Return all of the databases that belong to the given server.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Databases\GetDatabasesRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function index(GetDatabasesRequest $request, Server $server): array
|
public function index(GetDatabasesRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
|
@ -77,10 +68,6 @@ class DatabaseController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Create a new database for the given server and return it.
|
* Create a new database for the given server and return it.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Databases\StoreDatabaseRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
* @throws \Pterodactyl\Exceptions\Service\Database\TooManyDatabasesException
|
* @throws \Pterodactyl\Exceptions\Service\Database\TooManyDatabasesException
|
||||||
* @throws \Pterodactyl\Exceptions\Service\Database\DatabaseClientFeatureNotEnabledException
|
* @throws \Pterodactyl\Exceptions\Service\Database\DatabaseClientFeatureNotEnabledException
|
||||||
|
@ -99,9 +86,6 @@ class DatabaseController extends ClientApiController
|
||||||
* Rotates the password for the given server model and returns a fresh instance to
|
* Rotates the password for the given server model and returns a fresh instance to
|
||||||
* the caller.
|
* the caller.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Databases\RotatePasswordRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param \Pterodactyl\Models\Database $database
|
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
|
@ -120,11 +104,6 @@ class DatabaseController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Removes a database from the server.
|
* Removes a database from the server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Databases\DeleteDatabaseRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param \Pterodactyl\Models\Database $database
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
public function delete(DeleteDatabaseRequest $request, Server $server, Database $database): Response
|
public function delete(DeleteDatabaseRequest $request, Server $server, Database $database): Response
|
||||||
|
|
|
@ -39,11 +39,6 @@ class DownloadBackupController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DownloadBackupController constructor.
|
* DownloadBackupController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Repositories\Wings\DaemonBackupRepository $daemonBackupRepository
|
|
||||||
* @param \Pterodactyl\Services\Nodes\NodeJWTService $jwtService
|
|
||||||
* @param \Pterodactyl\Extensions\Backups\BackupManager $backupManager
|
|
||||||
* @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
DaemonBackupRepository $daemonBackupRepository,
|
DaemonBackupRepository $daemonBackupRepository,
|
||||||
|
@ -64,9 +59,6 @@ class DownloadBackupController extends ClientApiController
|
||||||
* will be streamed back through the Panel. For AWS S3 files, a signed URL will be generated
|
* will be streamed back through the Panel. For AWS S3 files, a signed URL will be generated
|
||||||
* which the user is redirected to.
|
* which the user is redirected to.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\DownloadBackupRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param \Pterodactyl\Models\Backup $backup
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function __invoke(DownloadBackupRequest $request, Server $server, Backup $backup)
|
public function __invoke(DownloadBackupRequest $request, Server $server, Backup $backup)
|
||||||
|
@ -79,7 +71,7 @@ class DownloadBackupController extends ClientApiController
|
||||||
$url = $this->getS3BackupUrl($backup, $server);
|
$url = $this->getS3BackupUrl($backup, $server);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new BadRequestHttpException;
|
throw new BadRequestHttpException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new JsonResponse([
|
return new JsonResponse([
|
||||||
|
@ -94,8 +86,6 @@ class DownloadBackupController extends ClientApiController
|
||||||
* Returns a signed URL that allows us to download a file directly out of a non-public
|
* Returns a signed URL that allows us to download a file directly out of a non-public
|
||||||
* S3 bucket by using a signed URL.
|
* S3 bucket by using a signed URL.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Backup $backup
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getS3BackupUrl(Backup $backup, Server $server)
|
protected function getS3BackupUrl(Backup $backup, Server $server)
|
||||||
|
@ -120,9 +110,6 @@ class DownloadBackupController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Returns a download link a backup stored on a wings instance.
|
* Returns a download link a backup stored on a wings instance.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Backup $backup
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param \Pterodactyl\Models\User $user
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getLocalBackupUrl(Backup $backup, Server $server, User $user)
|
protected function getLocalBackupUrl(Backup $backup, Server $server, User $user)
|
||||||
|
@ -138,7 +125,7 @@ class DownloadBackupController extends ClientApiController
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'%s/download/backup?token=%s',
|
'%s/download/backup?token=%s',
|
||||||
$server->node->getConnectionAddress(),
|
$server->node->getConnectionAddress(),
|
||||||
$token->__toString()
|
$token->toString()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ use Carbon\CarbonImmutable;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Pterodactyl\Models\Server;
|
use Pterodactyl\Models\Server;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Pterodactyl\Services\Nodes\NodeJWTService;
|
use Pterodactyl\Services\Nodes\NodeJWTService;
|
||||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||||
use Pterodactyl\Repositories\Wings\DaemonFileRepository;
|
use Pterodactyl\Repositories\Wings\DaemonFileRepository;
|
||||||
|
@ -15,9 +14,9 @@ use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
|
||||||
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CopyFileRequest;
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CopyFileRequest;
|
||||||
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\PullFileRequest;
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\PullFileRequest;
|
||||||
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\ListFilesRequest;
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\ListFilesRequest;
|
||||||
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\ChmodFilesRequest;
|
||||||
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\DeleteFileRequest;
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\DeleteFileRequest;
|
||||||
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\RenameFileRequest;
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\RenameFileRequest;
|
||||||
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\ChmodFilesRequest;
|
|
||||||
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CreateFolderRequest;
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CreateFolderRequest;
|
||||||
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CompressFilesRequest;
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\CompressFilesRequest;
|
||||||
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\DecompressFilesRequest;
|
use Pterodactyl\Http\Requests\Api\Client\Servers\Files\DecompressFilesRequest;
|
||||||
|
@ -43,10 +42,6 @@ class FileController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FileController constructor.
|
* FileController constructor.
|
||||||
*
|
|
||||||
* @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory
|
|
||||||
* @param \Pterodactyl\Services\Nodes\NodeJWTService $jwtService
|
|
||||||
* @param \Pterodactyl\Repositories\Wings\DaemonFileRepository $fileRepository
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ResponseFactory $responseFactory,
|
ResponseFactory $responseFactory,
|
||||||
|
@ -63,10 +58,6 @@ class FileController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Returns a listing of files in a given directory.
|
* Returns a listing of files in a given directory.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\ListFilesRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
public function directory(ListFilesRequest $request, Server $server): array
|
public function directory(ListFilesRequest $request, Server $server): array
|
||||||
|
@ -83,10 +74,6 @@ class FileController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Return the contents of a specified file for the user.
|
* Return the contents of a specified file for the user.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\GetFileContentsRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException
|
* @throws \Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
|
@ -94,7 +81,8 @@ class FileController extends ClientApiController
|
||||||
{
|
{
|
||||||
return new Response(
|
return new Response(
|
||||||
$this->fileRepository->setServer($server)->getContent(
|
$this->fileRepository->setServer($server)->getContent(
|
||||||
$request->get('file'), config('pterodactyl.files.max_edit_size')
|
$request->get('file'),
|
||||||
|
config('pterodactyl.files.max_edit_size')
|
||||||
),
|
),
|
||||||
Response::HTTP_OK,
|
Response::HTTP_OK,
|
||||||
['Content-Type' => 'text/plain']
|
['Content-Type' => 'text/plain']
|
||||||
|
@ -105,8 +93,6 @@ class FileController extends ClientApiController
|
||||||
* Generates a one-time token with a link that the user can use to
|
* Generates a one-time token with a link that the user can use to
|
||||||
* download a given file.
|
* download a given file.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\GetFileContentsRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
|
@ -127,7 +113,7 @@ class FileController extends ClientApiController
|
||||||
'url' => sprintf(
|
'url' => sprintf(
|
||||||
'%s/download/file?token=%s',
|
'%s/download/file?token=%s',
|
||||||
$server->node->getConnectionAddress(),
|
$server->node->getConnectionAddress(),
|
||||||
$token->__toString()
|
$token->toString()
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -136,10 +122,6 @@ class FileController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Writes the contents of the specified file to the server.
|
* Writes the contents of the specified file to the server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\WriteFileContentRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
public function write(WriteFileContentRequest $request, Server $server): JsonResponse
|
public function write(WriteFileContentRequest $request, Server $server): JsonResponse
|
||||||
|
@ -152,10 +134,6 @@ class FileController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Creates a new folder on the server.
|
* Creates a new folder on the server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\CreateFolderRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
public function create(CreateFolderRequest $request, Server $server): JsonResponse
|
public function create(CreateFolderRequest $request, Server $server): JsonResponse
|
||||||
|
@ -170,10 +148,6 @@ class FileController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Renames a file on the remote machine.
|
* Renames a file on the remote machine.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\RenameFileRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
public function rename(RenameFileRequest $request, Server $server): JsonResponse
|
public function rename(RenameFileRequest $request, Server $server): JsonResponse
|
||||||
|
@ -188,10 +162,6 @@ class FileController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Copies a file on the server.
|
* Copies a file on the server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\CopyFileRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
public function copy(CopyFileRequest $request, Server $server): JsonResponse
|
public function copy(CopyFileRequest $request, Server $server): JsonResponse
|
||||||
|
@ -204,10 +174,6 @@ class FileController extends ClientApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\CompressFilesRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
public function compress(CompressFilesRequest $request, Server $server): array
|
public function compress(CompressFilesRequest $request, Server $server): array
|
||||||
|
@ -217,7 +183,8 @@ class FileController extends ClientApiController
|
||||||
|
|
||||||
$file = $this->fileRepository->setServer($server)
|
$file = $this->fileRepository->setServer($server)
|
||||||
->compressFiles(
|
->compressFiles(
|
||||||
$request->input('root'), $request->input('files')
|
$request->input('root'),
|
||||||
|
$request->input('files')
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->fractal->item($file)
|
return $this->fractal->item($file)
|
||||||
|
@ -226,10 +193,6 @@ class FileController extends ClientApiController
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\DecompressFilesRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
public function decompress(DecompressFilesRequest $request, Server $server): JsonResponse
|
public function decompress(DecompressFilesRequest $request, Server $server): JsonResponse
|
||||||
|
@ -246,17 +209,14 @@ class FileController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Deletes files or folders for the server in the given root directory.
|
* Deletes files or folders for the server in the given root directory.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\DeleteFileRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
public function delete(DeleteFileRequest $request, Server $server): JsonResponse
|
public function delete(DeleteFileRequest $request, Server $server): JsonResponse
|
||||||
{
|
{
|
||||||
$this->fileRepository->setServer($server)
|
$this->fileRepository->setServer($server)
|
||||||
->deleteFiles(
|
->deleteFiles(
|
||||||
$request->input('root'), $request->input('files')
|
$request->input('root'),
|
||||||
|
$request->input('files')
|
||||||
);
|
);
|
||||||
|
|
||||||
return new JsonResponse([], Response::HTTP_NO_CONTENT);
|
return new JsonResponse([], Response::HTTP_NO_CONTENT);
|
||||||
|
@ -265,17 +225,14 @@ class FileController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Updates file permissions for file(s) in the given root directory.
|
* Updates file permissions for file(s) in the given root directory.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\ChmodFilesRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
public function chmod(ChmodFilesRequest $request, Server $server): JsonResponse
|
public function chmod(ChmodFilesRequest $request, Server $server): JsonResponse
|
||||||
{
|
{
|
||||||
$this->fileRepository->setServer($server)
|
$this->fileRepository->setServer($server)
|
||||||
->chmodFiles(
|
->chmodFiles(
|
||||||
$request->input('root'), $request->input('files')
|
$request->input('root'),
|
||||||
|
$request->input('files')
|
||||||
);
|
);
|
||||||
|
|
||||||
return new JsonResponse([], Response::HTTP_NO_CONTENT);
|
return new JsonResponse([], Response::HTTP_NO_CONTENT);
|
||||||
|
@ -285,8 +242,6 @@ class FileController extends ClientApiController
|
||||||
* Requests that a file be downloaded from a remote location by Wings.
|
* Requests that a file be downloaded from a remote location by Wings.
|
||||||
*
|
*
|
||||||
* @param $request
|
* @param $request
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,8 +19,6 @@ class FileUploadController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FileUploadController constructor.
|
* FileUploadController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Services\Nodes\NodeJWTService $jwtService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
NodeJWTService $jwtService
|
NodeJWTService $jwtService
|
||||||
|
@ -33,9 +31,6 @@ class FileUploadController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Returns a url where files can be uploaded to.
|
* Returns a url where files can be uploaded to.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\UploadFileRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function __invoke(UploadFileRequest $request, Server $server)
|
public function __invoke(UploadFileRequest $request, Server $server)
|
||||||
|
@ -51,8 +46,6 @@ class FileUploadController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Returns a url where files can be uploaded to.
|
* Returns a url where files can be uploaded to.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param \Pterodactyl\Models\User $user
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getUploadUrl(Server $server, User $user)
|
protected function getUploadUrl(Server $server, User $user)
|
||||||
|
@ -67,7 +60,7 @@ class FileUploadController extends ClientApiController
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'%s/upload/file?token=%s',
|
'%s/upload/file?token=%s',
|
||||||
$server->node->getConnectionAddress(),
|
$server->node->getConnectionAddress(),
|
||||||
$token->__toString()
|
$token->toString()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,6 @@ class NetworkAllocationController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NetworkController constructor.
|
* NetworkController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Repositories\Eloquent\AllocationRepository $repository
|
|
||||||
* @param \Pterodactyl\Repositories\Eloquent\ServerRepository $serverRepository
|
|
||||||
* @param \Pterodactyl\Services\Allocations\FindAssignableAllocationService $assignableAllocationService
|
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AllocationRepository $repository,
|
AllocationRepository $repository,
|
||||||
|
@ -56,10 +52,6 @@ class NetworkAllocationController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Lists all of the allocations available to a server and wether or
|
* Lists all of the allocations available to a server and wether or
|
||||||
* not they are currently assigned as the primary for this server.
|
* not they are currently assigned as the primary for this server.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\GetNetworkRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function index(GetNetworkRequest $request, Server $server): array
|
public function index(GetNetworkRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
|
@ -71,11 +63,6 @@ class NetworkAllocationController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Set the primary allocation for a server.
|
* Set the primary allocation for a server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\UpdateAllocationRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param \Pterodactyl\Models\Allocation $allocation
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
|
@ -93,11 +80,6 @@ class NetworkAllocationController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Set the primary allocation for a server.
|
* Set the primary allocation for a server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\SetPrimaryAllocationRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param \Pterodactyl\Models\Allocation $allocation
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
*/
|
*/
|
||||||
|
@ -112,20 +94,14 @@ class NetworkAllocationController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the notes for the allocation for a server.
|
* Set the notes for the allocation for a server.
|
||||||
*s
|
*s.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\NewAllocationRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return array
|
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
*/
|
*/
|
||||||
public function store(NewAllocationRequest $request, Server $server): array
|
public function store(NewAllocationRequest $request, Server $server): array
|
||||||
{
|
{
|
||||||
if ($server->allocations()->count() >= $server->allocation_limit) {
|
if ($server->allocations()->count() >= $server->allocation_limit) {
|
||||||
throw new DisplayException(
|
throw new DisplayException('Cannot assign additional allocations to this server: limit has been reached.');
|
||||||
'Cannot assign additional allocations to this server: limit has been reached.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$allocation = $this->assignableAllocationService->handle($server);
|
$allocation = $this->assignableAllocationService->handle($server);
|
||||||
|
@ -138,9 +114,6 @@ class NetworkAllocationController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Delete an allocation from a server.
|
* Delete an allocation from a server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\Network\DeleteAllocationRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @param \Pterodactyl\Models\Allocation $allocation
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||||
|
@ -148,9 +121,7 @@ class NetworkAllocationController extends ClientApiController
|
||||||
public function delete(DeleteAllocationRequest $request, Server $server, Allocation $allocation)
|
public function delete(DeleteAllocationRequest $request, Server $server, Allocation $allocation)
|
||||||
{
|
{
|
||||||
if ($allocation->id === $server->allocation_id) {
|
if ($allocation->id === $server->allocation_id) {
|
||||||
throw new DisplayException(
|
throw new DisplayException('You cannot delete the primary allocation for this server.');
|
||||||
'You cannot delete the primary allocation for this server.'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Allocation::query()->where('id', $allocation->id)->update([
|
Allocation::query()->where('id', $allocation->id)->update([
|
||||||
|
|
|
@ -17,8 +17,6 @@ class PowerController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PowerController constructor.
|
* PowerController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Repositories\Wings\DaemonPowerRepository $repository
|
|
||||||
*/
|
*/
|
||||||
public function __construct(DaemonPowerRepository $repository)
|
public function __construct(DaemonPowerRepository $repository)
|
||||||
{
|
{
|
||||||
|
@ -30,10 +28,6 @@ class PowerController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Send a power action to a server.
|
* Send a power action to a server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\SendPowerRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return \Illuminate\Http\Response
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
public function index(SendPowerRequest $request, Server $server): Response
|
public function index(SendPowerRequest $request, Server $server): Response
|
||||||
|
|
|
@ -17,8 +17,6 @@ class ResourceUtilizationController extends ClientApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResourceUtilizationController constructor.
|
* ResourceUtilizationController constructor.
|
||||||
*
|
|
||||||
* @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $repository
|
|
||||||
*/
|
*/
|
||||||
public function __construct(DaemonServerRepository $repository)
|
public function __construct(DaemonServerRepository $repository)
|
||||||
{
|
{
|
||||||
|
@ -30,10 +28,6 @@ class ResourceUtilizationController extends ClientApiController
|
||||||
/**
|
/**
|
||||||
* Return the current resource utilization for a server.
|
* Return the current resource utilization for a server.
|
||||||
*
|
*
|
||||||
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\GetServerRequest $request
|
|
||||||
* @param \Pterodactyl\Models\Server $server
|
|
||||||
* @return array
|
|
||||||
*
|
|
||||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||||
*/
|
*/
|
||||||
public function __invoke(GetServerRequest $request, Server $server): array
|
public function __invoke(GetServerRequest $request, Server $server): array
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue