-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (54 loc) · 2.03 KB
/
Makefile
File metadata and controls
71 lines (54 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
export PATH := $(HOME)/go/bin:$(PATH) # TODO: use goenv GOPATH instead of `$HOME/go/`
gen:
@mkdir -p pb/wg
protoc --proto_path=proto proto/*.proto --go_out=. --go-grpc_out=.
cert:
@mkdir -p certs
# generate server's key and CSR
openssl req -newkey rsa:2048 -sha256 -nodes -keyout certs/server.key \
-out certs/server.csr -outform PEM -subj "/CN=localhost" \
-subj "/CN=localhost" -addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
# generate client's key and CSR
openssl req -newkey rsa:2048 -sha256 -nodes -keyout certs/client.key \
-out certs/client.csr -outform PEM -subj "/CN=localhost" \
-subj "/CN=localhost" -addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
# generate CA
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 \
-nodes -keyout certs/ca.key -out certs/ca.crt -subj "/CN=Root CA"
# Sign CSRs
openssl x509 -req \
-days 365 -sha256 -in certs/server.csr -CA certs/ca.crt \
-CAkey certs/ca.key -set_serial 1 -out certs/server.crt \
-copy_extensions copy
openssl x509 -req \
-days 365 -sha256 -in certs/client.csr -CA certs/ca.crt \
-CAkey certs/ca.key -set_serial 2 -out certs/client.crt \
-copy_extensions copy
clean:
rm -rf pb; mkdir pb
rm -rf certs; mkdir certs
run-server:
go run server/main.go
build-linux:
GOOS=linux go build -o wireguard-grpc-linux server/main.go
build: tidy
go build -o wireguard-grpc server/main.go
mac-install:
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
brew install protobuf
brew install clang-format
brew install grpcurl
linux-install:
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
test:
go test -v -cover -race ./...
tidy:
go fmt ./...
go mod tidy -v
docker-build: test
docker build . --tag wireguard-grpc --tag atsevan/wireguard-grpc
docker-run:
docker run -it --cap-add=NET_ADMIN docker.io/atsevan/wireguard-grpc --insecure --host 0.0.0.0