hiddify-next
hiddify-next copied to clipboard
Fix: Support VPN modes on MacOS without hacks with osascript
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.
awesome work, hope would be merged soon!
For now used automator script but it feels like a crunch.
@0xConsumer @lymanjre @hiddify-com please take a look when possible
@hiddify-com can you have a look pelase?)
That is a great PR. However, We will use network extension in mac soon so i think it is better to not do such hack.
@hiddify-com Thank you for your response! In that case, it might not make much sense, depending on how soon it will be ready. However, it might be worth merging as a temporary solution and switching to NE once it's ready.
If you need any help with rewriting to NE, I'd be happy to assist with the Swift/Dart parts
It would be great if you can make it under network extenstion similar to ios one