mirror of
https://github.com/SagerNet/sing-tun.git
synced 2025-09-27 13:02:08 +08:00
26 lines
612 B
Go
26 lines
612 B
Go
//go:build with_gvisor && darwin
|
|
|
|
package tun
|
|
|
|
import (
|
|
"github.com/sagernet/gvisor/pkg/tcpip/link/qdisc/fifo"
|
|
"github.com/sagernet/gvisor/pkg/tcpip/stack"
|
|
"github.com/sagernet/sing-tun/internal/fdbased_darwin"
|
|
)
|
|
|
|
var _ GVisorTun = (*NativeTun)(nil)
|
|
|
|
func (t *NativeTun) NewEndpoint() (stack.LinkEndpoint, stack.NICOptions, error) {
|
|
ep, err := fdbased.New(&fdbased.Options{
|
|
FDs: []int{t.tunFd},
|
|
MTU: t.options.MTU,
|
|
RXChecksumOffload: true,
|
|
})
|
|
if err != nil {
|
|
return nil, stack.NICOptions{}, err
|
|
}
|
|
return ep, stack.NICOptions{
|
|
QDisc: fifo.New(ep, 1, 1000),
|
|
}, nil
|
|
}
|