English · 简体中文
Swift components for connecting an Apple Packet Tunnel provider to a proxy kernel. This repository contains the packet-flow bridge and provider lifecycle code used by the Hako client.
For the complete application, see Hako-Client. The proxy kernel and SDK build tools are in Hako.
| Source | Responsibility |
|---|---|
PacketFlowBridge.swift |
Transfers packets between NEPacketTunnelFlow and a file descriptor, with framing, bounded queues and flow statistics |
ProviderLifecycle.swift |
Coordinates provider state, session ownership, reloads, teardown and physical network path monitoring |
These components use Apple system frameworks. They do not include a proxy engine, an application interface or a complete NEPacketTunnelProvider implementation.
- macOS with Xcode and the SDK for your target platform.
- Swift 5.9 or later.
- Deployment targets: iOS 15+, macOS 13+ or tvOS 17+.
- A Packet Tunnel extension with its required capabilities and signing configured by your application.
The current types have Swift internal access. Compile the source files in your consuming target; importing the package from another module does not expose these types as a public API.
- Check out a specific revision of this repository.
- Add the files under
Sources/HakoAdapterto your Packet Tunnel extension target, keeping the accompanying license. - Supply your kernel connection and coordinate startup, network settings, packet handling and shutdown in your provider.
The Hako-Client bootstrap script demonstrates fetching a pinned revision and placing the sources in the consuming project.
PacketFlowBridge.start() returns the core-facing descriptor of a socket pair. The descriptor carries packets with a four-byte address-family prefix; it is not Apple's private utun descriptor. Keep the bridge alive for the tunnel session and call stop() during teardown. See the source for descriptor ownership and error handling.
This is pre-release integration code. Pin a revision and validate the lifecycle and packet flow in your own application. The repository's package declaration describes its build structure; it does not promise a stable external Swift API.
Report component problems in Issues, including the revision, target platform and a minimal reproduction. App issues belong in Hako-Client; kernel issues belong in Hako. Remove credentials and subscription links from public reports. Follow SECURITY.md for security reports.
GPL-3.0. See the source and license file for attribution.