mirror of
https://github.com/pelican-dev/panel.git
synced 2026-02-13 19:07:31 +03:00
Compare commits
2 Commits
main
...
lance/1769
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6775f5ad01 | ||
|
|
ce3fba5102 |
@@ -113,6 +113,12 @@ class CreateNode extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
if (in_array(strtolower($state), Node::BANNED_FQDNS)) {
|
||||
$set('dns', false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$ip = get_ip_from_hostname($state);
|
||||
if ($ip) {
|
||||
$set('dns', true);
|
||||
|
||||
@@ -174,6 +174,12 @@ class EditNode extends EditRecord
|
||||
return;
|
||||
}
|
||||
|
||||
if (in_array(strtolower($state), Node::BANNED_FQDNS)) {
|
||||
$set('dns', false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$ip = get_ip_from_hostname($state);
|
||||
if ($ip) {
|
||||
$set('dns', true);
|
||||
|
||||
@@ -18,6 +18,7 @@ use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
@@ -72,6 +73,8 @@ class Node extends Model implements Validatable
|
||||
|
||||
public const DAEMON_TOKEN_LENGTH = 64;
|
||||
|
||||
public const BANNED_FQDNS = ['0.0.0.0', '127.0.0.1', 'localhost'];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*/
|
||||
@@ -95,7 +98,7 @@ class Node extends Model implements Validatable
|
||||
'name' => ['required', 'string', 'min:1', 'max:100'],
|
||||
'description' => ['string', 'nullable'],
|
||||
'public' => ['boolean'],
|
||||
'fqdn' => ['required', 'string', 'notIn:0.0.0.0,127.0.0.1,localhost'],
|
||||
'fqdn' => ['required', 'string'],
|
||||
'scheme' => ['required', 'string', 'in:http,https'],
|
||||
'behind_proxy' => ['boolean'],
|
||||
'memory' => ['required', 'numeric', 'min:0'],
|
||||
@@ -114,6 +117,14 @@ class Node extends Model implements Validatable
|
||||
'tags' => ['array'],
|
||||
];
|
||||
|
||||
public static function getRules(): array
|
||||
{
|
||||
$rules = static::$validationRules;
|
||||
$rules['fqdn'][] = Rule::notIn(static::BANNED_FQDNS);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default values for specific columns that are generally not changed on base installs.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user