diff --git a/.gitignore b/.gitignore index bff7f5f..b3e84e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ .idea .vscode .pytest_cache +.jupyter +*.ipynb +*.ipynb_checkpoints +*.tmp __pycache__ .kiauh-env *.code-workspace diff --git a/kiauh/components/webui_client/client_utils.py b/kiauh/components/webui_client/client_utils.py index ca9727f..1c17aac 100644 --- a/kiauh/components/webui_client/client_utils.py +++ b/kiauh/components/webui_client/client_utils.py @@ -353,10 +353,16 @@ def read_ports_from_nginx_configs() -> List[int]: lines = cfg.readlines() for line in lines: - line = line.replace("default_server", "") - line = re.sub(r"[;:\[\]]", "", line.strip()) - if line.startswith("listen") and line.split()[-1] not in port_list: - port_list.append(line.split()[-1]) + line = re.sub( + r"default_server|http://|https://|[;\[\]]", + "", + line.strip(), + ) + if line.startswith("listen"): + if ":" not in line: + port_list.append(line.split()[-1]) + else: + port_list.append(line.split(":")[-1]) ports_to_ints_list = [int(port) for port in port_list] return sorted(ports_to_ints_list, key=lambda x: int(x))