mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Move wildcard DNS record to 'extra' category
This commit is contained in:
parent
128577686a
commit
ecce6f11cc
2 changed files with 59 additions and 31 deletions
|
@ -236,8 +236,7 @@ def domain_dns_conf(domain, ttl=None):
|
||||||
for record in record_list:
|
for record in record_list:
|
||||||
result += "\n{name} {ttl} IN {type} {value}".format(**record)
|
result += "\n{name} {ttl} IN {type} {value}".format(**record)
|
||||||
|
|
||||||
is_cli = True if msettings.get('interface') == 'cli' else False
|
if msettings.get('interface') == 'cli':
|
||||||
if is_cli:
|
|
||||||
logger.info(m18n.n("domain_dns_conf_is_just_a_recommendation"))
|
logger.info(m18n.n("domain_dns_conf_is_just_a_recommendation"))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -406,10 +405,8 @@ def _build_dns_conf(domain, ttl=3600):
|
||||||
"basic": [
|
"basic": [
|
||||||
# if ipv4 available
|
# if ipv4 available
|
||||||
{"type": "A", "name": "@", "value": "123.123.123.123", "ttl": 3600},
|
{"type": "A", "name": "@", "value": "123.123.123.123", "ttl": 3600},
|
||||||
{"type": "A", "name": "*", "value": "123.123.123.123", "ttl": 3600},
|
|
||||||
# if ipv6 available
|
# if ipv6 available
|
||||||
{"type": "AAAA", "name": "@", "value": "valid-ipv6", "ttl": 3600},
|
{"type": "AAAA", "name": "@", "value": "valid-ipv6", "ttl": 3600},
|
||||||
{"type": "AAAA", "name": "*", "value": "valid-ipv6", "ttl": 3600},
|
|
||||||
],
|
],
|
||||||
"xmpp": [
|
"xmpp": [
|
||||||
{"type": "SRV", "name": "_xmpp-client._tcp", "value": "0 5 5222 domain.tld.", "ttl": 3600},
|
{"type": "SRV", "name": "_xmpp-client._tcp", "value": "0 5 5222 domain.tld.", "ttl": 3600},
|
||||||
|
@ -426,6 +423,10 @@ def _build_dns_conf(domain, ttl=3600):
|
||||||
{"type": "TXT", "name": "_dmarc", "value": "\"v=DMARC1; p=none\"", "ttl": 3600}
|
{"type": "TXT", "name": "_dmarc", "value": "\"v=DMARC1; p=none\"", "ttl": 3600}
|
||||||
],
|
],
|
||||||
"extra": [
|
"extra": [
|
||||||
|
# if ipv4 available
|
||||||
|
{"type": "A", "name": "*", "value": "123.123.123.123", "ttl": 3600},
|
||||||
|
# if ipv6 available
|
||||||
|
{"type": "AAAA", "name": "*", "value": "valid-ipv6", "ttl": 3600},
|
||||||
{"type": "CAA", "name": "@", "value": "128 issue \"letsencrypt.org\"", "ttl": 3600},
|
{"type": "CAA", "name": "@", "value": "128 issue \"letsencrypt.org\"", "ttl": 3600},
|
||||||
],
|
],
|
||||||
"example_of_a_custom_rule": [
|
"example_of_a_custom_rule": [
|
||||||
|
@ -437,32 +438,21 @@ def _build_dns_conf(domain, ttl=3600):
|
||||||
ipv4 = get_public_ip()
|
ipv4 = get_public_ip()
|
||||||
ipv6 = get_public_ip(6)
|
ipv6 = get_public_ip(6)
|
||||||
|
|
||||||
basic = []
|
###########################
|
||||||
|
# Basic ipv4/ipv6 records #
|
||||||
|
###########################
|
||||||
|
|
||||||
# Basic ipv4/ipv6 records
|
basic = []
|
||||||
if ipv4:
|
if ipv4:
|
||||||
basic += [
|
basic.append(["@", ttl, "A", ipv4])
|
||||||
["@", ttl, "A", ipv4],
|
|
||||||
["*", ttl, "A", ipv4],
|
|
||||||
]
|
|
||||||
|
|
||||||
if ipv6:
|
if ipv6:
|
||||||
basic += [
|
basic.append(["@", ttl, "AAAA", ipv6])
|
||||||
["@", ttl, "AAAA", ipv6],
|
|
||||||
["*", ttl, "AAAA", ipv6],
|
|
||||||
]
|
|
||||||
|
|
||||||
# XMPP
|
#########
|
||||||
xmpp = [
|
# Email #
|
||||||
["_xmpp-client._tcp", ttl, "SRV", "0 5 5222 %s." % domain],
|
#########
|
||||||
["_xmpp-server._tcp", ttl, "SRV", "0 5 5269 %s." % domain],
|
|
||||||
["muc", ttl, "CNAME", "@"],
|
|
||||||
["pubsub", ttl, "CNAME", "@"],
|
|
||||||
["vjud", ttl, "CNAME", "@"],
|
|
||||||
["xmpp-upload", ttl, "CNAME", "@"],
|
|
||||||
]
|
|
||||||
|
|
||||||
# SPF record
|
|
||||||
spf_record = '"v=spf1 a mx'
|
spf_record = '"v=spf1 a mx'
|
||||||
if ipv4:
|
if ipv4:
|
||||||
spf_record += ' ip4:{ip4}'.format(ip4=ipv4)
|
spf_record += ' ip4:{ip4}'.format(ip4=ipv4)
|
||||||
|
@ -470,7 +460,6 @@ def _build_dns_conf(domain, ttl=3600):
|
||||||
spf_record += ' ip6:{ip6}'.format(ip6=ipv6)
|
spf_record += ' ip6:{ip6}'.format(ip6=ipv6)
|
||||||
spf_record += ' -all"'
|
spf_record += ' -all"'
|
||||||
|
|
||||||
# Email
|
|
||||||
mail = [
|
mail = [
|
||||||
["@", ttl, "MX", "10 %s." % domain],
|
["@", ttl, "MX", "10 %s." % domain],
|
||||||
["@", ttl, "TXT", spf_record],
|
["@", ttl, "TXT", spf_record],
|
||||||
|
@ -485,12 +474,36 @@ def _build_dns_conf(domain, ttl=3600):
|
||||||
["_dmarc", ttl, "TXT", '"v=DMARC1; p=none"'],
|
["_dmarc", ttl, "TXT", '"v=DMARC1; p=none"'],
|
||||||
]
|
]
|
||||||
|
|
||||||
# Extra
|
########
|
||||||
extra = [
|
# XMPP #
|
||||||
["@", ttl, "CAA", '128 issue "letsencrypt.org"']
|
########
|
||||||
|
|
||||||
|
xmpp = [
|
||||||
|
["_xmpp-client._tcp", ttl, "SRV", "0 5 5222 %s." % domain],
|
||||||
|
["_xmpp-server._tcp", ttl, "SRV", "0 5 5269 %s." % domain],
|
||||||
|
["muc", ttl, "CNAME", "@"],
|
||||||
|
["pubsub", ttl, "CNAME", "@"],
|
||||||
|
["vjud", ttl, "CNAME", "@"],
|
||||||
|
["xmpp-upload", ttl, "CNAME", "@"],
|
||||||
]
|
]
|
||||||
|
|
||||||
# Official record
|
#########
|
||||||
|
# Extra #
|
||||||
|
#########
|
||||||
|
|
||||||
|
extra = []
|
||||||
|
|
||||||
|
if ipv4:
|
||||||
|
extra.append(["*", ttl, "A", ipv4])
|
||||||
|
if ipv6:
|
||||||
|
extra.append(["*", ttl, "AAAA", ipv6])
|
||||||
|
|
||||||
|
extra.append(["@", ttl, "CAA", '128 issue "letsencrypt.org"'])
|
||||||
|
|
||||||
|
####################
|
||||||
|
# Standard records #
|
||||||
|
####################
|
||||||
|
|
||||||
records = {
|
records = {
|
||||||
"basic": [{"name": name, "ttl": ttl, "type": type_, "value": value} for name, ttl, type_, value in basic],
|
"basic": [{"name": name, "ttl": ttl, "type": type_, "value": value} for name, ttl, type_, value in basic],
|
||||||
"xmpp": [{"name": name, "ttl": ttl, "type": type_, "value": value} for name, ttl, type_, value in xmpp],
|
"xmpp": [{"name": name, "ttl": ttl, "type": type_, "value": value} for name, ttl, type_, value in xmpp],
|
||||||
|
@ -498,7 +511,12 @@ def _build_dns_conf(domain, ttl=3600):
|
||||||
"extra": [{"name": name, "ttl": ttl, "type": type_, "value": value} for name, ttl, type_, value in extra],
|
"extra": [{"name": name, "ttl": ttl, "type": type_, "value": value} for name, ttl, type_, value in extra],
|
||||||
}
|
}
|
||||||
|
|
||||||
# Custom records
|
##################
|
||||||
|
# Custom records #
|
||||||
|
##################
|
||||||
|
|
||||||
|
# Defined by custom hooks ships in apps for example ...
|
||||||
|
|
||||||
hook_results = hook_callback('custom_dns_rules', args=[domain])
|
hook_results = hook_callback('custom_dns_rules', args=[domain])
|
||||||
for hook_name, results in hook_results.items():
|
for hook_name, results in hook_results.items():
|
||||||
#
|
#
|
||||||
|
|
|
@ -258,7 +258,17 @@ def dyndns_update(operation_logger, dyn_host="dyndns.yunohost.org", domain=None,
|
||||||
logger.info("Updated needed, going on...")
|
logger.info("Updated needed, going on...")
|
||||||
|
|
||||||
dns_conf = _build_dns_conf(domain)
|
dns_conf = _build_dns_conf(domain)
|
||||||
del dns_conf["extra"] # Ignore records from the 'extra' category
|
|
||||||
|
for i, record in enumerate(dns_conf["extra"]):
|
||||||
|
# Ignore CAA record ... not sure why, we could probably enforce it...
|
||||||
|
if record[3] == "CAA":
|
||||||
|
del dns_conf["extra"][i]
|
||||||
|
|
||||||
|
# Delete custom DNS records, we don't support them (have to explicitly
|
||||||
|
# authorize them on dynette)
|
||||||
|
for category in dns_conf.keys():
|
||||||
|
if category not in ["basic", "mail", "xmpp", "extra"]:
|
||||||
|
del dns_conf[category]
|
||||||
|
|
||||||
# Delete the old records for all domain/subdomains
|
# Delete the old records for all domain/subdomains
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue