Added the actual logic
This commit is contained in:
parent
7cf79a12cb
commit
86c8ecdcdf
7 changed files with 101 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http;
|
||||
|
||||
use Pterodactyl\Http\Middleware\MaintenanceMiddleware;
|
||||
use Pterodactyl\Models\ApiKey;
|
||||
use Illuminate\Auth\Middleware\Authorize;
|
||||
use Illuminate\Auth\Middleware\Authenticate;
|
||||
|
@ -108,6 +109,7 @@ class Kernel extends HttpKernel
|
|||
'can' => Authorize::class,
|
||||
'bindings' => SubstituteBindings::class,
|
||||
'recaptcha' => VerifyReCaptcha::class,
|
||||
'maintenance' => MaintenanceMiddleware::class,
|
||||
|
||||
// Server specific middleware (used for authenticating access to resources)
|
||||
//
|
||||
|
|
27
app/Http/Middleware/MaintenanceMiddleware.php
Normal file
27
app/Http/Middleware/MaintenanceMiddleware.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class MaintenanceMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$server = $request->attributes->get('server');
|
||||
$node = $server->node;
|
||||
|
||||
if ($node->maintenance) {
|
||||
return response(view('errors.maintenance'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -48,6 +48,7 @@ class Node extends Model implements CleansAttributes, ValidableContract
|
|||
'daemonSFTP' => 'integer',
|
||||
'behind_proxy' => 'boolean',
|
||||
'public' => 'boolean',
|
||||
'maintenance' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -62,7 +63,7 @@ class Node extends Model implements CleansAttributes, ValidableContract
|
|||
'disk_overallocate', 'upload_size',
|
||||
'daemonSecret', 'daemonBase',
|
||||
'daemonSFTP', 'daemonListen',
|
||||
'description',
|
||||
'description', 'maintenance',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -111,6 +112,7 @@ class Node extends Model implements CleansAttributes, ValidableContract
|
|||
'daemonBase' => 'regex:/^([\/][\d\w.\-\/]+)$/',
|
||||
'daemonSFTP' => 'numeric|between:1024,65535',
|
||||
'daemonListen' => 'numeric|between:1024,65535',
|
||||
'maintenance' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -126,6 +128,7 @@ class Node extends Model implements CleansAttributes, ValidableContract
|
|||
'daemonBase' => '/srv/daemon-data',
|
||||
'daemonSFTP' => 2022,
|
||||
'daemonListen' => 8080,
|
||||
'maintenance' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ class RouteServiceProvider extends ServiceProvider
|
|||
->namespace($this->namespace . '\Auth')
|
||||
->group(base_path('routes/auth.php'));
|
||||
|
||||
Route::middleware(['web', 'csrf', 'auth', 'server', 'subuser.auth'])->prefix('/server/{server}')
|
||||
Route::middleware(['web', 'csrf', 'auth', 'server', 'subuser.auth', 'maintenance'])->prefix('/server/{server}')
|
||||
->namespace($this->namespace . '\Server')
|
||||
->group(base_path('routes/server.php'));
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddMaintenanceToNodes extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('nodes', function (Blueprint $table) {
|
||||
$table->boolean('maintenance')->after('behind_proxy')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('nodes', function (Blueprint $table) {
|
||||
$table->dropColumn('maintenance');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -21,6 +21,11 @@ return [
|
|||
'header' => 'Server Suspended',
|
||||
'desc' => 'This server has been suspended and cannot be accessed.',
|
||||
],
|
||||
'maintenance' => [
|
||||
'header' => 'Node Under Maintenance',
|
||||
'title' => 'Maintenance',
|
||||
'desc' => 'This node is under maintenance, therefore your server can temporarily not be accessed.'
|
||||
],
|
||||
],
|
||||
'index' => [
|
||||
'header' => 'Your Servers',
|
||||
|
|
30
resources/themes/pterodactyl/errors/maintenance.blade.php
Normal file
30
resources/themes/pterodactyl/errors/maintenance.blade.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
{{-- Pterodactyl - Panel --}}
|
||||
{{-- Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com> --}}
|
||||
|
||||
{{-- This software is licensed under the terms of the MIT license. --}}
|
||||
{{-- https://opensource.org/licenses/MIT --}}
|
||||
@extends('layouts.error')
|
||||
|
||||
@section('title')
|
||||
@lang('base.errors.maintenance.header')
|
||||
@endsection
|
||||
|
||||
@section('content-header')
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2 col-sm-10 col-sm-offset-1 col-xs-12">
|
||||
<div class="box box-danger">
|
||||
<div class="box-body text-center">
|
||||
<h1 class="text-red" style="font-size: 160px !important;font-weight: 100 !important;">@lang('base.errors.maintenance.title')</h1>
|
||||
<p class="text-muted">@lang('base.errors.maintenance.desc')</p>
|
||||
</div>
|
||||
<div class="box-footer with-border">
|
||||
<a href="{{ URL::previous() }}"><button class="btn btn-danger">← @lang('base.errors.return')</button></a>
|
||||
<a href="/"><button class="btn btn-default">@lang('base.errors.home')</button></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
Loading…
Reference in a new issue