Example #1
0
def statuspage():
    status = dict()
    status['system'] = sysstatus.get_system_status()
    status['resources'] = sysstatus.get_resources_status()
    status['wan'] = netif.get_wan_status()
    status['lan'] = netif.get_lan_status()
    status['wifi'] = netif.get_wifi_status()
    status['tor'] = tor.get_tor_status()
    return render_template('home.html', settings=None, status=status)
Example #2
0
def statuspage():
    status = dict()
    status['system'] = sysstatus.get_system_status()
    status['resources'] = sysstatus.get_resources_status()
    status['wan'] = netif.get_wan_status()
    status['lan'] = netif.get_lan_status()
    status['wifi'] = netif.get_wifi_status()
    status['tor'] = tor.get_tor_status()
    return render_template('home.html', settings=None, status=status)
Example #3
0
def wanpage():
    msg = list()
    status = dict(wan=netif.get_wan_status())
    if not status['wan']:
        msg.append(
            ("error", "Interface not detected, can not be configured."), )
        return render_template('wan.html',
                               form=None,
                               status=status,
                               messages=msg,
                               formerr=None)
    if request.method == 'GET':
        form = netif.get_wan_settings()
        return render_template('wan.html',
                               form=form,
                               status=status,
                               formerr=None)
    # Got this far, need to validate form
    formerr = dict()
    if request.form['ipv4method'] == 'disabled':
        pass  # no further validation
    elif request.form['ipv4method'] == 'dhcp':
        pass  # no further validation
    elif request.form['ipv4method'] == 'static':
        if not netif.is_valid_ipv4(request.form['ipv4addr']):
            formerr['ipv4addr'] = "Not a valid IPv4 address"
        if not netif.is_valid_ipv4mask(request.form['ipv4netmask']):
            formerr['ipv4netmask'] = "Not a valid IPv4 netmask"
        if not netif.is_valid_ipv4(request.form['ipv4gateway']):
            formerr['ipv4gateway'] = "Not a valid IPv4 address"
    else:
        ke = KeyError("Invalid net config method: %s" % form['ipv4method'])
        print ke
        raise ke
    if len(formerr.keys()) > 0:
        msg.append(("error", "Please correct the validation issues below"), )
    else:
        # Ok, we have a valid form, now to commit it
        try:
            netif.save_wan_settings(request.form)
            msg.append(("success",
                        "Configuration saved! Check logs for any errors"), )
        except IOError, ioerr:
            msg.append((
                "error",
                "Was unable to commit changes... permissions problem? \"%s\"" %
                ioerr))
Example #4
0
def wanpage():
    msg = list()
    status = dict(wan=netif.get_wan_status())
    if not status['wan']:
        msg.append(("error",
            "Interface not detected, can not be configured."),)
        return render_template('wan.html', form=None, status=status,
            messages=msg, formerr=None)
    if request.method == 'GET':
        form = netif.get_wan_settings()
        return render_template('wan.html', form=form, status=status,
            formerr=None)
    # Got this far, need to validate form
    formerr = dict()
    if request.form['ipv4method'] == 'disabled':
        pass    # no further validation
    elif request.form['ipv4method'] == 'dhcp':
        pass    # no further validation
    elif request.form['ipv4method'] == 'static':
        if not netif.is_valid_ipv4(request.form['ipv4addr']):
            formerr['ipv4addr'] = "Not a valid IPv4 address"
        if not netif.is_valid_ipv4mask(request.form['ipv4netmask']):
            formerr['ipv4netmask'] = "Not a valid IPv4 netmask"
        if not netif.is_valid_ipv4(request.form['ipv4gateway']):
            formerr['ipv4gateway'] = "Not a valid IPv4 address"
    else:
        ke = KeyError("Invalid net config method: %s" % form['ipv4method'])
        print ke
        raise ke
    if len(formerr.keys()) > 0:
        msg.append(("error",
            "Please correct the validation issues below"),)
    else:
        # Ok, we have a valid form, now to commit it
        try:
            netif.save_wan_settings(request.form)
            msg.append(("success",
                "Configuration saved! Check logs for any errors"),)
        except IOError, ioerr:
            msg.append(("error",
                "Was unable to commit changes... permissions problem? \"%s\""
                    % ioerr))