Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Support VPN modes on MacOS without hacks with osascript #1644

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

AlexStrNik
Copy link

I’ve added the SingboxHelper daemon agent, which registers on launch with privileged mode, allowing the VPN service to run smoothly without any hacks. To implement this, I added another SingboxService implementation, which is enabled by default on macOS 13+ (and honestly, I didn’t bother with settings no one’s asked for). macOS 13+ is the minimum supported version for the SMAppService daemons API, and while there’s SMBlessJob, it’s deprecated—so who even cares about supporting outdated macOS versions? Just to be clear, the app still works on earlier macOS versions, I just didn’t feel like writing two different daemon registration flows for those ancient OS versions.

Communication with the daemon is handled by NSXPCConnection, which is type-safe, secure, and fast. The daemon loads the dylib, so now all functions in libcore run with sudo rights, and the VPN mode just works™.

There’s also another thing: since libcore expects a DartDL_API, and Swift didn’t have that out of the box, I went ahead and created one. It’s mostly a bunch of stubs, semi-auto-generated from C++ headers (don’t judge me, I’m too lazy to finish the script and upload it, but it would be super easy, I swear). The only function that’s implemented so far is Dart_PostCObject, which receives different statuses from libcore.

What else, code is type-safe, with all the necessary assertions, checks, and guards. It’s not the most readable thing in the world, but who cares if it solves the problem? And if anyone cares to tidy it up, it should be pretty easy to reorganize.

they have no idea that XCode added folders
@Demezy
Copy link

Demezy commented Feb 20, 2025

awesome work, hope would be merged soon!

For now used automator script but it feels like a crunch.

@AlexStrNik
Copy link
Author

@0xConsumer @lymanjre please take a look when possible

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.

2 participants