コード例 #1
0
def load_page():
    return {
        'firewall_rules': System.firewall_rules(),
        'dmz_dnat_rules': System.nat_rules(),
        'local_snat_rules': System.nat_rules(nat_type='SRCNAT'),
        'netmasks': list(reversed(range(24, 33)))
    }
コード例 #2
0
def load_page():
    fw_rules = System.firewall_rules()
    nat_rules = System.nat_rules()

    netmasks = list(reversed(range(24, 33)))

    firewall_settings = {
        'firewall_rules': fw_rules,
        'nat_rules': nat_rules,
        'netmasks': netmasks
    }

    return firewall_settings
コード例 #3
0
def update_page(form):
    # initial input validation for presence of zone field
    zone = form.get('zone', None)
    if (zone not in valid_zones):
        return INVALID_FORM, 'GLOBAL_INTERFACE', None

    # if firewall rule, None will be used for evaluation.
    action = form.get('action', None)
    nat_type = form.get('nat_type', None)
    if (nat_type is None):
        error, zone = _firewall_rules(zone, action, form)

    elif (nat_type in ['DSTNAT', 'SRCNAT']):

        if (nat_type == 'DSTNAT'):
            error, zone = _dnat_rules(zone, action, form)

        elif (nat_type == 'SRCNAT'):
            error, zone = _snat_rules(zone, action, form)

    else:
        return INVALID_FORM, zone, None

    # updating page data then returning. this is because we need to serve the content with the newly added
    # configuration item.
    page_data = None
    if not error:
        page_data = {
            'firewall_rules': System.firewall_rules(chain=zone),
            'dmz_dnat_rules': System.nat_rules(),
            'local_snat_rules': System.nat_rules(nat_type='SRCNAT'),
            'netmasks': list(reversed(range(24, 33)))
        }

    print(f'RETURNING: {page_data}')

    return error, zone, page_data