aboutsummaryrefslogtreecommitdiffstats
path: root/tun/tun_openbsd.go (follow)
Commit message (Collapse)AuthorAgeFilesLines
* tun: openbsd: check for interface already being upJason A. Donenfeld2019-09-071-23/+31
| | | | | | | | | | | | In some cases, we operate on an already-up interface, or the user brings up the interface before we start monitoring. For those situations, we should first check if the interface is already up. This still technically races between the initial check and the start of the route loop, but fixing that is a bit ugly and probably not worth it at the moment. Reported-by: Theo Buehler <tb@theobuehler.org>
* tun: openbsd: don't change MTU when it's already the expected sizeMichael Zeltner2019-07-181-4/+7
| | | | | | Allows for running wireguard-go as non-root user. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* tun: remove TUN prefix from types to reduce stutter elsewhereMatt Layher2019-06-141-8/+8
| | | | Signed-off-by: Matt Layher <mdlayher@gmail.com>
* global: fixup TODO comment spacingJason A. Donenfeld2019-06-061-1/+1
|
* global: regroup all importsJason A. Donenfeld2019-05-141-2/+3
|
* receive: implement flush semanticsJason A. Donenfeld2019-03-211-0/+5
|
* tun: allow special methods in NativeTunJason A. Donenfeld2019-03-011-12/+12
|
* tun: use netpoll instead of rwcancelJason A. Donenfeld2019-02-271-32/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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") }
* tun: use sysconn instead of .Fd with Go 1.12Jason A. Donenfeld2019-02-271-2/+4
|
* Change package pathJason A. Donenfeld2019-02-181-1/+1
|
* Update copyrightJason A. Donenfeld2019-02-051-2/+2
|
* tun: only call .Fd() onceJason A. Donenfeld2018-10-171-13/+13
| | | | | Doing so tends to make the tunnel blocking, so we only retrieve it once before we call SetNonblock, and then cache the result.
* global: fix up copyright headersJason A. Donenfeld2018-09-161-1/+1
|
* Disable broadcast mode on *BSDJason A. Donenfeld2018-05-271-13/+0
| | | | Keeping it on makes IPv6 problematic and confuses routing daemons.
* Catch EINTRJason A. Donenfeld2018-05-241-5/+7
|
* Adopt GOPATHJason A. Donenfeld2018-05-231-1/+1
| | | | | GOPATH is annoying, but the Go community pushing me to adopt it is even more annoying.
* Move tun to subpackageJason A. Donenfeld2018-05-231-0/+359