diff --git a/core/device/fd/fd.go b/core/device/fdbased/fd.go similarity index 74% rename from core/device/fd/fd.go rename to core/device/fdbased/fd.go index 0e5c66f..20ae348 100644 --- a/core/device/fd/fd.go +++ b/core/device/fdbased/fd.go @@ -1,4 +1,4 @@ -package fd +package fdbased const Driver = "fd" diff --git a/core/device/fd/fd_unix.go b/core/device/fdbased/fd_unix.go similarity index 97% rename from core/device/fd/fd_unix.go rename to core/device/fdbased/fd_unix.go index 5b7d49d..cb9617b 100644 --- a/core/device/fd/fd_unix.go +++ b/core/device/fdbased/fd_unix.go @@ -1,6 +1,6 @@ //go:build !windows -package fd +package fdbased import ( "fmt" diff --git a/core/device/fd/fd_windows.go b/core/device/fdbased/fd_windows.go similarity index 91% rename from core/device/fd/fd_windows.go rename to core/device/fdbased/fd_windows.go index 0e7d5a3..897108b 100644 --- a/core/device/fd/fd_windows.go +++ b/core/device/fdbased/fd_windows.go @@ -1,4 +1,4 @@ -package fd +package fdbased import ( "errors" diff --git a/core/device/fd/open_linux.go b/core/device/fdbased/open_linux.go similarity index 81% rename from core/device/fd/open_linux.go rename to core/device/fdbased/open_linux.go index 8cd98f5..97797ca 100644 --- a/core/device/fd/open_linux.go +++ b/core/device/fdbased/open_linux.go @@ -1,4 +1,4 @@ -package fd +package fdbased import ( "fmt" @@ -12,8 +12,9 @@ func open(fd int, mtu uint32) (device.Device, error) { f := &FD{fd: fd, mtu: mtu} ep, err := fdbased.New(&fdbased.Options{ - MTU: mtu, - FDs: []int{fd}, + FDs: []int{fd}, + MTU: mtu, + // TUN only, ignore ethernet header. EthernetHeader: false, }) if err != nil { diff --git a/core/device/fd/open_others.go b/core/device/fdbased/open_others.go similarity index 96% rename from core/device/fd/open_others.go rename to core/device/fdbased/open_others.go index 977353c..16f41a4 100644 --- a/core/device/fd/open_others.go +++ b/core/device/fdbased/open_others.go @@ -1,6 +1,6 @@ //go:build !linux && !windows -package fd +package fdbased import ( "fmt" diff --git a/engine/parse.go b/engine/parse.go index b8d1293..12958f5 100644 --- a/engine/parse.go +++ b/engine/parse.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/xjasonlyu/tun2socks/v2/core/device" - "github.com/xjasonlyu/tun2socks/v2/core/device/fd" + "github.com/xjasonlyu/tun2socks/v2/core/device/fdbased" "github.com/xjasonlyu/tun2socks/v2/core/device/tun" "github.com/xjasonlyu/tun2socks/v2/proxy" "github.com/xjasonlyu/tun2socks/v2/proxy/proto" @@ -27,8 +27,8 @@ func parseDevice(s string, mtu uint32) (device.Device, error) { driver := strings.ToLower(u.Scheme) switch driver { - case fd.Driver: - return fd.Open(name, mtu) + case fdbased.Driver: + return fdbased.Open(name, mtu) case tun.Driver: return tun.Open(name, mtu) default: