From 5016482bdafbc079d303486630e6ed087c5ba926 Mon Sep 17 00:00:00 2001 From: Moul Date: Tue, 23 Feb 2016 00:53:02 +0100 Subject: [PATCH 1/8] [enh] add '-ttl' parameter to 'domain dns conf' command. --- data/actionsmap/yunohost.yml | 8 ++++++++ src/yunohost/domain.py | 19 +++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 80a74251b..8355472ce 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -302,6 +302,14 @@ domain: arguments: 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() # info: diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index 535b94d40..3586a761c 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -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, time_to_live): """ Generate DNS configuration for a domain Keyword argument: 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() - 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 From 3f1bd53c470ced04d01506331f88d1cfb24bedc6 Mon Sep 17 00:00:00 2001 From: Moul Date: Tue, 23 Feb 2016 13:13:36 +0100 Subject: [PATCH 2/8] [mod] Fixes on 'ttl' option. --- data/actionsmap/yunohost.yml | 6 +++--- src/yunohost/domain.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 8355472ce..a34d2af11 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -302,9 +302,9 @@ domain: arguments: 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. + -t: + full: --ttl + help: Time To Live (TTL) is second before DNS servers update. Default is 3600 second (i.e. 1 hour). extra: pattern: &pattern_ttl - !!str ^[0-9]+$ diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index 3586a761c..a7f4befae 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -220,7 +220,7 @@ def domain_remove(auth, domain, force=False): msignals.display(m18n.n('domain_deleted'), 'success') -def domain_dns_conf(domain, time_to_live): +def domain_dns_conf(domain, ttl): """ Generate DNS configuration for a domain @@ -229,7 +229,7 @@ def domain_dns_conf(domain, time_to_live): time to live -- Time to live """ - ttl = 3600 if time_to_live is None else time_to_live + ttl = 3600 if ttl is None else ttl ip4 = urlopen("http://ip.yunohost.org").read().strip() From fbf09e42b0a4dc09200d2bdb2c027a587ce310d1 Mon Sep 17 00:00:00 2001 From: Moul Date: Tue, 23 Feb 2016 21:48:17 +0100 Subject: [PATCH 3/8] [fix] ortho. --- data/actionsmap/yunohost.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index a34d2af11..c84cc30a8 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -304,7 +304,7 @@ domain: help: Target domain -t: full: --ttl - help: Time To Live (TTL) is second before DNS servers update. Default is 3600 second (i.e. 1 hour). + help: Time To Live (TTL) in second before DNS servers update. Default is 3600 second (i.e. 1 hour). extra: pattern: &pattern_ttl - !!str ^[0-9]+$ From 248104b8e460c2682d8487aaf284b1f9325103a7 Mon Sep 17 00:00:00 2001 From: Moul Date: Tue, 23 Feb 2016 23:07:32 +0100 Subject: [PATCH 4/8] [fix] set ttl value to 'None'. --- src/yunohost/domain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index a7f4befae..c8513e7fb 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -220,7 +220,7 @@ def domain_remove(auth, domain, force=False): msignals.display(m18n.n('domain_deleted'), 'success') -def domain_dns_conf(domain, ttl): +def domain_dns_conf(domain, ttl=None): """ Generate DNS configuration for a domain From 3d779cfdf84b9305c0f4c93adb879b53056ba6b0 Mon Sep 17 00:00:00 2001 From: Moul Date: Tue, 23 Feb 2016 23:18:02 +0100 Subject: [PATCH 5/8] =?UTF-8?q?[enh]=20ttl:=C2=A0Handle=20error=20message?= =?UTF-8?q?=20for=20non=20positive=20numbers.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/actionsmap/yunohost.yml | 2 +- locales/en.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index c84cc30a8..7261aa989 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -308,7 +308,7 @@ domain: extra: pattern: &pattern_ttl - !!str ^[0-9]+$ - - "pattern_ttl" + - "pattern_number" ### domain_info() diff --git a/locales/en.json b/locales/en.json index 858036132..8727e63f5 100644 --- a/locales/en.json +++ b/locales/en.json @@ -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_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", From be71b0f1d08834f250ebbeb50337a7febeb5c45b Mon Sep 17 00:00:00 2001 From: Moul Date: Wed, 24 Feb 2016 11:59:47 +0100 Subject: [PATCH 6/8] [fix] ttl: fixes. --- data/actionsmap/yunohost.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 7261aa989..fe74df202 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -304,9 +304,9 @@ domain: help: Target domain -t: full: --ttl - help: Time To Live (TTL) in second before DNS servers update. Default is 3600 second (i.e. 1 hour). + help: Time To Live (TTL) in second before DNS servers update. Default is 3600 seconds (i.e. 1 hour). extra: - pattern: &pattern_ttl + pattern: - !!str ^[0-9]+$ - "pattern_number" From abd9cfc44b1fe27f5d5de3a350f358024762e561 Mon Sep 17 00:00:00 2001 From: Moul Date: Wed, 24 Feb 2016 12:01:22 +0100 Subject: [PATCH 7/8] =?UTF-8?q?[enh]=20ttl:=C2=A0change=20pattern=20name.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/actionsmap/yunohost.yml | 2 +- locales/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index fe74df202..1798a9f26 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -308,7 +308,7 @@ domain: extra: pattern: - !!str ^[0-9]+$ - - "pattern_number" + - "pattern_positive_number" ### domain_info() diff --git a/locales/en.json b/locales/en.json index 8727e63f5..7b0f6445e 100644 --- a/locales/en.json +++ b/locales/en.json @@ -220,7 +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_number": "Must be a positive number", + "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", From 3744409aae178dd23cb22b1580ee6dc628f2b4f1 Mon Sep 17 00:00:00 2001 From: Moul Date: Fri, 26 Feb 2016 12:20:45 +0100 Subject: [PATCH 8/8] [fix] ttl: rename key argument. --- src/yunohost/domain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index c8513e7fb..f973b758d 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -226,7 +226,7 @@ def domain_dns_conf(domain, ttl=None): Keyword argument: domain -- Domain name - time to live -- Time to live + ttl -- Time to live """ ttl = 3600 if ttl is None else ttl