From 29df7b2a5357da855bbbf62e47252d943a639d84 Mon Sep 17 00:00:00 2001 From: Carl Date: Mon, 1 Jun 2026 13:48:36 +0200 Subject: [PATCH] fixed port input validation --- webui.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/webui.py b/webui.py index eaf2cad..5148972 100644 --- a/webui.py +++ b/webui.py @@ -48,14 +48,15 @@ def creator_page(): ).value # Port load_dotenv() - port_min = os.getenv("PORT_MIN") - port_max = os.getenv("PORT_MAX") + port_min = int(os.getenv("PORT_MIN", 1024)) + port_max = int(os.getenv("PORT_MAX", 65535)) port = ui.input( label="Port", validation={ - f"Port must be between {str(port_min)} and {str(port_max)}": lambda value: port_min - <= value - <= port_max + f"Port must be between {str(port_min)} and {str(port_max)}": lambda value: value.isdigit() + and port_min <= int(value) <= port_max, + "Port in use": lambda value: value.isdigit() + and not servermanager.is_port_in_use(int(value)), }, ) # Era