From be47565c782cfb73b7a5f9359e48f3653ebf8ee7 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Fri, 22 Jan 2016 20:31:47 -0500 Subject: [PATCH] Update to match new installer processing. --- .../Controllers/Remote/RemoteController.php | 31 +++++++++++++++++-- app/Http/Routes/RemoteRoutes.php | 5 +++ resources/views/admin/nodes/view.blade.php | 3 +- resources/views/admin/servers/view.blade.php | 9 ++++++ 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Remote/RemoteController.php b/app/Http/Controllers/Remote/RemoteController.php index 1f57cba95..ccbfdf445 100644 --- a/app/Http/Controllers/Remote/RemoteController.php +++ b/app/Http/Controllers/Remote/RemoteController.php @@ -23,7 +23,7 @@ */ namespace Pterodactyl\Http\Controllers\Remote; -use Pterodactyl\Models\Download; +use Pterodactyl\Models; use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Http\Controllers\Controller; @@ -41,7 +41,7 @@ class RemoteController extends Controller } public function postDownload(Request $request) { - $download = Download::where('token', $request->input('token', '00'))->first(); + $download = Models\Download::where('token', $request->input('token', '00'))->first(); if (!$download) { return response()->json([ 'error' => 'An invalid request token was recieved with this request.' @@ -55,4 +55,31 @@ class RemoteController extends Controller ]); } + public function postInstall(Request $request) + { + $server = Models\Server::where('uuid', $request->input('server'))->first(); + if (!$server) { + return response()->json([ + 'error' => 'No server by that ID was found on the system.' + ], 422); + } + + $node = Models\Node::findOrFail($server->node); + $hmac = $request->input('signed'); + $status = $request->input('installed'); + + if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $node->daemonSecret, true)) { + return response()->json([ + 'error' => 'Signed HMAC was invalid.' + ], 403); + } + + $server->installed = ($status === 'installed') ? 1 : 2; + $server->save(); + + return response()->json([ + 'message' => 'Recieved!' + ], 200); + } + } diff --git a/app/Http/Routes/RemoteRoutes.php b/app/Http/Routes/RemoteRoutes.php index d600161a5..713d31c0f 100644 --- a/app/Http/Routes/RemoteRoutes.php +++ b/app/Http/Routes/RemoteRoutes.php @@ -35,6 +35,11 @@ class RemoteRoutes { 'as' => 'remote.download', 'uses' => 'Remote\RemoteController@postDownload' ]); + + $router->post('install', [ + 'as' => 'remote.install', + 'uses' => 'Remote\RemoteController@postInstall' + ]); }); } diff --git a/resources/views/admin/nodes/view.blade.php b/resources/views/admin/nodes/view.blade.php index 94bbb8966..b390bb221 100644 --- a/resources/views/admin/nodes/view.blade.php +++ b/resources/views/admin/nodes/view.blade.php @@ -289,7 +289,8 @@ "count": 3 }, "remote": { - "download": "{{ url('/remote/download') }}" + "download": "{{ route('remote.download') }}", + "installed": "{{ route('remote.install') }}" }, "uploads": { "maximumSize": 1000000 diff --git a/resources/views/admin/servers/view.blade.php b/resources/views/admin/servers/view.blade.php index 89cf1d3b6..c3c7896b9 100644 --- a/resources/views/admin/servers/view.blade.php +++ b/resources/views/admin/servers/view.blade.php @@ -32,6 +32,15 @@
  • Servers
  • {{ $server->name }} ({{ $server->uuidShort}})
  • + @if($server->installed === 0) +
    + This server is still running through the install process and is not avaliable for use just yet. This message will disappear once this process is completed. +
    + @elseif($server->installed === 2) +
    + This server failed to install properly. You should delete it and try to create it again or check the daemon logs. +
    + @endif