diff --git a/app/Http/Controllers/Admin/Servers/ServerTransferController.php b/app/Http/Controllers/Admin/Servers/ServerTransferController.php index f805070d7..12656f3b7 100644 --- a/app/Http/Controllers/Admin/Servers/ServerTransferController.php +++ b/app/Http/Controllers/Admin/Servers/ServerTransferController.php @@ -3,16 +3,16 @@ namespace Pterodactyl\Http\Controllers\Admin\Servers; use Illuminate\Http\Request; -use Prologue\Alerts\AlertsMessageBag; -use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface; -use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Models\Server; +use Prologue\Alerts\AlertsMessageBag; use Pterodactyl\Models\ServerTransfer; +use Pterodactyl\Http\Controllers\Controller; +use Pterodactyl\Services\Servers\TransferService; +use Pterodactyl\Services\Servers\SuspensionService; +use Pterodactyl\Repositories\Eloquent\NodeRepository; use Pterodactyl\Repositories\Eloquent\ServerRepository; use Pterodactyl\Repositories\Eloquent\LocationRepository; -use Pterodactyl\Repositories\Eloquent\NodeRepository; -use Pterodactyl\Services\Servers\SuspensionService; -use Pterodactyl\Services\Servers\TransferService; +use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface; class ServerTransferController extends Controller { diff --git a/app/Http/Controllers/Admin/Servers/ServerViewController.php b/app/Http/Controllers/Admin/Servers/ServerViewController.php index 1a4a931fa..25e198592 100644 --- a/app/Http/Controllers/Admin/Servers/ServerViewController.php +++ b/app/Http/Controllers/Admin/Servers/ServerViewController.php @@ -10,10 +10,10 @@ use Illuminate\Contracts\View\Factory; use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Repositories\Eloquent\NestRepository; -use Pterodactyl\Repositories\Eloquent\LocationRepository; use Pterodactyl\Repositories\Eloquent\NodeRepository; use Pterodactyl\Repositories\Eloquent\ServerRepository; use Pterodactyl\Traits\Controllers\JavascriptInjection; +use Pterodactyl\Repositories\Eloquent\LocationRepository; use Pterodactyl\Repositories\Eloquent\DatabaseHostRepository; class ServerViewController extends Controller diff --git a/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php b/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php index ddaa08496..9b52eee45 100644 --- a/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php +++ b/app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php @@ -3,22 +3,22 @@ namespace Pterodactyl\Http\Controllers\Api\Remote\Servers; use Cake\Chronos\Chronos; -use Illuminate\Database\ConnectionInterface; -use Illuminate\Http\JsonResponse; -use Illuminate\Http\Request; -use Illuminate\Http\Response; -use Illuminate\Support\Facades\Log; use Lcobucci\JWT\Builder; -use Lcobucci\JWT\Signer\Hmac\Sha256; +use Illuminate\Http\Request; use Lcobucci\JWT\Signer\Key; +use Illuminate\Http\Response; +use Illuminate\Http\JsonResponse; +use Illuminate\Support\Facades\Log; +use Lcobucci\JWT\Signer\Hmac\Sha256; +use Illuminate\Database\ConnectionInterface; +use Pterodactyl\Http\Controllers\Controller; +use Pterodactyl\Services\Servers\SuspensionService; +use Pterodactyl\Repositories\Eloquent\NodeRepository; +use Pterodactyl\Repositories\Eloquent\ServerRepository; +use Pterodactyl\Repositories\Wings\DaemonTransferRepository; use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface; use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException; -use Pterodactyl\Http\Controllers\Controller; -use Pterodactyl\Repositories\Eloquent\ServerRepository; -use Pterodactyl\Repositories\Eloquent\NodeRepository; -use Pterodactyl\Repositories\Wings\DaemonTransferRepository; use Pterodactyl\Services\Servers\ServerConfigurationStructureService; -use Pterodactyl\Services\Servers\SuspensionService; class ServerTransferController extends Controller { @@ -102,7 +102,7 @@ class ServerTransferController extends Controller $server = $this->repository->getByUuid($uuid); // Unsuspend the server and don't continue the transfer. - if (!$request->input('successful')) { + if (! $request->input('successful')) { $this->suspensionService->toggle($server, 'unsuspend'); return JsonResponse::create([], Response::HTTP_NO_CONTENT); } diff --git a/app/Models/Node.php b/app/Models/Node.php index 01335448e..a38458dd6 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -244,7 +244,8 @@ class Node extends Validable * @param int $disk * @return bool */ - public function isViable(int $memory, int $disk): bool { + public function isViable(int $memory, int $disk): bool + { $memoryLimit = $this->memory * (1 + ($this->memory_overallocate / 100)); $diskLimit = $this->disk * (1 + ($this->disk_overallocate / 100)); diff --git a/app/Repositories/Wings/DaemonTransferRepository.php b/app/Repositories/Wings/DaemonTransferRepository.php index 9c47478db..e8a514196 100644 --- a/app/Repositories/Wings/DaemonTransferRepository.php +++ b/app/Repositories/Wings/DaemonTransferRepository.php @@ -17,7 +17,8 @@ class DaemonTransferRepository extends DaemonRepository * * @throws DaemonConnectionException */ - public function notify(Server $server, array $data, Node $node, string $token): void { + public function notify(Server $server, array $data, Node $node, string $token): void + { try { $this->getHttpClient()->post('/api/transfer', [ 'json' => [ @@ -27,7 +28,7 @@ class DaemonTransferRepository extends DaemonRepository 'server' => $data, ], ]); - } catch(TransferException $exception) { + } catch (TransferException $exception) { throw new DaemonConnectionException($exception); } } diff --git a/app/Services/Servers/SuspensionService.php b/app/Services/Servers/SuspensionService.php index b2d4cb4e4..9fb95645d 100644 --- a/app/Services/Servers/SuspensionService.php +++ b/app/Services/Servers/SuspensionService.php @@ -2,7 +2,6 @@ namespace Pterodactyl\Services\Servers; -use Illuminate\Support\Facades\Log; use Psr\Log\LoggerInterface; use Webmozart\Assert\Assert; use Pterodactyl\Models\Server; @@ -74,14 +73,10 @@ class SuspensionService return; } - Log::debug('SuspensionService: ' . $action); - $this->connection->transaction(function () use ($action, $server) { $this->repository->withoutFreshModel()->update($server->id, [ 'suspended' => $action === self::ACTION_SUSPEND, ]); - Log::debug('Server suspended: ' . ($action === self::ACTION_SUSPEND) ? 'true' : 'false'); - Log::debug('Daemon unsuspended: ' . ($action === self::ACTION_UNSUSPEND) ? 'true' : 'false'); $this->daemonServerRepository->setServer($server)->suspend($action === self::ACTION_UNSUSPEND); }); diff --git a/app/Services/Servers/TransferService.php b/app/Services/Servers/TransferService.php index 924ad5d03..b45a78dc8 100644 --- a/app/Services/Servers/TransferService.php +++ b/app/Services/Servers/TransferService.php @@ -2,11 +2,9 @@ namespace Pterodactyl\Services\Servers; -use Illuminate\Database\ConnectionInterface; -use Psr\Log\LoggerInterface; -use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; use Pterodactyl\Models\Server; use Pterodactyl\Repositories\Wings\DaemonServerRepository; +use Pterodactyl\Contracts\Repository\ServerRepositoryInterface; class TransferService { diff --git a/database/migrations/2020_04_04_172331_add_successful_column_to_server_transfers.php b/database/migrations/2020_04_04_172331_add_successful_column_to_server_transfers.php index e65ad7aa0..83f183abf 100644 --- a/database/migrations/2020_04_04_172331_add_successful_column_to_server_transfers.php +++ b/database/migrations/2020_04_04_172331_add_successful_column_to_server_transfers.php @@ -1,8 +1,8 @@ '/servers/{uuid}'], function () { Route::get('/transfer/failure', 'Servers\ServerTransferController@failure'); Route::get('/transfer/success', 'Servers\ServerTransferController@success'); }); - -