Go to file
Jason A. Donenfeld a050431f26 Makefile: export PWD for OpenBSD's ksh(1)
Interestingly, ksh(1) on OpenBSD does not export PWD by default, and it
also has a notion of the "logical cwd" vs the "physical cwd", with the
latter being passed to chdir, but the former being stored in the
non-exported PWD and displayed to the user. This means that if you `cd`
into a directory that's comprised of symlinks, exec'd processes will see
the physical path. Observe:

  # ksh
  # mkdir a
  # ln -s a b
  # cd b
  # pwd
  /root/b
  # ksh -c pwd
  /root/a

The fact of separating physical and logical paths is not too uncommon
for shells (bash does it too), but not exporting PWD is very odd.

Since this is common behavior for many shells, libraries that return the
working directory will do something strange: they `stat(".")` and then
`stat(getenv("PWD"))`, and if these point to the same inode, they roll
with the value of `getenv("PWD")`, or otherwise fallback to asking the
kernel for the cwd.

Since PWD was not exported by ksh(1), Go's dep utility did not understand
it was operating inside of our faked GOPATH and became upset.

This patch works around the whole situation by simply exporting PWD
before executing dep.
2018-06-02 16:36:12 +02:00
ratelimiter ratelimiter: do not run GC with nothing to do 2018-05-21 03:20:18 +02:00
replay Move replay into subpackage 2018-05-23 03:58:27 +02:00
rwcancel Catch EINTR 2018-05-24 15:36:29 +02:00
tai64n global: Add SPDX tags and copyright header 2018-05-03 15:06:25 +02:00
tests Moved test-processes to background 2018-02-11 23:31:53 +01:00
tun Disable broadcast mode on *BSD 2018-05-27 22:55:15 +02:00
xchacha20poly1305 global: Add SPDX tags and copyright header 2018-05-03 15:06:25 +02:00
.gitignore Adopt GOPATH 2018-05-23 05:18:13 +02:00
allowedips_rand_test.go Add copyright headers 2018-05-19 02:40:22 +02:00
allowedips_test.go Add copyright headers 2018-05-19 02:40:22 +02:00
allowedips.go Add copyright headers 2018-05-19 02:40:22 +02:00
bind_test.go Add copyright headers 2018-05-19 02:40:22 +02:00
conn_default.go Disappointing anti-sticky experiment 2018-05-27 22:55:15 +02:00
conn_linux.go Disappointing anti-sticky experiment 2018-05-27 22:55:15 +02:00
conn.go Cleanup 2018-05-23 03:58:27 +02:00
constants.go Add copyright headers 2018-05-19 02:40:22 +02:00
cookie_test.go Add copyright headers 2018-05-19 02:40:22 +02:00
cookie.go Catch EINTR 2018-05-24 15:36:29 +02:00
COPYING Initial scaffolding 2017-05-30 00:13:20 +02:00
device_test.go Make successful tests silent 2018-05-21 20:21:00 +02:00
device.go Adopt GOPATH 2018-05-23 05:18:13 +02:00
donotuseon_linux.go Adopt GOPATH 2018-05-23 05:18:13 +02:00
endpoint_test.go Add copyright headers 2018-05-19 02:40:22 +02:00
Gopkg.lock Update deps 2018-05-28 01:39:37 +02:00
Gopkg.toml Adopt GOPATH 2018-05-23 05:18:13 +02:00
helper_test.go Fix tests 2018-05-24 19:58:16 +02:00
indextable.go Add copyright headers 2018-05-19 02:40:22 +02:00
ip.go Add copyright headers 2018-05-19 02:40:22 +02:00
kdf_test.go Add copyright headers 2018-05-19 02:40:22 +02:00
keypair.go Catch EINTR 2018-05-24 15:36:29 +02:00
logger.go Add copyright headers 2018-05-19 02:40:22 +02:00
main.go Print version number in log 2018-05-30 01:09:18 +02:00
Makefile Makefile: export PWD for OpenBSD's ksh(1) 2018-06-02 16:36:12 +02:00
misc.go Move replay into subpackage 2018-05-23 03:58:27 +02:00
noise_test.go Properly close DummyTUN to avoid deadlock in TestNoiseHandshake 2018-05-21 20:20:13 +02:00
noise-helpers.go Add copyright headers 2018-05-19 02:40:22 +02:00
noise-protocol.go Catch EINTR 2018-05-24 15:36:29 +02:00
noise-types.go Add copyright headers 2018-05-19 02:40:22 +02:00
peer.go Disappointing anti-sticky experiment 2018-05-27 22:55:15 +02:00
README.md Adopt GOPATH 2018-05-23 05:18:13 +02:00
receive.go Disappointing anti-sticky experiment 2018-05-27 22:55:15 +02:00
send.go Make successful tests silent 2018-05-21 20:21:00 +02:00
timers.go Fix typo in timers 2018-05-27 22:55:15 +02:00
tun.go Adopt GOPATH 2018-05-23 05:18:13 +02:00
uapi_bsd.go Infoleak ifnames and be more permissive 2018-05-23 15:38:24 +02:00
uapi_linux.go Catch EINTR 2018-05-24 15:36:29 +02:00
uapi.go Straighten out UAPI logging 2018-05-21 03:38:50 +02:00
version.go version: bump snapshot 2018-05-31 02:26:07 +02:00

Go Implementation of WireGuard

This is an implementation of WireGuard in Go.

WARNING: This is a work in progress and not ready for prime time, with no official "releases" yet. It is extremely rough around the edges and leaves much to be desired. There are bugs and we are not yet in a position to make claims about its security. Beware.

Usage

Most Linux kernel WireGuard users are used to adding an interface with ip link add wg0 type wireguard. With wireguard-go, instead simply run:

$ wireguard-go wg0

This will create an interface and fork into the background. To remove the interface, use the usual ip link del wg0, or if your system does not support removing interfaces directly, you may instead remove the control socket via rm -f /var/run/wireguard/wg0.sock, which will result in wireguard-go shutting down.

To run wireguard-go without forking to the background, pass -f or --foreground:

$ wireguard-go -f wg0

When an interface is running, you may use wg(8) to configure it, as well as the usual ip(8) and ifconfig(8) commands.

To run with more logging you may set the environment variable LOG_LEVEL=debug.

Platforms

Linux

This will run on Linux; however YOU SHOULD NOT RUN THIS ON LINUX. Instead use the kernel module; see the installation page for instructions.

macOS

This runs on macOS using the utun driver. It does not yet support sticky sockets, and won't support fwmarks because of Darwin limitations. Since the utun driver cannot have arbitrary interface names, you must either use utun[0-9]+ for an explicit interface name or utun to have the kernel select one for you. If you choose utun as the interface name, and the environment variable WG_TUN_NAME_FILE is defined, then the actual name of the interface chosen by the kernel is written to the file specified by that variable.

Windows

It is currently a work in progress to strip out the beginnings of an experiment done with the OpenVPN tuntap driver and instead port to the new UWP APIs for tunnels. In other words, this does not yet work on Windows.

FreeBSD

This will run on FreeBSD. It does not yet support sticky sockets. Fwmark is mapped to SO_USER_COOKIE.

OpenBSD

This will run on OpenBSD. It does not yet support sticky sockets. Fwmark is mapped to SO_RTABLE. Since the tun driver cannot have arbitrary interface names, you must either use tun[0-9]+ for an explicit interface name or tun to have the program select one for you. If you choose tun as the interface name, and the environment variable WG_TUN_NAME_FILE is defined, then the actual name of the interface chosen by the kernel is written to the file specified by that variable.

Building

This requires an installation of go and of dep. If dep is not installed, it will be downloaded and built as part of the build process.

$ git clone https://git.zx2c4.com/wireguard-go
$ cd wireguard-go
$ make

License

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

---------------------------------------------------------------------------
Additional Permissions For Submission to Apple App Store: Provided that you
are otherwise in compliance with the GPLv2 for each covered work you convey
(including without limitation making the Corresponding Source available in
compliance with Section 3 of the GPLv2), you are granted the additional
the additional permission to convey through the Apple App Store
non-source executable versions of the Program as incorporated into each
applicable covered work as Executable Versions only under the Mozilla
Public License version 2.0 (https://www.mozilla.org/en-US/MPL/2.0/).