Browse Source

Adopt GOPATH

GOPATH is annoying, but the Go community pushing me to adopt it is even
more annoying.
Jason A. Donenfeld 2 years ago
parent
commit
588b9f01ae
19 changed files with 88 additions and 44 deletions
  1. 2
    0
      .gitignore
  2. 29
    3
      Gopkg.lock
  3. 3
    1
      Gopkg.toml
  4. 25
    4
      Makefile
  5. 1
    3
      README.md
  6. 1
    1
      conn_linux.go
  7. 1
    1
      cookie.go
  8. 2
    2
      device.go
  9. 15
    0
      donotuseon_linux.go
  10. 0
    20
      generate-vendor.sh
  11. 1
    1
      keypair.go
  12. 1
    1
      main.go
  13. 1
    1
      noise-protocol.go
  14. 1
    1
      tun.go
  15. 1
    1
      tun/tun_darwin.go
  16. 1
    1
      tun/tun_freebsd.go
  17. 1
    1
      tun/tun_linux.go
  18. 1
    1
      tun/tun_openbsd.go
  19. 1
    1
      uapi_linux.go

+ 2
- 0
.gitignore View File

@@ -1,2 +1,4 @@
1 1
 wireguard-go
2 2
 vendor
3
+.gopath
4
+ireallywantobuildon_linux.go

+ 29
- 3
Gopkg.lock View File

@@ -1,16 +1,42 @@
1
-# This was generated by ./generate-vendor.sh
1
+# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
2
+
3
+
2 4
 [[projects]]
3 5
   branch = "master"
4 6
   name = "golang.org/x/crypto"
7
+  packages = [
8
+    "blake2s",
9
+    "chacha20poly1305",
10
+    "curve25519",
11
+    "internal/chacha20",
12
+    "poly1305"
13
+  ]
5 14
   revision = "1a580b3eff7814fc9b40602fd35256c63b50f491"
6 15
 
7 16
 [[projects]]
8 17
   branch = "master"
9 18
   name = "golang.org/x/net"
10
-  revision = "8e0cdda24ed423affc8f35c241e5e9b16180338e"
19
+  packages = [
20
+    "bpf",
21
+    "internal/iana",
22
+    "internal/socket",
23
+    "ipv4",
24
+    "ipv6"
25
+  ]
26
+  revision = "9ef9f5bb98a1fdc41f8cf6c250a4404b4085e389"
11 27
 
12 28
 [[projects]]
13 29
   branch = "master"
14 30
   name = "golang.org/x/sys"
15
-  revision = "7f59abf37be6a6007f075af1bc7f16f137bc176b"
31
+  packages = [
32
+    "cpu",
33
+    "unix"
34
+  ]
35
+  revision = "88eb85aaee56831ad49eaf7aa80d73de9814cde2"
16 36
 
37
+[solve-meta]
38
+  analyzer-name = "dep"
39
+  analyzer-version = 1
40
+  inputs-digest = "d85ae9d2b4afafc3d7535505c46368cbbbec350cf876616302c1bcf44f6ec103"
41
+  solver-name = "gps-cdcl"
42
+  solver-version = 1

+ 3
- 1
Gopkg.toml View File

@@ -1,4 +1,3 @@
1
-# This was generated by ./generate-vendor.sh
2 1
 [[constraint]]
3 2
   branch = "master"
4 3
   name = "golang.org/x/crypto"
@@ -11,3 +10,6 @@
11 10
   branch = "master"
12 11
   name = "golang.org/x/sys"
13 12
 
13
+[prune]
14
+  go-tests = true
15
+  unused-packages = true

+ 25
- 4
Makefile View File

@@ -5,18 +5,39 @@ BINDIR ?= $(PREFIX)/bin
5 5
 ifeq ($(shell go env GOOS),linux)
6 6
 ifeq ($(wildcard .git),)
7 7
 $(error Do not build this for Linux. Instead use the Linux kernel module. See wireguard.com/install/ for more info.)
8
+else
9
+$(shell printf 'package main\nconst UseTheKernelModuleInstead = 0xdeadbabe\n' > ireallywantobuildon_linux.go)
8 10
 endif
9 11
 endif
10 12
 
11 13
 all: wireguard-go
12 14
 
13
-wireguard-go: $(wildcard *.go) $(wildcard */*.go)
14
-	go build -v -o $@
15
+export GOPATH := $(CURDIR)/.gopath
16
+export PATH := $(PATH):$(CURDIR)/.gopath/bin
17
+GO_IMPORT_PATH := git.zx2c4.com/wireguard-go
18
+
19
+.gopath/.created:
20
+	rm -rf .gopath
21
+	mkdir -p $(dir .gopath/src/$(GO_IMPORT_PATH))
22
+	ln -s ../../.. .gopath/src/$(GO_IMPORT_PATH)
23
+	touch $@
24
+
25
+vendor/.created: Gopkg.toml Gopkg.lock .gopath/.created
26
+	command -v dep >/dev/null || go get -v github.com/golang/dep/cmd/dep
27
+	cd .gopath/src/$(GO_IMPORT_PATH) && dep ensure -vendor-only -v
28
+	touch $@
29
+
30
+wireguard-go: $(wildcard *.go) $(wildcard */*.go) .gopath/.created vendor/.created
31
+	go build $(GO_BUILD_EXTRA_ARGS) -v $(GO_IMPORT_PATH)
15 32
 
16 33
 install: wireguard-go
17
-	@install -v -d "$(DESTDIR)$(BINDIR)" && install -m 0755 -v wireguard-go "$(DESTDIR)$(BINDIR)/wireguard-go"
34
+	@install -v -d "$(DESTDIR)$(BINDIR)" && install -v -m 0755 wireguard-go "$(DESTDIR)$(BINDIR)/wireguard-go"
18 35
 
19 36
 clean:
20 37
 	rm -f wireguard-go
21 38
 
22
-.PHONY: clean install
39
+update-dep:
40
+	command -v dep >/dev/null || go get -v github.com/golang/dep/cmd/dep
41
+	cd .gopath/src/$(GO_IMPORT_PATH) && dep ensure -update -v
42
+
43
+.PHONY: clean install update-dep

+ 1
- 3
README.md View File

@@ -48,13 +48,11 @@ This will run on OpenBSD. It does not yet support sticky sockets. Fwmark is mapp
48 48
 
49 49
 ## Building
50 50
 
51
-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:
51
+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.
52 52
 
53 53
 ```
54 54
 $ git clone https://git.zx2c4.com/wireguard-go
55 55
 $ cd wireguard-go
56
-$ export GOPATH="$PWD/gopath"
57
-$ go get -d -v
58 56
 $ make
59 57
 ```
60 58
 

+ 1
- 1
conn_linux.go View File

@@ -18,7 +18,7 @@
18 18
 package main
19 19
 
20 20
 import (
21
-	"./rwcancel"
21
+	"git.zx2c4.com/wireguard-go/rwcancel"
22 22
 	"errors"
23 23
 	"golang.org/x/sys/unix"
24 24
 	"net"

+ 1
- 1
cookie.go View File

@@ -7,7 +7,7 @@
7 7
 package main
8 8
 
9 9
 import (
10
-	"./xchacha20poly1305"
10
+	"git.zx2c4.com/wireguard-go/xchacha20poly1305"
11 11
 	"crypto/hmac"
12 12
 	"crypto/rand"
13 13
 	"golang.org/x/crypto/blake2s"

+ 2
- 2
device.go View File

@@ -7,8 +7,8 @@
7 7
 package main
8 8
 
9 9
 import (
10
-	"./ratelimiter"
11
-	"./tun"
10
+	"git.zx2c4.com/wireguard-go/ratelimiter"
11
+	"git.zx2c4.com/wireguard-go/tun"
12 12
 	"runtime"
13 13
 	"sync"
14 14
 	"sync/atomic"

+ 15
- 0
donotuseon_linux.go View File

@@ -0,0 +1,15 @@
1
+// +build !android
2
+
3
+/* SPDX-License-Identifier: GPL-2.0
4
+ *
5
+ * Copyright (C) 2017-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
6
+ */
7
+
8
+package main
9
+
10
+const DoNotUseThisProgramOnLinux = UseTheKernelModuleInstead
11
+
12
+// --------------------------------------------------------
13
+// Do not use this on Linux. Instead use the kernel module.
14
+// See wireguard.com/install for more information.
15
+// --------------------------------------------------------

+ 0
- 20
generate-vendor.sh View File

@@ -1,20 +0,0 @@
1
-#!/bin/bash
2
-
3
-echo "# This was generated by ./generate-vendor.sh" > Gopkg.lock
4
-echo "# This was generated by ./generate-vendor.sh" > Gopkg.toml
5
-
6
-while read -r package; do
7
-	cat >> Gopkg.lock <<-_EOF
8
-	[[projects]]
9
-	  branch = "master"
10
-	  name = "$package"
11
-	  revision = "$(< "$GOPATH/src/$package/.git/refs/heads/master")"
12
-
13
-	_EOF
14
-	cat >> Gopkg.toml <<-_EOF
15
-	[[constraint]]
16
-	  branch = "master"
17
-	  name = "$package"
18
-
19
-	_EOF
20
-done < <(sed -n 's/.*"\(golang.org\/x\/[^/]\+\)\/\?.*".*/\1/p' *.go */*.go | sort | uniq)

+ 1
- 1
keypair.go View File

@@ -7,7 +7,7 @@
7 7
 package main
8 8
 
9 9
 import (
10
-	"./replay"
10
+	"git.zx2c4.com/wireguard-go/replay"
11 11
 	"crypto/cipher"
12 12
 	"sync"
13 13
 	"time"

+ 1
- 1
main.go View File

@@ -7,7 +7,7 @@
7 7
 package main
8 8
 
9 9
 import (
10
-	"./tun"
10
+	"git.zx2c4.com/wireguard-go/tun"
11 11
 	"fmt"
12 12
 	"os"
13 13
 	"os/signal"

+ 1
- 1
noise-protocol.go View File

@@ -7,7 +7,7 @@
7 7
 package main
8 8
 
9 9
 import (
10
-	"./tai64n"
10
+	"git.zx2c4.com/wireguard-go/tai64n"
11 11
 	"errors"
12 12
 	"golang.org/x/crypto/blake2s"
13 13
 	"golang.org/x/crypto/chacha20poly1305"

+ 1
- 1
tun.go View File

@@ -7,7 +7,7 @@
7 7
 package main
8 8
 
9 9
 import (
10
-	"./tun"
10
+	"git.zx2c4.com/wireguard-go/tun"
11 11
 	"sync/atomic"
12 12
 )
13 13
 

+ 1
- 1
tun/tun_darwin.go View File

@@ -7,7 +7,7 @@
7 7
 package tun
8 8
 
9 9
 import (
10
-	"../rwcancel"
10
+	"git.zx2c4.com/wireguard-go/rwcancel"
11 11
 	"errors"
12 12
 	"fmt"
13 13
 	"golang.org/x/net/ipv6"

+ 1
- 1
tun/tun_freebsd.go View File

@@ -6,7 +6,7 @@
6 6
 package tun
7 7
 
8 8
 import (
9
-	"../rwcancel"
9
+	"git.zx2c4.com/wireguard-go/rwcancel"
10 10
 	"bytes"
11 11
 	"errors"
12 12
 	"fmt"

+ 1
- 1
tun/tun_linux.go View File

@@ -12,7 +12,7 @@ package tun
12 12
  */
13 13
 
14 14
 import (
15
-	"../rwcancel"
15
+	"git.zx2c4.com/wireguard-go/rwcancel"
16 16
 	"bytes"
17 17
 	"errors"
18 18
 	"fmt"

+ 1
- 1
tun/tun_openbsd.go View File

@@ -6,7 +6,7 @@
6 6
 package tun
7 7
 
8 8
 import (
9
-	"../rwcancel"
9
+	"git.zx2c4.com/wireguard-go/rwcancel"
10 10
 	"errors"
11 11
 	"fmt"
12 12
 	"golang.org/x/net/ipv6"

+ 1
- 1
uapi_linux.go View File

@@ -7,7 +7,7 @@
7 7
 package main
8 8
 
9 9
 import (
10
-	"./rwcancel"
10
+	"git.zx2c4.com/wireguard-go/rwcancel"
11 11
 	"errors"
12 12
 	"fmt"
13 13
 	"golang.org/x/sys/unix"

Loading…
Cancel
Save