From 87cfde1c4259dcfa9a3638a0be380508187f533c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Jul 2026 11:23:55 +0000 Subject: [PATCH 1/2] Initial plan From c44e7bfa34bdcf6671c79d1e8d654276b78b1725 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Jul 2026 11:28:01 +0000 Subject: [PATCH 2/2] =?UTF-8?q?Fix:=20Linux=20=E6=97=A0=20WiFi=20=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E6=97=B6=20MachineInfoProvider=20=E9=A2=91=E7=B9=81?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E6=97=A5=E5=BF=97=E5=99=AA=E9=9F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用 NetworkInterface.GetAllNetworkInterfaces() 动态查找无线网卡, 兼容 wlan0/wlp2s0/wlan1 等各种命名,无 WiFi 设备时跳过 iw 进程启动 - 启用 RedirectStandardError = true,彻底避免子进程 stderr 污染日志 Closes #146 --- Stardust/Managers/MachineInfoProvider.cs | 50 +++++++++++++++--------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/Stardust/Managers/MachineInfoProvider.cs b/Stardust/Managers/MachineInfoProvider.cs index a2e2ea23..ac7bed0b 100644 --- a/Stardust/Managers/MachineInfoProvider.cs +++ b/Stardust/Managers/MachineInfoProvider.cs @@ -232,25 +232,37 @@ public void Refresh(MachineInfo info) if (signal == 0) { - var rs = Execute("iw", "dev wlan0 link", 1_000); - if (!rs.IsNullOrEmpty()) + // 动态查找无线网卡,兼容 wlan0/wlp2s0/wlan1 等各种命名,避免无 WiFi 设备时启动 iw 进程 + var wirelessInterfaces = NetworkInterface.GetAllNetworkInterfaces() + .Where(e => e.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 + && e.OperationalStatus == OperationalStatus.Up) + .Select(e => e.Name) + .ToList(); + + foreach (var ifName in wirelessInterfaces) { - /* - * Connected to 24:4b:fe:6d:5c:f8 (on wlan0) - * SSID: FeiFan - * freq: 2462 - * RX: 36978860 bytes (198669 packets) - * TX: 12425460 bytes (48657 packets) - * signal: -31 dBm - * tx bitrate: 78.0 MBit/s VHT-MCS 8 VHT-NSS 1 - * - */ - var dic = rs.SplitAsDictionary(":", "\n"); - if (dic.TryGetValue("SSID", out var value)) - info["SSID"] = value; - - if (dic.TryGetValue("signal", out value)) - info["Signal"] = signal = value.TrimSuffix("dBm").Trim().ToInt(); + var linkOutput = Execute("iw", $"dev {ifName} link", 1_000); + if (!linkOutput.IsNullOrEmpty()) + { + /* + * Connected to 24:4b:fe:6d:5c:f8 (on wlan0) + * SSID: FeiFan + * freq: 2462 + * RX: 36978860 bytes (198669 packets) + * TX: 12425460 bytes (48657 packets) + * signal: -31 dBm + * tx bitrate: 78.0 MBit/s VHT-MCS 8 VHT-NSS 1 + * + */ + var dic = linkOutput.SplitAsDictionary(":", "\n"); + if (dic.TryGetValue("SSID", out var value)) + info["SSID"] = value; + + if (dic.TryGetValue("signal", out value)) + info["Signal"] = signal = value.TrimSuffix("dBm").Trim().ToInt(); + + if (signal != 0) break; + } } } } @@ -287,7 +299,7 @@ private static Boolean TryRead(String fileName, [NotNullWhen(true)] out String? CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, RedirectStandardOutput = true, - //RedirectStandardError = true, + RedirectStandardError = true, }; var process = Process.Start(psi); if (process == null) return null;