import Foundation import HevSocks5Tunnel /// Bridges NE utun fd ↔ local SOCKS (macOS sysproxy replacement). enum HevBridge { static func writeConfig(socksHost: String = "127.0.0.1", socksPort: Int = 1080, to url: URL) throws { let yaml = """ tunnel: mtu: 1400 socks5: address: \(socksHost) port: \(socksPort) udp: 'udp' misc: task-stack-size: 24576 connect-timeout: 5000 read-write-timeout: 60000 log-level: warn """ try yaml.write(to: url, atomically: true, encoding: .utf8) } /// Blocks until quit — call on a background thread. @discardableResult static func runBlocking(configPath: String, tunFd: Int32) -> Int32 { hev_socks5_tunnel_main(configPath, tunFd) } static func quit() { hev_socks5_tunnel_quit() } }