modified: src/netbox_plugin_bind_provisioner/__init__.py
modified: src/netbox_plugin_bind_provisioner/management/commands/bind-transfer-endpoint.py Improve TXT record formating.
This commit is contained in:
1 parent
d8f4b83c2a
commit
6ac1548eef
2 files changed
+7
-6
No files matched your search
@@ -5,7 +5,7 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
__version__ = "1.0.2"
|
__version__ = "1.0.3"
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -251,16 +251,17 @@ class DNSBaseRequestHandler(socketserver.BaseRequestHandler):
|
|||||||
# from cutting it up:
|
# from cutting it up:
|
||||||
value = record.value
|
value = record.value
|
||||||
if rdtype == dns.rdatatype.TXT:
|
if rdtype == dns.rdatatype.TXT:
|
||||||
if not value.startswith('"') and not value.endswith('"'):
|
if value.startswith('"') and value.endswith('"'):
|
||||||
value = value.replace('"', '\\"')
|
value = value[1:-1].replace('" "', '').replace('"', '\"')
|
||||||
if len(value) <= 255:
|
|
||||||
value = f'"{value}"'
|
if len(value) > 255:
|
||||||
else:
|
|
||||||
# This is a bug fix for netbox. If netbox allowed for
|
# This is a bug fix for netbox. If netbox allowed for
|
||||||
# an unquoted value to be larger then 255 characters,
|
# an unquoted value to be larger then 255 characters,
|
||||||
# it misunderstood everything behind a ; as a comment.
|
# it misunderstood everything behind a ; as a comment.
|
||||||
chunks = ['"{}"'.format(value[i:i+255]) for i in range(0, len(value), 255)]
|
chunks = ['"{}"'.format(value[i:i+255]) for i in range(0, len(value), 255)]
|
||||||
value = " ".join(chunks)
|
value = " ".join(chunks)
|
||||||
|
else:
|
||||||
|
value = f'"{value}"'
|
||||||
|
|
||||||
rdata = dns.rdata.from_text(
|
rdata = dns.rdata.from_text(
|
||||||
dns.rdataclass.IN,
|
dns.rdataclass.IN,
|
||||||
|
|||||||
Reference in new issue
Block a user