Skip to content

[Feature / RFC] macOS (Apple Silicon) support + split-tunneling route lists prototype #1

Backlog

Description

@akirill0v

Summary

mistgate-client currently targets Windows, while native macOS integration is missing.

I put together a working macOS (Apple Silicon / arm64) port in a fork branch:

  • Fork / branch: https://github.com/akirill0v/mistgate-client/tree/macos-client-port
image

Important disclaimer: This port was developed largely with Codex + Gemini assistance and verified locally on macOS. Because of that, I am intentionally not opening a PR blindly without maintainers' review first. I'm opening this issue so you can take a look at the approach — feel free to borrow ideas/pieces from it, suggest changes, or let me know if you'd like me to clean it up and submit proper PR(s) for upstream adoption.


What is implemented in the prototype

  1. Privileged daemon & IPC (core/cmd/mistgate-clientd, core/internal/ipc)

    • service_darwin.go: launchd LaunchDaemon lifecycle (install / uninstall) for /Library/PrivilegedHelperTools/com.mistgate.clientd.
    • server_darwin.go: UID-gated Unix domain socket IPC (/Library/Application Support/MistgateIPC/mistgate.sock) with explicit allow-uid enrollment.
    • core/internal/subs/keychain_darwin.go & protect_darwin.go: subscription secrets protected via macOS System Keychain (cgo).
  2. Darwin utun + gVisor bridge + tunnel backends (core/internal/engine, core/internal/netcfg)

    • Shared gvisor_bridge.go wired through tun_darwin.go (utun) and real_darwin.go.
    • Supports Hysteria2, AmneziaWG, VLESS, and TrustTunnel (scope_darwin.go binds outbound tunnel/direct sockets to the physical uplink). TrustTunnel already tested!
    • netcfg_darwin.go & dns_darwin.go: split default routes and supplemental DNS configuration (scutil), with rollback on disconnect/utun detach.
  3. Split-tunneling / Route lists & Smart routing (routes_darwin.go, real_darwin.go, ui/src/live-routes.ts)

    • Full support for all, smart, and selected route modes, region:* CIDR lists, geosite:* collections, and custom site rules.
    • RefreshAutoRegion on Darwin via STUN over the physical uplink (darwinPublicAddress) so smart + auto region detection works on macOS.
    • Suppresses AAAA DNS answers (noData) for direct-routed domains when the physical uplink lacks IPv6, preventing stalls on direct connections.
    • Also fixed a few route-list UI mapping bugs found along the way (cop → geosite:github-copilot and localized "ms" tile keys in fa/ru/zh route screens).
  4. Tauri desktop shell & build (ui/, .github/workflows/ci.yml)

    • macOS .app bundling (prepare-bundle.mjs, tauri-bundle.mjs, tauri.macos.conf.json), LaunchAgent autostart, tray/menu, and notifications.
    • Platform gating for unsupported Windows-only features (hides/disables per-app rules, updater where unsigned, and unavailable kill-switch status).
    • ... but not tested yet.

Local verification

  • Unit tests pass on macOS arm64 (go test ./internal/engine/..., node --test ui/src/live-routes.test.mjs, plus Darwin netcfg/ipc/subs/diag tests).
  • Tested live with TrustTunnel in smart:ru mode (geosite:category-ru, geosite:apple, geosite:steam, custom github.com):
    • Direct-listed and .ru/.рф resources exit directly through en0 (verified via ISP IP and nettop sockets on com.mistgate.clientd).
    • Foreign / default-routed resources exit through the VPN tunnel (verified via VPN exit IP and nettop).

Known limitations / Not implemented yet

  • Kill switch: An experimental PF adapter exists, but it is not wired into the tunnel lifecycle yet (kill_switch is disabled/reported unavailable on macOS).
  • Per-app split tunneling: Not implemented on macOS (UI and IPC omit per-app rules on Darwin).
  • Signing & distribution: Unsigned local .app build only (no Developer ID signing, notarization, .dmg packaging, or macOS auto-updater).
  • Branch hygiene: The prototype branch currently contains local helper files/docs (e.g. .codegraph/, docs/macos-install.ru.md) that would obviously be stripped out before any clean upstream PR.
  • Traffic metrics: not worked yet.

Next steps

If there is interest in supporting macOS upstream, I'd be happy to:

  • Discuss the architecture (launchd + Unix socket + utun + gvisor_bridge sharing with Windows),
  • Split this into smaller, reviewable PRs (e.g., shared engine refactor first, then Darwin daemon/IPC/netcfg, then Tauri macOS shell), or
  • Leave the branch as a reference if you'd prefer a different approach (such as a NetworkExtension / NEPacketTunnelProvider architecture).

Activity

  1. akirill0v commented on Nov 30, 2026

    @akirill0v
    Author

    This branch was meant as an exploratory/test prototype to verify that a macOS implementation works end-to-end with the existing core.

    If macOS support isn't already on your immediate roadmap and you're interested in having it, I'd be glad to put together a cleaner, properly structured implementation (without the prototype/local artifacts) and open a PR for review.

  2. limeflash commented on Dec 1, 2026

    @limeflash
    Contributor

    Thanks for the prototype — this is real work, and yes: a macOS release is planned, and help with it is welcome.

    We read the macos-client-port branch. The overall shape (a launchd daemon, utun, the shared gVisor stack, a unix socket with a UID check) is the one we would choose too. To take it in, we'd rather not merge one large branch; a series of small PRs is much easier to review and keeps the Windows build safe:

    1. changes to shared code only (renames, the bridge, session, settings), with Windows behaviour unchanged;
    2. the split of the Tauri configs per platform;
    3. the macOS network layer (tun, routes, DNS, interface binding);
    4. the daemon and IPC — this one gets a separate security review;
    5. Keychain storage;
    6. the window (tray, notifications, links, autostart);
    7. docs.

    Before that we will add a macOS CI job and a short CONTRIBUTING file on our side, so your PRs have something to run against. Please rebase on the current main and leave tool artefacts out of the branch.

    A few questions:

    • Were Hysteria2, AmneziaWG and VLESS checked live, or TrustTunnel only?
    • What happens on sleep/wake and on a network change?
    • The kill switch is off on macOS for now — what is your plan for it? We would not ship a release where a dropped tunnel sends traffic out directly without saying so.
    • Which Windows behaviour changes in the branch are intended?
    • Can you confirm you have the right to contribute this code under AGPL-3.0 (the commits carry a work address), and are you fine with a DCO sign-off?

    Signing, notarization and the release itself stay with us.

  3. akirill0v commented on Dec 1, 2026

    @akirill0v
    Author

    Thanks, the split makes sense. I'll wait for the CI/CONTRIBUTING PR (#9) to land, rebase on main,
    and open the series in the order you listed. Tool artefacts (.codegraph/, docs/superpowers/) and my
    own macOS CI job will not be in any of them.

    Answers:

    • Protocols: only TrustTunnel was tested live. It was the main protocol I needed for the move to macOS.
      Hysteria2, AmneziaWG and VLESS have not been tested at all yet. For each of them I'll do a complete
      implementation with tests and state the exact coverage in the PR.

    • Sleep/wake and network change: there is no explicit power-event handling yet. The engine pins the
      physical uplink at setup. The watchdog compares the uplink and the owned routes, and on a mismatch it
      tears the tunnel down and the session reconnects. So sleep currently behaves like a drop plus a
      network change. I haven't tested this systematically. I'll add sleep/wake and Wi-Fi switch checks to
      the network-layer PR.

    • Kill switch: I haven't given it much attention yet, because the branch was an experiment in getting
      the client running on macOS. Right now the setting is forced to "off" on macOS and the UI says
      protection is unavailable, so the app never claims to block traffic when it doesn't. A standalone PF
      anchor adapter exists (pf_darwin.go, with tests) but is not wired in. I'll work out a proper design
      that covers fail-closed on activation and tunnel loss, IPv6/DNS leaks and rollback, and propose it
      separately. Agreed that a release shouldn't ship without it.

    • Windows: no Windows behaviour change is intended. After rebasing on the current upstream I'll
      restructure the shared-code changes so the Windows implementation stays as it is. Anything that still
      touches Windows will be listed explicitly in the PR.

    • Licensing: I'll settle the legal questions on my side before opening the PRs. All commits in the
      series will come from my personal account, not linked to my employer, and will carry a DCO sign-off.

  4. limeflash commented on Dec 1, 2026

    @limeflash
    Contributor

    Thanks, that all works for us.

    #9 is merged: main now has CONTRIBUTING.md, CODEOWNERS and a macOS job that runs go vet, go build and go test for core/internal/.... The service binary (cmd/mistgate-clientd) does not build for darwin yet, so the job stops short of it — widen it to ./... in the PR that makes it build.

    Two notes for the series:

    • The first PR (shared code only) is the one we will read most carefully. Please keep pure moves and renames apart from any change in behaviour, and leave the order of the AAAA / DoH checks in the bridge as it is on Windows; if it has to change, make that its own PR with the reason.
    • For the licence: a line in the first PR saying you have the right to contribute the code under AGPL-3.0 is enough for us, together with the sign-off.

    The kill switch design can come as an issue before any code — it is easier to agree on the approach there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions