mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
- If a daemon is not-running, we already show an error message to the user. Use that mechanism instead of the custom one. Tests: - Functional tests work. - Initial setup for firewall on first boot works. - Default zone of the firewalld is set to external in /etc/firewalld.conf - Status of various apps is shown properly in the app page - If firewalld is not running, the app page is still displayed properly and message that firewalld is not running is shown. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
25 lines
863 B
Python
25 lines
863 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""FreedomBox app to configure a firewall."""
|
|
|
|
from plinth import views
|
|
from plinth.modules import firewall
|
|
|
|
from . import components
|
|
|
|
|
|
class FirewallAppView(views.AppView):
|
|
"""Serve firewall index page."""
|
|
|
|
app_id = 'firewall'
|
|
template_name = 'firewall.html'
|
|
|
|
def get_context_data(self, *args, **kwargs):
|
|
"""Add additional context data for the template."""
|
|
context = super().get_context_data(*args, **kwargs)
|
|
context['components'] = components.Firewall.list()
|
|
internal_enabled_ports = firewall.get_enabled_services(zone='internal')
|
|
external_enabled_ports = firewall.get_enabled_services(zone='external')
|
|
context['internal_enabled_ports'] = internal_enabled_ports
|
|
context['external_enabled_ports'] = external_enabled_ports
|
|
return context
|