Fix default value for dns check on EditNode (#635)

This commit is contained in:
Boy132 2024-10-18 08:24:49 +02:00 committed by GitHub
parent ff0215afed
commit 207d875df8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -83,7 +83,7 @@ class EditNode extends EditRecord
if (request()->isSecure()) { if (request()->isSecure()) {
return ' return '
Your panel is currently secured via an SSL certificate and that means your nodes require one too. Your panel is currently secured via an SSL certificate and that means your nodes require one too.
You must use a domain name, because you cannot get SSL certificates for IP Addresses You must use a domain name, because you cannot get SSL certificates for IP Addresses.
'; ';
} }
@ -98,7 +98,7 @@ class EditNode extends EditRecord
->hintColor('danger') ->hintColor('danger')
->hint(function ($state) { ->hint(function ($state) {
if (is_ip($state) && request()->isSecure()) { if (is_ip($state) && request()->isSecure()) {
return 'You cannot connect to an IP Address over SSL'; return 'You cannot connect to an IP Address over SSL!';
} }
return ''; return '';
@ -130,11 +130,9 @@ class EditNode extends EditRecord
$set('dns', false); $set('dns', false);
}) })
->maxLength(255), ->maxLength(255),
TextInput::make('ip') TextInput::make('ip')
->disabled() ->disabled()
->hidden(), ->hidden(),
ToggleButtons::make('dns') ToggleButtons::make('dns')
->label('DNS Record Check') ->label('DNS Record Check')
->helperText('This lets you know if your DNS record correctly points to an IP Address.') ->helperText('This lets you know if your DNS record correctly points to an IP Address.')
@ -157,7 +155,6 @@ class EditNode extends EditRecord
'md' => 1, 'md' => 1,
'lg' => 1, 'lg' => 1,
]), ]),
TextInput::make('daemon_listen') TextInput::make('daemon_listen')
->columnSpan([ ->columnSpan([
'default' => 1, 'default' => 1,
@ -172,7 +169,6 @@ class EditNode extends EditRecord
->default(8080) ->default(8080)
->required() ->required()
->integer(), ->integer(),
TextInput::make('name') TextInput::make('name')
->label('Display Name') ->label('Display Name')
->columnSpan([ ->columnSpan([
@ -184,7 +180,6 @@ class EditNode extends EditRecord
->required() ->required()
->helperText('This name is for display only and can be changed later.') ->helperText('This name is for display only and can be changed later.')
->maxLength(100), ->maxLength(100),
ToggleButtons::make('scheme') ToggleButtons::make('scheme')
->label('Communicate over SSL') ->label('Communicate over SSL')
->columnSpan([ ->columnSpan([
@ -441,6 +436,16 @@ class EditNode extends EditRecord
$data['config'] = $node->getYamlConfiguration(); $data['config'] = $node->getYamlConfiguration();
if (!is_ip($node->fqdn)) {
$validRecords = gethostbynamel($node->fqdn);
if ($validRecords) {
$data['dns'] = true;
$data['ip'] = collect($validRecords)->first();
} else {
$data['dns'] = false;
}
}
return $data; return $data;
} }
@ -448,6 +453,7 @@ class EditNode extends EditRecord
{ {
return []; return [];
} }
protected function getHeaderActions(): array protected function getHeaderActions(): array
{ {
return [ return [
@ -467,6 +473,7 @@ class EditNode extends EditRecord
{ {
return null; return null;
} }
protected function getColumnStart() protected function getColumnStart()
{ {
return null; return null;