mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-10 11:00:22 +00:00
names: Don't enumerate services for domains supporting all
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
d820ce15d0
commit
b743305e06
@ -27,8 +27,6 @@ from django.utils.translation import ugettext_lazy
|
||||
from plinth import actions
|
||||
from plinth import app as app_module
|
||||
from plinth import frontpage, menu
|
||||
from plinth.modules import firewall
|
||||
from plinth.modules.names import SERVICES
|
||||
from plinth.signals import domain_added
|
||||
|
||||
version = 2
|
||||
@ -152,21 +150,9 @@ def init():
|
||||
# Register domain with Name Services module.
|
||||
domainname = get_domainname()
|
||||
if domainname:
|
||||
try:
|
||||
domainname_services = firewall.get_enabled_services(
|
||||
zone='external')
|
||||
except actions.ActionError:
|
||||
# This happens when firewalld is not installed.
|
||||
# TODO: Are these services actually enabled?
|
||||
domainname_services = [service[0] for service in SERVICES]
|
||||
else:
|
||||
domainname_services = None
|
||||
|
||||
if domainname:
|
||||
domain_added.send_robust(sender='config', domain_type='domainname',
|
||||
name=domainname,
|
||||
description=ugettext_lazy('Domain Name'),
|
||||
services=domainname_services)
|
||||
domain_added.send_robust(
|
||||
sender='config', domain_type='domainname', name=domainname,
|
||||
description=ugettext_lazy('Domain Name'), services='__all__')
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
|
||||
@ -25,8 +25,7 @@ from django.template.response import TemplateResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth.modules import config, firewall
|
||||
from plinth.modules.names import SERVICES
|
||||
from plinth.modules import config
|
||||
from plinth.signals import (domain_added, domain_removed, domainname_change,
|
||||
post_hostname_change, pre_hostname_change)
|
||||
|
||||
@ -159,14 +158,6 @@ def set_domainname(domainname):
|
||||
# Update domain registered with Name Services module.
|
||||
domain_removed.send_robust(sender='config', domain_type='domainname')
|
||||
if domainname:
|
||||
try:
|
||||
domainname_services = firewall.get_enabled_services(
|
||||
zone='external')
|
||||
except actions.ActionError:
|
||||
# This happens when firewalld is not installed.
|
||||
# TODO: Are these services actually enabled?
|
||||
domainname_services = [service[0] for service in SERVICES]
|
||||
|
||||
domain_added.send_robust(sender='config', domain_type='domainname',
|
||||
name=domainname, description=_('Domain Name'),
|
||||
services=domainname_services)
|
||||
services='__all__')
|
||||
|
||||
@ -23,12 +23,10 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from plinth import actions
|
||||
from plinth import app as app_module
|
||||
from plinth import cfg, menu
|
||||
from plinth.modules import firewall
|
||||
from plinth.modules.names import SERVICES
|
||||
from plinth.signals import domain_added
|
||||
from plinth.utils import format_lazy
|
||||
|
||||
from .manifest import backup # noqa, pylint: disable=unused-import
|
||||
from .manifest import backup # noqa, pylint: disable=unused-import
|
||||
|
||||
version = 1
|
||||
|
||||
@ -82,11 +80,10 @@ def init():
|
||||
app = DynamicDNSApp()
|
||||
current_status = get_status()
|
||||
if current_status['enabled']:
|
||||
services = get_enabled_services(current_status['dynamicdns_domain'])
|
||||
domain_added.send_robust(
|
||||
sender='dynamicdns', domain_type='dynamicdnsservice',
|
||||
name=current_status['dynamicdns_domain'],
|
||||
description=_('Dynamic DNS Service'), services=services)
|
||||
description=_('Dynamic DNS Service'), services='__all__')
|
||||
app.set_enabled(True)
|
||||
|
||||
|
||||
@ -95,19 +92,6 @@ def setup(helper, old_version=None):
|
||||
helper.install(managed_packages)
|
||||
|
||||
|
||||
def get_enabled_services(domain_name):
|
||||
"""Get enabled services for the domain name."""
|
||||
if domain_name is not None and domain_name != '':
|
||||
try:
|
||||
domainname_services = firewall.get_enabled_services(
|
||||
zone='external')
|
||||
except actions.ActionError:
|
||||
domainname_services = [service[0] for service in SERVICES]
|
||||
else:
|
||||
domainname_services = None
|
||||
return domainname_services
|
||||
|
||||
|
||||
def get_status():
|
||||
"""Return the current status."""
|
||||
# TODO: use key/value instead of hard coded value list
|
||||
|
||||
@ -161,12 +161,10 @@ def _apply_changes(request, old_status, new_status):
|
||||
_run(['stop'])
|
||||
|
||||
if new_status['enabled']:
|
||||
services = dynamicdns.get_enabled_services(
|
||||
new_status['dynamicdns_domain'])
|
||||
domain_added.send_robust(
|
||||
sender='dynamicdns', domain_type='dynamicdnsservice',
|
||||
name=new_status['dynamicdns_domain'],
|
||||
description=_('Dynamic DNS Service'), services=services)
|
||||
description=_('Dynamic DNS Service'), services='__all__')
|
||||
_run(['start'])
|
||||
|
||||
messages.success(request, _('Configuration updated'))
|
||||
|
||||
@ -153,4 +153,6 @@ def get_enabled_services(domain_type, domain):
|
||||
def get_services_status(domain_type, domain):
|
||||
"""Get list of whether each service is enabled for a domain."""
|
||||
enabled = get_enabled_services(domain_type, domain)
|
||||
return [service[0] in enabled for service in SERVICES]
|
||||
return [
|
||||
enabled == '__all__' or service[0] in enabled for service in SERVICES
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user