mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 05:14:46 +02:00
Discard ipAddresses cache if wings is offline + Switch to Select (#862)
* Change TextInputColumn to SelectColumn * Discard cache if wings is offline * Return 0.0.0.0 instead of an empty array * Adjustment & remove dns resolve
This commit is contained in:
parent
77fd54fdc2
commit
ae445840f7
@ -16,6 +16,7 @@ use Filament\Resources\RelationManagers\RelationManager;
|
|||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\BulkActionGroup;
|
use Filament\Tables\Actions\BulkActionGroup;
|
||||||
use Filament\Tables\Actions\DeleteBulkAction;
|
use Filament\Tables\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Tables\Columns\SelectColumn;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Columns\TextInputColumn;
|
use Filament\Tables\Columns\TextInputColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
@ -69,7 +70,9 @@ class AllocationsRelationManager extends RelationManager
|
|||||||
TextInputColumn::make('ip_alias')
|
TextInputColumn::make('ip_alias')
|
||||||
->searchable()
|
->searchable()
|
||||||
->label('Alias'),
|
->label('Alias'),
|
||||||
TextInputColumn::make('ip')
|
SelectColumn::make('ip')
|
||||||
|
->options(fn (Allocation $allocation) => collect($this->getOwnerRecord()->ipAddresses())->merge([$allocation->ip])->mapWithKeys(fn (string $ip) => [$ip => $ip]))
|
||||||
|
->selectablePlaceholder(false)
|
||||||
->searchable()
|
->searchable()
|
||||||
->label('IP'),
|
->label('IP'),
|
||||||
])
|
])
|
||||||
|
@ -374,24 +374,21 @@ class Node extends Model
|
|||||||
{
|
{
|
||||||
return cache()->remember("nodes.$this->id.ips", now()->addHour(), function () {
|
return cache()->remember("nodes.$this->id.ips", now()->addHour(), function () {
|
||||||
$ips = collect();
|
$ips = collect();
|
||||||
if (is_ip($this->fqdn)) {
|
|
||||||
$ips = $ips->push($this->fqdn);
|
|
||||||
} elseif ($dnsRecords = gethostbynamel($this->fqdn)) {
|
|
||||||
$ips = $ips->concat($dnsRecords);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$addresses = Http::daemon($this)->connectTimeout(1)->timeout(1)->get('/api/system/ips')->json();
|
$addresses = Http::daemon($this)->connectTimeout(1)->timeout(1)->get('/api/system/ips')->json();
|
||||||
$ips = $ips->concat(fluent($addresses)->get('ip_addresses'));
|
$ips = $ips->concat(fluent($addresses)->get('ip_addresses'));
|
||||||
} catch (Exception) {
|
} catch (Exception) {
|
||||||
// pass
|
if (is_ip($this->fqdn)) {
|
||||||
|
$ips->push($this->fqdn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ips->push('0.0.0.0');
|
|
||||||
|
|
||||||
// Only IPV4
|
// Only IPV4
|
||||||
$ips = $ips->filter(fn (string $ip) => filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false);
|
$ips = $ips->filter(fn (string $ip) => filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false);
|
||||||
|
|
||||||
|
$ips->push('0.0.0.0');
|
||||||
|
|
||||||
return $ips->unique()->all();
|
return $ips->unique()->all();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user