]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
Adopt GOPATH
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 23 May 2018 01:17:51 +0000 (03:17 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 23 May 2018 03:18:13 +0000 (05:18 +0200)
GOPATH is annoying, but the Go community pushing me to adopt it is even
more annoying.

19 files changed:
.gitignore
Gopkg.lock
Gopkg.toml
Makefile
README.md
conn_linux.go
cookie.go
device.go
donotuseon_linux.go [new file with mode: 0644]
generate-vendor.sh [deleted file]
keypair.go
main.go
noise-protocol.go
tun.go
tun/tun_darwin.go
tun/tun_freebsd.go
tun/tun_linux.go
tun/tun_openbsd.go
uapi_linux.go

index 431991b32c5fab38683b3e9d21f8f5676c8db649..96650bbd94a20a9af33076be8514a9bcee517a76 100644 (file)
@@ -1,2 +1,4 @@
 wireguard-go
 vendor
+.gopath
+ireallywantobuildon_linux.go
index 15c0109cbc95c965491fafbc1f21d36306f65fb4..3731e9bcbcc89a7016a6bec3aee6654410a4e1dc 100644 (file)
@@ -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
index cc569b308e7783acb157f1bcabebcdc0535b3126..3aafd448d208937f9bfbfb9660b526e7e262edb2 100644 (file)
@@ -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
index e1c53c57e4441f96bb13a3be8a8dbf5266ff9879..bef7edfa541e3579b48aa5e1d64d8b20ae784052 100644 (file)
--- 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
index 92ef4da84d57ce220d340889b71033bf5948640b..35fc23ab38d700d10422354ff33ba210c812a596 100644 (file)
--- 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
 ```
 
index fa0908756ea0b6ccff992b6f409fc47fcc718d79..fe30afba4ce394540b3a9b75be01356ba7a49b3e 100644 (file)
@@ -18,7 +18,7 @@
 package main
 
 import (
-       "./rwcancel"
+       "git.zx2c4.com/wireguard-go/rwcancel"
        "errors"
        "golang.org/x/sys/unix"
        "net"
index c39ad228785d827f1a7c19b84fc24a50cd9d1df8..8211323511a14cb5f8fcbff2064829bc9892f226 100644 (file)
--- 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"
index e11673103e09b5e91ccd79b573688471e3d7ec98..5f7254cb9ca95e2b7bb2135c4a6c65a67397bccb 100644 (file)
--- 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 (file)
index 0000000..7197375
--- /dev/null
@@ -0,0 +1,15 @@
+// +build !android
+
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2017-2018 Jason A. Donenfeld <Jason@zx2c4.com>. 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 (executable)
index 51d0fff..0000000
+++ /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)
index face310d543fa6a316818b7e8847fb645a5610f6..b125189d30fe8cf311095177ee7477d47eb8ee3c 100644 (file)
@@ -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 a04cd15c6fe5dbce0d851857f4bc1eda708c548e..29693eb291485567fad3e9b62846f428ccd10196 100644 (file)
--- a/main.go
+++ b/main.go
@@ -7,7 +7,7 @@
 package main
 
 import (
-       "./tun"
+       "git.zx2c4.com/wireguard-go/tun"
        "fmt"
        "os"
        "os/signal"
index c6a95d8913a4004478c74ad248509b948b2d409b..a527be946a443ef2a9af7b0e0255b64efc8f4e9f 100644 (file)
@@ -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 97526361a1e80353e92e09105003b05175368d00..6c239ea3c38777cafb9b5afe146ec2b3e767b350 100644 (file)
--- a/tun.go
+++ b/tun.go
@@ -7,7 +7,7 @@
 package main
 
 import (
-       "./tun"
+       "git.zx2c4.com/wireguard-go/tun"
        "sync/atomic"
 )
 
index fcbb4f9f7be838a68681b8a2cd06fe40e48a9ac2..04020cbd1e625189cd2c3cf822d7f94470ee638f 100644 (file)
@@ -7,7 +7,7 @@
 package tun
 
 import (
-       "../rwcancel"
+       "git.zx2c4.com/wireguard-go/rwcancel"
        "errors"
        "fmt"
        "golang.org/x/net/ipv6"
index b4cf57d36c20d96503188d18731281a02ffa2036..bd70104760d8d2b9ff22c8a6bdd5df832fd15938 100644 (file)
@@ -6,7 +6,7 @@
 package tun
 
 import (
-       "../rwcancel"
+       "git.zx2c4.com/wireguard-go/rwcancel"
        "bytes"
        "errors"
        "fmt"
index acfb942b68f323e1496c43ff1eb56bf2e73ebc25..d048c21afda7e4315f8efdd82ebbac5d3fac933e 100644 (file)
@@ -12,7 +12,7 @@ package tun
  */
 
 import (
-       "../rwcancel"
+       "git.zx2c4.com/wireguard-go/rwcancel"
        "bytes"
        "errors"
        "fmt"
index 74b25e56132ffe17f622c0ca7c4155736034519d..709b5cd5ffa503e9d1a3fdbbc585c214e90b0d97 100644 (file)
@@ -6,7 +6,7 @@
 package tun
 
 import (
-       "../rwcancel"
+       "git.zx2c4.com/wireguard-go/rwcancel"
        "errors"
        "fmt"
        "golang.org/x/net/ipv6"
index 2b5b9a0780c0e7a13d26b788da5eb6fab83185d4..5e866287452a92354e4ad24fd88f3b754ac1ae22 100644 (file)
@@ -7,7 +7,7 @@
 package main
 
 import (
-       "./rwcancel"
+       "git.zx2c4.com/wireguard-go/rwcancel"
        "errors"
        "fmt"
        "golang.org/x/sys/unix"