mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
names: Retrieve the most important domain in a more generic way
- The get_domain_name() has some problem. It returns only static domain names but not a dynamic domain name. It may not always return the same domain when multiple static domains are configured. It may return return an empty string. Tests: - JSXC page shows the alphabetically first static domain. If no static domain is configured, first dynamic domain is shown, next pagekite domain, next pagekite domain, next tor onion domain, and finally .local domain. - Downloading profile from OpenVPN will set the first domain in it. - When ejabberd is installed, the first domain is configured by default. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
eeeec6710f
commit
85a694f20f
@ -11,12 +11,12 @@ from plinth import app as app_module
|
||||
from plinth import cfg, frontpage, menu
|
||||
from plinth.config import DropinConfigs
|
||||
from plinth.daemon import Daemon
|
||||
from plinth.modules import names
|
||||
from plinth.modules.apache.components import Webserver
|
||||
from plinth.modules.backups.components import BackupRestore
|
||||
from plinth.modules.coturn.components import TurnConfiguration, TurnConsumer
|
||||
from plinth.modules.firewall.components import Firewall
|
||||
from plinth.modules.letsencrypt.components import LetsEncrypt
|
||||
from plinth.modules.names.components import DomainName
|
||||
from plinth.modules.users.components import UsersAndGroups
|
||||
from plinth.package import Packages
|
||||
from plinth.signals import (domain_added, post_hostname_change,
|
||||
@ -136,7 +136,7 @@ class EjabberdApp(app_module.App):
|
||||
|
||||
def setup(self, old_version):
|
||||
"""Install and configure the app."""
|
||||
domain_name = names.get_domain_name()
|
||||
domain_name = DomainName.list_names()[0]
|
||||
logger.info('ejabberd service domain name - %s', domain_name)
|
||||
|
||||
privileged.pre_install(domain_name)
|
||||
|
||||
@ -5,7 +5,7 @@ from django.http import Http404
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
import plinth.app as app_module
|
||||
from plinth.modules import names
|
||||
from plinth.modules.names.components import DomainName
|
||||
|
||||
|
||||
class JsxcView(TemplateView):
|
||||
@ -21,8 +21,8 @@ class JsxcView(TemplateView):
|
||||
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
def get_context_data(self, *args, **kwargs) -> dict[str, object]:
|
||||
"""Add domain information to view context."""
|
||||
context = super().get_context_data(*args, **kwargs)
|
||||
context['domain_name'] = names.get_domain_name()
|
||||
context['domain_name'] = DomainName.list_names()[0]
|
||||
return context
|
||||
|
||||
@ -239,12 +239,6 @@ def on_domain_removed(sender: str, domain_type: str, name: str = '', **kwargs):
|
||||
######################################################
|
||||
|
||||
|
||||
def get_domain_name() -> str | None:
|
||||
"""Return the currently set static domain name."""
|
||||
domains = privileged.get_domains()
|
||||
return domains[0] if domains else ''
|
||||
|
||||
|
||||
def get_hostname():
|
||||
"""Return the hostname."""
|
||||
process = subprocess.run(['hostnamectl', 'hostname', '--static'],
|
||||
|
||||
@ -5,7 +5,7 @@ import logging
|
||||
|
||||
from django.http import HttpResponse
|
||||
|
||||
from plinth.modules import names
|
||||
from plinth.modules.names.components import DomainName
|
||||
from plinth.views import AppView
|
||||
|
||||
from . import privileged
|
||||
@ -23,10 +23,7 @@ class OpenVPNAppView(AppView):
|
||||
def profile(request):
|
||||
"""Provide the user's profile for download."""
|
||||
username = request.user.username
|
||||
domain_name = names.get_domain_name()
|
||||
|
||||
if not domain_name:
|
||||
domain_name = names.get_hostname()
|
||||
domain_name = DomainName.list_names()[0]
|
||||
|
||||
profile_string = privileged.get_profile(username, domain_name)
|
||||
response = HttpResponse(profile_string,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user