]> git.ipfire.org Git - thirdparty/wireguard-go.git/log
thirdparty/wireguard-go.git
5 years agocode quality: fw/codeQuality
Frank Werner-Krippendorf [Fri, 26 Jun 2020 10:29:30 +0000 (12:29 +0200)] 
code quality:
- main.go: un-export local constants
- main.go: use camelcase instead of snake case where possible
- main.go: ignore unhandled exception explicitly
- main.go: avoid local variable names that collide with imported package names

Signed-off-by: Frank Werner-Krippendorf <mail@hb9fxq.ch>
5 years agodevice: export Bind and remove socketfd shims for android
David Crawshaw [Mon, 22 Jun 2020 00:42:28 +0000 (10:42 +1000)] 
device: export Bind and remove socketfd shims for android

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
5 years agoipc: add comment about socketDirectory linker override on android
David Crawshaw [Mon, 22 Jun 2020 00:41:19 +0000 (10:41 +1000)] 
ipc: add comment about socketDirectory linker override on android

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
5 years agoconn: add comments saying what uses these interfaces
David Crawshaw [Mon, 22 Jun 2020 00:40:59 +0000 (10:40 +1000)] 
conn: add comments saying what uses these interfaces

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
5 years agodevice: do not include sticky sockets on android
Jason A. Donenfeld [Sun, 7 Jun 2020 07:50:20 +0000 (01:50 -0600)] 
device: do not include sticky sockets on android

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
5 years agoconn: unbreak boundif on android
Jason A. Donenfeld [Sun, 7 Jun 2020 07:41:08 +0000 (01:41 -0600)] 
conn: unbreak boundif on android

Another thing never tested ever.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
5 years agoconn: remove useless comment
Jason A. Donenfeld [Sun, 7 Jun 2020 07:37:01 +0000 (01:37 -0600)] 
conn: remove useless comment

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
5 years agoconn: fix windows situation with boundif
Jason A. Donenfeld [Sun, 7 Jun 2020 07:24:06 +0000 (01:24 -0600)] 
conn: fix windows situation with boundif

This was evidently never tested before committing.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
5 years agoreplay: account for fqcodel reordering
Jason A. Donenfeld [Tue, 19 May 2020 23:46:29 +0000 (17:46 -0600)] 
replay: account for fqcodel reordering

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
5 years agodevice: rework padding calculation and don't shadow paddedSize
Jason A. Donenfeld [Mon, 18 May 2020 20:32:31 +0000 (14:32 -0600)] 
device: rework padding calculation and don't shadow paddedSize

Reported-by: Jayakumar S <jayakumar82.s@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
5 years agotai64n: make the test deterministic
Dmytro Shynkevych [Tue, 5 May 2020 22:37:54 +0000 (18:37 -0400)] 
tai64n: make the test deterministic

In the presence of preemption, the current test may fail transiently.
This uses static test data instead to ensure consistent behavior.

Signed-off-by: Dmytro Shynkevych <dmytro@tailscale.com>
5 years agomain: now that we're upstreamed, relax Linux warning
Jason A. Donenfeld [Sat, 2 May 2020 08:14:53 +0000 (02:14 -0600)] 
main: now that we're upstreamed, relax Linux warning

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
5 years agoREADME: specify go 1.13
Jason A. Donenfeld [Sat, 2 May 2020 08:08:52 +0000 (02:08 -0600)] 
README: specify go 1.13

Due to the use of the new errors module, we now require at least 1.13
instead of 1.12.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
5 years agoglobal: update header comments and modules
Jason A. Donenfeld [Sat, 2 May 2020 08:08:26 +0000 (02:08 -0600)] 
global: update header comments and modules

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
5 years agoipc: deduplicate some unix-specific code
David Crawshaw [Sat, 2 May 2020 06:28:33 +0000 (16:28 +1000)] 
ipc: deduplicate some unix-specific code

Cleans up and splits out UAPIOpen to its own file.

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
[zx2c4: changed const to var for socketDirectory]
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
5 years agoipc: remove unnecessary error check
David Crawshaw [Sat, 2 May 2020 06:18:17 +0000 (16:18 +1000)] 
ipc: remove unnecessary error check

os.MkdirAll never returns an os.IsExist error.

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
5 years agodevice: use atomic access for unlocked keypair.next
Jason A. Donenfeld [Sat, 2 May 2020 07:30:23 +0000 (01:30 -0600)] 
device: use atomic access for unlocked keypair.next

Go's GC semantics might not always guarantee the safety of this, and the
race detector gets upset too, so instead we wrap this all in atomic
accessors.

Reported-by: David Anderson <danderson@tailscale.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
5 years agowintun: make remaining HWID comparisons case insensitive
Simon Rozman [Sat, 2 May 2020 06:49:35 +0000 (08:49 +0200)] 
wintun: make remaining HWID comparisons case insensitive

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>
5 years agosetupapi: extend struct size constant definitions for arm(64)
Simon Rozman [Fri, 1 May 2020 04:57:23 +0000 (06:57 +0200)] 
setupapi: extend struct size constant definitions for arm(64)

Signed-off-by: Simon Rozman <simon@rozman.si>
5 years agodevice: add debug logs describing handshake rejection
Avery Pennarun [Wed, 16 Oct 2019 02:39:44 +0000 (22:39 -0400)] 
device: add debug logs describing handshake rejection

Useful in testing when bad network stacks repeat or
batch large numbers of packets.

Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
5 years agotun: return a better error message if /dev/net/tun doesn't exist
Brad Fitzpatrick [Wed, 18 Mar 2020 20:23:00 +0000 (13:23 -0700)] 
tun: return a better error message if /dev/net/tun doesn't exist

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>
5 years agodevice: return generic error from Ipc{Get,Set}Operation.
David Anderson [Wed, 1 Apr 2020 16:27:02 +0000 (09:27 -0700)] 
device: return generic error from Ipc{Get,Set}Operation.

This makes uapi.go's public API conform to Go style in terms
of error types.

Signed-off-by: David Anderson <danderson@tailscale.com>
5 years agotun: NetlinkListener: don't send EventDown before sending EventUp
Avery Pennarun [Wed, 6 Nov 2019 08:28:02 +0000 (00:28 -0800)] 
tun: NetlinkListener: don't send EventDown before sending EventUp

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>
5 years agodevice: give handshake state a type
David Crawshaw [Thu, 5 Mar 2020 01:58:39 +0000 (20:58 -0500)] 
device: give handshake state a type

And unexport handshake constants.

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
5 years agotuntest: split out testing package
David Crawshaw [Tue, 7 Jan 2020 15:43:17 +0000 (07:43 -0800)] 
tuntest: split out testing package

This code is useful to other packages writing tests.

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
5 years agotun: fix data race on name field
Brad Fitzpatrick [Fri, 28 Feb 2020 17:10:16 +0000 (09:10 -0800)] 
tun: fix data race on name field

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
5 years agotun: remove unused isUp method
Brad Fitzpatrick [Fri, 28 Feb 2020 16:53:29 +0000 (08:53 -0800)] 
tun: remove unused isUp method

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
5 years agoconn: introduce new package that splits out the Bind and Endpoint types
David Crawshaw [Thu, 7 Nov 2019 16:13:05 +0000 (11:13 -0500)] 
conn: introduce new package that splits out the Bind and Endpoint types

The sticky socket code stays in the device package for now,
as it reaches deeply into the peer list.

This is the first step in an effort to split some code out of
the very busy device package.

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
5 years agowintun: split error message for create vs open namespace.
Avery Pennarun [Wed, 23 Oct 2019 04:08:52 +0000 (00:08 -0400)] 
wintun: split error message for create vs open namespace.

Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
5 years agodevice: add test to ensure Peer fields are safe for atomic access on 32-bit
David Anderson [Sun, 1 Mar 2020 08:39:24 +0000 (00:39 -0800)] 
device: add test to ensure Peer fields are safe for atomic access on 32-bit

Adds a test that will fail consistently on 32-bit platforms if the
struct ever changes again to violate the rules. This is likely not
needed because unaligned access crashes reliably, but this will reliably
fail even if tests accidentally pass due to lucky alignment.

Signed-Off-By: David Anderson <danderson@tailscale.com>
5 years agorwcancel: no-op builds for windows and darwin
David Crawshaw [Wed, 19 Feb 2020 15:09:24 +0000 (10:09 -0500)] 
rwcancel: no-op builds for windows and darwin

This lets us include the package on those platforms in a
followup commit where we split out a conn package from device.
It also lets us run `go test ./...` when developing on macOS.

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
5 years agoratelimiter: use a fake clock in tests and style cleanups
David Crawshaw [Sun, 8 Dec 2019 23:22:31 +0000 (18:22 -0500)] 
ratelimiter: use a fake clock in tests and style cleanups

The existing test would occasionally flake out with:

--- FAIL: TestRatelimiter (0.12s)
    ratelimiter_test.go:99: Test failed for 127.0.0.1 , on: 7 ( not having refilled enough ) expected: false got: true
FAIL
FAIL    golang.zx2c4.com/wireguard/ratelimiter  0.171s

The fake clock also means the tests run much faster, so
testing this package with -count=1000 now takes < 100ms.

While here, several style cleanups. The most significant one
is unembeding the sync.Mutex fields in the rate limiter objects.
Embedded as they were, the lock methods were accessible
outside the ratelimiter package. As they aren't needed externally,
keep them internal to make them easier to reason about.

Passes `go test -race -count=10000 ./ratelimiter`

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
5 years agoversion: bump snapshot 0.0.20200320
Jason A. Donenfeld [Fri, 20 Mar 2020 18:00:53 +0000 (12:00 -0600)] 
version: bump snapshot

5 years agonoise: unify zero checking of ecdh
Jason A. Donenfeld [Wed, 18 Mar 2020 05:06:56 +0000 (23:06 -0600)] 
noise: unify zero checking of ecdh

5 years agoglobal: use RTMGRP_* consts from x/sys/unix
Tobias Klauser [Wed, 4 Mar 2020 16:21:54 +0000 (17:21 +0100)] 
global: use RTMGRP_* consts from x/sys/unix

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>
5 years agosend: account for zero mtu
Jason A. Donenfeld [Thu, 13 Feb 2020 15:20:56 +0000 (16:20 +0100)] 
send: account for zero mtu

Don't divide by zero.

5 years agodevice: fix private key removal logic
Jason A. Donenfeld [Tue, 4 Feb 2020 17:08:51 +0000 (18:08 +0100)] 
device: fix private key removal logic

5 years agouapi: allow unsetting device private key with /dev/null
Jason A. Donenfeld [Tue, 4 Feb 2020 17:03:31 +0000 (18:03 +0100)] 
uapi: allow unsetting device private key with /dev/null

5 years agoversion: bump snapshot 0.0.20200121
Jason A. Donenfeld [Tue, 21 Jan 2020 15:27:19 +0000 (16:27 +0100)] 
version: bump snapshot

5 years agotun: darwin: ignore ENOMEM errors
Jason A. Donenfeld [Wed, 15 Jan 2020 18:39:37 +0000 (13:39 -0500)] 
tun: darwin: ignore ENOMEM errors

Coauthored-by: Andrej Mihajlov <and@mullvad.net>
5 years agotun: windows: serialize write calls
Jason A. Donenfeld [Tue, 7 Jan 2020 16:40:45 +0000 (11:40 -0500)] 
tun: windows: serialize write calls

5 years agoREADME: update repo urls
Jason A. Donenfeld [Mon, 30 Dec 2019 10:46:34 +0000 (11:46 +0100)] 
README: update repo urls

5 years agodevice: SendmsgN mutates the input sockaddr
Jason A. Donenfeld [Wed, 27 Nov 2019 12:38:45 +0000 (13:38 +0100)] 
device: SendmsgN mutates the input sockaddr

So we take a new granular lock to prevent concurrent writes from
racing.

WARNING: DATA RACE
Write at 0x00c0011f2740 by goroutine 27:
  golang.org/x/sys/unix.(*SockaddrInet4).sockaddr()
      /go/pkg/mod/golang.org/x/sys@v0.0.0-20191105231009-c1f44814a5cd/unix/syscall_linux.go:384
+0x114
  golang.org/x/sys/unix.SendmsgN()
      /go/pkg/mod/golang.org/x/sys@v0.0.0-20191105231009-c1f44814a5cd/unix/syscall_linux.go:1304
+0x288
  golang.zx2c4.com/wireguard/device.send4()
      /go/pkg/mod/golang.zx2c4.com/wireguard@v0.0.20191012/device/conn_linux.go:485
+0x11f
  golang.zx2c4.com/wireguard/device.(*nativeBind).Send()
      /go/pkg/mod/golang.zx2c4.com/wireguard@v0.0.20191012/device/conn_linux.go:268
+0x1d6
  golang.zx2c4.com/wireguard/device.(*Peer).SendBuffer()
      /go/pkg/mod/golang.zx2c4.com/wireguard@v0.0.20191012/device/peer.go:151
+0x285
  golang.zx2c4.com/wireguard/device.(*Peer).SendHandshakeInitiation()
      /go/pkg/mod/golang.zx2c4.com/wireguard@v0.0.20191012/device/send.go:163
+0x692
  golang.zx2c4.com/wireguard/device.(*Device).RoutineReadFromTUN()
      /go/pkg/mod/golang.zx2c4.com/wireguard@v0.0.20191012/device/send.go:318
+0x4b8

Previous write at 0x00c0011f2740 by goroutine 386:
  golang.org/x/sys/unix.(*SockaddrInet4).sockaddr()
      /go/pkg/mod/golang.org/x/sys@v0.0.0-20191105231009-c1f44814a5cd/unix/syscall_linux.go:384
+0x114
  golang.org/x/sys/unix.SendmsgN()
      /go/pkg/mod/golang.org/x/sys@v0.0.0-20191105231009-c1f44814a5cd/unix/syscall_linux.go:1304
+0x288
  golang.zx2c4.com/wireguard/device.send4()
      /go/pkg/mod/golang.zx2c4.com/wireguard@v0.0.20191012/device/conn_linux.go:485
+0x11f
  golang.zx2c4.com/wireguard/device.(*nativeBind).Send()
      /go/pkg/mod/golang.zx2c4.com/wireguard@v0.0.20191012/device/conn_linux.go:268
+0x1d6
  golang.zx2c4.com/wireguard/device.(*Peer).SendBuffer()
      /go/pkg/mod/golang.zx2c4.com/wireguard@v0.0.20191012/device/peer.go:151
+0x285
  golang.zx2c4.com/wireguard/device.(*Peer).SendHandshakeInitiation()
      /go/pkg/mod/golang.zx2c4.com/wireguard@v0.0.20191012/device/send.go:163
+0x692
  golang.zx2c4.com/wireguard/device.expiredRetransmitHandshake()
      /go/pkg/mod/golang.zx2c4.com/wireguard@v0.0.20191012/device/timers.go:110
+0x40c
  golang.zx2c4.com/wireguard/device.(*Peer).NewTimer.func1()
      /go/pkg/mod/golang.zx2c4.com/wireguard@v0.0.20191012/device/timers.go:42
+0xd8

Goroutine 27 (running) created at:
  golang.zx2c4.com/wireguard/device.NewDevice()
      /go/pkg/mod/golang.zx2c4.com/wireguard@v0.0.20191012/device/device.go:322
+0x5e8
  main.main()
      /go/src/x/main.go:102 +0x58e

Goroutine 386 (finished) created at:
  time.goFunc()
      /usr/local/go/src/time/sleep.go:168 +0x51

Reported-by: Ben Burkert <ben@benburkert.com>
5 years agowintun: manage ring memory manually
Jason A. Donenfeld [Thu, 21 Nov 2019 13:48:21 +0000 (14:48 +0100)] 
wintun: manage ring memory manually

It's large and Go's garbage collector doesn't deal with it especially
well.

5 years agoconstants: recalculate rekey max based on a one minute flood
Jason A. Donenfeld [Wed, 30 Oct 2019 13:29:32 +0000 (14:29 +0100)] 
constants: recalculate rekey max based on a one minute flood

Discussed-with: Mathias Hall-Andersen <mathias@hall-andersen.dk>

5 years agoglobal: fix a few typos courtesy of codespell
Jonathan Tooker [Mon, 21 Oct 2019 20:52:26 +0000 (15:52 -0500)] 
global: fix a few typos courtesy of codespell

Signed-off-by: Jonathan Tooker <jonathan.tooker@netprotect.com>
5 years agodevice: allow blackholing sockets
Jason A. Donenfeld [Mon, 21 Oct 2019 11:29:57 +0000 (13:29 +0200)] 
device: allow blackholing sockets

5 years agodevice: remove dead error reporting code
Jason A. Donenfeld [Mon, 21 Oct 2019 09:46:54 +0000 (11:46 +0200)] 
device: remove dead error reporting code

5 years agonamespaceapi: remove tasteless comment
Jason A. Donenfeld [Mon, 21 Oct 2019 07:02:29 +0000 (09:02 +0200)] 
namespaceapi: remove tasteless comment

5 years agodevice: recheck counters while holding write lock
Jason A. Donenfeld [Thu, 17 Oct 2019 13:43:06 +0000 (15:43 +0200)] 
device: recheck counters while holding write lock

5 years agowintun: normalize variable names for their types
Jason A. Donenfeld [Thu, 17 Oct 2019 13:30:56 +0000 (15:30 +0200)] 
wintun: normalize variable names for their types

5 years agowintun: quickly ignore non-Wintun devices
Avery Pennarun [Fri, 5 Apr 2019 06:26:40 +0000 (02:26 -0400)] 
wintun: quickly ignore non-Wintun devices

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]

5 years agotun: match windows CreateTUN signature to the Linux variant
Avery Pennarun [Sat, 20 Apr 2019 07:28:06 +0000 (03:28 -0400)] 
tun: match windows CreateTUN signature to the Linux variant

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
[zx2c4: fix default value]

5 years agorwcancel: handle EINTR and EAGAIN in unixSelect()
Avery Pennarun [Sat, 12 Oct 2019 07:46:13 +0000 (00:46 -0700)] 
rwcancel: handle EINTR and EAGAIN in unixSelect()

On my Chromebook (Linux 4.19.44 in a VM) and on an AWS EC2
machine, select() was sometimes returning EINTR. This is
harmless and just means you should try again. So let's try
again.

This eliminates a problem where the tunnel fails to come up
correctly and the program needs to be restarted.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
5 years agodevice: test packets between two fake devices
David Crawshaw [Sat, 12 Oct 2019 16:44:05 +0000 (12:44 -0400)] 
device: test packets between two fake devices

Signed-off-by: David Crawshaw <crawshaw@tailscale.io>
5 years agoversion: bump snapshot 0.0.20191012
Jason A. Donenfeld [Sat, 12 Oct 2019 20:34:10 +0000 (22:34 +0200)] 
version: bump snapshot

5 years agoMakefile: remove v prefix
Jason A. Donenfeld [Tue, 8 Oct 2019 14:48:18 +0000 (16:48 +0200)] 
Makefile: remove v prefix

5 years agowintun: expose version
Jason A. Donenfeld [Tue, 8 Oct 2019 07:58:58 +0000 (09:58 +0200)] 
wintun: expose version

5 years agouapi: allow preventing creation of new peers when updating
Jason A. Donenfeld [Sat, 28 Sep 2019 18:12:46 +0000 (20:12 +0200)] 
uapi: allow preventing creation of new peers when updating

This enables race-free updates for wg-dynamic and similar tools.

Suggested-by: Thomas Gschwantner <tharre3@gmail.com>
5 years agomod: bump versions
Jason A. Donenfeld [Sat, 21 Sep 2019 19:13:54 +0000 (21:13 +0200)] 
mod: bump versions

5 years agowinpipe: use x/sys/windows instead of syscall
Jason A. Donenfeld [Tue, 17 Sep 2019 05:39:16 +0000 (23:39 -0600)] 
winpipe: use x/sys/windows instead of syscall

5 years agowintun: use correct length for security attributes
Jason A. Donenfeld [Tue, 17 Sep 2019 01:38:33 +0000 (19:38 -0600)] 
wintun: use correct length for security attributes

5 years agotun: windows: unify error message format
Jason A. Donenfeld [Sun, 8 Sep 2019 18:52:44 +0000 (13:52 -0500)] 
tun: windows: unify error message format

5 years agoversion: bump snapshot 0.0.20190908
Jason A. Donenfeld [Sun, 8 Sep 2019 15:56:55 +0000 (10:56 -0500)] 
version: bump snapshot

5 years agomain: simplify warnings
Jason A. Donenfeld [Sun, 8 Sep 2019 15:56:00 +0000 (10:56 -0500)] 
main: simplify warnings

5 years agotun: openbsd: check for interface already being up
Jason A. Donenfeld [Sat, 7 Sep 2019 05:02:07 +0000 (00:02 -0500)] 
tun: openbsd: check for interface already being up

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>
5 years agonamespaceapi: AddSIDToBoundaryDescriptor modifies the handle
Jason A. Donenfeld [Fri, 6 Sep 2019 03:48:21 +0000 (21:48 -0600)] 
namespaceapi: AddSIDToBoundaryDescriptor modifies the handle

5 years agowintun: take mutex first always
Jason A. Donenfeld [Mon, 2 Sep 2019 03:32:28 +0000 (21:32 -0600)] 
wintun: take mutex first always

This prevents an ABA deadlock with setupapi's internal locks.

5 years agowintun: consider abandoned mutexes as released
Jason A. Donenfeld [Mon, 2 Sep 2019 03:25:47 +0000 (21:25 -0600)] 
wintun: consider abandoned mutexes as released

5 years agoipc: windows: use protected prefix
Jason A. Donenfeld [Sat, 31 Aug 2019 13:48:42 +0000 (07:48 -0600)] 
ipc: windows: use protected prefix

5 years agowinpipe: enforce ownership of client connection
Jason A. Donenfeld [Fri, 30 Aug 2019 19:21:47 +0000 (13:21 -0600)] 
winpipe: enforce ownership of client connection

5 years agowintun: put mutex into private namespace
Jason A. Donenfeld [Fri, 30 Aug 2019 16:31:27 +0000 (10:31 -0600)] 
wintun: put mutex into private namespace

5 years agonamespaceapi: fix mistake
Jason A. Donenfeld [Fri, 30 Aug 2019 15:59:25 +0000 (09:59 -0600)] 
namespaceapi: fix mistake

5 years agonamespaceapi: initial version
Simon Rozman [Fri, 30 Aug 2019 12:41:33 +0000 (14:41 +0200)] 
namespaceapi: initial version

Signed-off-by: Simon Rozman <simon@rozman.si>
5 years agowintun: take mutex so that deletion uses the right name
Jason A. Donenfeld [Thu, 29 Aug 2019 23:42:28 +0000 (17:42 -0600)] 
wintun: take mutex so that deletion uses the right name

5 years agowintun: move ring constants into module
Jason A. Donenfeld [Thu, 29 Aug 2019 18:47:16 +0000 (12:47 -0600)] 
wintun: move ring constants into module

5 years agowintun: delete all interfaces is not used anymore
Jason A. Donenfeld [Thu, 29 Aug 2019 18:22:15 +0000 (12:22 -0600)] 
wintun: delete all interfaces is not used anymore

5 years agowintun: Wintun->Interface
Jason A. Donenfeld [Thu, 29 Aug 2019 18:20:40 +0000 (12:20 -0600)] 
wintun: Wintun->Interface

5 years agowintun: keep reference to pool in wintun object
Jason A. Donenfeld [Thu, 29 Aug 2019 18:13:16 +0000 (12:13 -0600)] 
wintun: keep reference to pool in wintun object

5 years agowintun: introduce adapter pools
Simon Rozman [Thu, 29 Aug 2019 16:00:44 +0000 (18:00 +0200)] 
wintun: introduce adapter pools

This makes wintun package reusable for non-WireGuard applications.

Signed-off-by: Simon Rozman <simon@rozman.si>
5 years agowintun: simplify rename logic
Jason A. Donenfeld [Thu, 29 Aug 2019 01:31:20 +0000 (19:31 -0600)] 
wintun: simplify rename logic

5 years agowintun: give better errors when ndis interface listing fails
Jason A. Donenfeld [Wed, 28 Aug 2019 14:39:26 +0000 (08:39 -0600)] 
wintun: give better errors when ndis interface listing fails

5 years agowintun: also check for numbered suffix and friendly name
Jason A. Donenfeld [Wed, 28 Aug 2019 14:08:07 +0000 (08:08 -0600)] 
wintun: also check for numbered suffix and friendly name

5 years agowintun: upgrade deleting all interfaces and make it reusable
Simon Rozman [Wed, 28 Aug 2019 09:39:01 +0000 (11:39 +0200)] 
wintun: upgrade deleting all interfaces and make it reusable

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>
5 years agowintun: cleanup earlier
Jason A. Donenfeld [Tue, 27 Aug 2019 16:54:49 +0000 (10:54 -0600)] 
wintun: cleanup earlier

5 years agowintun: rename duplicate adapters instead of ourselves
Jason A. Donenfeld [Tue, 27 Aug 2019 16:09:16 +0000 (10:09 -0600)] 
wintun: rename duplicate adapters instead of ourselves

5 years agowintun: match suffix numbers
Jason A. Donenfeld [Mon, 26 Aug 2019 20:46:43 +0000 (14:46 -0600)] 
wintun: match suffix numbers

5 years agodevice: getsockname on linux to determine port
Jason A. Donenfeld [Sun, 25 Aug 2019 18:45:13 +0000 (12:45 -0600)] 
device: getsockname on linux to determine port

It turns out Go isn't passing the pointer properly so we wound up with a
zero port every time.

5 years agowintun: make description consistent across fields
Jason A. Donenfeld [Sat, 24 Aug 2019 10:29:17 +0000 (12:29 +0200)] 
wintun: make description consistent across fields

5 years agowintun: try multiple names until one isn't a duplicate
Jason A. Donenfeld [Thu, 22 Aug 2019 06:52:59 +0000 (08:52 +0200)] 
wintun: try multiple names until one isn't a duplicate

5 years agowintun: use nci.dll directly instead of buggy netshell
Jason A. Donenfeld [Wed, 21 Aug 2019 06:40:44 +0000 (08:40 +0200)] 
wintun: use nci.dll directly instead of buggy netshell

5 years agowintun: set friendly a bit better
Jason A. Donenfeld [Tue, 20 Aug 2019 13:48:08 +0000 (15:48 +0200)] 
wintun: set friendly a bit better

This is still wrong, but NETSETUPPKEY_Driver_FriendlyName seems a bit
tricky to use.

5 years agowintun: also set friendly name after setting interface name
Jason A. Donenfeld [Mon, 19 Aug 2019 07:20:23 +0000 (09:20 +0200)] 
wintun: also set friendly name after setting interface name

5 years agowintun: defer requires unique variable
Jason A. Donenfeld [Mon, 19 Aug 2019 07:11:21 +0000 (09:11 +0200)] 
wintun: defer requires unique variable

5 years agowintun: set adapter description name
Jason A. Donenfeld [Mon, 19 Aug 2019 07:01:53 +0000 (09:01 +0200)] 
wintun: set adapter description name

5 years agotun: windows: don't spin unless we really need it
Jason A. Donenfeld [Sun, 18 Aug 2019 09:49:37 +0000 (11:49 +0200)] 
tun: windows: don't spin unless we really need it

6 years agoversion: bump snapshot 0.0.20190805
Jason A. Donenfeld [Mon, 5 Aug 2019 17:29:12 +0000 (19:29 +0200)] 
version: bump snapshot

6 years agodevice: drop lock before expiring keys
Jason A. Donenfeld [Mon, 5 Aug 2019 15:46:34 +0000 (17:46 +0200)] 
device: drop lock before expiring keys

6 years agouapi: skip peers with invalid keys
Jason A. Donenfeld [Mon, 5 Aug 2019 14:57:41 +0000 (16:57 +0200)] 
uapi: skip peers with invalid keys

6 years agotun: windows: spin for only a millisecond/80
Jason A. Donenfeld [Sat, 3 Aug 2019 17:05:53 +0000 (19:05 +0200)] 
tun: windows: spin for only a millisecond/80

Performance stays the same as before.