Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
fdbased tun, close #227
Browse files Browse the repository at this point in the history
  • Loading branch information
e1732a364fed committed Feb 12, 2023
1 parent aa44011 commit b439ca2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions netLayer/tun/tun.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"io"
"log"
"net"
"runtime"
"strconv"
"time"

"github.com/e1732a364fed/v2ray_simple/netLayer"
Expand All @@ -40,18 +40,18 @@ import (
"gvisor.dev/gvisor/pkg/waiter"
)

// 若name为空则会返回错误
// 若name为空则会返回错误. 若name可转换为数字,则会将其解析为fd 号
func Open(name string) (device.Device, error) {
if name == "" {
return nil, errors.New("tun: dev name can't be empty")
}

if runtime.GOOS == "android" {
_, err := strconv.Atoi(name)
if err == nil {
return fdbased.Open(name, uint32(utils.MTU))

} else {
return tun.Open(name, uint32(utils.MTU))
}

return tun.Open(name, uint32(utils.MTU))
}

type StackCloser struct {
Expand Down

0 comments on commit b439ca2

Please sign in to comment.