Skip to content

feat: implement macOS connectivity detection#11

Open
polw1 wants to merge 3 commits into
silvermine:masterfrom
polw1:feat/macos-connectivity
Open

feat: implement macOS connectivity detection#11
polw1 wants to merge 3 commits into
silvermine:masterfrom
polw1:feat/macos-connectivity

Conversation

@polw1
Copy link
Copy Markdown

@polw1 polw1 commented May 13, 2026

Summary

Adds macOS support for connection_status() using Apple’s Network framework.

  • implement the macOS backend with NWPathMonitor
  • map connectivity, metered, constrained, and transport status into the existing plugin types
  • treat only nw_path_status_satisfied as connected: true
  • document the macOS path-status semantics in code comments and README
  • add test coverage for macOS path-status handling and connection-type priority

Closes #8

Test plan

  • cargo check
  • cargo test --workspace --lib
  • npm run standards

@polw1
Copy link
Copy Markdown
Author

polw1 commented May 16, 2026

Creating and destroying an NWPathMonitor on every call feels fragile, especially with a fixed timeout. Apple’s API delivers path updates through callbacks scheduled on a dispatch queue, so treating the first frontend request as a synchronous one-shot query felt like the wrong model.

NWPathMonitor is better treated as a long-lived monitor than as a synchronous status getter.

So i changed the implementation to create the monitor once, caches the latest status, and returns that cached value from plugin calls.

I also start the monitor during plugin setup so the system has a chance to receive the first path update before the frontend makes its first real request, instead of making that request responsible for initializing the monitor.

Comment thread Cargo.toml Outdated
Comment thread src/platform/macos.rs
Comment thread src/platform/macos.rs
@polw1 polw1 requested a review from velocitysystems June 2, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement macOS support for connectivity detection

2 participants