@@ -38,7 +38,7 @@ ifeq ($(shell echo "$(GOARCH)" | grep -Eq "(mips|mipsle)" && echo true),true)
3838ADDITION = GOMIPS=softfloat go build -o $(NAME ) _softfloat -trimpath -ldflags "$(LDFLAGS ) " -v $(MAIN )
3939endif
4040
41- .PHONY : clean build
41+ .PHONY : clean build test test-race-wireguard test-integration test-integration-full test-integration-wireguard
4242
4343build :
4444 CGO_ENABLED=0 go build -o $(OUTPUT ) $(PARAMS ) $(MAIN )
@@ -129,11 +129,47 @@ else
129129 @exit 1
130130endif
131131
132+ install_wg : update_os
133+ ifeq ($(UNAME_S ) ,Linux)
134+ @echo "Installing WireGuard for $(DISTRO)..."
135+ if [ "$(DISTRO)" = "debian" ] || [ "$(DISTRO)" = "ubuntu" ]; then \
136+ sudo apt-get update && sudo apt-get install -y wireguard wireguard-tools; \
137+ elif [ "$(DISTRO)" = "centos" ] || [ "$(DISTRO)" = "rhel" ]; then \
138+ sudo yum install -y epel-release && sudo yum install -y wireguard-tools; \
139+ elif [ "$(DISTRO)" = "fedora" ]; then \
140+ sudo dnf install -y wireguard-tools; \
141+ elif [ "$(DISTRO)" = "arch" ] || [ "$(DISTRO)" = "manjaro" ]; then \
142+ sudo pacman -Sy --noconfirm wireguard-tools; \
143+ elif [ "$(DISTRO)" = "alpine" ]; then \
144+ apk add --no-cache wireguard-tools; \
145+ elif [ "$(DISTRO)" = "opensuse" ] || [ "$(DISTRO)" = "opensuse-leap" ] || [ "$(DISTRO)" = "opensuse-tumbleweed" ]; then \
146+ sudo zypper install -y wireguard-tools; \
147+ else \
148+ echo "Unsupported distribution: $(DISTRO)"; \
149+ exit 1; \
150+ fi
151+ @echo "WireGuard installed successfully"
152+ @wg --version
153+ else
154+ @echo "Unsupported operating system: $(UNAME_S)"
155+ @exit 1
156+ endif
157+
132158test-integration :
133- TEST_INTEGRATION=true go test ./... -v -p 1
159+ $(MAKE ) test-integration-full
160+
161+ test-integration-full :
162+ GOTOOLCHAIN=auto TEST_INTEGRATION=true go test ./... -v -p 1
163+ GOTOOLCHAIN=auto go test -tags=integration -v -p 1 ./backend/wireguard
164+
165+ test-integration-wireguard :
166+ GOTOOLCHAIN=auto go test -tags=integration -v -p 1 ./backend/wireguard
134167
135168test :
136- TEST_INTEGRATION=false go test ./... -v -p 1
169+ GOTOOLCHAIN=auto TEST_INTEGRATION=false go test ./... -v -p 1
170+
171+ test-race-wireguard :
172+ GOTOOLCHAIN=auto CGO_ENABLED=1 go test -race -v -p 1 ./backend/wireguard
137173
138174serve :
139175 go run main.go serve
0 commit comments