From 838b9a9093bc3beb643cdc2cf5c9894eb10fb4c4 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 1 Mar 2018 18:46:59 -0600 Subject: [PATCH] Add support for filesystem caching, closes #993 --- .../Commands/Environment/AppSettingsCommand.php | 1 + app/Http/Controllers/Admin/NodesController.php | 2 +- app/Http/Controllers/Daemon/ActionController.php | 11 ++--------- .../Controllers/Server/Files/DownloadController.php | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/app/Console/Commands/Environment/AppSettingsCommand.php b/app/Console/Commands/Environment/AppSettingsCommand.php index ecf171adc..17c2b5bbc 100644 --- a/app/Console/Commands/Environment/AppSettingsCommand.php +++ b/app/Console/Commands/Environment/AppSettingsCommand.php @@ -22,6 +22,7 @@ class AppSettingsCommand extends Command const ALLOWED_CACHE_DRIVERS = [ 'redis' => 'Redis (recommended)', 'memcached' => 'Memcached', + 'file' => 'Filesystem', ]; const ALLOWED_SESSION_DRIVERS = [ diff --git a/app/Http/Controllers/Admin/NodesController.php b/app/Http/Controllers/Admin/NodesController.php index a67abf9d1..0d0dd187b 100644 --- a/app/Http/Controllers/Admin/NodesController.php +++ b/app/Http/Controllers/Admin/NodesController.php @@ -366,7 +366,7 @@ class NodesController extends Controller public function setToken(Node $node) { $token = bin2hex(random_bytes(16)); - $this->cache->tags(['Node:Configuration'])->put($token, $node->id, 5); + $this->cache->put('Node:Configuration:' . $token, $node->id, 5); return response()->json(['token' => $token]); } diff --git a/app/Http/Controllers/Daemon/ActionController.php b/app/Http/Controllers/Daemon/ActionController.php index 1c67ec6cd..64c0a0c21 100644 --- a/app/Http/Controllers/Daemon/ActionController.php +++ b/app/Http/Controllers/Daemon/ActionController.php @@ -1,11 +1,4 @@ . - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ namespace Pterodactyl\Http\Controllers\Daemon; @@ -25,7 +18,7 @@ class ActionController extends Controller */ public function authenticateDownload(Request $request) { - $download = Cache::tags(['Server:Downloads'])->pull($request->input('token')); + $download = Cache::pull('Server:Downloads:' . $request->input('token')); if (is_null($download)) { return response()->json([ @@ -78,7 +71,7 @@ class ActionController extends Controller */ public function configuration(Request $request, $token) { - $nodeId = Cache::tags(['Node:Configuration'])->pull($token); + $nodeId = Cache::pull('Node:Configuration:' . $token); if (is_null($nodeId)) { return response()->json(['error' => 'token_invalid'], 403); } diff --git a/app/Http/Controllers/Server/Files/DownloadController.php b/app/Http/Controllers/Server/Files/DownloadController.php index 79155a63a..06a31f9e5 100644 --- a/app/Http/Controllers/Server/Files/DownloadController.php +++ b/app/Http/Controllers/Server/Files/DownloadController.php @@ -48,7 +48,7 @@ class DownloadController extends Controller $token = str_random(40); $node = $server->getRelation('node'); - $this->cache->tags(['Server:Downloads'])->put($token, ['server' => $server->uuid, 'path' => $file], 5); + $this->cache->put('Server:Downloads:' . $token, ['server' => $server->uuid, 'path' => $file], 5); return redirect(sprintf('%s://%s:%s/v1/server/file/download/%s', $node->scheme, $node->fqdn, $node->daemonListen, $token)); }