mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
networks: Disable DNS-over-TLS option if resolved is not installed
Tests: - Ensure that systemd-resolved package is not installed. DNS-over-TLS field is disabled. - Submitting the form works with and without changes. - Value of global DNS-over-TLS setting shows as 'unknown'. - Current value of DNS-over-TLS for this connection is show in the form. - Ensure that systemd-resolved package is installed. DNS-over-TLS field is enabled. - Submitting the form works with and without changes. - Value of the global DNS-over-TLS setting shows the current value set in names app. - Current value of DNS-over-TLS for this connection is show in the form. - Introduce an exception in get_resolved_configuration privileged action and notice that value shows up as 'unknown' in the form. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
parent
71ed5f16c2
commit
1f17728321
@ -7,6 +7,7 @@ from django.utils.functional import lazy
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from plinth import cfg, network
|
from plinth import cfg, network
|
||||||
|
from plinth.modules import names
|
||||||
from plinth.utils import format_lazy, import_from_gi
|
from plinth.utils import format_lazy, import_from_gi
|
||||||
|
|
||||||
nm = import_from_gi('NM', '1.0')
|
nm = import_from_gi('NM', '1.0')
|
||||||
@ -14,11 +15,14 @@ nm = import_from_gi('NM', '1.0')
|
|||||||
|
|
||||||
def _get_dns_over_tls():
|
def _get_dns_over_tls():
|
||||||
"""Return the value of DNS over TLS."""
|
"""Return the value of DNS over TLS."""
|
||||||
|
if not names.is_resolved_installed():
|
||||||
|
return str(_('unknown'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from plinth.modules.names import privileged
|
from plinth.modules.names import privileged
|
||||||
dns_over_tls = privileged.get_resolved_configuration()['dns_over_tls']
|
dns_over_tls = privileged.get_resolved_configuration()['dns_over_tls']
|
||||||
except Exception:
|
except Exception:
|
||||||
return _('unknown')
|
return str(_('unknown'))
|
||||||
|
|
||||||
value_map = {
|
value_map = {
|
||||||
'yes': _('yes'),
|
'yes': _('yes'),
|
||||||
@ -160,6 +164,13 @@ class ConnectionForm(forms.Form):
|
|||||||
'provided by a DHCP server will be ignored.'),
|
'provided by a DHCP server will be ignored.'),
|
||||||
validators=[validators.validate_ipv6_address], required=False)
|
validators=[validators.validate_ipv6_address], required=False)
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Disable DNS fallback field if necessary."""
|
||||||
|
from plinth.modules import names
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.fields['dns_over_tls'].disabled = (
|
||||||
|
not names.is_resolved_installed())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_interface_choices(device_type):
|
def _get_interface_choices(device_type):
|
||||||
"""Return a list of choices for a given device type."""
|
"""Return a list of choices for a given device type."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user