firewall: Show port forwarding info contextually

- When port forwarding configuration is not required in the router, don't show
the ports information.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa authored and Veiko Aasa committed 2020-09-04 16:32:46 +03:00
1 parent f58b5f8962
commit 50fb524972
2 files changed
+52 -26

No files matched your search

+10 -2
View File
@@ -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