Skip to content

Commit be47565

Browse files
committed
Update to match new installer processing.
1 parent 4719b20 commit be47565

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

app/Http/Controllers/Remote/RemoteController.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
namespace Pterodactyl\Http\Controllers\Remote;
2525

26-
use Pterodactyl\Models\Download;
26+
use Pterodactyl\Models;
2727
use Pterodactyl\Exceptions\DisplayException;
2828

2929
use Pterodactyl\Http\Controllers\Controller;
@@ -41,7 +41,7 @@ public function __construct()
4141
}
4242

4343
public function postDownload(Request $request) {
44-
$download = Download::where('token', $request->input('token', '00'))->first();
44+
$download = Models\Download::where('token', $request->input('token', '00'))->first();
4545
if (!$download) {
4646
return response()->json([
4747
'error' => 'An invalid request token was recieved with this request.'
@@ -55,4 +55,31 @@ public function postDownload(Request $request) {
5555
]);
5656
}
5757

58+
public function postInstall(Request $request)
59+
{
60+
$server = Models\Server::where('uuid', $request->input('server'))->first();
61+
if (!$server) {
62+
return response()->json([
63+
'error' => 'No server by that ID was found on the system.'
64+
], 422);
65+
}
66+
67+
$node = Models\Node::findOrFail($server->node);
68+
$hmac = $request->input('signed');
69+
$status = $request->input('installed');
70+
71+
if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $node->daemonSecret, true)) {
72+
return response()->json([
73+
'error' => 'Signed HMAC was invalid.'
74+
], 403);
75+
}
76+
77+
$server->installed = ($status === 'installed') ? 1 : 2;
78+
$server->save();
79+
80+
return response()->json([
81+
'message' => 'Recieved!'
82+
], 200);
83+
}
84+
5885
}

app/Http/Routes/RemoteRoutes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public function map(Router $router) {
3535
'as' => 'remote.download',
3636
'uses' => 'Remote\RemoteController@postDownload'
3737
]);
38+
39+
$router->post('install', [
40+
'as' => 'remote.install',
41+
'uses' => 'Remote\RemoteController@postInstall'
42+
]);
3843
});
3944
}
4045

resources/views/admin/nodes/view.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@
289289
"count": 3
290290
},
291291
"remote": {
292-
"download": "{{ url('/remote/download') }}"
292+
"download": "{{ route('remote.download') }}",
293+
"installed": "{{ route('remote.install') }}"
293294
},
294295
"uploads": {
295296
"maximumSize": 1000000

resources/views/admin/servers/view.blade.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@
3232
<li><a href="/admin/servers">Servers</a></li>
3333
<li class="active">{{ $server->name }} ({{ $server->uuidShort}})</li>
3434
</ul>
35+
@if($server->installed === 0)
36+
<div class="alert alert-warning">
37+
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.
38+
</div>
39+
@elseif($server->installed === 2)
40+
<div class="alert alert-danger">
41+
This server <strong>failed</strong> to install properly. You should delete it and try to create it again or check the daemon logs.
42+
</div>
43+
@endif
3544
<ul class="nav nav-tabs tabs_with_panel" id="config_tabs">
3645
<li class="active"><a href="#tab_about" data-toggle="tab">About</a></li>
3746
<li><a href="#tab_details" data-toggle="tab">Details</a></li>

0 commit comments

Comments
 (0)