mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #1514 from YunoHost/get-parent
call _get_parent_domain_of to ensure getting any level parent
This commit is contained in:
commit
43b7a1a9a0
3 changed files with 15 additions and 14 deletions
|
@ -50,9 +50,7 @@ name = "Features"
|
|||
name = "DNS"
|
||||
|
||||
[dns.registrar]
|
||||
optional = true
|
||||
|
||||
# This part is automatically generated in DomainConfigPanel
|
||||
# This part is automatically generated in DomainConfigPanel
|
||||
|
||||
# [dns.advanced]
|
||||
#
|
||||
|
|
19
src/dns.py
19
src/dns.py
|
@ -41,6 +41,7 @@ from yunohost.domain import (
|
|||
_get_domain_settings,
|
||||
_set_domain_settings,
|
||||
_list_subdomains_of,
|
||||
_get_parent_domain_of,
|
||||
)
|
||||
from yunohost.utils.dns import dig, is_yunohost_dyndns_domain, is_special_use_tld
|
||||
from yunohost.utils.error import YunohostValidationError, YunohostError
|
||||
|
@ -446,8 +447,8 @@ def _get_dns_zone_for_domain(domain):
|
|||
# This is another strick to try to prevent this function from being
|
||||
# a bottleneck on system with 1 main domain + 10ish subdomains
|
||||
# when building the dns conf for the main domain (which will call domain_config_get, etc...)
|
||||
parent_domain = domain.split(".", 1)[1]
|
||||
if parent_domain in domain_list()["domains"]:
|
||||
parent_domain = _get_parent_domain_of(domain)
|
||||
if parent_domain:
|
||||
parent_cache_file = f"{cache_folder}/{parent_domain}"
|
||||
if (
|
||||
os.path.exists(parent_cache_file)
|
||||
|
@ -512,17 +513,19 @@ def _get_registrar_config_section(domain):
|
|||
|
||||
from lexicon.providers.auto import _relevant_provider_for_domain
|
||||
|
||||
registrar_infos = {}
|
||||
registrar_infos = {
|
||||
"name": m18n.n('registrar_infos'), # This is meant to name the config panel section, for proper display in the webadmin
|
||||
}
|
||||
|
||||
dns_zone = _get_dns_zone_for_domain(domain)
|
||||
|
||||
# If parent domain exists in yunohost
|
||||
parent_domain = domain.split(".", 1)[1]
|
||||
if parent_domain in domain_list()["domains"]:
|
||||
parent_domain = _get_parent_domain_of(domain, topest=True)
|
||||
if parent_domain:
|
||||
|
||||
# Dirty hack to have a link on the webadmin
|
||||
if Moulinette.interface.type == "api":
|
||||
parent_domain_link = f"[{parent_domain}](#/domains/{parent_domain}/config)"
|
||||
parent_domain_link = f"[{parent_domain}](#/domains/{parent_domain}/dns)"
|
||||
else:
|
||||
parent_domain_link = parent_domain
|
||||
|
||||
|
@ -532,7 +535,7 @@ def _get_registrar_config_section(domain):
|
|||
"style": "info",
|
||||
"ask": m18n.n(
|
||||
"domain_dns_registrar_managed_in_parent_domain",
|
||||
parent_domain=domain,
|
||||
parent_domain=parent_domain,
|
||||
parent_domain_link=parent_domain_link,
|
||||
),
|
||||
"value": "parent_domain",
|
||||
|
@ -647,7 +650,7 @@ def domain_dns_push(operation_logger, domain, dry_run=False, force=False, purge=
|
|||
return {}
|
||||
|
||||
if registrar == "parent_domain":
|
||||
parent_domain = domain.split(".", 1)[1]
|
||||
parent_domain = _get_parent_domain_of(domain, topest=True)
|
||||
registar, registrar_credentials = _get_registar_settings(parent_domain)
|
||||
if any(registrar_credentials.values()):
|
||||
raise YunohostValidationError(
|
||||
|
|
|
@ -95,7 +95,7 @@ def _get_domains(exclude_subdomains=False):
|
|||
return [
|
||||
domain
|
||||
for domain in domain_list_cache
|
||||
if not _get_parent_domain_of(domain, return_self=False)
|
||||
if not _get_parent_domain_of(domain)
|
||||
]
|
||||
|
||||
return domain_list_cache
|
||||
|
@ -167,7 +167,7 @@ def domain_info(domain):
|
|||
"registrar": registrar,
|
||||
"apps": apps,
|
||||
"main": _get_maindomain() == domain,
|
||||
"topest_parent": _get_parent_domain_of(domain, return_self=True, topest=True),
|
||||
"topest_parent": _get_parent_domain_of(domain, topest=True),
|
||||
# TODO : add parent / child domains ?
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ def _list_subdomains_of(parent_domain):
|
|||
return out
|
||||
|
||||
|
||||
def _get_parent_domain_of(domain, return_self=True, topest=False):
|
||||
def _get_parent_domain_of(domain, return_self=False, topest=False):
|
||||
|
||||
_assert_domain_exists(domain)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue