From 779f42c98cdd6496c6390f41d5c698cb2894eb87 Mon Sep 17 00:00:00 2001 From: hz4th_coder Date: Mon, 1 Jun 2026 18:32:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9C=8D=E5=8A=A1=E5=8F=91=E7=8E=B0?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=97=A0=E6=9D=83=E9=99=90=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E7=9A=84=E7=AB=AF=E5=8F=A3=EF=BC=88Docker=20host=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E7=AD=89=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ss -tlnp 输出中没有 pid= 的端口不再跳过 - pid 为 None 时显示「受权限限制」, 进程名标记「未知进程」 - 当前发现: 8088, 9119, 16031, 16067, 18789 --- routes_discovery.py | 21 ++++++++++++--------- templates_full.txt | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/routes_discovery.py b/routes_discovery.py index 95e7eae..a31c055 100644 --- a/routes_discovery.py +++ b/routes_discovery.py @@ -71,13 +71,10 @@ def _get_listening_ports(): port = int(port_match.group(1)) pid_match = re.search(r'pid=(\d+)', line) - if not pid_match: - continue - pid = int(pid_match.group(1)) + pid = int(pid_match.group(1)) if pid_match else None - # 提取进程名 proc_match = re.search(r'users:\(\(\"([^\"]+)\"', line) - proc_name = proc_match.group(1) if proc_match else 'unknown' + proc_name = proc_match.group(1) if proc_match else '未知进程' services.append({ 'port': port, @@ -219,10 +216,16 @@ def register_discovery_routes(app): continue seen_ports.add(port) - cmdline = _get_process_cmdline(pid) - cwd = _get_process_cwd(pid) - name = _guess_service_name(pid, svc['process'], cmdline) - svc_type = _guess_service_type(cmdline) + if pid: + cmdline = _get_process_cmdline(pid) + cwd = _get_process_cwd(pid) + name = _guess_service_name(pid, svc['process'], cmdline) + svc_type = _guess_service_type(cmdline) + else: + cmdline = '' + cwd = '' + name = svc['process'] + svc_type = 'unknown' undiscovered.append({ 'port': port, diff --git a/templates_full.txt b/templates_full.txt index 3f780eb..675dd04 100644 --- a/templates_full.txt +++ b/templates_full.txt @@ -2905,7 +2905,7 @@
:${s.port} ${s.suggested_name} - PID ${s.pid} + PID ${s.pid != null ? s.pid : '受权限限制'}