github.com/labulakalia/water@v0.0.5-0.20231118024244-f351ca6784b6/syscalls_linux_legacy.go (about) 1 // +build linux,!go1.11 2 3 package water 4 5 import ( 6 "os" 7 ) 8 9 func openDev(config Config) (ifce *Interface, err error) { 10 var file *os.File 11 if file, err = os.OpenFile( 12 "/dev/net/tun", os.O_RDWR, 0); err != nil { 13 return nil, err 14 } 15 16 name, err := setupFd(config, file.Fd()) 17 if err != nil { 18 return nil, err 19 } 20 21 return &Interface{ 22 isTAP: config.DeviceType == TAP, 23 ReadWriteCloser: file, 24 name: name, 25 }, nil 26 }