Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,9 @@ async def disconnect(self) -> bool:
def current(self) -> tuple[str | None, SsidState]:
"""Get the currently connected SSID if there is one.

Raises:
RuntimeError: the current Wi-Fi network is redacted

Returns:
tuple[str | None, SsidState]: (SSID or None if not connected, SSID state)
"""
Expand All @@ -794,9 +797,12 @@ def current(self) -> tuple[str | None, SsidState]:
ssid = output.replace("Current Wi-Fi Network: ", "").strip()
except Exception as e:
pass
# For current MacOs versions or if above failed
if match := re.search(r"\n\s+SSID : ([\x20-\x7E]{1,32})", cmd(f"ipconfig getsummary {self.interface}")):
ssid = match.group(1)
if ssid is None:
# For current MacOs versions or if above failed
if match := re.search(r"\n\s+SSID : ([\x20-\x7E]{1,32})", cmd(f"ipconfig getsummary {self.interface}")):
ssid = match.group(1)
if ssid == "<redacted>":
raise RuntimeError("current Wi-Fi network is redacted")

return (ssid, SsidState.CONNECTED) if ssid else (None, SsidState.DISCONNECTED)

Expand Down
Loading