diff --git a/core/device/fdbased/open_unix.go b/core/device/fdbased/open_unix.go index 60958850..4944438f 100644 --- a/core/device/fdbased/open_unix.go +++ b/core/device/fdbased/open_unix.go @@ -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) diff --git a/engine/parse.go b/engine/parse.go index 2662e08a..bd7f46bb 100644 --- a/engine/parse.go +++ b/engine/parse.go @@ -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) {