From 575edc836d23021fa9bc1216b5ff17023170e9f8 Mon Sep 17 00:00:00 2001 From: Matthew Grotke Date: Sun, 17 May 2026 03:37:26 -0400 Subject: [PATCH] Added missing files due to gitignore --- docker/router-dash/Dockerfile | 7 + .../app/action_apply_blocklists.py | 2 + .../app/action_apply_dhcp_reservations.py | 3 +- .../app/action_apply_host_overrides.py | 3 +- .../app/action_apply_inter_vlan.py | 3 +- .../app/action_apply_port_forwarding.py | 3 +- docker/router-dash/data/page_content.json | 586 +++++------------- docker/router-dash/docker-compose.yml | 21 + docker/router-dash/requirements.txt | 2 + 9 files changed, 208 insertions(+), 422 deletions(-) create mode 100644 docker/router-dash/Dockerfile create mode 100644 docker/router-dash/docker-compose.yml create mode 100644 docker/router-dash/requirements.txt diff --git a/docker/router-dash/Dockerfile b/docker/router-dash/Dockerfile new file mode 100644 index 0000000..0833fde --- /dev/null +++ b/docker/router-dash/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.12-slim +WORKDIR /app +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt +COPY app/*.py . +EXPOSE 25327 +CMD ["python", "main.py"] diff --git a/docker/router-dash/app/action_apply_blocklists.py b/docker/router-dash/app/action_apply_blocklists.py index e9bd297..ccf9ee8 100644 --- a/docker/router-dash/app/action_apply_blocklists.py +++ b/docker/router-dash/app/action_apply_blocklists.py @@ -128,11 +128,13 @@ def edit_blocklist(): flash('Entry not found.', 'error') return redirect(VIEW) + enabled = request.form.get('enabled') == 'on' items[idx].update({ 'name': fields['name'], 'description': fields['description'], 'format': fields['format'], 'url': fields['url'], + 'enabled': enabled, }) save_core(core) diff --git a/docker/router-dash/app/action_apply_dhcp_reservations.py b/docker/router-dash/app/action_apply_dhcp_reservations.py index f6553bb..1cd10b8 100644 --- a/docker/router-dash/app/action_apply_dhcp_reservations.py +++ b/docker/router-dash/app/action_apply_dhcp_reservations.py @@ -147,14 +147,13 @@ def edit_dhcp_reservation(): return redirect(VIEW) res = vlans[vi]['reservations'][ri] - enabled = res.get('enabled', True) res.update({ 'description': description, 'hostname': hostname, 'mac': mac, 'ip': ip, 'radius_client': radius_client, - 'enabled': enabled, + 'enabled': 'enabled' in request.form, }) save_core(core) diff --git a/docker/router-dash/app/action_apply_host_overrides.py b/docker/router-dash/app/action_apply_host_overrides.py index 934b061..71718ab 100644 --- a/docker/router-dash/app/action_apply_host_overrides.py +++ b/docker/router-dash/app/action_apply_host_overrides.py @@ -84,6 +84,7 @@ def edit_host_override(): description = sanitize.text(request.form.get('description', '')) host = sanitize.hostname(request.form.get('host', '')) ip = sanitize.ip(request.form.get('ip', '')) + enabled = request.form.get('enabled') == 'on' if not host or not ip: flash('Hostname and IP address are required.', 'error') @@ -98,7 +99,7 @@ def edit_host_override(): flash('Entry not found.', 'error') return redirect(VIEW) - items[idx].update({'description': description, 'host': host, 'ip': ip}) + items[idx].update({'description': description, 'host': host, 'ip': ip, 'enabled': enabled}) save_core(core) flash(apply_msg(), 'success') diff --git a/docker/router-dash/app/action_apply_inter_vlan.py b/docker/router-dash/app/action_apply_inter_vlan.py index f6961f7..b3d3621 100644 --- a/docker/router-dash/app/action_apply_inter_vlan.py +++ b/docker/router-dash/app/action_apply_inter_vlan.py @@ -134,9 +134,8 @@ def edit_inter_vlan(): flash('Entry not found.', 'error') return redirect(VIEW) - enabled = items[idx].get('enabled', True) items[idx] = entry - items[idx]['enabled'] = enabled + items[idx]['enabled'] = request.form.get('enabled') == 'on' save_core(core) flash(apply_msg(), 'success') diff --git a/docker/router-dash/app/action_apply_port_forwarding.py b/docker/router-dash/app/action_apply_port_forwarding.py index 8ff5281..6fb2358 100644 --- a/docker/router-dash/app/action_apply_port_forwarding.py +++ b/docker/router-dash/app/action_apply_port_forwarding.py @@ -135,9 +135,8 @@ def edit_port_forward(): flash('Entry not found.', 'error') return redirect(VIEW) - enabled = items[idx].get('enabled', True) items[idx] = entry - items[idx]['enabled'] = enabled + items[idx]['enabled'] = request.form.get('enabled') == 'on' save_core(core) flash(apply_msg(), 'success') diff --git a/docker/router-dash/data/page_content.json b/docker/router-dash/data/page_content.json index 99ecce4..57b1451 100644 --- a/docker/router-dash/data/page_content.json +++ b/docker/router-dash/data/page_content.json @@ -796,19 +796,30 @@ } ], "row_actions": [ - { - "text": "Toggle", - "class": "btn-ghost btn-sm", - "action": "/action/toggle_host_override", - "method": "post", - "client_requirement": "client_is_administrator+" - }, { "text": "Edit", "class": "btn-ghost btn-sm", - "action": "#", - "method": "js_edit", - "client_requirement": "client_is_administrator+" + "action": "/action/edit_host_override", + "method": "inline_edit", + "client_requirement": "client_is_administrator+", + "fields": [ + { + "col": "description", + "input_type": "text" + }, + { + "col": "host", + "input_type": "text" + }, + { + "col": "ip", + "input_type": "text" + }, + { + "col": "enabled", + "input_type": "checkbox" + } + ] }, { "text": "Delete", @@ -865,63 +876,6 @@ ] } ] - }, - { - "id": "edit-form", - "type": "card", - "label": "Edit Host Override", - "hidden": true, - "client_requirement": "client_is_administrator+", - "items": [ - { - "type": "form", - "action": "/action/edit_host_override", - "method": "post", - "items": [ - { - "type": "field", - "name": "row_index", - "input_type": "hidden", - "value": "" - }, - { - "type": "field", - "label": "Description", - "name": "description", - "input_type": "text" - }, - { - "type": "field", - "label": "Hostname", - "name": "host", - "input_type": "text" - }, - { - "type": "field", - "label": "Resolves To", - "name": "ip", - "input_type": "text" - }, - { - "type": "button_row", - "items": [ - { - "type": "button_primary", - "text": "Save Changes", - "action": "/action/edit_host_override", - "method": "post" - }, - { - "type": "button_secondary", - "text": "Cancel", - "action": "#", - "class": "js-hide-card" - } - ] - } - ] - } - ] } ] }, @@ -983,19 +937,44 @@ ] }, "row_actions": [ - { - "text": "Toggle", - "class": "btn-ghost btn-sm", - "action": "/action/toggle_blocklist", - "method": "post", - "client_requirement": "client_is_administrator+" - }, { "text": "Edit", "class": "btn-ghost btn-sm", - "action": "#", - "method": "js_edit", - "client_requirement": "client_is_administrator+" + "action": "/action/edit_blocklist", + "method": "inline_edit", + "client_requirement": "client_is_administrator+", + "fields": [ + { + "col": "name", + "input_type": "text" + }, + { + "col": "description", + "input_type": "text" + }, + { + "col": "format", + "input_type": "select", + "options": [ + { + "value": "hosts", + "label": "hosts \u2014 /etc/hosts format" + }, + { + "value": "dnsmasq", + "label": "dnsmasq \u2014 local=/ syntax" + } + ] + }, + { + "col": "url", + "input_type": "text" + }, + { + "col": "enabled", + "input_type": "checkbox" + } + ] }, { "text": "Delete", @@ -1068,79 +1047,6 @@ ] } ] - }, - { - "id": "edit-form", - "type": "card", - "label": "Edit Blocklist", - "hidden": true, - "client_requirement": "client_is_administrator+", - "items": [ - { - "type": "form", - "action": "/action/edit_blocklist", - "method": "post", - "items": [ - { - "type": "field", - "name": "row_index", - "input_type": "hidden", - "value": "" - }, - { - "type": "field", - "label": "Name", - "name": "name", - "input_type": "text" - }, - { - "type": "field", - "label": "Description", - "name": "description", - "input_type": "text" - }, - { - "type": "field", - "label": "Format", - "name": "format", - "input_type": "select", - "options": [ - { - "value": "hosts", - "label": "hosts \u2014 /etc/hosts format" - }, - { - "value": "dnsmasq", - "label": "dnsmasq \u2014 local=/ syntax" - } - ] - }, - { - "type": "field", - "label": "Source URL", - "name": "url", - "input_type": "text" - }, - { - "type": "button_row", - "items": [ - { - "type": "button_primary", - "text": "Save Changes", - "action": "/action/edit_blocklist", - "method": "post" - }, - { - "type": "button_secondary", - "text": "Cancel", - "action": "#", - "class": "js-hide-card" - } - ] - } - ] - } - ] } ] }, @@ -1371,19 +1277,52 @@ } ], "row_actions": [ - { - "text": "Toggle", - "class": "btn-ghost btn-sm", - "action": "/action/toggle_inter_vlan", - "method": "post", - "client_requirement": "client_is_administrator+" - }, { "text": "Edit", "class": "btn-ghost btn-sm", - "action": "#", - "method": "js_edit", - "client_requirement": "client_is_administrator+" + "action": "/action/edit_inter_vlan", + "method": "inline_edit", + "client_requirement": "client_is_administrator+", + "fields": [ + { + "col": "description", + "input_type": "text" + }, + { + "col": "protocol", + "input_type": "select", + "options": [ + { + "value": "tcp", + "label": "TCP" + }, + { + "value": "udp", + "label": "UDP" + }, + { + "value": "both", + "label": "TCP/UDP" + } + ] + }, + { + "col": "src_ip_or_subnet", + "input_type": "text" + }, + { + "col": "dst_ip_or_subnet", + "input_type": "text" + }, + { + "col": "dst_port", + "input_type": "text" + }, + { + "col": "enabled", + "input_type": "checkbox" + } + ] }, { "text": "Delete", @@ -1467,89 +1406,6 @@ ] } ] - }, - { - "id": "edit-form", - "type": "card", - "label": "Edit Exception", - "hidden": true, - "client_requirement": "client_is_administrator+", - "items": [ - { - "type": "form", - "action": "/action/edit_inter_vlan", - "method": "post", - "items": [ - { - "type": "field", - "name": "row_index", - "input_type": "hidden", - "value": "" - }, - { - "type": "field", - "label": "Description", - "name": "description", - "input_type": "text" - }, - { - "type": "field", - "label": "Protocol", - "name": "protocol", - "input_type": "select", - "options": [ - { - "value": "tcp", - "label": "TCP" - }, - { - "value": "udp", - "label": "UDP" - }, - { - "value": "both", - "label": "TCP/UDP" - } - ] - }, - { - "type": "field", - "label": "Source", - "name": "src_ip_or_subnet", - "input_type": "text" - }, - { - "type": "field", - "label": "Destination", - "name": "dst_ip_or_subnet", - "input_type": "text" - }, - { - "type": "field", - "label": "Dest Port", - "name": "dst_port", - "input_type": "text" - }, - { - "type": "button_row", - "items": [ - { - "type": "button_primary", - "text": "Save Changes", - "action": "/action/edit_inter_vlan", - "method": "post" - }, - { - "type": "button_secondary", - "text": "Cancel", - "action": "#", - "class": "js-hide-card" - } - ] - } - ] - } - ] } ] }, @@ -1606,19 +1462,52 @@ } ], "row_actions": [ - { - "text": "Toggle", - "class": "btn-ghost btn-sm", - "action": "/action/toggle_port_forward", - "method": "post", - "client_requirement": "client_is_administrator+" - }, { "text": "Edit", "class": "btn-ghost btn-sm", - "action": "#", - "method": "js_edit", - "client_requirement": "client_is_administrator+" + "action": "/action/edit_port_forward", + "method": "inline_edit", + "client_requirement": "client_is_administrator+", + "fields": [ + { + "col": "description", + "input_type": "text" + }, + { + "col": "protocol", + "input_type": "select", + "options": [ + { + "value": "tcp", + "label": "TCP" + }, + { + "value": "udp", + "label": "UDP" + }, + { + "value": "both", + "label": "TCP/UDP" + } + ] + }, + { + "col": "dest_port", + "input_type": "text" + }, + { + "col": "nat_ip", + "input_type": "text" + }, + { + "col": "nat_port", + "input_type": "text" + }, + { + "col": "enabled", + "input_type": "checkbox" + } + ] }, { "text": "Delete", @@ -1702,89 +1591,6 @@ ] } ] - }, - { - "id": "edit-form", - "type": "card", - "label": "Edit Rule", - "hidden": true, - "client_requirement": "client_is_administrator+", - "items": [ - { - "type": "form", - "action": "/action/edit_port_forward", - "method": "post", - "items": [ - { - "type": "field", - "name": "row_index", - "input_type": "hidden", - "value": "" - }, - { - "type": "field", - "label": "Description", - "name": "description", - "input_type": "text" - }, - { - "type": "field", - "label": "Protocol", - "name": "protocol", - "input_type": "select", - "options": [ - { - "value": "tcp", - "label": "TCP" - }, - { - "value": "udp", - "label": "UDP" - }, - { - "value": "both", - "label": "TCP/UDP" - } - ] - }, - { - "type": "field", - "label": "Ext Port", - "name": "dest_port", - "input_type": "text" - }, - { - "type": "field", - "label": "NAT IP", - "name": "nat_ip", - "input_type": "text" - }, - { - "type": "field", - "label": "NAT Port", - "name": "nat_port", - "input_type": "text" - }, - { - "type": "button_row", - "items": [ - { - "type": "button_primary", - "text": "Save Changes", - "action": "/action/edit_port_forward", - "method": "post" - }, - { - "type": "button_secondary", - "text": "Cancel", - "action": "#", - "class": "js-hide-card" - } - ] - } - ] - } - ] } ] }, @@ -1884,19 +1690,38 @@ ] }, "row_actions": [ - { - "text": "Toggle", - "class": "btn-ghost btn-sm", - "action": "/action/toggle_dhcp_reservation", - "method": "post", - "client_requirement": "client_is_administrator+" - }, { "text": "Edit", "class": "btn-ghost btn-sm", - "action": "#", - "method": "js_edit", - "client_requirement": "client_is_administrator+" + "action": "/action/edit_dhcp_reservation", + "method": "inline_edit", + "client_requirement": "client_is_administrator+", + "fields": [ + { + "col": "description", + "input_type": "text" + }, + { + "col": "hostname", + "input_type": "text" + }, + { + "col": "mac", + "input_type": "text" + }, + { + "col": "ip", + "input_type": "text" + }, + { + "col": "radius_client", + "input_type": "checkbox" + }, + { + "col": "enabled", + "input_type": "checkbox" + } + ] }, { "text": "Delete", @@ -1975,75 +1800,6 @@ ] } ] - }, - { - "id": "edit-form", - "type": "card", - "label": "Edit Reservation", - "hidden": true, - "client_requirement": "client_is_administrator+", - "items": [ - { - "type": "form", - "action": "/action/edit_dhcp_reservation", - "method": "post", - "items": [ - { - "type": "field", - "name": "row_index", - "input_type": "hidden", - "value": "" - }, - { - "type": "field", - "label": "Description", - "name": "description", - "input_type": "text" - }, - { - "type": "field", - "label": "Hostname", - "name": "hostname", - "input_type": "text" - }, - { - "type": "field", - "label": "MAC Address", - "name": "mac", - "input_type": "text" - }, - { - "type": "field", - "label": "IP Address", - "name": "ip", - "input_type": "text" - }, - { - "type": "field", - "label": "RADIUS Client", - "name": "radius_client", - "input_type": "checkbox" - }, - { - "type": "button_row", - "items": [ - { - "type": "button_primary", - "text": "Save Changes", - "action": "/action/edit_dhcp_reservation", - "method": "post" - }, - { - "type": "button_secondary", - "text": "Cancel", - "action": "#", - "class": "js-hide-card" - } - ] - } - ] - } - ] } ] }, diff --git a/docker/router-dash/docker-compose.yml b/docker/router-dash/docker-compose.yml new file mode 100644 index 0000000..5bf422e --- /dev/null +++ b/docker/router-dash/docker-compose.yml @@ -0,0 +1,21 @@ +name: router-dash + +services: + flask-app: + container_name: router-dash + build: . + ports: + - "25327:25327" + volumes: + - ./data:/data + - $HOME/router:/configs + - $HOME/router/validation.py:/app/validation.py + environment: + - INITIAL_MANAGER_EMAIL=mgrotke@gmail.com + - SECRET_KEY=ey8hSQCCYE5kQXV8nOg1CB44LSd3AoUet2ZBc3aZlFrwBbazE7aHcxXWyuT97eAObet5jmOL0CjMg0rB1hE4d2SBVYHPfl8De55EiFv307r1QP3Mf5XgOSSCxD3TuD + - SMTP_HOST=smtp.gmail.com + - SMTP_PORT=587 + - SMTP_USER=grotek.industries@gmail.com + - SMTP_PASSWORD=lfhrygyuwvlaczaw + - SMTP_FROM=grotek.industries@gmail.com + restart: unless-stopped diff --git a/docker/router-dash/requirements.txt b/docker/router-dash/requirements.txt new file mode 100644 index 0000000..bb2793b --- /dev/null +++ b/docker/router-dash/requirements.txt @@ -0,0 +1,2 @@ +flask +bcrypt