mirror of
https://github.com/dw-0/kiauh.git
synced 2025-10-26 06:56:07 +01:00
fix: correctly handle IPs in nginx config files when parsing ports (#568)
* chore: add jupyter files to .gitignore Signed-off-by: Dominik Willner <th33xitus@gmail.com> * fix: correctly handle IPs in nginx config files when parsing ports Signed-off-by: Dominik Willner <th33xitus@gmail.com> --------- Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,6 +1,10 @@
|
||||
.idea
|
||||
.vscode
|
||||
.pytest_cache
|
||||
.jupyter
|
||||
*.ipynb
|
||||
*.ipynb_checkpoints
|
||||
*.tmp
|
||||
__pycache__
|
||||
.kiauh-env
|
||||
*.code-workspace
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user