diff --git a/plinth/modules/firewall/components.py b/plinth/modules/firewall/components.py index dd721861d..37c4dbc29 100644 --- a/plinth/modules/firewall/components.py +++ b/plinth/modules/firewall/components.py @@ -153,7 +153,12 @@ class Firewall(app.FollowerComponent): def get_port_forwarding_info(app_): """Return a list of ports to be forwarded for this app to work.""" - info = [] + from plinth.modules import networks + info = { + 'network_topology_type': networks.get_network_topology_type(), + 'router_configuration_type': networks.get_router_configuration_type(), + 'ports': [] + } for component in app_.components.values(): if not isinstance(component, Firewall): continue @@ -166,6 +171,9 @@ def get_port_forwarding_info(app_): continue for detail in port['details']: - info.append((detail[1].upper(), detail[0])) + info['ports'].append({ + 'protocol': detail[1].upper(), + 'ports': detail[0] + }) return info diff --git a/plinth/templates/port-forwarding-info.html b/plinth/templates/port-forwarding-info.html index a7b2211a8..c37737c62 100644 --- a/plinth/templates/port-forwarding-info.html +++ b/plinth/templates/port-forwarding-info.html @@ -4,33 +4,51 @@ {% load i18n %} -{% if port_forwarding_info %} +{% if port_forwarding_info.ports %}
- {% blocktrans trimmed %} - If your FreedomBox is behind a router, you will need to set up port - forwarding on your router. You should forward the following ports for - {{ service_name }}: - {% endblocktrans %} + {% url 'networks:index' as networks_url %} + {% if port_forwarding_info.network_topology_type != "to_router" %} + {% blocktrans trimmed %} + Your FreedomBox is not behind a router. + No action is necessary. + {% endblocktrans %} + + {% elif port_forwarding_info.router_configuration_type == 'dmz' %} + {% blocktrans trimmed %} + Your FreedomBox is behind a router and + you are using the DMZ feature to forward all ports. No further router + configuration is necessary. + {% endblocktrans %} + + {% else %} + {% blocktrans trimmed %} + Your FreedomBox is behind a router and + you are not using the DMZ feature. You will need to set up port + forwarding on your router. You should forward the following ports for + {{ service_name }}: + {% endblocktrans %} + +
| {% trans "Protocol" %} | +{% trans "From Router/WAN Ports" %} | +{% blocktrans %}To {{box_name}} Ports{% endblocktrans %} | +
|---|---|---|
| {{ port.protocol }} | +{{ port.ports }} | +{{ port.ports }} | +
| {% trans "Protocol" %} | -{% trans "From Router/WAN Ports" %} | -{% blocktrans %}To {{box_name}} Ports{% endblocktrans %} | -
|---|---|---|
| {{ port.0 }} | -{{ port.1 }} | -{{ port.1 }} | -