blob: 20c3d8878cc0399164b1377b4678a0e24218d84d (
plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
GOPATH ?= $(HOME)/.local/share/go
WAILS := $(GOPATH)/bin/wails
SERVER := root@178.20.40.99
RELEASES_DIR := /opt/vpnem/data/releases
export GOPATH
.PHONY: all server client-linux client-windows installer vpnemctl test test-control test-hy2 clean deploy release release-assets release-verify install-ruleset-timer
all: server client-linux
# --- Server ---
server:
go build -o build/vpnem-server ./cmd/server
# --- Client ---
client-linux:
cd cmd/client && $(WAILS) build -platform linux/amd64 -o vpnem -tags with_gvisor,with_utls,with_quic
cp cmd/client/build/bin/vpnem build/vpnem-linux-amd64
client-windows:
cd cmd/client && CC=x86_64-w64-mingw32-gcc $(WAILS) build -platform windows/amd64 -o vpnem.exe -tags with_gvisor,with_utls,with_quic
cp cmd/client/build/bin/vpnem.exe build/vpnem-windows-amd64.exe
installer:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-H windowsgui" -o build/vpnem-installer.exe ./cmd/installer
vpnemctl:
go build -o build/vpnemctl ./cmd/vpnemctl
# --- Test ---
test:
go test ./... -v
test-control:
go test ./internal/control -v
test-hy2:
go test ./internal/config/ -run TestBuildConfigHysteria2 -v
go test ./internal/control/ -run TestHysteria2Bundle -v
.PHONY: test-multi
test-multi:
go test ./internal/config/ -run "TestBuildConfig(VLESSReality|Hysteria2|SplitRealityHysteria2)" -v
go test ./internal/control/ -run "Test(RenderRuntimeBundleReality|Hysteria2Bundle|RenderRuntimeBundleMultiProtocol)" -v
go test ./internal/sync/ -run "TestCatalogToServers(MultiProtocolNode)?" -v
# --- Deploy: server code only ---
deploy:
rsync -avz --exclude '.git' --exclude 'build' --exclude '*.srs' --exclude '.claude' --exclude '.env' --exclude 'VPNUI_ADMIN_TOKEN.txt' \
./ $(SERVER):/opt/vpnem/
ssh $(SERVER) "cd /opt/vpnem && docker compose up -d --build"
@echo "Verify: curl https://vpn.em-sysadmin.xyz/health"
# --- Release: build all + deploy binaries + bump version ---
release-assets: client-linux client-windows installer
rm -f build/vpnem-linux-amd64
cp cmd/client/build/bin/vpnem build/vpnem-linux-amd64
test -f build/sing-box.exe
test -f build/wintun.dll
scp build/vpnem-linux-amd64 build/vpnem-windows-amd64.exe build/vpnem-installer.exe build/sing-box.exe build/wintun.dll \
$(SERVER):$(RELEASES_DIR)/
scp data/version.json $(SERVER):/opt/vpnem/data/version.json
release-verify:
@echo ""
@echo "Verifying health..."
@ok=0; \
for attempt in 1 2 3 4 5; do \
if curl -fSs https://vpn.em-sysadmin.xyz/health; then \
ok=1; \
break; \
fi; \
echo "retry $$attempt for /health"; \
sleep 2; \
done; \
if [ "$$ok" -ne 1 ]; then \
echo "release verify failed for /health"; \
exit 1; \
fi
@echo ""
@echo "Verifying version..."
@ok=0; \
for attempt in 1 2 3 4 5; do \
if curl -fSs https://vpn.em-sysadmin.xyz/api/v1/version; then \
ok=1; \
break; \
fi; \
echo "retry $$attempt for /api/v1/version"; \
sleep 2; \
done; \
if [ "$$ok" -ne 1 ]; then \
echo "release verify failed for /api/v1/version"; \
exit 1; \
fi
@echo ""
@echo "Verifying release assets..."
@for url in \
https://vpn.em-sysadmin.xyz/releases/vpnem-windows-amd64.exe \
https://vpn.em-sysadmin.xyz/releases/vpnem-installer.exe \
https://vpn.em-sysadmin.xyz/releases/sing-box.exe \
https://vpn.em-sysadmin.xyz/releases/wintun.dll; do \
ok=0; \
for attempt in 1 2 3 4 5; do \
if curl -fSs -I "$$url" | sed -n '1,5p'; then \
ok=1; \
break; \
fi; \
echo "retry $$attempt for $$url"; \
sleep 2; \
done; \
if [ "$$ok" -ne 1 ]; then \
echo "release verify failed for $$url"; \
exit 1; \
fi; \
echo ""; \
done
release: release-assets
rsync -avz --exclude '.git' --exclude 'build' --exclude '*.srs' --exclude '.claude' --exclude '.env' --exclude 'VPNUI_ADMIN_TOKEN.txt' \
./ $(SERVER):/opt/vpnem/
ssh $(SERVER) "cd /opt/vpnem && docker compose up -d --build"
$(MAKE) release-verify
@echo "Release deployed."
install-ruleset-timer:
chmod +x scripts/install-ruleset-timer.sh
rsync -avz deploy/systemd/vpnem-rulesets-update.service deploy/systemd/vpnem-rulesets-update.timer scripts/install-ruleset-timer.sh \
$(SERVER):/opt/vpnem/
ssh $(SERVER) "cd /opt/vpnem && ./scripts/install-ruleset-timer.sh"
# --- Clean ---
clean:
rm -rf build/ cmd/client/build/
|