Allocation limit added

This commit is contained in:
AVMG20 2021-07-05 20:47:29 +02:00
parent 6499941166
commit 6a431edd8b
3 changed files with 14 additions and 3 deletions

View file

@ -2,6 +2,7 @@
namespace App\Classes; namespace App\Classes;
use App\Models\Configuration;
use App\Models\Egg; use App\Models\Egg;
use App\Models\Nest; use App\Models\Nest;
use App\Models\Node; use App\Models\Node;
@ -124,7 +125,8 @@ class Pterodactyl
*/ */
public static function getAllocations(Node $node) public static function getAllocations(Node $node)
{ {
$response = self::client()->get("/application/nodes/{$node->id}/allocations"); $per_page = Configuration::getValueByKey('ALLOCATION_LIMIT' , 200);
$response = self::client()->get("/application/nodes/{$node->id}/allocations?per_page={$per_page}");
if ($response->failed()) throw self::getException(); if ($response->failed()) throw self::getException();
return $response->json(); return $response->json();
} }

View file

@ -2,8 +2,6 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\UsefulLink;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;

View file

@ -109,5 +109,16 @@ class ConfigurationSeeder extends Seeder
'type' => 'boolean', 'type' => 'boolean',
'description' => 'Prevent users from making multiple accounts using the same IP address' 'description' => 'Prevent users from making multiple accounts using the same IP address'
]); ]);
//per_page on allocations request
Configuration::firstOrCreate([
'key' => 'ALLOCATION_LIMIT',
], [
'value' => '200',
'type' => 'integer',
'description' => 'The maximum amount of allocations to pull per node for automatic deployment, if more allocations are being used than this limit is set to, no new servers can be created!'
]);
} }
} }