2016-01-05 04:59:45 +00:00
|
|
|
<?php
|
2016-01-20 00:10:39 +00:00
|
|
|
/**
|
2016-01-20 21:05:16 +00:00
|
|
|
* Pterodactyl - Panel
|
2017-01-24 22:57:08 +00:00
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
2016-01-20 00:10:39 +00:00
|
|
|
*
|
2017-09-26 02:43:01 +00:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2016-01-20 00:10:39 +00:00
|
|
|
*/
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2016-01-05 04:59:45 +00:00
|
|
|
namespace Pterodactyl\Http\Controllers\Admin;
|
|
|
|
|
2017-03-03 22:30:39 +00:00
|
|
|
use Javascript;
|
2016-12-07 22:46:38 +00:00
|
|
|
use Illuminate\Http\Request;
|
2017-08-05 22:26:30 +00:00
|
|
|
use Pterodactyl\Models\Node;
|
|
|
|
use Prologue\Alerts\AlertsMessageBag;
|
2016-01-05 04:59:45 +00:00
|
|
|
use Pterodactyl\Http\Controllers\Controller;
|
2017-08-27 20:10:51 +00:00
|
|
|
use Pterodactyl\Services\Nodes\NodeUpdateService;
|
2017-08-31 02:14:20 +00:00
|
|
|
use Illuminate\Cache\Repository as CacheRepository;
|
2017-08-27 20:10:51 +00:00
|
|
|
use Pterodactyl\Services\Nodes\NodeCreationService;
|
|
|
|
use Pterodactyl\Services\Nodes\NodeDeletionService;
|
2017-08-06 02:10:32 +00:00
|
|
|
use Pterodactyl\Services\Allocations\AssignmentService;
|
2017-09-11 05:27:43 +00:00
|
|
|
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
2017-08-06 02:10:32 +00:00
|
|
|
use Pterodactyl\Http\Requests\Admin\Node\NodeFormRequest;
|
2017-08-05 22:26:30 +00:00
|
|
|
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
|
2017-08-06 02:10:32 +00:00
|
|
|
use Pterodactyl\Http\Requests\Admin\Node\AllocationFormRequest;
|
2017-08-05 22:26:30 +00:00
|
|
|
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
2017-08-06 02:10:32 +00:00
|
|
|
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
|
|
|
|
use Pterodactyl\Http\Requests\Admin\Node\AllocationAliasFormRequest;
|
2016-01-05 04:59:45 +00:00
|
|
|
|
|
|
|
class NodesController extends Controller
|
|
|
|
{
|
2017-08-05 22:20:07 +00:00
|
|
|
/**
|
|
|
|
* @var \Prologue\Alerts\AlertsMessageBag
|
|
|
|
*/
|
|
|
|
protected $alert;
|
|
|
|
|
2017-08-06 02:10:32 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $allocationRepository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Services\Allocations\AssignmentService
|
|
|
|
*/
|
|
|
|
protected $assignmentService;
|
|
|
|
|
2017-08-05 22:20:07 +00:00
|
|
|
/**
|
|
|
|
* @var \Illuminate\Cache\Repository
|
|
|
|
*/
|
|
|
|
protected $cache;
|
|
|
|
|
|
|
|
/**
|
2017-08-27 20:10:51 +00:00
|
|
|
* @var \Pterodactyl\Services\Nodes\NodeCreationService
|
2017-08-05 22:20:07 +00:00
|
|
|
*/
|
|
|
|
protected $creationService;
|
|
|
|
|
|
|
|
/**
|
2017-08-27 20:10:51 +00:00
|
|
|
* @var \Pterodactyl\Services\Nodes\NodeDeletionService
|
2017-08-05 22:20:07 +00:00
|
|
|
*/
|
|
|
|
protected $deletionService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $locationRepository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $repository;
|
|
|
|
|
|
|
|
/**
|
2017-08-27 20:10:51 +00:00
|
|
|
* @var \Pterodactyl\Services\Nodes\NodeUpdateService
|
2017-08-05 22:20:07 +00:00
|
|
|
*/
|
|
|
|
protected $updateService;
|
|
|
|
|
2017-09-11 05:27:43 +00:00
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
|
|
|
|
*/
|
|
|
|
protected $versionService;
|
|
|
|
|
2017-08-06 02:10:32 +00:00
|
|
|
/**
|
|
|
|
* NodesController constructor.
|
|
|
|
*
|
|
|
|
* @param \Prologue\Alerts\AlertsMessageBag $alert
|
|
|
|
* @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $allocationRepository
|
|
|
|
* @param \Pterodactyl\Services\Allocations\AssignmentService $assignmentService
|
|
|
|
* @param \Illuminate\Cache\Repository $cache
|
2017-08-27 20:10:51 +00:00
|
|
|
* @param \Pterodactyl\Services\Nodes\NodeCreationService $creationService
|
|
|
|
* @param \Pterodactyl\Services\Nodes\NodeDeletionService $deletionService
|
2017-08-06 02:10:32 +00:00
|
|
|
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
|
|
|
|
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository
|
2017-08-27 20:10:51 +00:00
|
|
|
* @param \Pterodactyl\Services\Nodes\NodeUpdateService $updateService
|
2017-09-11 05:27:43 +00:00
|
|
|
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $versionService
|
2017-08-06 02:10:32 +00:00
|
|
|
*/
|
2017-08-05 22:20:07 +00:00
|
|
|
public function __construct(
|
|
|
|
AlertsMessageBag $alert,
|
2017-08-06 02:10:32 +00:00
|
|
|
AllocationRepositoryInterface $allocationRepository,
|
|
|
|
AssignmentService $assignmentService,
|
2017-08-05 22:20:07 +00:00
|
|
|
CacheRepository $cache,
|
2017-08-27 20:10:51 +00:00
|
|
|
NodeCreationService $creationService,
|
|
|
|
NodeDeletionService $deletionService,
|
2017-08-05 22:20:07 +00:00
|
|
|
LocationRepositoryInterface $locationRepository,
|
|
|
|
NodeRepositoryInterface $repository,
|
2017-09-11 05:27:43 +00:00
|
|
|
NodeUpdateService $updateService,
|
|
|
|
SoftwareVersionService $versionService
|
2017-08-05 22:20:07 +00:00
|
|
|
) {
|
|
|
|
$this->alert = $alert;
|
2017-08-06 02:10:32 +00:00
|
|
|
$this->allocationRepository = $allocationRepository;
|
|
|
|
$this->assignmentService = $assignmentService;
|
2017-08-05 22:20:07 +00:00
|
|
|
$this->cache = $cache;
|
|
|
|
$this->creationService = $creationService;
|
|
|
|
$this->deletionService = $deletionService;
|
|
|
|
$this->locationRepository = $locationRepository;
|
|
|
|
$this->repository = $repository;
|
|
|
|
$this->updateService = $updateService;
|
2017-09-11 05:27:43 +00:00
|
|
|
$this->versionService = $versionService;
|
2017-08-05 22:20:07 +00:00
|
|
|
}
|
|
|
|
|
2016-01-05 04:59:45 +00:00
|
|
|
/**
|
2017-03-04 04:37:41 +00:00
|
|
|
* Displays the index page listing all nodes on the panel.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
2017-03-04 04:37:41 +00:00
|
|
|
* @return \Illuminate\View\View
|
2016-01-05 04:59:45 +00:00
|
|
|
*/
|
2017-03-04 04:37:41 +00:00
|
|
|
public function index(Request $request)
|
2016-01-05 04:59:45 +00:00
|
|
|
{
|
2017-08-05 22:20:07 +00:00
|
|
|
return view('admin.nodes.index', [
|
2018-01-05 04:49:50 +00:00
|
|
|
'nodes' => $this->repository->setSearchTerm($request->input('query'))->getNodeListingData(),
|
2017-08-05 22:20:07 +00:00
|
|
|
]);
|
2016-01-05 04:59:45 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 04:37:41 +00:00
|
|
|
/**
|
|
|
|
* Displays create new node page.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
2017-03-04 04:37:41 +00:00
|
|
|
*/
|
2017-08-05 22:20:07 +00:00
|
|
|
public function create()
|
2016-01-05 04:59:45 +00:00
|
|
|
{
|
2017-08-05 22:20:07 +00:00
|
|
|
$locations = $this->locationRepository->all();
|
|
|
|
if (count($locations) < 1) {
|
2017-08-09 02:21:10 +00:00
|
|
|
$this->alert->warning(trans('admin/node.notices.location_required'))->flash();
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2016-09-30 20:05:39 +00:00
|
|
|
return redirect()->route('admin.locations');
|
|
|
|
}
|
|
|
|
|
2017-03-04 04:37:41 +00:00
|
|
|
return view('admin.nodes.new', ['locations' => $locations]);
|
2016-01-05 04:59:45 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 04:37:41 +00:00
|
|
|
/**
|
|
|
|
* Post controller to create a new node on the system.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Http\Requests\Admin\Node\NodeFormRequest $request
|
2017-03-19 23:36:50 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-08-05 22:20:07 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2017-03-04 04:37:41 +00:00
|
|
|
*/
|
2017-08-05 22:20:07 +00:00
|
|
|
public function store(NodeFormRequest $request)
|
2016-01-05 04:59:45 +00:00
|
|
|
{
|
2017-08-05 22:20:07 +00:00
|
|
|
$node = $this->creationService->handle($request->normalize());
|
2017-08-09 02:21:10 +00:00
|
|
|
$this->alert->info(trans('admin/node.notices.node_created'))->flash();
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2017-08-05 22:20:07 +00:00
|
|
|
return redirect()->route('admin.nodes.view.allocation', $node->id);
|
2016-01-05 04:59:45 +00:00
|
|
|
}
|
|
|
|
|
2017-03-03 22:30:39 +00:00
|
|
|
/**
|
|
|
|
* Shows the index overview page for a specific node.
|
|
|
|
*
|
2018-01-05 04:49:50 +00:00
|
|
|
* @param \Pterodactyl\Models\Node $node
|
2017-03-03 22:30:39 +00:00
|
|
|
* @return \Illuminate\View\View
|
2017-08-21 00:23:50 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-03 22:30:39 +00:00
|
|
|
*/
|
2018-01-05 04:49:50 +00:00
|
|
|
public function viewIndex(Node $node)
|
2017-03-03 22:30:39 +00:00
|
|
|
{
|
2017-08-05 22:20:07 +00:00
|
|
|
return view('admin.nodes.view.index', [
|
2018-01-05 04:49:50 +00:00
|
|
|
'node' => $this->repository->loadLocationAndServerCount($node),
|
2017-08-05 22:20:07 +00:00
|
|
|
'stats' => $this->repository->getUsageStats($node),
|
2017-09-11 05:27:43 +00:00
|
|
|
'version' => $this->versionService,
|
2017-08-05 22:20:07 +00:00
|
|
|
]);
|
2017-03-03 22:30:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the settings page for a specific node.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Models\Node $node
|
2017-03-03 22:30:39 +00:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
2017-08-05 22:20:07 +00:00
|
|
|
public function viewSettings(Node $node)
|
2017-03-03 22:30:39 +00:00
|
|
|
{
|
|
|
|
return view('admin.nodes.view.settings', [
|
2017-08-05 22:20:07 +00:00
|
|
|
'node' => $node,
|
|
|
|
'locations' => $this->locationRepository->all(),
|
2017-03-03 22:30:39 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the configuration page for a specific node.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Models\Node $node
|
2017-03-03 22:30:39 +00:00
|
|
|
* @return \Illuminate\View\View
|
|
|
|
*/
|
2017-08-05 22:20:07 +00:00
|
|
|
public function viewConfiguration(Node $node)
|
2017-03-03 22:30:39 +00:00
|
|
|
{
|
2017-08-05 22:20:07 +00:00
|
|
|
return view('admin.nodes.view.configuration', ['node' => $node]);
|
2017-03-03 22:30:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the allocation page for a specific node.
|
|
|
|
*
|
2018-01-05 04:49:50 +00:00
|
|
|
* @param \Pterodactyl\Models\Node $node
|
2017-03-03 22:30:39 +00:00
|
|
|
* @return \Illuminate\View\View
|
2017-08-21 00:23:50 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-03 22:30:39 +00:00
|
|
|
*/
|
2018-01-05 04:49:50 +00:00
|
|
|
public function viewAllocation(Node $node)
|
2017-03-03 22:30:39 +00:00
|
|
|
{
|
2018-01-05 04:49:50 +00:00
|
|
|
$this->repository->loadNodeAllocations($node);
|
2017-08-05 22:20:07 +00:00
|
|
|
Javascript::put(['node' => collect($node)->only(['id'])]);
|
2017-03-03 22:30:39 +00:00
|
|
|
|
|
|
|
return view('admin.nodes.view.allocation', ['node' => $node]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the server listing page for a specific node.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param int $node
|
2017-03-03 22:30:39 +00:00
|
|
|
* @return \Illuminate\View\View
|
2017-08-21 00:23:50 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-03 22:30:39 +00:00
|
|
|
*/
|
2017-08-05 22:20:07 +00:00
|
|
|
public function viewServers($node)
|
2017-03-03 22:30:39 +00:00
|
|
|
{
|
2017-08-05 22:20:07 +00:00
|
|
|
$node = $this->repository->getNodeServers($node);
|
2017-03-03 22:30:39 +00:00
|
|
|
Javascript::put([
|
|
|
|
'node' => collect($node->makeVisible('daemonSecret'))->only(['scheme', 'fqdn', 'daemonListen', 'daemonSecret']),
|
|
|
|
]);
|
|
|
|
|
2017-08-05 22:20:07 +00:00
|
|
|
return view('admin.nodes.view.servers', ['node' => $node]);
|
2017-03-03 22:30:39 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 04:14:23 +00:00
|
|
|
/**
|
|
|
|
* Updates settings for a node.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Http\Requests\Admin\Node\NodeFormRequest $request
|
|
|
|
* @param \Pterodactyl\Models\Node $node
|
2017-03-04 04:14:23 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-08-05 22:20:07 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2017-09-30 17:40:07 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-04 04:14:23 +00:00
|
|
|
*/
|
2017-08-05 22:20:07 +00:00
|
|
|
public function updateSettings(NodeFormRequest $request, Node $node)
|
2016-01-05 23:31:25 +00:00
|
|
|
{
|
2017-08-05 22:20:07 +00:00
|
|
|
$this->updateService->handle($node, $request->normalize());
|
2017-08-09 02:21:10 +00:00
|
|
|
$this->alert->success(trans('admin/node.notices.node_updated'))->flash();
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2017-08-05 22:20:07 +00:00
|
|
|
return redirect()->route('admin.nodes.view.settings', $node->id)->withInput();
|
2016-01-05 23:31:25 +00:00
|
|
|
}
|
|
|
|
|
2017-03-03 22:30:39 +00:00
|
|
|
/**
|
|
|
|
* Removes a single allocation from a node.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param int $node
|
|
|
|
* @param int $allocation
|
2017-03-04 04:14:23 +00:00
|
|
|
* @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
|
2017-03-03 22:30:39 +00:00
|
|
|
*/
|
2017-08-06 02:10:32 +00:00
|
|
|
public function allocationRemoveSingle($node, $allocation)
|
2016-01-09 01:01:18 +00:00
|
|
|
{
|
2017-08-09 02:21:10 +00:00
|
|
|
$this->allocationRepository->deleteWhere([
|
|
|
|
['id', '=', $allocation],
|
|
|
|
['node_id', '=', $node],
|
|
|
|
['server_id', '=', null],
|
|
|
|
]);
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2016-01-09 01:01:18 +00:00
|
|
|
return response('', 204);
|
|
|
|
}
|
|
|
|
|
2017-03-03 22:30:39 +00:00
|
|
|
/**
|
|
|
|
* Remove all allocations for a specific IP at once on a node.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param int $node
|
2017-03-04 04:14:23 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-03-03 22:30:39 +00:00
|
|
|
*/
|
|
|
|
public function allocationRemoveBlock(Request $request, $node)
|
2016-09-30 01:34:20 +00:00
|
|
|
{
|
2017-08-09 02:21:10 +00:00
|
|
|
$this->allocationRepository->deleteWhere([
|
|
|
|
['node_id', '=', $node],
|
|
|
|
['server_id', '=', null],
|
|
|
|
['ip', '=', $request->input('ip')],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->alert->success(trans('admin/node.notices.unallocated_deleted', ['ip' => $request->input('ip')]))
|
|
|
|
->flash();
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2017-03-03 22:30:39 +00:00
|
|
|
return redirect()->route('admin.nodes.view.allocation', $node);
|
2016-09-30 01:34:20 +00:00
|
|
|
}
|
|
|
|
|
2017-03-03 22:30:39 +00:00
|
|
|
/**
|
|
|
|
* Sets an alias for a specific allocation on a node.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Http\Requests\Admin\Node\AllocationAliasFormRequest $request
|
2017-08-21 00:23:50 +00:00
|
|
|
* @return \Symfony\Component\HttpFoundation\Response
|
2017-08-06 02:10:32 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2017-08-21 00:23:50 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-03-03 22:30:39 +00:00
|
|
|
*/
|
2017-08-06 02:10:32 +00:00
|
|
|
public function allocationSetAlias(AllocationAliasFormRequest $request)
|
2016-09-30 01:34:20 +00:00
|
|
|
{
|
2017-08-06 02:10:32 +00:00
|
|
|
$this->allocationRepository->update($request->input('allocation_id'), [
|
|
|
|
'ip_alias' => (empty($request->input('alias'))) ? null : $request->input('alias'),
|
|
|
|
]);
|
2016-09-30 01:34:20 +00:00
|
|
|
|
2017-08-06 02:10:32 +00:00
|
|
|
return response('', 204);
|
2016-09-30 01:34:20 +00:00
|
|
|
}
|
|
|
|
|
2017-03-03 22:30:39 +00:00
|
|
|
/**
|
|
|
|
* Creates new allocations on a node.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Http\Requests\Admin\Node\AllocationFormRequest $request
|
|
|
|
* @param int|\Pterodactyl\Models\Node $node
|
2017-03-03 22:30:39 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-08-06 02:10:32 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
2017-03-03 22:30:39 +00:00
|
|
|
*/
|
2017-08-06 02:10:32 +00:00
|
|
|
public function createAllocation(AllocationFormRequest $request, Node $node)
|
2016-01-10 05:38:16 +00:00
|
|
|
{
|
2017-08-06 02:10:32 +00:00
|
|
|
$this->assignmentService->handle($node, $request->normalize());
|
2017-08-09 02:21:10 +00:00
|
|
|
$this->alert->success(trans('admin/node.notices.allocations_added'))->flash();
|
2016-09-30 21:12:36 +00:00
|
|
|
|
2017-08-06 02:10:32 +00:00
|
|
|
return redirect()->route('admin.nodes.view.allocation', $node->id);
|
2017-03-03 22:30:39 +00:00
|
|
|
}
|
2016-01-10 05:38:16 +00:00
|
|
|
|
2017-03-04 04:14:23 +00:00
|
|
|
/**
|
|
|
|
* Deletes a node from the system.
|
|
|
|
*
|
2017-08-05 22:20:07 +00:00
|
|
|
* @param $node
|
2017-03-04 04:14:23 +00:00
|
|
|
* @return \Illuminate\Http\RedirectResponse
|
2017-08-05 22:20:07 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
2017-03-04 04:14:23 +00:00
|
|
|
*/
|
2017-08-05 22:20:07 +00:00
|
|
|
public function delete($node)
|
2017-03-03 22:30:39 +00:00
|
|
|
{
|
2017-08-05 22:20:07 +00:00
|
|
|
$this->deletionService->handle($node);
|
2017-08-09 02:21:10 +00:00
|
|
|
$this->alert->success(trans('admin/node.notices.node_deleted'))->flash();
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2017-08-05 22:20:07 +00:00
|
|
|
return redirect()->route('admin.nodes');
|
2016-01-10 21:59:19 +00:00
|
|
|
}
|
2017-01-07 17:10:11 +00:00
|
|
|
|
2017-03-04 04:14:23 +00:00
|
|
|
/**
|
|
|
|
* Returns the configuration token to auto-deploy a node.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param \Pterodactyl\Models\Node $node
|
2017-03-04 04:14:23 +00:00
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
*/
|
2017-08-05 22:20:07 +00:00
|
|
|
public function setToken(Node $node)
|
2017-01-07 17:39:41 +00:00
|
|
|
{
|
2017-08-05 22:20:07 +00:00
|
|
|
$token = bin2hex(random_bytes(16));
|
|
|
|
$this->cache->tags(['Node:Configuration'])->put($token, $node->id, 5);
|
2017-03-04 04:14:23 +00:00
|
|
|
|
2017-05-01 18:21:18 +00:00
|
|
|
return response()->json(['token' => $token]);
|
2017-01-07 17:10:11 +00:00
|
|
|
}
|
2016-01-05 04:59:45 +00:00
|
|
|
}
|