mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
firewall: Use service files for showing port forwarding info
- Start showing port ranges properly. - Fixes issue with Coturn TURN relay ports not being shown. Closes: #1851. Tests: - Visit each of affected apps and see the port forwarding information. The information is same as before. - HTTP and HTTPS ports are not shown. - Coturn app shows additional port ranges for TURN relay ports. - Shadowsocks app does not show port forwarding information as it is internal only. - Visit one of the apps not effected by the patch. There is no section related to port forwarding. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
parent
c218f3845f
commit
4aa8e6da09
@ -36,11 +36,6 @@ _description = [
|
||||
box_name=_(cfg.box_name)),
|
||||
]
|
||||
|
||||
port_forwarding_info = [
|
||||
('TCP', 53),
|
||||
('UDP', 53),
|
||||
]
|
||||
|
||||
CONFIG_FILE = '/etc/bind/named.conf.options'
|
||||
ZONES_DIR = '/var/bind/pri'
|
||||
|
||||
|
||||
@ -7,10 +7,10 @@ from django.contrib import messages
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth.views import AppView
|
||||
from plinth.modules import bind, names
|
||||
from plinth.views import AppView
|
||||
|
||||
from . import get_config, port_forwarding_info
|
||||
from . import get_config
|
||||
from .forms import BindForm
|
||||
|
||||
|
||||
@ -19,7 +19,6 @@ class BindAppView(AppView): # pylint: disable=too-many-ancestors
|
||||
app_id = 'bind'
|
||||
form_class = BindForm
|
||||
template_name = 'bind.html'
|
||||
port_forwarding_info = port_forwarding_info
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
"""
|
||||
|
||||
@ -36,18 +36,6 @@ _description = [
|
||||
'matrix-synapse need to be configured with the details provided here.'),
|
||||
]
|
||||
|
||||
port_forwarding_info = [
|
||||
('UDP', 3478),
|
||||
('TCP', 3478),
|
||||
('UDP', 3479),
|
||||
('TCP', 3479),
|
||||
('UDP', 5349),
|
||||
('TCP', 5349),
|
||||
('UDP', 5350),
|
||||
('TCP', 5350),
|
||||
# XXX: Add relay ports here
|
||||
]
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
|
||||
@ -17,7 +17,6 @@ class CoturnAppView(views.AppView):
|
||||
app_id = 'coturn'
|
||||
template_name = 'coturn.html'
|
||||
form_class = forms.CoturnForm
|
||||
port_forwarding_info = coturn.port_forwarding_info
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Return additional context for rendering the template."""
|
||||
|
||||
@ -18,10 +18,10 @@ from plinth.modules import config
|
||||
from plinth.modules.apache.components import Webserver
|
||||
from plinth.modules.firewall.components import Firewall
|
||||
from plinth.modules.letsencrypt.components import LetsEncrypt
|
||||
from plinth.modules.users.components import UsersAndGroups
|
||||
from plinth.signals import (domain_added, post_hostname_change,
|
||||
pre_hostname_change)
|
||||
from plinth.utils import format_lazy
|
||||
from plinth.modules.users.components import UsersAndGroups
|
||||
|
||||
from .manifest import backup, clients # noqa, pylint: disable=unused-import
|
||||
|
||||
@ -46,12 +46,6 @@ _description = [
|
||||
jsxc_url=reverse_lazy('jsxc:index'))
|
||||
]
|
||||
|
||||
port_forwarding_info = [
|
||||
('TCP', 5222),
|
||||
('TCP', 5269),
|
||||
('TCP', 5280),
|
||||
]
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
app = None
|
||||
|
||||
@ -18,7 +18,6 @@ class EjabberdAppView(AppView):
|
||||
app_id = 'ejabberd'
|
||||
template_name = 'ejabberd.html'
|
||||
form_class = EjabberdForm
|
||||
port_forwarding_info = ejabberd.port_forwarding_info
|
||||
|
||||
def get_initial(self):
|
||||
initdict = super().get_initial()
|
||||
|
||||
@ -149,3 +149,23 @@ class Firewall(app.FollowerComponent):
|
||||
results.append([message, result])
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def get_port_forwarding_info(app_):
|
||||
"""Return a list of ports to be forwarded for this app to work."""
|
||||
info = []
|
||||
for component in app_.components.values():
|
||||
if not isinstance(component, Firewall):
|
||||
continue
|
||||
|
||||
if not component.is_external:
|
||||
continue
|
||||
|
||||
for port in component.ports_details:
|
||||
if port['name'] in ['http', 'https']:
|
||||
continue
|
||||
|
||||
for detail in port['details']:
|
||||
info.append((detail[1].upper(), detail[0]))
|
||||
|
||||
return info
|
||||
|
||||
@ -35,12 +35,6 @@ _description = [
|
||||
'configuration process.')
|
||||
]
|
||||
|
||||
port_forwarding_info = [
|
||||
('TCP', 4444),
|
||||
('TCP', 4445),
|
||||
('TCP', 6668),
|
||||
]
|
||||
|
||||
tunnels_to_manage = {
|
||||
'I2P HTTP Proxy': 'i2p-http-proxy-freedombox',
|
||||
'I2P HTTPS Proxy': 'i2p-https-proxy-freedombox',
|
||||
|
||||
@ -4,7 +4,7 @@ Views for I2P application.
|
||||
"""
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from plinth.modules import i2p
|
||||
|
||||
from plinth.views import AppView
|
||||
|
||||
|
||||
@ -29,7 +29,6 @@ class I2PAppView(AppView):
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Return the context data for rendering the template view."""
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['port_forwarding_info'] = i2p.port_forwarding_info
|
||||
context['proxies_description'] = self.proxies_description
|
||||
context['torrents_description'] = self.torrents_description
|
||||
|
||||
|
||||
@ -30,8 +30,6 @@ _description = [
|
||||
box_name=_(cfg.box_name)),
|
||||
]
|
||||
|
||||
port_forwarding_info = [('TCP', 6523)]
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
|
||||
@ -5,8 +5,9 @@ URLs for the infinoted module.
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
from .views import InfinotedAppView
|
||||
from plinth.views import AppView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^apps/infinoted/$', InfinotedAppView.as_view(), name='index'),
|
||||
url(r'^apps/infinoted/$', AppView.as_view(app_id='infinoted'),
|
||||
name='index'),
|
||||
]
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""
|
||||
Views for the infinoted app.
|
||||
"""
|
||||
from plinth.modules import infinoted
|
||||
from plinth.views import AppView
|
||||
|
||||
|
||||
class InfinotedAppView(AppView):
|
||||
"""Main app view for Infinoted."""
|
||||
app_id = 'infinoted'
|
||||
port_forwarding_info = infinoted.port_forwarding_info
|
||||
@ -44,8 +44,6 @@ _description = [
|
||||
'<a href="https://element.io/">Element</a> client is recommended.')
|
||||
]
|
||||
|
||||
port_forwarding_info = [('TCP', 8448)]
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
SERVER_NAME_PATH = "/etc/matrix-synapse/conf.d/server_name.yaml"
|
||||
|
||||
@ -46,7 +46,6 @@ class MatrixSynapseAppView(AppView):
|
||||
app_id = 'matrixsynapse'
|
||||
template_name = 'matrix-synapse.html'
|
||||
form_class = MatrixSynapseForm
|
||||
port_forwarding_info = matrixsynapse.port_forwarding_info
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
"""Redirect to setup page if setup is not done yet."""
|
||||
|
||||
@ -11,8 +11,8 @@ from plinth import app as app_module
|
||||
from plinth import cfg, frontpage, menu
|
||||
from plinth.daemon import Daemon
|
||||
from plinth.modules.firewall.components import Firewall
|
||||
from plinth.utils import format_lazy
|
||||
from plinth.modules.users.components import UsersAndGroups
|
||||
from plinth.utils import format_lazy
|
||||
|
||||
from .manifest import backup, clients # noqa, pylint: disable=unused-import
|
||||
|
||||
@ -42,8 +42,6 @@ _description = [
|
||||
'is needed.'), box_name=_(cfg.box_name)),
|
||||
]
|
||||
|
||||
port_forwarding_info = [('UDP', 30000)]
|
||||
|
||||
CONFIG_FILE = '/etc/minetest/minetest.conf'
|
||||
AUG_PATH = '/files' + CONFIG_FILE + '/.anon'
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ from django.contrib import messages
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth.modules import minetest, names
|
||||
from plinth.modules import names
|
||||
from plinth.views import AppView
|
||||
|
||||
from . import get_configuration
|
||||
@ -19,7 +19,6 @@ class MinetestAppView(AppView): # pylint: disable=too-many-ancestors
|
||||
app_id = 'minetest'
|
||||
template_name = 'minetest.html'
|
||||
form_class = MinetestForm
|
||||
port_forwarding_info = minetest.port_forwarding_info
|
||||
|
||||
def get_initial(self):
|
||||
"""Return the values to fill in the form."""
|
||||
|
||||
@ -28,11 +28,6 @@ _description = [
|
||||
'from your desktop and Android devices are available.')
|
||||
]
|
||||
|
||||
port_forwarding_info = [
|
||||
('TCP', 64738),
|
||||
('UDP', 64738),
|
||||
]
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
|
||||
@ -3,14 +3,12 @@ from django.contrib import messages
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth.modules.mumble import port_forwarding_info
|
||||
from plinth.modules.mumble.forms import MumbleForm
|
||||
from plinth.views import AppView
|
||||
|
||||
|
||||
class MumbleAppView(AppView):
|
||||
app_id = 'mumble'
|
||||
port_forwarding_info = port_forwarding_info
|
||||
form_class = MumbleForm
|
||||
|
||||
def form_valid(self, form):
|
||||
|
||||
@ -32,8 +32,6 @@ _description = [
|
||||
'for added security and anonymity.'), box_name=_(cfg.box_name))
|
||||
]
|
||||
|
||||
port_forwarding_info = [('UDP', 1194)]
|
||||
|
||||
app = None
|
||||
|
||||
setup_process = None
|
||||
|
||||
@ -22,7 +22,6 @@ class OpenVPNAppView(AppView):
|
||||
"""Show OpenVPN app main page."""
|
||||
app_id = 'openvpn'
|
||||
template_name = 'openvpn.html'
|
||||
port_forwarding_info = openvpn.port_forwarding_info
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
"""Collect the result of running setup process."""
|
||||
|
||||
@ -15,8 +15,8 @@ from plinth.daemon import Daemon
|
||||
from plinth.modules import names
|
||||
from plinth.modules.firewall.components import Firewall
|
||||
from plinth.modules.letsencrypt.components import LetsEncrypt
|
||||
from plinth.utils import format_lazy
|
||||
from plinth.modules.users.components import UsersAndGroups
|
||||
from plinth.utils import format_lazy
|
||||
|
||||
from .manifest import backup, clients # noqa, pylint: disable=unused-import
|
||||
|
||||
@ -44,8 +44,6 @@ _description = [
|
||||
'are available.'),
|
||||
]
|
||||
|
||||
port_forwarding_info = [('TCP', 4242)]
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@ from .forms import QuasselForm
|
||||
|
||||
class QuasselAppView(AppView):
|
||||
app_id = 'quassel'
|
||||
port_forwarding_info = quassel.port_forwarding_info
|
||||
form_class = QuasselForm
|
||||
|
||||
def get_initial(self):
|
||||
|
||||
@ -32,8 +32,6 @@ _description = [
|
||||
'using such connections.')
|
||||
]
|
||||
|
||||
port_forwarding_info = [('TCP', 22)]
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
|
||||
@ -37,11 +37,6 @@ _description = [
|
||||
'node to the other storage nodes.'), box_name=_(cfg.box_name)),
|
||||
]
|
||||
|
||||
port_forwarding_info = [
|
||||
('TCP', 3456),
|
||||
('TCP', 5678),
|
||||
]
|
||||
|
||||
tahoe_home = '/var/lib/tahoe-lafs'
|
||||
introducer_name = 'introducer'
|
||||
storage_node_name = 'storage_node'
|
||||
|
||||
@ -36,7 +36,6 @@ class TahoeAppView(AppView):
|
||||
"""Show tahoe-lafs service page."""
|
||||
app_id = 'tahoe'
|
||||
template_name = 'tahoe-post-setup.html'
|
||||
port_forwarding_info = tahoe.port_forwarding_info
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if not tahoe.is_setup():
|
||||
|
||||
@ -33,8 +33,6 @@ _description = [
|
||||
box_name=_(cfg.box_name))
|
||||
]
|
||||
|
||||
port_forwarding_info = [('UDP', 51820)]
|
||||
|
||||
app = None
|
||||
|
||||
SERVER_INTERFACE = 'wg0'
|
||||
|
||||
@ -13,7 +13,6 @@ from django.urls import reverse_lazy
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views.generic import FormView, TemplateView
|
||||
|
||||
import plinth.modules.wireguard as wireguard
|
||||
from plinth import network
|
||||
from plinth.modules.names.components import DomainName
|
||||
from plinth.views import AppView
|
||||
@ -26,7 +25,6 @@ class WireguardView(AppView):
|
||||
app_id = 'wireguard'
|
||||
diagnostics_module_name = 'wireguard'
|
||||
template_name = 'wireguard.html'
|
||||
port_forwarding_info = wireguard.port_forwarding_info
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Return additional context for rendering the template."""
|
||||
|
||||
@ -19,6 +19,7 @@ from stronghold.decorators import public
|
||||
from plinth import app, package
|
||||
from plinth.daemon import app_is_running
|
||||
from plinth.modules.config import get_advanced_mode
|
||||
from plinth.modules.firewall.components import get_port_forwarding_info
|
||||
from plinth.translation import get_language_from_request, set_language
|
||||
|
||||
from . import forms, frontpage
|
||||
@ -146,15 +147,10 @@ class AppView(FormView):
|
||||
to customize the appearance of the app to achieve more complex presentation
|
||||
instead of the simple appearance provided by default.
|
||||
|
||||
'port_forwarding_info' is a list of port information dictionaries that can
|
||||
used to show a special section in the app page that tells the users how to
|
||||
forward ports on their router for this app to work properly.
|
||||
|
||||
"""
|
||||
form_class = None
|
||||
app_id = None
|
||||
template_name = 'app.html'
|
||||
port_forwarding_info = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Initialize the view."""
|
||||
@ -254,7 +250,7 @@ class AppView(FormView):
|
||||
context['is_running'] = app_is_running(self.app)
|
||||
context['app_info'] = self.app.info
|
||||
context['has_diagnostics'] = self.app.has_diagnostics()
|
||||
context['port_forwarding_info'] = self.port_forwarding_info
|
||||
context['port_forwarding_info'] = get_port_forwarding_info(self.app)
|
||||
context['app_enable_disable_form'] = self.get_enable_disable_form()
|
||||
|
||||
from plinth.modules.firewall.components import Firewall
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user