mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2024-12-30 02:37:01 +00:00
Feature: set open FD offset for iOS (#418)
Co-authored-by: Jason Lyu <xjasonlyu@gmail.com>
This commit is contained in:
co-authored by
Jason Lyu
parent
a821cc483c
commit
b65d23180c
@@ -12,7 +12,6 @@ import (
|
|||||||
|
|
||||||
func open(fd int, mtu uint32, offset int) (device.Device, error) {
|
func open(fd int, mtu uint32, offset int) (device.Device, error) {
|
||||||
f := &FD{fd: fd, mtu: mtu}
|
f := &FD{fd: fd, mtu: mtu}
|
||||||
|
|
||||||
ep, err := iobased.New(os.NewFile(uintptr(fd), f.Name()), mtu, offset)
|
ep, err := iobased.New(os.NewFile(uintptr(fd), f.Name()), mtu, offset)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("create endpoint: %w", err)
|
return nil, fmt.Errorf("create endpoint: %w", err)
|
||||||
|
|||||||
+8
-1
@@ -6,6 +6,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gorilla/schema"
|
"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) {
|
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) {
|
func parseProxy(s string) (proxy.Proxy, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user