Development

This commit is contained in:
Matthew Grotke 2026-06-06 17:14:01 -04:00
parent e37029a066
commit 574a45111d
8 changed files with 164 additions and 110 deletions

View file

@ -49,14 +49,15 @@ def vlans_addedit():
radius_default = 'radius_default' in request.form
mdns_reflection = 'mdns_reflection' in request.form
dnsmasq_log_queries = 'dnsmasq_log_queries' in request.form
restricted_vlan = 'restricted_vlan' in request.form
restricted_vlan_raw = request.form.get('restricted_vlan', '').strip()
restricted_vlan = restricted_vlan_raw if restricted_vlan_raw in ('q', 'c') else ''
use_blocklists = sanitize.filterlist(
request.form.getlist('use_blocklists'),
{b.get('name') for b in load_config().get('dns_blocking', {}).get('blocklists', [])},
)
if restricted_vlan and not PRO_LICENSE:
flash('Restricted VLAN requires a Routlin Pro license.', 'error')
flash('Quarantined and Captive Portal VLANs require a Routlin Pro license.', 'error')
return redirect(f'/{_PAGE}')
if not name:
@ -269,8 +270,7 @@ def vlans_addedit():
'use_blocklists': use_blocklists,
'server_identities': new_identities,
})
if PRO_LICENSE:
existing['restricted_vlan'] = restricted_vlan
existing['restricted_vlan'] = restricted_vlan if PRO_LICENSE else ''
if dhcp_info:
existing['dhcp_information'] = dhcp_info
else:
@ -330,8 +330,7 @@ def vlans_addedit():
'mdns_reflection': mdns_reflection,
'server_identities': new_identities,
}
if PRO_LICENSE:
entry['restricted_vlan'] = restricted_vlan
entry['restricted_vlan'] = restricted_vlan if PRO_LICENSE else ''
if dhcp_info:
entry['dhcp_information'] = dhcp_info
if is_vpn:

View file

@ -97,11 +97,7 @@
"label": "Restricted",
"field": "restricted_vlan",
"class": "col-narrow",
"render": "badge_yes_no",
"render_options": {
"title_true": "Restricted VLAN",
"title_false": "Not Restricted"
}
"render": "badge_vlan_restriction"
}
],
"row_actions": [
@ -350,11 +346,11 @@
},
{
"type": "field",
"label": "%RESTRICTED_VLAN_LABEL%",
"label": "Restricted VLAN",
"name": "restricted_vlan",
"input_type": "checkbox",
"disabled": "%RESTRICTED_VLAN_DISABLED%",
"hint": "Block devices on this VLAN from communicating with the Internet. Block all LAN traffic as well (except where Inter-VLAN-Exception rules allow)."
"input_type": "select",
"options": "%RESTRICTED_VLAN_OPTIONS%",
"hint": "Quarantined VLAN devices are blocked from communicating with the Internet and may only be reached by Inter-VLAN-Exception rules. Captive Portal VLAN devices are redirected to an authentication page until they complete a login or accept terms."
},
{
"type": "button_row",

View file

@ -13,8 +13,19 @@ def collect_tokens(cfg):
tokens['EXISTING_VLAN_IDS_JSON'] = json.dumps([v.get('vlan_id') for v in vlans])
tokens['EXISTING_VLAN_NAMES_JSON'] = json.dumps([v.get('name') for v in vlans])
tokens['RADIUS_DEFAULT_VLAN'] = f'"{dv["name"]}" (VLAN {dv["vlan_id"]})' if dv else 'none set'
tokens['RESTRICTED_VLAN_LABEL'] = 'Restricted VLAN' if PRO_LICENSE else 'Restricted VLAN (PRO FEATURE)'
tokens['RESTRICTED_VLAN_DISABLED'] = '' if PRO_LICENSE else 'true'
tokens['PRO_LICENSE_JS'] = 'true' if PRO_LICENSE else ''
if PRO_LICENSE:
tokens['RESTRICTED_VLAN_OPTIONS'] = json.dumps([
{'value': '', 'label': 'Unrestricted'},
{'value': 'q', 'label': 'Quarantined'},
{'value': 'c', 'label': 'Captive Portal'},
])
else:
tokens['RESTRICTED_VLAN_OPTIONS'] = json.dumps([
{'value': '', 'label': 'Unrestricted'},
{'value': 'q', 'label': 'Quarantined (PRO REQUIRED)', 'disabled': True},
{'value': 'c', 'label': 'Captive Portal (PRO REQUIRED)', 'disabled': True},
])
tokens['BLOCKLIST_NAME_OPTIONS'] = json.dumps([
{'value': bl.get('name', ''), 'label': bl.get('description', bl.get('name', ''))}
for bl in cfg.get('dns_blocking', {}).get('blocklists', [])