TUN inbound: Refine gateway and autoSystemRoutingTable on macOS#6434
Conversation
|
There was a problem hiding this comment.
Pull request overview
This pull request updates the Darwin (macOS) TUN implementation to derive the utun point-to-point IPv4 addressing and IPv4 system-route gateway from the configured gateway list (first IPv4 prefix), with a safe default fallback (169.254.10.1/30). It also documents the macOS behavior and adds unit tests for gateway selection.
Changes:
- Add
selectDarwinGatewaylogic to choose the first IPv4gatewayprefix (or fall back todefaultDarwinGateway) and validate that a usable local IPv4 address exists. - Use the selected gateway both for utun point-to-point configuration (
setIPAddress) and as the IPv4 gateway when adding/removing system routes. - Update TUN documentation for macOS behavior and add darwin-only unit tests for gateway selection.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| proxy/tun/tun_darwin.go | Selects/validates a macOS gateway prefix, configures utun addressing from it, and uses it for IPv4 system route gateway. |
| proxy/tun/tun_darwin_test.go | Adds darwin-only unit tests covering default selection, IPv4 selection, IPv6 skipping, and validation failures. |
| proxy/tun/README.md | Documents macOS gateway, autoSystemRoutingTable, and dns behavior (including defaults and IPv6 notes). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
gateway and autoSystemRoutingTable on macOS
|
@yiguodev 三大系统的 TUN 就差 macOS 还没实现进程匹配了,你研究一下, |
|
@yiguodev Rejection reason: Guideline 2.5.1 (Performance — Software Requirements) — unapproved use of public APIs, specifically citing NEVPNManager, on the grounds that API behavior may change unpredictably. |
|
@iambabyninja 是这个 PR #6447 ,@yiguodev 话说 Go 有没有 |
|
修改中,一会发 PR 。 |
|
@iambabyninja fixed in #6524 |
Summary
gatewayfor the utun point-to-point address169.254.10.1/30as the default fallback whengatewayis not configuredgateway,autoSystemRoutingTable, anddnsbehaviorValidation
git diff --checkgo test ./proxy/tun -count=1go test ./infra/conf ./infra/conf/serial ./proxy/tun -count=1AI Coding by GPT-5.5 Extra High