mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-06 17:26:58 +08:00
24 lines
435 B
Go
24 lines
435 B
Go
//go:build !linux && !windows
|
|
|
|
package fd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device"
|
|
"github.com/xjasonlyu/tun2socks/v2/core/device/rwbased"
|
|
)
|
|
|
|
func open(fd int, mtu uint32) (device.Device, error) {
|
|
f := &FD{fd: fd, mtu: mtu}
|
|
|
|
ep, err := rwbased.New(os.NewFile(uintptr(fd), f.Name()), mtu)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("create endpoint: %w", err)
|
|
}
|
|
f.LinkEndpoint = ep
|
|
|
|
return f, nil
|
|
}
|