summaryrefslogtreecommitdiffhomepage
path: root/tun/tun_darwin.go
AgeCommit message (Collapse)Author
2019-08-02tun: darwin: do not attempt to close tun.event twiceJason A. Donenfeld
Previously it was possible for this to race. It turns out we really don't need to set anything to -1 anyway.
2019-06-14tun: remove TUN prefix from types to reduce stutter elsewhereMatt Layher
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2019-06-06global: fixup TODO comment spacingJason A. Donenfeld
2019-05-14global: regroup all importsJason A. Donenfeld
2019-04-19tun: darwin: write routeSocket variable in helperJason A. Donenfeld
Otherwise the race detector "complains".
2019-03-21receive: implement flush semanticsJason A. Donenfeld
2019-03-04tun: import mobile particularitiesJason A. Donenfeld
2019-03-01tun: allow special methods in NativeTunJason A. Donenfeld
2019-02-27tun: use netpoll instead of rwcancelJason A. Donenfeld
The new sysconn function of Go 1.12 makes this possible: package main import "log" import "os" import "unsafe" import "time" import "syscall" import "sync" import "golang.org/x/sys/unix" func main() { fd, err := os.OpenFile("/dev/net/tun", os.O_RDWR, 0) if err != nil { log.Fatal(err) } var ifr [unix.IFNAMSIZ + 64]byte copy(ifr[:], []byte("cheese")) *(*uint16)(unsafe.Pointer(&ifr[unix.IFNAMSIZ])) = unix.IFF_TUN var errno syscall.Errno s, _ := fd.SyscallConn() s.Control(func(fd uintptr) { _, _, errno = unix.Syscall( unix.SYS_IOCTL, fd, uintptr(unix.TUNSETIFF), uintptr(unsafe.Pointer(&ifr[0])), ) }) if errno != 0 { log.Fatal(errno) } b := [4]byte{} wait := sync.WaitGroup{} wait.Add(1) go func() { _, err := fd.Read(b[:]) log.Print("Read errored: ", err) wait.Done() }() time.Sleep(time.Second) log.Print("Closing") err = fd.Close() if err != nil { log.Print("Close errored: " , err) } wait.Wait() log.Print("Exiting") }
2019-02-27tun: use sysconn instead of .Fd with Go 1.12Jason A. Donenfeld
2019-02-18Change package pathJason A. Donenfeld
2019-02-05Update copyrightJason A. Donenfeld
2018-11-06Use darwin tun on iosJason A. Donenfeld
2018-10-17tun: only call .Fd() onceJason A. Donenfeld
Doing so tends to make the tunnel blocking, so we only retrieve it once before we call SetNonblock, and then cache the result.
2018-09-16global: fix up copyright headersJason A. Donenfeld
2018-06-09Do not build tun device on iosJason A. Donenfeld
2018-05-24Catch EINTRJason A. Donenfeld
2018-05-23Adopt GOPATHJason A. Donenfeld
GOPATH is annoying, but the Go community pushing me to adopt it is even more annoying.
2018-05-23Move tun to subpackageJason A. Donenfeld