Feature: set open FD offset for iOS (#418)

Co-authored-by: Jason Lyu <xjasonlyu@gmail.com>
This commit is contained in:
Hossin Asaadi
2024-10-13 03:51:27 +08:00
committed by GitHub
co-authored by Jason Lyu
parent a821cc483c
commit b65d23180c
2 changed files with 8 additions and 2 deletions
-1
View File
@@ -12,7 +12,6 @@ import (
func open(fd int, mtu uint32, offset int) (device.Device, error) {
f := &FD{fd: fd, mtu: mtu}
ep, err := iobased.New(os.NewFile(uintptr(fd), f.Name()), mtu, offset)
if err != nil {
return nil, fmt.Errorf("create endpoint: %w", err)
+8 -1
View File
@@ -6,6 +6,7 @@ import (
"net"
"net/netip"
"net/url"
"runtime"
"strings"
"github.com/gorilla/schema"
@@ -67,7 +68,13 @@ func parseDevice(s string, mtu uint32) (device.Device, error) {
}
func parseFD(u *url.URL, mtu uint32) (device.Device, error) {
return fdbased.Open(u.Host, mtu, 0)
offset := 0
// fd offset in ios
// https://stackoverflow.com/questions/69260852/ios-network-extension-packet-parsing/69487795#69487795
if runtime.GOOS == "ios" {
offset = 4
}
return fdbased.Open(u.Host, mtu, offset)
}
func parseProxy(s string) (proxy.Proxy, error) {