mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 21:04:44 +02:00
Disallow 0.0.0.0
, 127.0.0.1
and localhost
as node fqdn (#1158)
* disallow `0.0.0.0`, `127.0.01` and `localhost` as node fqdn * use rules of model
This commit is contained in:
parent
a73404c1b4
commit
c689f6860b
@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Admin\Resources\NodeResource\Pages;
|
namespace App\Filament\Admin\Resources\NodeResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Admin\Resources\NodeResource;
|
use App\Filament\Admin\Resources\NodeResource;
|
||||||
|
use App\Models\Node;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Components\Actions\Action;
|
use Filament\Forms\Components\Actions\Action;
|
||||||
use Filament\Forms\Components\Grid;
|
use Filament\Forms\Components\Grid;
|
||||||
@ -44,7 +45,8 @@ class CreateNode extends CreateRecord
|
|||||||
->required()
|
->required()
|
||||||
->autofocus()
|
->autofocus()
|
||||||
->live(debounce: 1500)
|
->live(debounce: 1500)
|
||||||
->rule('prohibited', fn ($state) => is_ip($state) && request()->isSecure())
|
->rules(Node::getRulesForField('fqdn'))
|
||||||
|
->prohibited(fn ($state) => is_ip($state) && request()->isSecure())
|
||||||
->label(fn ($state) => is_ip($state) ? trans('admin/node.ip_address') : trans('admin/node.domain'))
|
->label(fn ($state) => is_ip($state) ? trans('admin/node.ip_address') : trans('admin/node.domain'))
|
||||||
->placeholder(fn ($state) => is_ip($state) ? '192.168.1.1' : 'node.example.com')
|
->placeholder(fn ($state) => is_ip($state) ? '192.168.1.1' : 'node.example.com')
|
||||||
->helperText(function ($state) {
|
->helperText(function ($state) {
|
||||||
|
@ -108,7 +108,8 @@ class EditNode extends EditRecord
|
|||||||
->required()
|
->required()
|
||||||
->autofocus()
|
->autofocus()
|
||||||
->live(debounce: 1500)
|
->live(debounce: 1500)
|
||||||
->rule('prohibited', fn ($state) => is_ip($state) && request()->isSecure())
|
->rules(Node::getRulesForField('fqdn'))
|
||||||
|
->prohibited(fn ($state) => is_ip($state) && request()->isSecure())
|
||||||
->label(fn ($state) => is_ip($state) ? trans('admin/node.ip_address') : trans('admin/node.domain'))
|
->label(fn ($state) => is_ip($state) ? trans('admin/node.ip_address') : trans('admin/node.domain'))
|
||||||
->placeholder(fn ($state) => is_ip($state) ? '192.168.1.1' : 'node.example.com')
|
->placeholder(fn ($state) => is_ip($state) ? '192.168.1.1' : 'node.example.com')
|
||||||
->helperText(function ($state) {
|
->helperText(function ($state) {
|
||||||
|
@ -89,7 +89,7 @@ class Node extends Model implements Validatable
|
|||||||
'name' => ['required', 'string', 'min:1', 'max:100'],
|
'name' => ['required', 'string', 'min:1', 'max:100'],
|
||||||
'description' => ['string', 'nullable'],
|
'description' => ['string', 'nullable'],
|
||||||
'public' => ['boolean'],
|
'public' => ['boolean'],
|
||||||
'fqdn' => ['required', 'string'],
|
'fqdn' => ['required', 'string', 'notIn:0.0.0.0,127.0.0.1,localhost'],
|
||||||
'scheme' => ['required', 'string', 'in:http,https'],
|
'scheme' => ['required', 'string', 'in:http,https'],
|
||||||
'behind_proxy' => ['boolean'],
|
'behind_proxy' => ['boolean'],
|
||||||
'memory' => ['required', 'numeric', 'min:0'],
|
'memory' => ['required', 'numeric', 'min:0'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user