From ae337d921644b41a0b5f17fa0a5568e78fff582d Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Fri, 30 Jun 2017 21:42:12 -0500 Subject: [PATCH 01/16] Bump version for release --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index 3c3fb772d..c049872c5 100644 --- a/config/app.php +++ b/config/app.php @@ -4,7 +4,7 @@ return [ 'env' => env('APP_ENV', 'production'), - 'version' => env('APP_VERSION', 'canary'), + 'version' => env('APP_VERSION', '0.6.4'), /* |-------------------------------------------------------------------------- From 58c16e706d3eb98ce28963b6e12243b0e8fc6ddb Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 17 Feb 2018 17:02:21 -0600 Subject: [PATCH 02/16] Bump for stable release :100: --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index 03742244b..1376becd6 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ return [ | change this value if you are not maintaining your own internal versions. */ - 'version' => 'canary', + 'version' => '0.7.0', /* |-------------------------------------------------------------------------- From 5d1d8a73988e5624915dad42e97931bbd5a7e126 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 18 Feb 2018 15:18:21 -0600 Subject: [PATCH 03/16] Bump for release --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index c1c94fa61..b1f233eb6 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ return [ | change this value if you are not maintaining your own internal versions. */ - 'version' => 'canary', + 'version' => '0.7.1', /* |-------------------------------------------------------------------------- From 2460d99eb64ded1758f8a2f05fa3e8d4471bc4d7 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 24 Feb 2018 16:28:05 -0600 Subject: [PATCH 04/16] bump for release --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index c1c94fa61..bb4b66015 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ return [ | change this value if you are not maintaining your own internal versions. */ - 'version' => 'canary', + 'version' => '0.7.2', /* |-------------------------------------------------------------------------- From 301ff759957770ff56bc9d515a8203634a7e0ea1 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 25 Feb 2018 16:23:16 -0600 Subject: [PATCH 05/16] bump for release --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index c1c94fa61..50ab9f19c 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ return [ | change this value if you are not maintaining your own internal versions. */ - 'version' => 'canary', + 'version' => '0.7.3', /* |-------------------------------------------------------------------------- From 95c1fe4fb726219a2c49e956e0023e6a995886eb Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Fri, 2 Mar 2018 21:28:30 -0600 Subject: [PATCH 06/16] bump for release :+1: --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index c1c94fa61..f95d7162d 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ return [ | change this value if you are not maintaining your own internal versions. */ - 'version' => 'canary', + 'version' => '0.7.4', /* |-------------------------------------------------------------------------- From 58e0dac4f9a584b00bba89527e52fc6b53a4973b Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Fri, 2 Mar 2018 23:14:24 -0600 Subject: [PATCH 07/16] Bump for hotfix --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index c1c94fa61..74c1b0266 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ return [ | change this value if you are not maintaining your own internal versions. */ - 'version' => 'canary', + 'version' => '0.7.4.1', /* |-------------------------------------------------------------------------- From 4e3dd288250dc774d985050c86ea10bc9eb30c5e Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 3 Mar 2018 22:24:52 -0600 Subject: [PATCH 08/16] bump for release --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index c1c94fa61..fe5ed34ca 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ return [ | change this value if you are not maintaining your own internal versions. */ - 'version' => 'canary', + 'version' => '0.7.5', /* |-------------------------------------------------------------------------- From e57fbd3fb4ca6865a9ed34cac7a3773d21200a8b Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 10 Mar 2018 15:20:27 -0600 Subject: [PATCH 09/16] Bump for release --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index c1c94fa61..12034dd00 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ return [ | change this value if you are not maintaining your own internal versions. */ - 'version' => 'canary', + 'version' => '0.7.6', /* |-------------------------------------------------------------------------- From 86c8ecdcdf1520729ab48e37e310faf38bef18d6 Mon Sep 17 00:00:00 2001 From: stanjg Date: Fri, 4 May 2018 15:02:51 +0200 Subject: [PATCH 10/16] Added the actual logic --- app/Http/Kernel.php | 2 ++ app/Http/Middleware/MaintenanceMiddleware.php | 27 ++++++++++++++++ app/Models/Node.php | 5 ++- app/Providers/RouteServiceProvider.php | 2 +- ..._05_04_123826_add_maintenance_to_nodes.php | 32 +++++++++++++++++++ resources/lang/en/base.php | 5 +++ .../pterodactyl/errors/maintenance.blade.php | 30 +++++++++++++++++ 7 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 app/Http/Middleware/MaintenanceMiddleware.php create mode 100644 database/migrations/2018_05_04_123826_add_maintenance_to_nodes.php create mode 100644 resources/themes/pterodactyl/errors/maintenance.blade.php diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index b6d44530e..db01e70c3 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -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) // diff --git a/app/Http/Middleware/MaintenanceMiddleware.php b/app/Http/Middleware/MaintenanceMiddleware.php new file mode 100644 index 000000000..493582809 --- /dev/null +++ b/app/Http/Middleware/MaintenanceMiddleware.php @@ -0,0 +1,27 @@ +attributes->get('server'); + $node = $server->node; + + if ($node->maintenance) { + return response(view('errors.maintenance')); + } + + return $next($request); + } +} diff --git a/app/Models/Node.php b/app/Models/Node.php index 26d9eb443..ea0258e8f 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -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, ]; /** diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 3de307d9a..3604b3d79 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -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')); diff --git a/database/migrations/2018_05_04_123826_add_maintenance_to_nodes.php b/database/migrations/2018_05_04_123826_add_maintenance_to_nodes.php new file mode 100644 index 000000000..6c55912aa --- /dev/null +++ b/database/migrations/2018_05_04_123826_add_maintenance_to_nodes.php @@ -0,0 +1,32 @@ +boolean('maintenance')->after('behind_proxy')->default(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('nodes', function (Blueprint $table) { + $table->dropColumn('maintenance'); + }); + } +} diff --git a/resources/lang/en/base.php b/resources/lang/en/base.php index ee3fb1f37..1603f4a17 100644 --- a/resources/lang/en/base.php +++ b/resources/lang/en/base.php @@ -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', diff --git a/resources/themes/pterodactyl/errors/maintenance.blade.php b/resources/themes/pterodactyl/errors/maintenance.blade.php new file mode 100644 index 000000000..97bb810e5 --- /dev/null +++ b/resources/themes/pterodactyl/errors/maintenance.blade.php @@ -0,0 +1,30 @@ +{{-- Pterodactyl - Panel --}} +{{-- Copyright (c) 2015 - 2017 Dane Everitt --}} + +{{-- 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') +
+
+
+
+

@lang('base.errors.maintenance.title')

+

@lang('base.errors.maintenance.desc')

+
+ +
+
+
+@endsection From baea1d61912d16ae76bc0841142d820cb706e6a9 Mon Sep 17 00:00:00 2001 From: stanjg Date: Fri, 4 May 2018 15:13:34 +0200 Subject: [PATCH 11/16] Added the option to toggle, and made it display on the details page --- .../pterodactyl/admin/nodes/view/index.blade.php | 11 +++++++++++ .../admin/nodes/view/settings.blade.php | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/resources/themes/pterodactyl/admin/nodes/view/index.blade.php b/resources/themes/pterodactyl/admin/nodes/view/index.blade.php index 76a2ca627..2880fba51 100644 --- a/resources/themes/pterodactyl/admin/nodes/view/index.blade.php +++ b/resources/themes/pterodactyl/admin/nodes/view/index.blade.php @@ -96,6 +96,17 @@
+ @if($node->maintenance) +
+
+ +
+ This node is under + Maintenance +
+
+
+ @endif
diff --git a/resources/themes/pterodactyl/admin/nodes/view/settings.blade.php b/resources/themes/pterodactyl/admin/nodes/view/settings.blade.php index 919ad958b..ba9a952b7 100644 --- a/resources/themes/pterodactyl/admin/nodes/view/settings.blade.php +++ b/resources/themes/pterodactyl/admin/nodes/view/settings.blade.php @@ -108,6 +108,20 @@

If you are running the daemon behind a proxy such as Cloudflare, select this to have the daemon skip looking for certificates on boot.

+
+ +
+
+ maintenance) == false) ? 'checked' : '' }}> + +
+
+ maintenance) == true) ? 'checked' : '' }}> + +
+
+

If the node is marked as 'Under Maintenance' users won't be able to access servers that are on this node.

+
From f39720f15db760e05a49c691d8b545d196e6592b Mon Sep 17 00:00:00 2001 From: stanjg Date: Fri, 4 May 2018 15:16:14 +0200 Subject: [PATCH 12/16] Made it display 'maintenance' on the index page --- resources/themes/pterodactyl/base/index.blade.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/resources/themes/pterodactyl/base/index.blade.php b/resources/themes/pterodactyl/base/index.blade.php index 95cce6128..09596298c 100644 --- a/resources/themes/pterodactyl/base/index.blade.php +++ b/resources/themes/pterodactyl/base/index.blade.php @@ -64,9 +64,15 @@ @lang('strings.subuser') @endif - - - + @if($server->node->maintenance) + + Maintenance + + @else + + + + @endif @if (! empty($server->description)) From 5a9d76a7e10c06c7a2ac434260025c5f172eba6f Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 26 May 2018 10:35:20 -0700 Subject: [PATCH 13/16] Revert "Merge branch 'master' into pr/1129" This reverts commit 35d108c41082eb7aa2328d0beb4366cf14cd450f, reversing changes made to f39720f15db760e05a49c691d8b545d196e6592b. --- config/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/app.php b/config/app.php index 70e4fe577..a7c196b3c 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ return [ | change this value if you are not maintaining your own internal versions. */ - 'version' => '0.7.6', + 'version' => 'canary', /* |-------------------------------------------------------------------------- From e648e50d90cf2c1893b44a5066b2774dbc0af84f Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 26 May 2018 11:00:28 -0700 Subject: [PATCH 14/16] Write some example tests for @stanjg --- app/Http/Middleware/MaintenanceMiddleware.php | 25 +++++-- resources/lang/en/base.php | 4 +- .../pterodactyl/errors/maintenance.blade.php | 2 +- .../Middleware/MaintenanceMiddlewareTest.php | 70 +++++++++++++++++++ 4 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 tests/Unit/Http/Middleware/MaintenanceMiddlewareTest.php diff --git a/app/Http/Middleware/MaintenanceMiddleware.php b/app/Http/Middleware/MaintenanceMiddleware.php index 493582809..39f260594 100644 --- a/app/Http/Middleware/MaintenanceMiddleware.php +++ b/app/Http/Middleware/MaintenanceMiddleware.php @@ -3,23 +3,40 @@ namespace Pterodactyl\Http\Middleware; use Closure; +use Illuminate\Contracts\Routing\ResponseFactory; class MaintenanceMiddleware { + /** + * @var \Illuminate\Contracts\Routing\ResponseFactory + */ + private $response; + + /** + * MaintenanceMiddleware constructor. + * + * @param \Illuminate\Contracts\Routing\ResponseFactory $response + */ + public function __construct(ResponseFactory $response) + { + $this->response = $response; + } + /** * Handle an incoming request. * - * @param \Illuminate\Http\Request $request - * @param \Closure $next + * @param \Illuminate\Http\Request $request + * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { + /** @var \Pterodactyl\Models\Server $server */ $server = $request->attributes->get('server'); - $node = $server->node; + $node = $server->getRelation('node'); if ($node->maintenance) { - return response(view('errors.maintenance')); + return $this->response->view('errors.maintenance'); } return $next($request); diff --git a/resources/lang/en/base.php b/resources/lang/en/base.php index 579aa1080..01ac79b1e 100644 --- a/resources/lang/en/base.php +++ b/resources/lang/en/base.php @@ -23,8 +23,8 @@ return [ ], 'maintenance' => [ 'header' => 'Node Under Maintenance', - 'title' => 'Maintenance', - 'desc' => 'This node is under maintenance, therefore your server can temporarily not be accessed.' + 'title' => 'Temporarily Unavailable', + 'desc' => 'This node is under maintenance, therefore your server can temporarily not be accessed.', ], ], 'index' => [ diff --git a/resources/themes/pterodactyl/errors/maintenance.blade.php b/resources/themes/pterodactyl/errors/maintenance.blade.php index 97bb810e5..8cc8eea27 100644 --- a/resources/themes/pterodactyl/errors/maintenance.blade.php +++ b/resources/themes/pterodactyl/errors/maintenance.blade.php @@ -17,7 +17,7 @@
-

@lang('base.errors.maintenance.title')

+

@lang('base.errors.maintenance.title')

@lang('base.errors.maintenance.desc')

- @if($node->maintenance) + @if($node->maintenance_mode)
diff --git a/resources/themes/pterodactyl/admin/nodes/view/settings.blade.php b/resources/themes/pterodactyl/admin/nodes/view/settings.blade.php index 0e042fab4..5afd65ed4 100644 --- a/resources/themes/pterodactyl/admin/nodes/view/settings.blade.php +++ b/resources/themes/pterodactyl/admin/nodes/view/settings.blade.php @@ -109,15 +109,15 @@

If you are running the daemon behind a proxy such as Cloudflare, select this to have the daemon skip looking for certificates on boot.

- +
- maintenance) == false) ? 'checked' : '' }}> - + maintenance_mode) == false) ? 'checked' : '' }}> +
- maintenance) == true) ? 'checked' : '' }}> - + maintenance_mode) == true) ? 'checked' : '' }}> +

If the node is marked as 'Under Maintenance' users won't be able to access servers that are on this node.

diff --git a/resources/themes/pterodactyl/base/index.blade.php b/resources/themes/pterodactyl/base/index.blade.php index 09596298c..28f4c4d57 100644 --- a/resources/themes/pterodactyl/base/index.blade.php +++ b/resources/themes/pterodactyl/base/index.blade.php @@ -64,9 +64,9 @@ @lang('strings.subuser') @endif - @if($server->node->maintenance) + @if($server->node->maintenance_mode) - Maintenance + @lang('strings.under_maintenance') @else From ccf3e3511f6344239dcc49ed7dbcb667c7f0461a Mon Sep 17 00:00:00 2001 From: stanjg Date: Thu, 31 May 2018 16:40:18 +0200 Subject: [PATCH 16/16] Renamed middleware, and fixed the test --- app/Http/Kernel.php | 2 +- app/Providers/RouteServiceProvider.php | 2 +- tests/Unit/Http/Middleware/MaintenanceMiddlewareTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 4221672e9..d21c8d3c8 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -109,7 +109,7 @@ class Kernel extends HttpKernel 'can' => Authorize::class, 'bindings' => SubstituteBindings::class, 'recaptcha' => VerifyReCaptcha::class, - 'maintenance' => MaintenanceMiddleware::class, + 'node.maintenance' => MaintenanceMiddleware::class, // Server specific middleware (used for authenticating access to resources) // diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 3604b3d79..f0e978116 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -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', 'maintenance'])->prefix('/server/{server}') + Route::middleware(['web', 'csrf', 'auth', 'server', 'subuser.auth', 'node.maintenance'])->prefix('/server/{server}') ->namespace($this->namespace . '\Server') ->group(base_path('routes/server.php')); diff --git a/tests/Unit/Http/Middleware/MaintenanceMiddlewareTest.php b/tests/Unit/Http/Middleware/MaintenanceMiddlewareTest.php index 6b7380f3b..fedeaa0c6 100644 --- a/tests/Unit/Http/Middleware/MaintenanceMiddlewareTest.php +++ b/tests/Unit/Http/Middleware/MaintenanceMiddlewareTest.php @@ -46,7 +46,7 @@ class MaintenanceMiddlewareTest extends MiddlewareTestCase public function testHandleInMaintenanceMode() { $server = factory(Server::class)->make(); - $node = factory(Node::class)->make(['maintenance' => 1]); + $node = factory(Node::class)->make(['maintenance_mode' => 1]); $server->setRelation('node', $node); $this->setRequestAttribute('server', $server);