mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] add '-ttl' parameter to 'domain dns conf' command.
This commit is contained in:
parent
b27aa33192
commit
5016482bda
2 changed files with 19 additions and 8 deletions
|
@ -302,6 +302,14 @@ domain:
|
||||||
arguments:
|
arguments:
|
||||||
domain:
|
domain:
|
||||||
help: Target domain
|
help: Target domain
|
||||||
|
-ttl:
|
||||||
|
full: --time-to-live
|
||||||
|
help: Time to live in secound before DNS servers update this information. Without this option, ttl is set to 3600s, one hour.
|
||||||
|
extra:
|
||||||
|
pattern: &pattern_ttl
|
||||||
|
- !!str ^[0-9]+$
|
||||||
|
- "pattern_ttl"
|
||||||
|
|
||||||
|
|
||||||
### domain_info()
|
### domain_info()
|
||||||
# info:
|
# info:
|
||||||
|
|
|
@ -220,17 +220,20 @@ def domain_remove(auth, domain, force=False):
|
||||||
msignals.display(m18n.n('domain_deleted'), 'success')
|
msignals.display(m18n.n('domain_deleted'), 'success')
|
||||||
|
|
||||||
|
|
||||||
def domain_dns_conf(domain):
|
def domain_dns_conf(domain, time_to_live):
|
||||||
"""
|
"""
|
||||||
Generate DNS configuration for a domain
|
Generate DNS configuration for a domain
|
||||||
|
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
domain -- Domain name
|
domain -- Domain name
|
||||||
|
time to live -- Time to live
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ttl = 3600 if time_to_live is None else time_to_live
|
||||||
|
|
||||||
ip4 = urlopen("http://ip.yunohost.org").read().strip()
|
ip4 = urlopen("http://ip.yunohost.org").read().strip()
|
||||||
|
|
||||||
result = "@ 1400 IN A {ip4}\n* 1400 IN A {ip4}\n".format(ip4=ip4)
|
result = "@ {ttl} IN A {ip4}\n* {ttl} IN A {ip4}\n".format(ttl=ttl, ip4=ip4)
|
||||||
|
|
||||||
ip6 = None
|
ip6 = None
|
||||||
|
|
||||||
|
@ -239,17 +242,17 @@ def domain_dns_conf(domain):
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
result += "@ 1400 IN AAAA {ip6}\n* 1400 IN AAAA {ip6}\n".format(ip6=ip6)
|
result += "@ {ttl} IN AAAA {ip6}\n* {ttl} IN AAAA {ip6}\n".format(ttl=ttl, ip6=ip6)
|
||||||
|
|
||||||
result += "\n_xmpp-client._tcp 14400 IN SRV 0 5 5222 {domain}.\n_xmpp-server._tcp 14400 IN SRV 0 5 5269 {domain}.\n".format(domain=domain)
|
result += "\n_xmpp-client._tcp {ttl} IN SRV 0 5 5222 {domain}.\n_xmpp-server._tcp {ttl} IN SRV 0 5 5269 {domain}.\n".format(ttl=ttl, domain=domain)
|
||||||
|
|
||||||
result += "muc 1800 IN CNAME @\npubsub 1800 IN CNAME @\nvjud 1800 IN CNAME @\n\n"
|
result += "muc {ttl} IN CNAME @\npubsub {ttl} IN CNAME @\nvjud {ttl} IN CNAME @\n\n".format(ttl=ttl)
|
||||||
|
|
||||||
result += "@ 1400 IN MX 10 {domain}.\n".format(domain=domain)
|
result += "@ {ttl} IN MX 10 {domain}.\n".format(ttl=ttl, domain=domain)
|
||||||
|
|
||||||
if ip6 is None:
|
if ip6 is None:
|
||||||
result += '@ 1400 IN TXT "v=spf1 a mx ip4:{ip4} -all"\n'.format(ip4=ip4)
|
result += '@ {ttl} IN TXT "v=spf1 a mx ip4:{ip4} -all"\n'.format(ttl=ttl, ip4=ip4)
|
||||||
else:
|
else:
|
||||||
result += '@ 1400 IN TXT "v=spf1 a mx ip4:{ip4} ip6:{ip6} -all"\n'.format(ip4=ip4, ip6=ip6)
|
result += '@ {ttl} IN TXT "v=spf1 a mx ip4:{ip4} ip6:{ip6} -all"\n'.format(ttl=ttl, ip4=ip4, ip6=ip6)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Add table
Reference in a new issue