1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-30 19:15:23 +00:00

chore: rename DeviceCreator

This commit is contained in:
AkinoKaede 2023-05-28 14:17:40 +08:00 committed by Shelikhoo
parent a3728b6abc
commit 4276ee9464
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
3 changed files with 5 additions and 4 deletions

View File

@ -16,4 +16,4 @@ type Options struct {
MTU uint32 MTU uint32
} }
type NewTUNFunc func(Options) (Device, error) type DeviceCreator func(Options) (Device, error)

View File

@ -9,6 +9,8 @@ import (
"gvisor.dev/gvisor/pkg/tcpip/transport/udp" "gvisor.dev/gvisor/pkg/tcpip/transport/udp"
) )
type StackOption func(*stack.Stack) error
func CreateStack(_ stack.LinkEndpoint) (*stack.Stack, error) { func CreateStack(_ stack.LinkEndpoint) (*stack.Stack, error) {
s := stack.New(stack.Options{ s := stack.New(stack.Options{
NetworkProtocols: []stack.NetworkProtocolFactory{ NetworkProtocols: []stack.NetworkProtocolFactory{

View File

@ -31,9 +31,8 @@ func (t *TUN) Type() interface{} {
} }
func (t *TUN) Start() error { func (t *TUN) Start() error {
var newDeviceFunc device.NewTUNFunc DeviceCreator := tun.New
newDeviceFunc = tun.New device, err := DeviceCreator(device.Options{
device, err := newDeviceFunc(device.Options{
Name: t.config.Name, Name: t.config.Name,
MTU: t.config.Mtu, MTU: t.config.Mtu,
}) })