Move old /remote routes into /daemon sphere.
This commit is contained in:
parent
d7e52435ee
commit
2330c25a8c
6 changed files with 17 additions and 75 deletions
|
@ -22,14 +22,15 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Pterodactyl\Http\Controllers\Remote;
|
namespace Pterodactyl\Http\Controllers\Daemon;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Pterodactyl\Models;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Pterodactyl\Models\Server;
|
||||||
|
use Pterodactyl\Models\Download;
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
|
use Pterodactyl\Models\NodeConfigurationToken;
|
||||||
|
|
||||||
class RemoteController extends Controller
|
class ActionController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Handles download request from daemon.
|
* Handles download request from daemon.
|
||||||
|
@ -37,9 +38,9 @@ class RemoteController extends Controller
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function postDownload(Request $request)
|
public function authenticateDownload(Request $request)
|
||||||
{
|
{
|
||||||
$download = Models\Download::where('token', $request->input('token'))->first();
|
$download = Download::where('token', $request->input('token'))->first();
|
||||||
if (! $download) {
|
if (! $download) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'error' => 'An invalid request token was recieved with this request.',
|
'error' => 'An invalid request token was recieved with this request.',
|
||||||
|
@ -60,9 +61,9 @@ class RemoteController extends Controller
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function postInstall(Request $request)
|
public function markInstall(Request $request)
|
||||||
{
|
{
|
||||||
$server = Models\Server::where('uuid', $request->input('server'))->with('node')->first();
|
$server = Server::where('uuid', $request->input('server'))->with('node')->first();
|
||||||
if (! $server) {
|
if (! $server) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'error' => 'No server by that ID was found on the system.',
|
'error' => 'No server by that ID was found on the system.',
|
||||||
|
@ -72,7 +73,7 @@ class RemoteController extends Controller
|
||||||
$hmac = $request->input('signed');
|
$hmac = $request->input('signed');
|
||||||
$status = $request->input('installed');
|
$status = $request->input('installed');
|
||||||
|
|
||||||
if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $server->node->daemonSecret, true)) {
|
if (! hash_equals(base64_decode($hmac), hash_hmac('sha256', $server->uuid, $server->node->daemonSecret, true))) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'error' => 'Signed HMAC was invalid.',
|
'error' => 'Signed HMAC was invalid.',
|
||||||
], 403);
|
], 403);
|
||||||
|
@ -81,35 +82,7 @@ class RemoteController extends Controller
|
||||||
$server->installed = ($status === 'installed') ? 1 : 2;
|
$server->installed = ($status === 'installed') ? 1 : 2;
|
||||||
$server->save();
|
$server->save();
|
||||||
|
|
||||||
return response()->json([
|
return response('', 204);
|
||||||
'message' => 'Recieved!',
|
|
||||||
], 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles event from daemon.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public function event(Request $request)
|
|
||||||
{
|
|
||||||
$server = Models\Server::where('uuid', $request->input('server'))->with('node')->first();
|
|
||||||
if (! $server) {
|
|
||||||
return response()->json([
|
|
||||||
'error' => 'No server by that ID was found on the system.',
|
|
||||||
], 422);
|
|
||||||
}
|
|
||||||
|
|
||||||
$hmac = $request->input('signed');
|
|
||||||
if (base64_decode($hmac) !== hash_hmac('sha256', $server->uuid, $server->node->daemonSecret, true)) {
|
|
||||||
return response()->json([
|
|
||||||
'error' => 'Signed HMAC was invalid.',
|
|
||||||
], 403);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response('', 201);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,11 +92,11 @@ class RemoteController extends Controller
|
||||||
* @param string $token
|
* @param string $token
|
||||||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function getConfiguration(Request $request, $token)
|
public function configuration(Request $request, $token)
|
||||||
{
|
{
|
||||||
// Try to query the token and the node from the database
|
// Try to query the token and the node from the database
|
||||||
try {
|
try {
|
||||||
$model = Models\NodeConfigurationToken::with('node')->where('token', $token)->firstOrFail();
|
$model = NodeConfigurationToken::with('node')->where('token', $token)->firstOrFail();
|
||||||
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
|
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
|
||||||
return response()->json(['error' => 'token_invalid'], 403);
|
return response()->json(['error' => 'token_invalid'], 403);
|
||||||
}
|
}
|
|
@ -145,8 +145,6 @@ class Node extends Model
|
||||||
],
|
],
|
||||||
'remote' => [
|
'remote' => [
|
||||||
'base' => route('index'),
|
'base' => route('index'),
|
||||||
'download' => route('remote.download'),
|
|
||||||
'installed' => route('remote.install'),
|
|
||||||
],
|
],
|
||||||
'uploads' => [
|
'uploads' => [
|
||||||
'size_limit' => $this->upload_size,
|
'size_limit' => $this->upload_size,
|
||||||
|
|
|
@ -57,10 +57,6 @@ class RouteServiceProvider extends ServiceProvider
|
||||||
->namespace($this->namespace . '\Server')
|
->namespace($this->namespace . '\Server')
|
||||||
->group(base_path('routes/server.php'));
|
->group(base_path('routes/server.php'));
|
||||||
|
|
||||||
Route::middleware(['web'])->prefix('/remote')
|
|
||||||
->namespace($this->namespace . '\Remote')
|
|
||||||
->group(base_path('routes/remote.php'));
|
|
||||||
|
|
||||||
Route::middleware(['web', 'daemon'])->prefix('/daemon')
|
Route::middleware(['web', 'daemon'])->prefix('/daemon')
|
||||||
->namespace($this->namespace . '\Daemon')
|
->namespace($this->namespace . '\Daemon')
|
||||||
->group(base_path('routes/daemon.php'));
|
->group(base_path('routes/daemon.php'));
|
||||||
|
|
|
@ -177,8 +177,6 @@ class NodeRepository
|
||||||
],
|
],
|
||||||
'remote' => [
|
'remote' => [
|
||||||
'base' => config('app.url'),
|
'base' => config('app.url'),
|
||||||
'download' => route('remote.download'),
|
|
||||||
'installed' => route('remote.install'),
|
|
||||||
],
|
],
|
||||||
'uploads' => [
|
'uploads' => [
|
||||||
'size_limit' => $node->upload_size,
|
'size_limit' => $node->upload_size,
|
||||||
|
|
|
@ -26,3 +26,7 @@ Route::get('/services/pull/{service}/{file}', 'ServiceController@pull')->name('d
|
||||||
Route::get('/packs/pull/{uuid}', 'PackController@pull')->name('daemon.pack.pull');
|
Route::get('/packs/pull/{uuid}', 'PackController@pull')->name('daemon.pack.pull');
|
||||||
Route::get('/packs/pull/{uuid}/hash', 'PackController@hash')->name('daemon.pack.hash');
|
Route::get('/packs/pull/{uuid}/hash', 'PackController@hash')->name('daemon.pack.hash');
|
||||||
Route::get('/details/option/{server}', 'OptionController@details')->name('daemon.option.details');
|
Route::get('/details/option/{server}', 'OptionController@details')->name('daemon.option.details');
|
||||||
|
Route::get('/configure/{token}', 'ActionController@configuration')->name('daemon.configuration');
|
||||||
|
|
||||||
|
Route::post('/download', 'ActionController@authentiateDownload')->name('daemon.download');
|
||||||
|
Route::post('/install', 'ActionController@markInstall')->name('daemon.install');
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Pterodactyl - Panel
|
|
||||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.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.
|
|
||||||
*/
|
|
||||||
Route::get('/configuration/{token}', 'RemoteController@getConfiguration')->name('remote.configuration');
|
|
||||||
|
|
||||||
Route::post('/download', 'RemoteController@postDownload')->name('remote.download');
|
|
||||||
Route::post('/install', 'RemoteController@postInstall')->name('remote.install');
|
|
Loading…
Reference in a new issue