mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +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 actions
|
||||||
from plinth import app as app_module
|
from plinth import app as app_module
|
||||||
from plinth import frontpage, menu
|
from plinth import frontpage, menu
|
||||||
from plinth.modules import firewall
|
|
||||||
from plinth.modules.names import SERVICES
|
|
||||||
from plinth.signals import domain_added
|
from plinth.signals import domain_added
|
||||||
|
|
||||||
version = 2
|
version = 2
|
||||||
@ -152,21 +150,9 @@ def init():
|
|||||||
# Register domain with Name Services module.
|
# Register domain with Name Services module.
|
||||||
domainname = get_domainname()
|
domainname = get_domainname()
|
||||||
if domainname:
|
if domainname:
|
||||||
try:
|
domain_added.send_robust(
|
||||||
domainname_services = firewall.get_enabled_services(
|
sender='config', domain_type='domainname', name=domainname,
|
||||||
zone='external')
|
description=ugettext_lazy('Domain Name'), services='__all__')
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
||||||
def setup(helper, old_version=None):
|
def setup(helper, old_version=None):
|
||||||
|
|||||||
@ -25,8 +25,7 @@ from django.template.response import TemplateResponse
|
|||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from plinth import actions
|
from plinth import actions
|
||||||
from plinth.modules import config, firewall
|
from plinth.modules import config
|
||||||
from plinth.modules.names import SERVICES
|
|
||||||
from plinth.signals import (domain_added, domain_removed, domainname_change,
|
from plinth.signals import (domain_added, domain_removed, domainname_change,
|
||||||
post_hostname_change, pre_hostname_change)
|
post_hostname_change, pre_hostname_change)
|
||||||
|
|
||||||
@ -159,14 +158,6 @@ def set_domainname(domainname):
|
|||||||
# Update domain registered with Name Services module.
|
# Update domain registered with Name Services module.
|
||||||
domain_removed.send_robust(sender='config', domain_type='domainname')
|
domain_removed.send_robust(sender='config', domain_type='domainname')
|
||||||
if 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',
|
domain_added.send_robust(sender='config', domain_type='domainname',
|
||||||
name=domainname, description=_('Domain Name'),
|
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 actions
|
||||||
from plinth import app as app_module
|
from plinth import app as app_module
|
||||||
from plinth import cfg, menu
|
from plinth import cfg, menu
|
||||||
from plinth.modules import firewall
|
|
||||||
from plinth.modules.names import SERVICES
|
|
||||||
from plinth.signals import domain_added
|
from plinth.signals import domain_added
|
||||||
from plinth.utils import format_lazy
|
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
|
version = 1
|
||||||
|
|
||||||
@ -82,11 +80,10 @@ def init():
|
|||||||
app = DynamicDNSApp()
|
app = DynamicDNSApp()
|
||||||
current_status = get_status()
|
current_status = get_status()
|
||||||
if current_status['enabled']:
|
if current_status['enabled']:
|
||||||
services = get_enabled_services(current_status['dynamicdns_domain'])
|
|
||||||
domain_added.send_robust(
|
domain_added.send_robust(
|
||||||
sender='dynamicdns', domain_type='dynamicdnsservice',
|
sender='dynamicdns', domain_type='dynamicdnsservice',
|
||||||
name=current_status['dynamicdns_domain'],
|
name=current_status['dynamicdns_domain'],
|
||||||
description=_('Dynamic DNS Service'), services=services)
|
description=_('Dynamic DNS Service'), services='__all__')
|
||||||
app.set_enabled(True)
|
app.set_enabled(True)
|
||||||
|
|
||||||
|
|
||||||
@ -95,19 +92,6 @@ def setup(helper, old_version=None):
|
|||||||
helper.install(managed_packages)
|
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():
|
def get_status():
|
||||||
"""Return the current status."""
|
"""Return the current status."""
|
||||||
# TODO: use key/value instead of hard coded value list
|
# TODO: use key/value instead of hard coded value list
|
||||||
|
|||||||
@ -161,12 +161,10 @@ def _apply_changes(request, old_status, new_status):
|
|||||||
_run(['stop'])
|
_run(['stop'])
|
||||||
|
|
||||||
if new_status['enabled']:
|
if new_status['enabled']:
|
||||||
services = dynamicdns.get_enabled_services(
|
|
||||||
new_status['dynamicdns_domain'])
|
|
||||||
domain_added.send_robust(
|
domain_added.send_robust(
|
||||||
sender='dynamicdns', domain_type='dynamicdnsservice',
|
sender='dynamicdns', domain_type='dynamicdnsservice',
|
||||||
name=new_status['dynamicdns_domain'],
|
name=new_status['dynamicdns_domain'],
|
||||||
description=_('Dynamic DNS Service'), services=services)
|
description=_('Dynamic DNS Service'), services='__all__')
|
||||||
_run(['start'])
|
_run(['start'])
|
||||||
|
|
||||||
messages.success(request, _('Configuration updated'))
|
messages.success(request, _('Configuration updated'))
|
||||||
|
|||||||
@ -153,4 +153,6 @@ def get_enabled_services(domain_type, domain):
|
|||||||
def get_services_status(domain_type, domain):
|
def get_services_status(domain_type, domain):
|
||||||
"""Get list of whether each service is enabled for a domain."""
|
"""Get list of whether each service is enabled for a domain."""
|
||||||
enabled = get_enabled_services(domain_type, 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