-
Notifications
You must be signed in to change notification settings - Fork 239
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (84 loc) · 2.81 KB
/
Copy pathMakefile
File metadata and controls
99 lines (84 loc) · 2.81 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
BUILD_TYPE ?= release
ifeq ($(BUILD_TYPE), release)
CARGO_BUILD_TYPE = --release
endif
LOG_LEVEL ?= trace
CONFIG_FILE ?= vpn.toml
HOSTS_CONFIG_FILE ?= hosts.toml
DOCKER_IMAGE_NAME ?= trusttunnel-endpoint
ENDPOINT_URL ?= git@github.com:TrustTunnel/TrustTunnel.git
ENDPOINT_VERSION ?= master
ENDPOINT_HOSTNAME ?= vpn.endpoint
DOCKER_DIR = docker
DOCKER_ENDPOINT_DIR = TrustTunnel
DOCKER_ENDPOINT_CONFIG_DIR = config
LISTEN_ADDRESS ?= 0.0.0.0
LISTEN_PORT ?= 443
.PHONY: init
## Initialize the development environment (git hooks, etc.)
init:
git config core.hooksPath ./scripts/hooks
.PHONY: endpoint/build-wizard
## Build the setup wizard
endpoint/build-wizard:
cargo build $(CARGO_BUILD_TYPE) --bin setup_wizard
.PHONY: endpoint/setup
## Run the setup wizard to create all the required configuration files
endpoint/setup: endpoint/build-wizard
cargo run $(CARGO_BUILD_TYPE) --bin setup_wizard -- \
--hostname "$(ENDPOINT_HOSTNAME)" \
--address "$(LISTEN_ADDRESS):$(LISTEN_PORT)" \
--lib-settings "$(CONFIG_FILE)" \
--hosts-settings "$(HOSTS_CONFIG_FILE)"
.PHONY: endpoint/build
## Build the endpoint
endpoint/build:
cargo build $(CARGO_BUILD_TYPE) --bin trusttunnel_endpoint
.PHONY: endpoint/run
## Run the endpoint with the existing configuration files
endpoint/run: endpoint/build
cargo run $(CARGO_BUILD_TYPE) --bin trusttunnel_endpoint -- \
-l "$(LOG_LEVEL)" "$(CONFIG_FILE)" "$(HOSTS_CONFIG_FILE)"
.PHONY: endpoint/gen_client_config
## Generate the config for specified client to be used with vpn client and exit
endpoint/gen_client_config:
$(if $(CLIENT_NAME),,$(error CLIENT_NAME is not set. Specify the client name to generate the config for))
$(if $(ENDPOINT_ADDRESS),,$(error ENDPOINT_ADDRESS is not set. Set it to `ip:port` that client is going to use to connect to the endpoint))
cargo run $(CARGO_BUILD_TYPE) --bin trusttunnel_endpoint -- \
-c "$(CLIENT_NAME)" --address "$(ENDPOINT_ADDRESS)" "$(CONFIG_FILE)" "$(HOSTS_CONFIG_FILE)"
.PHONY: endpoint/clean
## Clean cargo artifacts
endpoint/clean:
cargo clean
.PHONY: lint
lint: lint-md lint-rust
## Lint markdown files.
## `markdownlint-cli` should be installed:
## macOS: `brew install markdownlint-cli`
## Linux: `npm install -g markdownlint-cli`
.PHONY: lint-md
lint-md:
markdownlint .
## Check Rust code formatting with rustfmt.
## `rustfmt` should be installed:
## rustup component add rustfmt
.PHONY: lint-rust
lint-rust:
cargo fmt --all -- --check
cargo clippy -- -D warnings
## Fix linter issues that are auto-fixable.
.PHONY: lint-fix
lint-fix: lint-fix-rust lint-fix-md
## Auto-fix Rust code formatting issues with rustfmt.
.PHONY: lint-fix-rust
lint-fix-rust:
cargo clippy --fix --allow-dirty
cargo fmt --all
## Auto-fix markdown files.
.PHONY: lint-fix-md
lint-fix-md:
markdownlint --fix .
.PHONY: test
test: test-rust
test-rust:
cargo test --workspace