Sunil Mohan Adapa d7e0752d12
privacy: Implement a way to disable fallback DNS servers
- Using public DNS servers leads to user's domain queries being known to the
servers, violating privacy. However, it is necessary to address many corner
cases when DNS servers are not known to systemd-resolved but internet
connectivity is working. Allow users to disable fallback DNS servers.

Tests:

- After upgrade to latest version of FreedomBox, the setting is on by default.

- Disabling removes the /etc configuration file and resolvectl shows no fallback
DNS entries.

- Enabling add the /etc configuration file and resolvectl shows fallback
entries. After removing existing DNS servers using resolvectl, one can still
query using fallback servers.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-09-04 10:30:25 +03:00

49 lines
1.5 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""Views for privacy app."""
from django.contrib import messages
from django.utils.translation import gettext as _
import plinth.modules.names.privileged as names_privileged
from plinth.modules.privacy.forms import PrivacyForm
from plinth.views import AppView
from . import privileged
class PrivacyAppView(AppView):
"""Serve configuration page."""
app_id = 'privacy'
form_class = PrivacyForm
def get_initial(self):
"""Return the values to fill in the form."""
initial = super().get_initial()
initial.update(privileged.get_configuration())
initial.update(names_privileged.get_resolved_configuration())
return initial
def form_valid(self, form):
"""Change the configurations of Minetest service."""
new_config = form.cleaned_data
old_config = form.initial
changes = {}
is_changed = False
if old_config['enable_popcon'] != new_config['enable_popcon']:
changes['enable_popcon'] = new_config['enable_popcon']
if old_config['dns_fallback'] != new_config['dns_fallback']:
names_privileged.set_resolved_configuration(
dns_fallback=new_config['dns_fallback'])
is_changed = True
if changes:
privileged.set_configuration(**changes)
if changes or is_changed:
messages.success(self.request, _('Configuration updated'))
return super().form_valid(form)