mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-23 15:53:36 +05:00
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:
@@ -7,7 +7,7 @@
|
|||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -152,8 +152,9 @@ def read_ports_from_nginx_configs() -> List[str]:
|
|||||||
lines = cfg.readlines()
|
lines = cfg.readlines()
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
line = line.strip().replace(";", "")
|
line = line.replace("default_server", "")
|
||||||
if line.startswith("listen"):
|
line = re.sub(r"[;:\[\]]", "", line.strip())
|
||||||
|
if line.startswith("listen") and line.split()[-1] not in port_list:
|
||||||
port_list.append(line.split()[-1])
|
port_list.append(line.split()[-1])
|
||||||
|
|
||||||
return sorted(port_list, key=lambda x: int(x))
|
return sorted(port_list, key=lambda x: int(x))
|
||||||
|
|||||||
Reference in New Issue
Block a user