#!/usr/bin/env bash # wireproxy-awg: the AmneziaWG client as a SOCKS listener, behind AmneziaWG and WARP outbounds # of the "userspace" kind; no driver, no interface. Built from upstream's tag as upstream's # pkgs/wireproxy-awg.nix builds it: its patch, and its vendored amneziawg-go with the suite's. # Modules are checked against the project's go.sum; the source by its commit. # # tools/build-wireproxy-awg.sh OUT_DIR [GOOS] (needs git, go, patch; GOOS: windows) set -euo pipefail . "$(dirname "$0")/lib.sh" OUT=$(realpath -m "${1:?output directory}") GOOS=${2:-windows} cd "$(dirname "$0")" VERSION=1.0.18 COMMIT=84f4795ea76f9c3168a61e478d0fe0e5c3238308 PATCHES=$(realpath ../../pkgs/patches) WORK=$(mktemp -d) trap 'rm -rf "$WORK"' EXIT clone_tag https://github.com/artem-russkikh/wireproxy-awg "v$VERSION" "$WORK/src" [ "$(git -C "$WORK/src" rev-parse HEAD)" = "$COMMIT" ] || { echo "tag v$VERSION moved off $COMMIT"; exit 1; } cd "$WORK/src" patch -s -p1 <"$PATCHES/wireproxy-awg-fwmark.patch" # The Go of the shell, never one Go would fetch for itself. export GOTOOLCHAIN=local GOFLAGS=-mod=mod go mod vendor chmod -R u+w vendor/github.com/amnezia-vpn/amneziawg-go/v3 patch -s -p1 -d vendor/github.com/amnezia-vpn/amneziawg-go/v3 <"$PATCHES/amneziawg-go-random-trailers-transport.patch" rm -rf "$OUT" && mkdir -p "$OUT" exe=wireproxy [ "$GOOS" = windows ] && exe=wireproxy.exe CGO_ENABLED=0 GOOS=$GOOS GOARCH=amd64 GOFLAGS=-mod=vendor go build -trimpath -ldflags "-s -w -X main.version=$VERSION" -o "$OUT/$exe" ./cmd/wireproxy cp LICENSE "$OUT/" echo "$VERSION" >"$OUT/.version" echo "wireproxy-awg $VERSION ($GOOS) in $OUT"