mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-09 18:50:26 +08:00
Feature: bump gVisor to latest version (#376)
This commit is contained in:
23
core/device/fdbased/open_unix.go
Normal file
23
core/device/fdbased/open_unix.go
Normal file
@@ -0,0 +1,23 @@
|
||||
//go:build unix && !linux
|
||||
|
||||
package fdbased
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/xjasonlyu/tun2socks/v2/core/device"
|
||||
"github.com/xjasonlyu/tun2socks/v2/core/device/iobased"
|
||||
)
|
||||
|
||||
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)
|
||||
}
|
||||
f.LinkEndpoint = ep
|
||||
|
||||
return f, nil
|
||||
}
|
Reference in New Issue
Block a user