From d6cf9469aa0462d1b8313cc85907176eee1214a2 Mon Sep 17 00:00:00 2001
From: Matthias Nott <mnott@mnsoft.org>
Date: Wed, 25 Mar 2026 17:10:54 +0100
Subject: [PATCH] fix: C3 debug logs, H1-H5 image cache, temp files, controller leak, validation, lifecycle

---
 lib/screens/settings_screen.dart |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index f4b36e3..c0d9580 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -158,6 +158,11 @@
                   hintText: '192.168.1.100',
                 ),
                 keyboardType: TextInputType.url,
+                validator: (v) {
+                  if (v == null || v.trim().isEmpty) return null;
+                  final ip = RegExp(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$');
+                  return ip.hasMatch(v.trim()) ? null : 'Enter a valid IP address';
+                },
               ),
               const SizedBox(height: 16),
 
@@ -171,6 +176,11 @@
                   hintText: '10.8.0.1 (OpenVPN static IP)',
                 ),
                 keyboardType: TextInputType.url,
+                validator: (v) {
+                  if (v == null || v.trim().isEmpty) return null;
+                  final ip = RegExp(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$');
+                  return ip.hasMatch(v.trim()) ? null : 'Enter a valid IP address';
+                },
               ),
               const SizedBox(height: 16),
 
@@ -198,6 +208,14 @@
                   hintText: '8765',
                 ),
                 keyboardType: TextInputType.number,
+                validator: (v) {
+                  if (v == null || v.trim().isEmpty) return 'Required';
+                  final port = int.tryParse(v.trim());
+                  if (port == null || port < 1 || port > 65535) {
+                    return 'Port must be 1–65535';
+                  }
+                  return null;
+                },
               ),
               const SizedBox(height: 16),
 
@@ -210,6 +228,14 @@
                 decoration: const InputDecoration(
                   hintText: 'AA:BB:CC:DD:EE:FF',
                 ),
+                validator: (v) {
+                  if (v == null || v.trim().isEmpty) return null;
+                  final mac = RegExp(
+                      r'^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}$');
+                  return mac.hasMatch(v.trim())
+                      ? null
+                      : 'Enter a valid MAC address (AA:BB:CC:DD:EE:FF)';
+                },
               ),
               const SizedBox(height: 16),
 

--
Gitblit v1.3.1