Added the actual logic

This commit is contained in:
stanjg 2018-05-04 15:02:51 +02:00
parent 7cf79a12cb
commit 86c8ecdcdf
No known key found for this signature in database
GPG key ID: 27D9DF9D28935303
7 changed files with 101 additions and 2 deletions

View file

@ -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)
//

View 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);
}
}

View file

@ -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,
];
/**

View file

@ -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'));

View file

@ -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');
});
}
}

View file

@ -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',

View 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">&larr; @lang('base.errors.return')</button></a>
<a href="/"><button class="btn btn-default">@lang('base.errors.home')</button></a>
</div>
</div>
</div>
</div>
@endsection