mirror of
https://github.com/pelican-dev/panel.git
synced 2025-06-19 06:41:16 +02:00
Refactor
This commit is contained in:
parent
69acc48b5e
commit
3fa714c7e3
@ -5,6 +5,7 @@ namespace App\Filament\Resources\ServerResource\Pages;
|
|||||||
use App\Filament\Resources\ServerResource;
|
use App\Filament\Resources\ServerResource;
|
||||||
use App\Models\Egg;
|
use App\Models\Egg;
|
||||||
use App\Models\Node;
|
use App\Models\Node;
|
||||||
|
use App\Models\Objects\Endpoint;
|
||||||
use App\Services\Servers\RandomWordService;
|
use App\Services\Servers\RandomWordService;
|
||||||
use App\Services\Servers\ServerCreationService;
|
use App\Services\Servers\ServerCreationService;
|
||||||
use Filament\Forms\Components\Actions\Action;
|
use Filament\Forms\Components\Actions\Action;
|
||||||
@ -664,30 +665,27 @@ class CreateServer extends CreateRecord
|
|||||||
public function ports($state, Forms\Set $set)
|
public function ports($state, Forms\Set $set)
|
||||||
{
|
{
|
||||||
$ports = collect();
|
$ports = collect();
|
||||||
$update = false;
|
|
||||||
foreach ($state as $portEntry) {
|
foreach ($state as $portEntry) {
|
||||||
if (!str_contains($portEntry, '-')) {
|
if (str_contains($portEntry, '-')) {
|
||||||
if (is_numeric($portEntry)) {
|
|
||||||
$ports->push((int) $portEntry);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
[$start, $end] = explode('-', $portEntry);
|
[$start, $end] = explode('-', $portEntry);
|
||||||
if (!is_numeric($start) || !is_numeric($end)) {
|
if (!is_numeric($start) || !is_numeric($end)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$start = max((int) $start, 0);
|
$start = max((int) $start, Endpoint::PORT_FLOOR);
|
||||||
$end = min((int) $end, 2 ** 16 - 1);
|
$end = min((int) $end, Endpoint::PORT_CEIL);
|
||||||
for ($i = $start; $i <= $end; $i++) {
|
for ($i = $start; $i <= $end; $i++) {
|
||||||
$ports->push($i);
|
$ports->push($i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_numeric($portEntry)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ports->push((int) $portEntry);
|
||||||
|
}
|
||||||
|
|
||||||
$uniquePorts = $ports->unique()->values();
|
$uniquePorts = $ports->unique()->values();
|
||||||
if ($ports->count() > $uniquePorts->count()) {
|
if ($ports->count() > $uniquePorts->count()) {
|
||||||
$ports = $uniquePorts;
|
$ports = $uniquePorts;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user