summaryrefslogtreecommitdiff
path: root/tun (follow)
Commit message (Collapse)AuthorAgeFilesLines
* wintun: rename device using undocumented API that netsh.exe usesJason A. Donenfeld2019-04-012-1/+41
|
* wintun: add more retry loopsJason A. Donenfeld2019-04-013-30/+56
|
* tun: windows: cancel ongoing reads on closing and delete after closeJason A. Donenfeld2019-03-261-4/+11
| | | | | This reverts commit 52ec440d7977fad966002c3710ed9df957943407 and adds some spice.
* wintun: query for NetCfgInstanceId several timesJason A. Donenfeld2019-03-221-5/+16
|
* tun: windows: delete interface before deleting file handlesJason A. Donenfeld2019-03-221-9/+4
|
* tun: windows: Make adapter rename asynchronousSimon Rozman2019-03-222-60/+13
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* tun: windows: Adapter devices renamed to WINTUN<LUID Index>Simon Rozman2019-03-224-52/+63
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* tun: windows: Increase unavailable adapter timeout to 30secSimon Rozman2019-03-221-1/+1
| | | | | | 5 seconds was too short when debugging. Signed-off-by: Simon Rozman <simon@rozman.si>
* tun: windows: Make writing persistent tooSimon Rozman2019-03-221-15/+17
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* tun: windows: Fix paused adapter testSimon Rozman2019-03-221-1/+1
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* tun: windows: just open two file handlesJason A. Donenfeld2019-03-213-162/+83
|
* receive: implement flush semanticsJason A. Donenfeld2019-03-217-5/+28
|
* tun: windows: add dummy overlapped events backJason A. Donenfeld2019-03-211-2/+21
| | | | These seem basically wrong to me, but we get crashes without them.
* tun: windows: use new constants in sysJason A. Donenfeld2019-03-201-1/+1
|
* wintun: Use native Win32 API for I/OSimon Rozman2019-03-215-38/+173
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* tun: windows: wintun does iocpJason A. Donenfeld2019-03-182-142/+49
|
* tun: windows: temporary hack for forcing MTUJason A. Donenfeld2019-03-131-1/+8
|
* wintun: Poll more oftenJason A. Donenfeld2019-03-101-1/+1
|
* wintun: Make errors more descriptiveSimon Rozman2019-03-081-15/+20
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Return correct reboot-req flag on CreateInterface() error tooSimon Rozman2019-03-081-1/+1
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Fix double-quoted strings escaping on outputSimon Rozman2019-03-082-4/+4
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Introduce SetupAPI enumerator and machineName constsSimon Rozman2019-03-081-4/+7
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: CleanupSimon Rozman2019-03-071-1/+1
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Refactor network registry key name generationSimon Rozman2019-03-071-22/+18
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Revise interface creation waitSimon Rozman2019-03-073-59/+106
| | | | | | | | | | | | | | | | | | | | DIF_INSTALLDEVICE returns almost immediately, while the device installation continues in the background. It might take a while, before all registry keys and values are populated. Previously, wireguard-go waited for HKLM\SYSTEM\CurrentControlSet\ Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\<id> registry key only. Followed by a SetInterfaceName() method of Wintun struct which tried to access HKLM\SYSTEM\CurrentControlSet\Control\Network\ {4D36E972-E325-11CE-BFC1-08002BE10318}\<id>\Connection registry key might not be available yet. This commit loops until both registry keys are available before returning from CreateInterface() function. Signed-off-by: Simon Rozman <simon@rozman.si>
* tun: linux: work out netpoll trickJason A. Donenfeld2019-03-071-54/+46
|
* wintun: Resolve some of golint warningsSimon Rozman2019-03-044-17/+33
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* Elaborate the failing step when forwarding errors on returnSimon Rozman2019-03-041-3/+3
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* Simplify reading NetCfgInstanceId from registrySimon Rozman2019-03-041-8/+2
| | | | | | | | As querying non-existing registry value and reading non-existing registry string value both return ERROR_FILE_NOT_FOUND, we can use later only. Signed-off-by: Simon Rozman <simon@rozman.si>
* Unify interface-specific network registry key openSimon Rozman2019-03-041-10/+19
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* tun: import mobile particularitiesJason A. Donenfeld2019-03-042-5/+29
|
* global: begin modularizationJason A. Donenfeld2019-03-032-1/+93
|
* tun: windows: expose GUIDJason A. Donenfeld2019-03-011-0/+4
|
* tun: allow special methods in NativeTunJason A. Donenfeld2019-03-016-65/+65
|
* tun: linux: netpoll is broken for tun's epollJason A. Donenfeld2019-02-271-27/+48
| | | | | | So this mostly reverts the switch to Sysconn for Linux. Issue: https://github.com/golang/go/issues/30426
* tun: linux: netlink sock needs cleaning up but file will be gc'dJason A. Donenfeld2019-02-271-4/+2
|
* tun: use netpoll instead of rwcancelJason A. Donenfeld2019-02-275-138/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-275-54/+79
|
* wintun: Read/write packet size from/to exchange buffer directlySimon Rozman2019-02-221-3/+3
| | | | | | Driver <-> user-space communication is local and using native endian. Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Make two-step slicing a one stepSimon Rozman2019-02-221-3/+3
| | | | | | | Stop relying to Go compiler optimizations and calculate the end offset directly. Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Write exchange buffer increased back to 1MiBSimon Rozman2019-02-201-5/+4
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Migrate from unsafe buffer handling to encoding/binarySimon Rozman2019-02-201-5/+8
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Adopt new packet data alignmentSimon Rozman2019-02-201-10/+10
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: CleanupSimon Rozman2019-02-201-2/+2
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Add TUN device lockingSimon Rozman2019-02-201-40/+64
| | | | | | | | | | | | In case reading from TUN device detected TUN device was closed, it closed the file handle and set tunFile to nil. The tunFile is automatically reopened on retry, but... If another packet comes in the WireGuard calls Write() method. With tunFile set to nil, this will cause access violation. Therefore, locking was introduced. Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Move exchange buffer in separate struct on heapSimon Rozman2019-02-201-33/+44
| | | | | | | | | This allows buffer alignment and keeps it together with its meta-data. Furthermore, the write buffer has been reduced - as long as we flush after _every_ write, we don't need a 1MiB write buffer. Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Switch to dynamic packet sizesSimon Rozman2019-02-191-50/+46
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* Change package pathJason A. Donenfeld2019-02-187-8/+8
|
* wintun: Auto-calculate TUN exchange buffer sizeSimon Rozman2019-02-081-8/+7
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: Simplify Read method()Simon Rozman2019-02-081-51/+51
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>