refactor(KIAUH): allow reading ipv6 configured ports with possible default_server suffixes

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
dw-0
2024-02-24 15:46:02 +01:00
parent 750cb7b307
commit 7fd91e6cef

View File

@@ -7,7 +7,7 @@
# #
# This file may be distributed under the terms of the GNU GPLv3 license #
# ======================================================================= #
import re
import shutil
import subprocess
from pathlib import Path
@@ -152,8 +152,9 @@ def read_ports_from_nginx_configs() -> List[str]:
lines = cfg.readlines()
for line in lines:
line = line.strip().replace(";", "")
if line.startswith("listen"):
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])
return sorted(port_list, key=lambda x: int(x))