mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #124 from M5oul/unstable
Add '-ttl' parameter to 'domain dns conf' command.
This commit is contained in:
commit
fe0a8e4cd9
3 changed files with 20 additions and 8 deletions
|
@ -302,6 +302,14 @@ domain:
|
|||
arguments:
|
||||
domain:
|
||||
help: Target domain
|
||||
-t:
|
||||
full: --ttl
|
||||
help: Time To Live (TTL) in second before DNS servers update. Default is 3600 seconds (i.e. 1 hour).
|
||||
extra:
|
||||
pattern:
|
||||
- !!str ^[0-9]+$
|
||||
- "pattern_positive_number"
|
||||
|
||||
|
||||
### domain_info()
|
||||
# info:
|
||||
|
|
|
@ -220,6 +220,7 @@
|
|||
"unlimit" : "No quota",
|
||||
"pattern_domain" : "Must be a valid domain name (e.g. my-domain.org)",
|
||||
"pattern_listname" : "Must be alphanumeric and underscore characters only",
|
||||
"pattern_positive_number": "Must be a positive number",
|
||||
"pattern_port" : "Must be a valid port number (i.e. 0-65535)",
|
||||
"pattern_port_or_range" : "Must be a valid port number (i.e. 0-65535) or range of ports (e.g. 100:200)",
|
||||
"pattern_backup_archive_name" : "Must be a valid filename with alphanumeric and -_. characters only",
|
||||
|
|
|
@ -220,17 +220,20 @@ def domain_remove(auth, domain, force=False):
|
|||
msignals.display(m18n.n('domain_deleted'), 'success')
|
||||
|
||||
|
||||
def domain_dns_conf(domain):
|
||||
def domain_dns_conf(domain, ttl=None):
|
||||
"""
|
||||
Generate DNS configuration for a domain
|
||||
|
||||
Keyword argument:
|
||||
domain -- Domain name
|
||||
ttl -- Time to live
|
||||
"""
|
||||
|
||||
ttl = 3600 if ttl is None else ttl
|
||||
|
||||
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
|
||||
|
||||
|
@ -239,17 +242,17 @@ def domain_dns_conf(domain):
|
|||
except Exception:
|
||||
pass
|
||||
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:
|
||||
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:
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue