Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mailinabox
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mailinabox
Commits
1ad9c708
Commit
1ad9c708
authored
Jul 20, 2014
by
Joshua Tauberer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor custom DNS records
parent
2e0680de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
16 deletions
+37
-16
dns_update.py
management/dns_update.py
+37
-16
No files found.
management/dns_update.py
View file @
1ad9c708
...
...
@@ -182,22 +182,9 @@ def build_zone(domain, all_domains, additional_records, env, is_zone=True):
return
False
# The user may set other records that don't conflict with our settings.
for
qname
,
value
in
additional_records
.
items
():
if
qname
!=
domain
and
not
qname
.
endswith
(
"."
+
domain
):
continue
if
qname
==
domain
:
qname
=
None
else
:
qname
=
qname
[
0
:
len
(
qname
)
-
len
(
"."
+
domain
)]
if
isinstance
(
value
,
str
):
values
=
[(
"A"
,
value
)]
elif
isinstance
(
value
,
dict
):
values
=
value
.
items
()
else
:
raise
ValueError
()
for
rtype
,
value2
in
values
:
if
has_rec
(
qname
,
rtype
):
continue
if
rtype
==
"TXT"
:
value2
=
"
\"
"
+
value2
+
"
\"
"
records
.
append
((
qname
,
rtype
,
value2
,
"(Set by user.)"
))
for
qname
,
rtype
,
value
in
get_custom_records
(
domain
,
additional_records
):
if
has_rec
(
qname
,
rtype
):
continue
records
.
append
((
qname
,
rtype
,
value
,
"(Set by user.)"
))
# Add defaults if not overridden by the user's custom settings.
defaults
=
[
...
...
@@ -230,6 +217,40 @@ def build_zone(domain, all_domains, additional_records, env, is_zone=True):
########################################################################
def
get_custom_records
(
domain
,
additional_records
):
for
qname
,
value
in
additional_records
.
items
():
# Is this record for the domain or one of its subdomains?
if
qname
!=
domain
and
not
qname
.
endswith
(
"."
+
domain
):
continue
# Turn the fully qualified domain name in the YAML file into
# our short form (None => domain, or a relative QNAME).
if
qname
==
domain
:
qname
=
None
else
:
qname
=
qname
[
0
:
len
(
qname
)
-
len
(
"."
+
domain
)]
# Short form. Mapping a domain name to a string is short-hand
# for creating A records.
if
isinstance
(
value
,
str
):
values
=
[(
"A"
,
value
)]
# A mapping creates multiple records.
elif
isinstance
(
value
,
dict
):
values
=
value
.
items
()
# No other type of data is allowed.
else
:
raise
ValueError
()
for
rtype
,
value2
in
values
:
# For typical zone file output, quote a text record.
if
rtype
==
"TXT"
:
value2
=
"
\"
"
+
value2
+
"
\"
"
yield
(
qname
,
rtype
,
value2
)
########################################################################
def
build_tlsa_record
(
env
):
# A DANE TLSA record in DNS specifies that connections on a port
# must use TLS and the certificate must match a particular certificate.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment