Add unknown MC status placeholder to cache

This commit is contained in:
Miguel Nogueira 2021-10-12 23:01:15 +01:00
parent d8e836980a
commit 92679e94d5
Signed by: miguel456
GPG Key ID: 2CF61B825316C6A0
1 changed files with 6 additions and 0 deletions

View File

@ -28,6 +28,8 @@ class MojangStatusProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
$unknown_status = '[{"minecraft.net":"red"},{"session.minecraft.net":"red"},{"account.mojang.com":"red"},{"authserver.mojang.com":"red"},{"sessionserver.mojang.com":"red"},{"api.mojang.com":"red"},{"textures.minecraft.net":"red"},{"mojang.com":"red"}]';
// TODO: (IMPORTANT) Switch this to Middleware // TODO: (IMPORTANT) Switch this to Middleware
if (!Cache::has('mojang_status')) if (!Cache::has('mojang_status'))
{ {
@ -40,6 +42,10 @@ class MojangStatusProvider extends ServiceProvider
} }
catch(ConnectionException $connectException) catch(ConnectionException $connectException)
{ {
// Shorter TTL because mojang status server might have recovered
Cache::put('mojang_status', base64_encode($unknown_status), now()->addMinutes(60));
Log::alert('Writing unknown Mojang status placeholder to cache');
Log::critical('Could not connect to Mojang servers: Cannot check/refresh status', [ Log::critical('Could not connect to Mojang servers: Cannot check/refresh status', [
'message' => $connectException->getMessage() 'message' => $connectException->getMessage()
]); ]);