Exemple #1
0
def get_port_forwarding_info(app_):
    """Return a list of ports to be forwarded for this app to work."""
    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

        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['ports'].append({
                    'protocol': detail[1].upper(),
                    'ports': detail[0]
                })

    return info
Exemple #2
0
    def dispatch(self, request, *args, **kwargs):
        """Don't show wizard step if FreedomBox is not behind a router."""
        network_topology = networks.get_network_topology_type()
        if network_topology != 'to_router':
            first_boot.mark_step_done('router_setup_wizard')
            return HttpResponseRedirect(reverse_lazy(first_boot.next_step()))

        return super().dispatch(request, *args, *kwargs)
Exemple #3
0
def index(request):
    """Show connection list."""
    connections = network.get_connection_list()

    network_topology_type = networks.get_network_topology_type()
    internet_connection_type = networks.get_internet_connection_type()
    return TemplateResponse(
        request, 'networks_configuration.html', {
            'app_id': 'networks',
            'app_info': networks.app.info,
            'title': _('Network Connections'),
            'has_diagnostics': True,
            'is_enabled': True,
            'connections': connections,
            'network_topology': network_topology_type,
            'internet_connectivity_type': internet_connection_type,
        })
Exemple #4
0
 def get_initial(self):
     """Get initial form data."""
     return {'network_topology': networks.get_network_topology_type()}