Skip to content

Commit

Permalink
Feature: set open FD offset for iOS (#418)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Lyu <[email protected]>
  • Loading branch information
hossinasaadi and xjasonlyu authored Oct 12, 2024
1 parent a821cc4 commit b65d231
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 0 additions & 1 deletion core/device/fdbased/open_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion engine/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"net/netip"
"net/url"
"runtime"
"strings"

"github.com/gorilla/schema"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b65d231

Please sign in to comment.