aboutsummaryrefslogtreecommitdiffstats
path: root/tun (follow)
Commit message (Collapse)AuthorAgeFilesLines
* wintun: load wintun.dll from RCDATA resourceSimon Rozman2020-11-0717-1/+1575
| | | | | Signed-off-by: Simon Rozman <simon@rozman.si> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* wintun: migrate to wintun.dll APISimon Rozman2020-11-0725-3711/+169
| | | | | | | | Rather than having every application using Wintun driver reinvent the wheel, the Wintun device/adapter/interface management has been moved from wireguard-go to wintun.dll deployed with Wintun itself. Signed-off-by: Simon Rozman <simon@rozman.si>
* tun: use SockaddrCtl from golang.org/x/sys/unix on macOSTobias Klauser2020-10-271-29/+6
| | | | | | | | | Direct syscalls using unix.Syscall(unix.SYS_*, ...) are discouraged on macOS and might not be supported in future versions. Switch to use unix.Connect with unix.SockaddrCtl instead. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* tun: use Ioctl{Get,Set}IfreqMTU from golang.org/x/sys/unix on macOSTobias Klauser2020-10-271-35/+10
| | | | | | | | | Direct syscalls using unix.Syscall(unix.SYS_*, ...) are discouraged on macOS and might not be supported in future versions. Switch to use unix.Ioctl{Get,Set}IfreqMTU to get and set an interface's MTU. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* tun: use IoctlCtlInfo from golang.org/x/sys/unix on macOSTobias Klauser2020-10-271-20/+6
| | | | | | | | | Direct syscalls using unix.Syscall(unix.SYS_*, ...) are discouraged on macOS and might not be supported in future versions. Switch to use unix.IoctlCtlInfo to get the kernel control info. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* tun: use GetsockoptString in (*NativeTun).Name on macOSTobias Klauser2020-10-271-14/+6
| | | | | | | | | Direct syscalls using unix.Syscall(unix.SYS_*, ...) are discouraged on macOS and might not be supported in future versions. Instead, use the existing unix.GetsockoptString wrapper to get the interface name. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* tun/wintun/registry: fix Go 1.15 race/checkptr failureBrad Fitzpatrick2020-10-211-1/+1
| | | | | | Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> [Jason: ran go mod tidy.] Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* global: update header comments and modulesJason A. Donenfeld2020-05-0227-27/+27
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* wintun: make remaining HWID comparisons case insensitiveSimon Rozman2020-05-021-2/+19
| | | | | | | | | | | | | | | | | c85e4a410f27986a2967a49c0155633c716bf3ca introduced preliminary HWID checking to speed up Wintun adapter enumeration. However, all HWID are case insensitive by Windows convention. Furthermore, a device might have multiple HWIDs. When DevInfo's DeviceRegistryProperty(SPDRP_HARDWAREID) method returns []string, all strings returned should be checked against given hardware ID. This issue was discovered when researching Wintun and wireguard-go on Windows 10 ARM64. The Wintun adapter was created using devcon.exe utility with "wintun" hardware ID, causing wireguard-go fail to enumerate the adapter properly. Signed-off-by: Simon Rozman <simon@rozman.si>
* setupapi: extend struct size constant definitions for arm(64)Simon Rozman2020-05-022-0/+4
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* tun: return a better error message if /dev/net/tun doesn't existBrad Fitzpatrick2020-05-021-0/+3
| | | | | | | It was just returning "no such file or directory" (the String of the syscall.Errno returned by CreateTUN). Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
* tun: NetlinkListener: don't send EventDown before sending EventUpAvery Pennarun2020-05-021-1/+13
| | | | | | | | | | | | | | | | | | This works around a startup race condition when competing with HackListener, which is trying to do the same job. If HackListener detects that the tundev is running while there is still an event in the netlink queue that says it isn't running, then the device receives a string of events like EventUp (HackListener) EventDown (NetlinkListener) EventUp (NetlinkListener) Unfortunately, after the first EventDown, the device stops itself, thinking incorrectly that the administrator has downed its tundev. The device is ignoring the initial EventDown anyway, so just don't emit it. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
* tuntest: split out testing packageDavid Crawshaw2020-05-021-0/+150
| | | | | | This code is useful to other packages writing tests. Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
* tun: fix data race on name fieldBrad Fitzpatrick2020-05-021-13/+31
| | | | Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
* tun: remove unused isUp methodBrad Fitzpatrick2020-05-021-6/+0
| | | | Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
* wintun: split error message for create vs open namespace.Avery Pennarun2020-05-021-1/+4
| | | | Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
* global: use RTMGRP_* consts from x/sys/unixTobias Klauser2020-03-171-1/+1
| | | | | | | | Update the golang.org/x/sys/unix dependency and use the newly introduced RTMGRP_* consts instead of using the corresponding RTNLGRP_* const to create a mask. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* tun: darwin: ignore ENOMEM errorsJason A. Donenfeld2020-01-151-1/+18
| | | | Coauthored-by: Andrej Mihajlov <and@mullvad.net>
* tun: windows: serialize write callsJason A. Donenfeld2020-01-071-0/+5
|
* wintun: manage ring memory manuallyJason A. Donenfeld2019-11-222-7/+27
| | | | | It's large and Go's garbage collector doesn't deal with it especially well.
* global: fix a few typos courtesy of codespellJonathan Tooker2019-10-222-2/+2
| | | | Signed-off-by: Jonathan Tooker <jonathan.tooker@netprotect.com>
* namespaceapi: remove tasteless commentJason A. Donenfeld2019-10-211-1/+1
|
* wintun: normalize variable names for their typesJason A. Donenfeld2019-10-171-72/+72
|
* wintun: quickly ignore non-Wintun devicesAvery Pennarun2019-10-171-0/+18
| | | | | | | | | Some devices take ~2 seconds to enumerate on Windows if we try to get their instance name. The hardware id property, on the other hand, is available right away. Signed-off-by: Avery Pennarun <apenwarr@gmail.com> [zx2c4: inlined this to where it makes sense, reused setupapi const]
* tun: match windows CreateTUN signature to the Linux variantAvery Pennarun2019-10-171-4/+9
| | | | | Signed-off-by: Avery Pennarun <apenwarr@gmail.com> [zx2c4: fix default value]
* wintun: expose versionJason A. Donenfeld2019-10-082-1/+34
|
* mod: bump versionsJason A. Donenfeld2019-10-046-6/+6
|
* winpipe: use x/sys/windows instead of syscallJason A. Donenfeld2019-09-161-3/+2
|
* wintun: use correct length for security attributesJason A. Donenfeld2019-09-161-1/+1
|
* tun: windows: unify error message formatJason A. Donenfeld2019-09-081-2/+2
|
* 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>
* namespaceapi: AddSIDToBoundaryDescriptor modifies the handleJason A. Donenfeld2019-09-051-2/+2
|
* wintun: take mutex first alwaysJason A. Donenfeld2019-09-011-9/+9
| | | | This prevents an ABA deadlock with setupapi's internal locks.
* wintun: consider abandoned mutexes as releasedJason A. Donenfeld2019-09-011-1/+1
|
* wintun: put mutex into private namespaceJason A. Donenfeld2019-08-303-26/+99
|
* namespaceapi: fix mistakeJason A. Donenfeld2019-08-302-4/+4
|
* namespaceapi: initial versionSimon Rozman2019-08-303-0/+207
| | | | Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: take mutex so that deletion uses the right nameJason A. Donenfeld2019-08-302-16/+71
|
* wintun: move ring constants into moduleJason A. Donenfeld2019-08-293-96/+133
|
* wintun: delete all interfaces is not used anymoreJason A. Donenfeld2019-08-291-9/+0
|
* wintun: Wintun->InterfaceJason A. Donenfeld2019-08-292-37/+36
|
* wintun: keep reference to pool in wintun objectJason A. Donenfeld2019-08-291-7/+9
|
* wintun: introduce adapter poolsSimon Rozman2019-08-292-26/+50
| | | | | | This makes wintun package reusable for non-WireGuard applications. Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: simplify rename logicJason A. Donenfeld2019-08-281-5/+4
|
* wintun: give better errors when ndis interface listing failsJason A. Donenfeld2019-08-281-2/+2
|
* wintun: also check for numbered suffix and friendly nameJason A. Donenfeld2019-08-281-9/+22
|
* wintun: upgrade deleting all interfaces and make it reusableSimon Rozman2019-08-281-4/+29
| | | | | | | | | | | DeleteAllInterfaces() didn't check if SPDRP_DEVICEDESC == "WireGuard Tunnel". It deleted _all_ Wintun adapters, not just WireGuard's. Furthermore, the DeleteAllInterfaces() was upgraded into a new function called DeleteMatchingInterfaces() for selectively deletion. This will be used by WireGuard to clean stale Wintun adapters. Signed-off-by: Simon Rozman <simon@rozman.si>
* wintun: cleanup earlierJason A. Donenfeld2019-08-271-19/+20
|
* wintun: rename duplicate adapters instead of ourselvesJason A. Donenfeld2019-08-274-0/+118
|
* wintun: match suffix numbersJason A. Donenfeld2019-08-261-1/+8
|