Merge branch 'develop' into feature/api-v1
# Conflicts: # app/Contracts/Repository/RepositoryInterface.php # app/Repositories/Eloquent/EloquentRepository.php # app/Services/Nodes/NodeUpdateService.php # tests/Unit/Services/Nodes/NodeUpdateServiceTest.php
This commit is contained in:
commit
800e2df6b2
187 changed files with 1878 additions and 3143 deletions
|
@ -139,7 +139,6 @@ class DatabaseController extends Controller
|
|||
* @param int $host
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
|
|
|
@ -126,7 +126,7 @@ class NodesController extends Controller
|
|||
public function index(Request $request)
|
||||
{
|
||||
return view('admin.nodes.index', [
|
||||
'nodes' => $this->repository->search($request->input('query'))->getNodeListingData(),
|
||||
'nodes' => $this->repository->setSearchTerm($request->input('query'))->getNodeListingData(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -166,15 +166,15 @@ class NodesController extends Controller
|
|||
/**
|
||||
* Shows the index overview page for a specific node.
|
||||
*
|
||||
* @param int $node
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function viewIndex($node)
|
||||
public function viewIndex(Node $node)
|
||||
{
|
||||
return view('admin.nodes.view.index', [
|
||||
'node' => $this->repository->getSingleNode($node),
|
||||
'node' => $this->repository->loadLocationAndServerCount($node),
|
||||
'stats' => $this->repository->getUsageStats($node),
|
||||
'version' => $this->versionService,
|
||||
]);
|
||||
|
@ -208,17 +208,18 @@ class NodesController extends Controller
|
|||
/**
|
||||
* Shows the allocation page for a specific node.
|
||||
*
|
||||
* @param int $node
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function viewAllocation($node)
|
||||
public function viewAllocation(Node $node)
|
||||
{
|
||||
$node = $this->repository->getNodeAllocations($node);
|
||||
$this->repository->loadNodeAllocations($node);
|
||||
Javascript::put(['node' => collect($node)->only(['id'])]);
|
||||
|
||||
return view('admin.nodes.view.allocation', ['node' => $node]);
|
||||
return view('admin.nodes.view.allocation', [
|
||||
'allocations' => $this->allocationRepository->setColumns(['ip'])->getUniqueAllocationIpsForNode($node->id),
|
||||
'node' => $node,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -114,9 +114,7 @@ class PackController extends Controller
|
|||
public function index(Request $request)
|
||||
{
|
||||
return view('admin.packs.index', [
|
||||
'packs' => $this->repository->search($request->input('query'))->paginateWithEggAndServerCount(
|
||||
$this->config->get('pterodactyl.paginate.admin.packs')
|
||||
),
|
||||
'packs' => $this->repository->setSearchTerm($request->input('query'))->paginateWithEggAndServerCount(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -177,14 +175,14 @@ class PackController extends Controller
|
|||
/**
|
||||
* Display pack view template to user.
|
||||
*
|
||||
* @param int $pack
|
||||
* @param \Pterodactyl\Models\Pack $pack
|
||||
* @return \Illuminate\View\View
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function view($pack)
|
||||
public function view(Pack $pack)
|
||||
{
|
||||
return view('admin.packs.view', [
|
||||
'pack' => $this->repository->getWithServers($pack),
|
||||
'pack' => $this->repository->loadServerData($pack),
|
||||
'nests' => $this->serviceRepository->getWithEggs(),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -254,6 +254,7 @@ class ServersController extends Controller
|
|||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(ServerFormRequest $request)
|
||||
{
|
||||
|
@ -352,14 +353,12 @@ class ServersController extends Controller
|
|||
/**
|
||||
* Display the database management page for a specific server.
|
||||
*
|
||||
* @param int $server
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function viewDatabase($server)
|
||||
public function viewDatabase(Server $server)
|
||||
{
|
||||
$server = $this->repository->getWithDatabases($server);
|
||||
$this->repository->loadDatabaseRelations($server);
|
||||
|
||||
return view('admin.servers.view.database', [
|
||||
'hosts' => $this->databaseHostRepository->all(),
|
||||
|
@ -459,12 +458,10 @@ class ServersController extends Controller
|
|||
*
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function rebuildContainer(Server $server)
|
||||
{
|
||||
$this->containerRebuildService->rebuild($server);
|
||||
$this->containerRebuildService->handle($server);
|
||||
$this->alert->success(trans('admin/server.alerts.rebuild_on_boot'))->flash();
|
||||
|
||||
return redirect()->route('admin.servers.view.manage', $server->id);
|
||||
|
|
|
@ -83,7 +83,7 @@ class UserController extends Controller
|
|||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$users = $this->repository->search($request->input('query'))->getAllUsersWithCounts();
|
||||
$users = $this->repository->setSearchTerm($request->input('query'))->getAllUsersWithCounts();
|
||||
|
||||
return view('admin.users.index', ['users' => $users]);
|
||||
}
|
||||
|
|
|
@ -1,31 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>
|
||||
* Some Modifications (c) 2015 Dylan Seidt <dylan.seidt@gmail.com>.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Base;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Models\User;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
@ -75,8 +53,8 @@ class IndexController extends Controller
|
|||
*/
|
||||
public function getIndex(Request $request)
|
||||
{
|
||||
$servers = $this->repository->search($request->input('query'))->filterUserAccessServers(
|
||||
$request->user()->id, $request->user()->root_admin, 'all', ['user']
|
||||
$servers = $this->repository->setSearchTerm($request->input('query'))->filterUserAccessServers(
|
||||
$request->user(), User::FILTER_LEVEL_ALL
|
||||
);
|
||||
|
||||
return view('base.index', ['servers' => $servers]);
|
||||
|
@ -102,10 +80,7 @@ class IndexController extends Controller
|
|||
}
|
||||
|
||||
try {
|
||||
$response = $this->daemonRepository->setNode($server->node_id)
|
||||
->setAccessServer($server->uuid)
|
||||
->setAccessToken($token)
|
||||
->details();
|
||||
$response = $this->daemonRepository->setServer($server)->setToken($token)->details();
|
||||
} catch (RequestException $exception) {
|
||||
throw new HttpException(500, $exception->getMessage());
|
||||
}
|
||||
|
|
|
@ -96,7 +96,6 @@ class FileActionsController extends Controller
|
|||
* @return \Illuminate\View\View
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function view(UpdateFileContentsFormRequest $request, string $uuid, string $file): View
|
||||
{
|
||||
|
@ -104,9 +103,7 @@ class FileActionsController extends Controller
|
|||
|
||||
$dirname = pathinfo($file, PATHINFO_DIRNAME);
|
||||
try {
|
||||
$content = $this->repository->setNode($server->node_id)->setAccessServer($server->uuid)
|
||||
->setAccessToken($request->attributes->get('server_token'))
|
||||
->getContent($file);
|
||||
$content = $this->repository->setServer($server)->setToken($request->attributes->get('server_token'))->getContent($file);
|
||||
} catch (RequestException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
}
|
||||
|
|
|
@ -66,10 +66,7 @@ class RemoteRequestController extends Controller
|
|||
}
|
||||
|
||||
try {
|
||||
$listing = $this->repository->setNode($server->node_id)
|
||||
->setAccessServer($server->uuid)
|
||||
->setAccessToken($request->attributes->get('server_token'))
|
||||
->getDirectory($requestDirectory);
|
||||
$listing = $this->repository->setServer($server)->setToken($request->attributes->get('server_token'))->getDirectory($requestDirectory);
|
||||
} catch (RequestException $exception) {
|
||||
throw new DaemonConnectionException($exception, true);
|
||||
}
|
||||
|
@ -90,7 +87,6 @@ class RemoteRequestController extends Controller
|
|||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function store(Request $request): Response
|
||||
{
|
||||
|
@ -98,9 +94,7 @@ class RemoteRequestController extends Controller
|
|||
$this->authorize('save-files', $server);
|
||||
|
||||
try {
|
||||
$this->repository->setNode($server->node_id)
|
||||
->setAccessServer($server->uuid)
|
||||
->setAccessToken($request->attributes->get('server_token'))
|
||||
$this->repository->setServer($server)->setToken($request->attributes->get('server_token'))
|
||||
->putContent($request->input('file'), $request->input('contents') ?? '');
|
||||
|
||||
return response('', 204);
|
||||
|
|
70
app/Http/Controllers/Server/Tasks/ActionController.php
Normal file
70
app/Http/Controllers/Server/Tasks/ActionController.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Controllers\Server\Tasks;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Pterodactyl\Services\Schedules\ProcessScheduleService;
|
||||
use Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface;
|
||||
|
||||
class ActionController extends Controller
|
||||
{
|
||||
private $processScheduleService;
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ScheduleRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
public function __construct(ProcessScheduleService $processScheduleService, ScheduleRepositoryInterface $repository)
|
||||
{
|
||||
$this->processScheduleService = $processScheduleService;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle a task to be active or inactive for a given server.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function toggle(Request $request): Response
|
||||
{
|
||||
$server = $request->attributes->get('server');
|
||||
$schedule = $request->attributes->get('schedule');
|
||||
$this->authorize('toggle-schedule', $server);
|
||||
|
||||
$this->repository->update($schedule->id, [
|
||||
'is_active' => ! $schedule->is_active,
|
||||
]);
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger a schedule to run now.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function trigger(Request $request): Response
|
||||
{
|
||||
$server = $request->attributes->get('server');
|
||||
$this->authorize('toggle-schedule', $server);
|
||||
|
||||
$this->processScheduleService->setRunTimeOverride(Carbon::now())->handle(
|
||||
$request->attributes->get('schedule')
|
||||
);
|
||||
|
||||
return response('', 204);
|
||||
}
|
||||
}
|
|
@ -112,7 +112,7 @@ class TaskManagementController extends Controller
|
|||
$server = $request->attributes->get('server');
|
||||
|
||||
$schedule = $this->creationService->handle($server, $request->normalize(), $request->getTasks());
|
||||
$this->alert->success(trans('server.schedules.task_created'))->flash();
|
||||
$this->alert->success(trans('server.schedule.task_created'))->flash();
|
||||
|
||||
return redirect()->route('server.schedules.view', [
|
||||
'server' => $server->uuidShort,
|
||||
|
|
|
@ -34,6 +34,7 @@ class DaemonAuthenticate
|
|||
* Create a new filter instance.
|
||||
*
|
||||
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository
|
||||
* @deprecated
|
||||
*/
|
||||
public function __construct(NodeRepositoryInterface $repository)
|
||||
{
|
||||
|
@ -47,6 +48,7 @@ class DaemonAuthenticate
|
|||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
|
@ -59,7 +61,7 @@ class DaemonAuthenticate
|
|||
throw new AccessDeniedHttpException;
|
||||
}
|
||||
|
||||
$node = $this->repository->findWhere(['daemonSecret' => $request->header('X-Access-Node')]);
|
||||
$node = $this->repository->findFirstWhere(['daemonSecret' => $request->header('X-Access-Node')]);
|
||||
$request->attributes->set('node', $node);
|
||||
|
||||
return $next($request);
|
||||
|
|
|
@ -20,7 +20,7 @@ class AllocationFormRequest extends AdminFormRequest
|
|||
{
|
||||
return [
|
||||
'allocation_ip' => 'required|string',
|
||||
'allocation_alias' => 'sometimes|string|max:255',
|
||||
'allocation_alias' => 'sometimes|nullable|string|max:255',
|
||||
'allocation_ports' => 'required|array',
|
||||
];
|
||||
}
|
||||
|
|
|
@ -21,7 +21,10 @@ class ServerFormRequest extends AdminFormRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
return Server::getCreateRules();
|
||||
$rules = Server::getCreateRules();
|
||||
$rules['description'][] = 'nullable';
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,7 +69,6 @@ class UpdateFileContentsFormRequest extends ServerFormRequest
|
|||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException
|
||||
* @throws \Pterodactyl\Exceptions\Http\Server\FileTypeNotEditableException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
private function checkFileCanBeEdited($server, $token)
|
||||
{
|
||||
|
@ -77,9 +76,7 @@ class UpdateFileContentsFormRequest extends ServerFormRequest
|
|||
$repository = app()->make(FileRepositoryInterface::class);
|
||||
|
||||
try {
|
||||
$stats = $repository->setNode($server->node_id)->setAccessServer($server->uuid)
|
||||
->setAccessToken($token)
|
||||
->getFileStat($this->route()->parameter('file'));
|
||||
$stats = $repository->setServer($server)->setToken($token)->getFileStat($this->route()->parameter('file'));
|
||||
} catch (RequestException $exception) {
|
||||
switch ($exception->getCode()) {
|
||||
case 404:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue