github.com/borderzero/water@v0.0.1/syscalls_linux_go1.11.go (about) 1 // +build linux,go1.11 2 3 package water 4 5 import ( 6 "os" 7 "syscall" 8 ) 9 10 func openDev(config Config) (ifce *Interface, err error) { 11 var fdInt int 12 if fdInt, err = syscall.Open( 13 "/dev/net/tun", os.O_RDWR|syscall.O_NONBLOCK, 0); err != nil { 14 return nil, err 15 } 16 17 name, err := setupFd(config, uintptr(fdInt)) 18 if err != nil { 19 return nil, err 20 } 21 22 return &Interface{ 23 isTAP: config.DeviceType == TAP, 24 ReadWriteCloser: os.NewFile(uintptr(fdInt), "tun"), 25 name: name, 26 }, nil 27 }