diff --git a/.gitignore b/.gitignore index 431991b..96650bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ wireguard-go vendor +.gopath +ireallywantobuildon_linux.go diff --git a/Gopkg.lock b/Gopkg.lock index 15c0109..3731e9b 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1,16 +1,42 @@ -# This was generated by ./generate-vendor.sh +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + [[projects]] branch = "master" name = "golang.org/x/crypto" + packages = [ + "blake2s", + "chacha20poly1305", + "curve25519", + "internal/chacha20", + "poly1305" + ] revision = "1a580b3eff7814fc9b40602fd35256c63b50f491" [[projects]] branch = "master" name = "golang.org/x/net" - revision = "8e0cdda24ed423affc8f35c241e5e9b16180338e" + packages = [ + "bpf", + "internal/iana", + "internal/socket", + "ipv4", + "ipv6" + ] + revision = "9ef9f5bb98a1fdc41f8cf6c250a4404b4085e389" [[projects]] branch = "master" name = "golang.org/x/sys" - revision = "7f59abf37be6a6007f075af1bc7f16f137bc176b" + packages = [ + "cpu", + "unix" + ] + revision = "88eb85aaee56831ad49eaf7aa80d73de9814cde2" +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "d85ae9d2b4afafc3d7535505c46368cbbbec350cf876616302c1bcf44f6ec103" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index cc569b3..3aafd44 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,4 +1,3 @@ -# This was generated by ./generate-vendor.sh [[constraint]] branch = "master" name = "golang.org/x/crypto" @@ -11,3 +10,6 @@ branch = "master" name = "golang.org/x/sys" +[prune] + go-tests = true + unused-packages = true diff --git a/Makefile b/Makefile index e1c53c5..bef7edf 100644 --- a/Makefile +++ b/Makefile @@ -5,18 +5,39 @@ BINDIR ?= $(PREFIX)/bin ifeq ($(shell go env GOOS),linux) ifeq ($(wildcard .git),) $(error Do not build this for Linux. Instead use the Linux kernel module. See wireguard.com/install/ for more info.) +else +$(shell printf 'package main\nconst UseTheKernelModuleInstead = 0xdeadbabe\n' > ireallywantobuildon_linux.go) endif endif all: wireguard-go -wireguard-go: $(wildcard *.go) $(wildcard */*.go) - go build -v -o $@ +export GOPATH := $(CURDIR)/.gopath +export PATH := $(PATH):$(CURDIR)/.gopath/bin +GO_IMPORT_PATH := git.zx2c4.com/wireguard-go + +.gopath/.created: + rm -rf .gopath + mkdir -p $(dir .gopath/src/$(GO_IMPORT_PATH)) + ln -s ../../.. .gopath/src/$(GO_IMPORT_PATH) + touch $@ + +vendor/.created: Gopkg.toml Gopkg.lock .gopath/.created + command -v dep >/dev/null || go get -v github.com/golang/dep/cmd/dep + cd .gopath/src/$(GO_IMPORT_PATH) && dep ensure -vendor-only -v + touch $@ + +wireguard-go: $(wildcard *.go) $(wildcard */*.go) .gopath/.created vendor/.created + go build $(GO_BUILD_EXTRA_ARGS) -v $(GO_IMPORT_PATH) install: wireguard-go - @install -v -d "$(DESTDIR)$(BINDIR)" && install -m 0755 -v wireguard-go "$(DESTDIR)$(BINDIR)/wireguard-go" + @install -v -d "$(DESTDIR)$(BINDIR)" && install -v -m 0755 wireguard-go "$(DESTDIR)$(BINDIR)/wireguard-go" clean: rm -f wireguard-go -.PHONY: clean install +update-dep: + command -v dep >/dev/null || go get -v github.com/golang/dep/cmd/dep + cd .gopath/src/$(GO_IMPORT_PATH) && dep ensure -update -v + +.PHONY: clean install update-dep diff --git a/README.md b/README.md index 92ef4da..35fc23a 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,11 @@ This will run on OpenBSD. It does not yet support sticky sockets. Fwmark is mapp ## Building -You can satisfy dependencies with either `go get -d -v` or `dep ensure -vendor-only`. Then run `make`. As this is a Go project, a `GOPATH` is required. For example, wireguard-go can be built with: +This requires an installation of [go](https://golang.org) and of [dep](https://github.com/golang/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 -$ export GOPATH="$PWD/gopath" -$ go get -d -v $ make ``` diff --git a/conn_linux.go b/conn_linux.go index fa09087..fe30afb 100644 --- a/conn_linux.go +++ b/conn_linux.go @@ -18,7 +18,7 @@ package main import ( - "./rwcancel" + "git.zx2c4.com/wireguard-go/rwcancel" "errors" "golang.org/x/sys/unix" "net" diff --git a/cookie.go b/cookie.go index c39ad22..8211323 100644 --- a/cookie.go +++ b/cookie.go @@ -7,7 +7,7 @@ package main import ( - "./xchacha20poly1305" + "git.zx2c4.com/wireguard-go/xchacha20poly1305" "crypto/hmac" "crypto/rand" "golang.org/x/crypto/blake2s" diff --git a/device.go b/device.go index e116731..5f7254c 100644 --- a/device.go +++ b/device.go @@ -7,8 +7,8 @@ package main import ( - "./ratelimiter" - "./tun" + "git.zx2c4.com/wireguard-go/ratelimiter" + "git.zx2c4.com/wireguard-go/tun" "runtime" "sync" "sync/atomic" diff --git a/donotuseon_linux.go b/donotuseon_linux.go new file mode 100644 index 0000000..7197375 --- /dev/null +++ b/donotuseon_linux.go @@ -0,0 +1,15 @@ +// +build !android + +/* SPDX-License-Identifier: GPL-2.0 + * + * Copyright (C) 2017-2018 Jason A. Donenfeld . All Rights Reserved. + */ + +package main + +const DoNotUseThisProgramOnLinux = UseTheKernelModuleInstead + +// -------------------------------------------------------- +// Do not use this on Linux. Instead use the kernel module. +// See wireguard.com/install for more information. +// -------------------------------------------------------- diff --git a/generate-vendor.sh b/generate-vendor.sh deleted file mode 100755 index 51d0fff..0000000 --- a/generate-vendor.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -echo "# This was generated by ./generate-vendor.sh" > Gopkg.lock -echo "# This was generated by ./generate-vendor.sh" > Gopkg.toml - -while read -r package; do - cat >> Gopkg.lock <<-_EOF - [[projects]] - branch = "master" - name = "$package" - revision = "$(< "$GOPATH/src/$package/.git/refs/heads/master")" - - _EOF - cat >> Gopkg.toml <<-_EOF - [[constraint]] - branch = "master" - name = "$package" - - _EOF -done < <(sed -n 's/.*"\(golang.org\/x\/[^/]\+\)\/\?.*".*/\1/p' *.go */*.go | sort | uniq) diff --git a/keypair.go b/keypair.go index face310..b125189 100644 --- a/keypair.go +++ b/keypair.go @@ -7,7 +7,7 @@ package main import ( - "./replay" + "git.zx2c4.com/wireguard-go/replay" "crypto/cipher" "sync" "time" diff --git a/main.go b/main.go index a04cd15..29693eb 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,7 @@ package main import ( - "./tun" + "git.zx2c4.com/wireguard-go/tun" "fmt" "os" "os/signal" diff --git a/noise-protocol.go b/noise-protocol.go index c6a95d8..a527be9 100644 --- a/noise-protocol.go +++ b/noise-protocol.go @@ -7,7 +7,7 @@ package main import ( - "./tai64n" + "git.zx2c4.com/wireguard-go/tai64n" "errors" "golang.org/x/crypto/blake2s" "golang.org/x/crypto/chacha20poly1305" diff --git a/tun.go b/tun.go index 9752636..6c239ea 100644 --- a/tun.go +++ b/tun.go @@ -7,7 +7,7 @@ package main import ( - "./tun" + "git.zx2c4.com/wireguard-go/tun" "sync/atomic" ) diff --git a/tun/tun_darwin.go b/tun/tun_darwin.go index fcbb4f9..04020cb 100644 --- a/tun/tun_darwin.go +++ b/tun/tun_darwin.go @@ -7,7 +7,7 @@ package tun import ( - "../rwcancel" + "git.zx2c4.com/wireguard-go/rwcancel" "errors" "fmt" "golang.org/x/net/ipv6" diff --git a/tun/tun_freebsd.go b/tun/tun_freebsd.go index b4cf57d..bd70104 100644 --- a/tun/tun_freebsd.go +++ b/tun/tun_freebsd.go @@ -6,7 +6,7 @@ package tun import ( - "../rwcancel" + "git.zx2c4.com/wireguard-go/rwcancel" "bytes" "errors" "fmt" diff --git a/tun/tun_linux.go b/tun/tun_linux.go index acfb942..d048c21 100644 --- a/tun/tun_linux.go +++ b/tun/tun_linux.go @@ -12,7 +12,7 @@ package tun */ import ( - "../rwcancel" + "git.zx2c4.com/wireguard-go/rwcancel" "bytes" "errors" "fmt" diff --git a/tun/tun_openbsd.go b/tun/tun_openbsd.go index 74b25e5..709b5cd 100644 --- a/tun/tun_openbsd.go +++ b/tun/tun_openbsd.go @@ -6,7 +6,7 @@ package tun import ( - "../rwcancel" + "git.zx2c4.com/wireguard-go/rwcancel" "errors" "fmt" "golang.org/x/net/ipv6" diff --git a/uapi_linux.go b/uapi_linux.go index 2b5b9a0..5e86628 100644 --- a/uapi_linux.go +++ b/uapi_linux.go @@ -7,7 +7,7 @@ package main import ( - "./rwcancel" + "git.zx2c4.com/wireguard-go/rwcancel" "errors" "fmt" "golang.org/x/sys/unix"