Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions netbox_ddns/migrations/0014_alter_extradnsname_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.2.5 on 2025-09-01 09:17

import netbox_ddns.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('netbox_ddns', '0013_reversezone_created_reversezone_custom_field_data_and_more'),
]

operations = [
migrations.AlterField(
model_name='extradnsname',
name='name',
field=models.CharField(max_length=255, validators=[netbox_ddns.validators.DNSNameValidator()]),
),
]
4 changes: 2 additions & 2 deletions netbox_ddns/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ipam.models import IPAddress
from utilities.querysets import RestrictedQuerySet
from .utils import normalize_fqdn
from .validators import HostnameAddressValidator, HostnameValidator, validate_base64, MinValueValidator, \
from .validators import DNSNameValidator, HostnameAddressValidator, HostnameValidator, validate_base64, MinValueValidator, \
MaxValueValidator

logger = logging.getLogger('netbox_ddns')
Expand Down Expand Up @@ -374,7 +374,7 @@ class ExtraDNSName(NetBoxModel):
name = models.CharField(
verbose_name=_('DNS name'),
max_length=255,
validators=[HostnameValidator()],
validators=[DNSNameValidator()],
)

last_update = models.DateTimeField(
Expand Down
6 changes: 6 additions & 0 deletions netbox_ddns/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ def validate_base64(value):
base64.b64decode(value, validate=True)
except binascii.Error:
raise ValidationError('Invalid base64 string')

class DNSNameValidator(RegexValidator):
regex = r"^([0-9A-Za-z_-]+|\*)(\.[0-9A-Za-z_-]+)*\.?$"
message = _(
"Only alphanumeric characters, asterisks, hyphens, periods, and underscores are allowed in DNS names"
)