mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Apply easy fixes from code review
Co-authored-by: ljf (zamentur) <zamentur@users.noreply.github.com>
This commit is contained in:
parent
914bd1f20a
commit
e40f8fb861
2 changed files with 39 additions and 20 deletions
|
@ -450,7 +450,7 @@ domain:
|
|||
### domain_push_config()
|
||||
push_config:
|
||||
action_help: Push DNS records to registrar
|
||||
api: GET /domains/push
|
||||
api: GET /domains/<domain>/push
|
||||
arguments:
|
||||
domain:
|
||||
help: Domain name to add
|
||||
|
@ -568,11 +568,13 @@ domain:
|
|||
help: The path to check (e.g. /coffee)
|
||||
### domain_setting()
|
||||
setting:
|
||||
action_help: Set or get an app setting value
|
||||
action_help: Set or get a domain setting value
|
||||
api: GET /domains/<domain>/settings
|
||||
arguments:
|
||||
domain:
|
||||
help: Domain name
|
||||
extra:
|
||||
pattern: *pattern_domain
|
||||
key:
|
||||
help: Key to get/set
|
||||
-v:
|
||||
|
@ -589,23 +591,38 @@ domain:
|
|||
### domain_registrar_set()
|
||||
set:
|
||||
action_help: Set domain registrar
|
||||
api: POST /domains/registrar
|
||||
api: POST /domains/<domain>/registrar
|
||||
arguments:
|
||||
domain:
|
||||
help: Domain name
|
||||
extra:
|
||||
pattern: *pattern_domain
|
||||
registrar:
|
||||
help: registrar_key, see yunohost domain registrar list
|
||||
-a:
|
||||
full: --args
|
||||
help: Serialized arguments for app script (i.e. "domain=domain.tld&path=/path")
|
||||
help: Serialized arguments for registrar API (i.e. "auth_token=TOKEN&auth_username=USER").
|
||||
### domain_registrar_set()
|
||||
get:
|
||||
action_help: Get domain registrar
|
||||
api: GET /domains/registrar
|
||||
api: GET /domains/<domain>/registrar
|
||||
arguments:
|
||||
domain:
|
||||
help: Domain name
|
||||
extra:
|
||||
pattern: *pattern_domain
|
||||
### domain_registrar_list()
|
||||
list:
|
||||
action_help: List available registrars
|
||||
api: GET /domains/registrar/list
|
||||
action_help: List registrars configured by DNS zone
|
||||
api: GET /domains/registrars
|
||||
catalog:
|
||||
action_help: List supported registrars API
|
||||
api: GET /domains/registrars/catalog
|
||||
arguments:
|
||||
-f:
|
||||
full: --full
|
||||
help: Display all details, including info to create forms
|
||||
action: store_true
|
||||
|
||||
#############################
|
||||
# App #
|
||||
|
|
|
@ -131,7 +131,7 @@ def domain_add(operation_logger, domain, dyndns=False):
|
|||
|
||||
# Do not allow to subscribe to multiple dyndns domains...
|
||||
if _guess_current_dyndns_domain("dyndns.yunohost.org") != (None, None):
|
||||
raise YunohostValidationError('domain_dyndns_already_subscribed')
|
||||
raise YunohostValidationError("domain_dyndns_already_subscribed")
|
||||
|
||||
# Check that this domain can effectively be provided by
|
||||
# dyndns.yunohost.org. (i.e. is it a nohost.me / noho.st)
|
||||
|
@ -208,8 +208,8 @@ def domain_remove(operation_logger, domain, remove_apps=False, force=False):
|
|||
# the 'force' here is related to the exception happening in domain_add ...
|
||||
# we don't want to check the domain exists because the ldap add may have
|
||||
# failed
|
||||
if not force and domain not in domain_list()['domains']:
|
||||
raise YunohostValidationError('domain_name_unknown', domain=domain)
|
||||
if not force and domain not in domain_list()["domains"]:
|
||||
raise YunohostValidationError("domain_name_unknown", domain=domain)
|
||||
|
||||
# Check domain is not the main domain
|
||||
if domain == _get_maindomain():
|
||||
|
@ -223,7 +223,9 @@ def domain_remove(operation_logger, domain, remove_apps=False, force=False):
|
|||
other_domains="\n * " + ("\n * ".join(other_domains)),
|
||||
)
|
||||
else:
|
||||
raise YunohostValidationError("domain_cannot_remove_main_add_new_one", domain=domain)
|
||||
raise YunohostValidationError(
|
||||
"domain_cannot_remove_main_add_new_one", domain=domain
|
||||
)
|
||||
|
||||
# Check if apps are installed on the domain
|
||||
apps_on_that_domain = []
|
||||
|
@ -515,12 +517,12 @@ def _build_dns_conf(domains):
|
|||
]
|
||||
|
||||
# DKIM/DMARC record
|
||||
dkim_host, dkim_publickey = _get_DKIM(domain)
|
||||
dkim_host, dkim_publickey = _get_DKIM(domain_name)
|
||||
|
||||
if dkim_host:
|
||||
mail += [
|
||||
[dkim_host, ttl, "TXT", dkim_publickey],
|
||||
["_dmarc", ttl, "TXT", '"v=DMARC1; p=none"'],
|
||||
[f"_dmarc{child_domain_suffix}", ttl, "TXT", '"v=DMARC1; p=none"'],
|
||||
]
|
||||
|
||||
########
|
||||
|
@ -528,8 +530,8 @@ def _build_dns_conf(domains):
|
|||
########
|
||||
if domain["xmpp"]:
|
||||
xmpp += [
|
||||
["_xmpp-client._tcp", ttl, "SRV", "0 5 5222 %s." % domain_name],
|
||||
["_xmpp-server._tcp", ttl, "SRV", "0 5 5269 %s." % domain_name],
|
||||
[f"_xmpp-client._tcp{child_domain_suffix}", ttl, "SRV", f"0 5 5222 {domain_name}."],
|
||||
[f"_xmpp-server._tcp{child_domain_suffix}", ttl, "SRV", f"0 5 5269 {domain_name}."],
|
||||
["muc" + child_domain_suffix, ttl, "CNAME", name],
|
||||
["pubsub" + child_domain_suffix, ttl, "CNAME", name],
|
||||
["vjud" + child_domain_suffix, ttl, "CNAME", name],
|
||||
|
@ -542,10 +544,10 @@ def _build_dns_conf(domains):
|
|||
|
||||
|
||||
if ipv4:
|
||||
extra.append(["*", ttl, "A", ipv4])
|
||||
extra.append([f"*{child_domain_suffix}", ttl, "A", ipv4])
|
||||
|
||||
if ipv6:
|
||||
extra.append(["*", ttl, "AAAA", ipv6])
|
||||
extra.append([f"*{child_domain_suffix}", ttl, "AAAA", ipv6])
|
||||
# TODO
|
||||
# elif include_empty_AAAA_if_no_ipv6:
|
||||
# extra.append(["*", ttl, "AAAA", None])
|
||||
|
@ -727,7 +729,7 @@ def _load_domain_settings():
|
|||
new_domains[domain] = {}
|
||||
# new_domains[domain] = { "main": is_maindomain }
|
||||
# Set other values (default value if missing)
|
||||
for setting, default in [ ("xmpp", is_maindomain), ("mail", is_maindomain), ("owned_dns_zone", default_owned_dns_zone), ("ttl", 3600), ("provider", False)]:
|
||||
for setting, default in [ ("xmpp", is_maindomain), ("mail", True), ("owned_dns_zone", default_owned_dns_zone), ("ttl", 3600), ("provider", False)]:
|
||||
if domain_in_old_domains and setting in old_domains[domain].keys():
|
||||
new_domains[domain][setting] = old_domains[domain][setting]
|
||||
else:
|
||||
|
@ -773,7 +775,7 @@ def domain_setting(domain, key, value=None, delete=False):
|
|||
if "ttl" == key:
|
||||
try:
|
||||
ttl = int(value)
|
||||
except:
|
||||
except ValueError:
|
||||
# TODO add locales
|
||||
raise YunohostError("bad_value_type", value_type=type(ttl))
|
||||
|
||||
|
@ -934,7 +936,7 @@ def domain_push_config(domain):
|
|||
|
||||
for key in types:
|
||||
for distant_record in distant_records[key]:
|
||||
print('distant_record:', distant_record);
|
||||
logger.debug(f"distant_record: {distant_record}");
|
||||
for local_record in flatten_dns_conf:
|
||||
print('local_record:', local_record);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue