diff --git a/.gitea/workflows/windows-release.yml b/.gitea/workflows/windows-release.yml new file mode 100644 index 0000000..edf7f8e --- /dev/null +++ b/.gitea/workflows/windows-release.yml @@ -0,0 +1,160 @@ +name: Windows release + +# The Windows port (windows/). On a tag windows-v it builds the release zip and +# publishes it as a Gitea release, with the notes in windows/release-notes/.md. Run +# by hand, it only builds: the zip is the run's artifact. +# +# Two jobs, as upstream's dependency updates: the one that runs fetched code (crates, +# components, wheels, the Nix closure) holds no token that can write. Only the publishing job +# sees RELEASE_TOKEN (write:repository), and it runs nothing it fetched: curl and jq on the +# first job's artifact. Gitea ignores `permissions:`; they are here to say what each job needs. +on: + push: + tags: ["windows-v*"] + workflow_dispatch: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-24.04 + timeout-minutes: 150 + env: + # Single-user Nix without a daemon: the job's container has no init to run one, nor + # the namespaces a build sandbox needs. Set for the job, so the installer has it too. + NIX_CONFIG: | + experimental-features = nix-command flakes + sandbox = false + build-users-group = + defaults: + run: + shell: bash + steps: + # Full history: the flake is windows/ inside this repository, fetched by Nix as git. + - name: Check out + uses: https://github.com/actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Check the version + working-directory: windows + run: | + set -euo pipefail + version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) + if [[ "$GITHUB_REF" == refs/tags/* ]]; then + [[ "$GITHUB_REF_NAME" == "windows-v$version" ]] || + { echo "::error::the tag is $GITHUB_REF_NAME, but windows/Cargo.toml says $version"; exit 1; } + [ -f "release-notes/$version.md" ] || + { echo "::error::no windows/release-notes/$version.md"; exit 1; } + fi + echo "Proxy Suite for Windows $version" + + # Pinned: this installer checks the hash of the Nix it downloads, and is checked here. + - name: Install Nix + env: + NIX_VERSION: 2.34.9 + NIX_INSTALL_SHA256: a03ce2e9eaf4ea1560260b9a93e311dbaf589d28fb5c9318f8d9e768ee6339d8 + run: | + set -euo pipefail + # The runner may run as root (no sudo in the image) or as a user with sudo. + as_root() { if [ "$(id -u)" -eq 0 ]; then "$@"; else sudo "$@"; fi; } + if ! command -v xz >/dev/null 2>&1; then + as_root apt-get update -qq + as_root apt-get install -y -qq xz-utils + fi + as_root install -d -m 0755 -o "$(id -u)" -g "$(id -g)" /nix + tmp=$(mktemp -d) + curl -sSfL -o "$tmp/install" "https://releases.nixos.org/nix/nix-$NIX_VERSION/install" + echo "$NIX_INSTALL_SHA256 $tmp/install" | sha256sum -c --quiet + USER=${USER:-$(id -un)} sh "$tmp/install" --no-daemon --no-modify-profile --no-channel-add + echo "$HOME/.nix-profile/bin" >> "$GITHUB_PATH" + + - name: Dev shell and Rust toolchain + working-directory: windows + run: nix develop --command rustup toolchain install + + - name: Test + working-directory: windows + run: nix develop --command cargo test --workspace --locked + + - name: Package + working-directory: windows + run: nix develop --command tools/package.sh + + - name: Collect + working-directory: windows + run: | + set -euo pipefail + version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) + mkdir -p ../release + cp "dist/ProxySuite-$version-windows-x64.zip" "dist/ProxySuite-$version-windows-x64.zip.sha256" ../release/ + if [ -f "release-notes/$version.md" ]; then cp "release-notes/$version.md" ../release/notes.md; fi + + - name: Upload + uses: https://github.com/actions/upload-artifact@v4 + with: + name: windows-release + path: release/ + if-no-files-found: error + + publish: + needs: build + if: startsWith(github.ref, 'refs/tags/windows-v') + runs-on: ubuntu-24.04 + timeout-minutes: 20 + permissions: + contents: write + defaults: + run: + shell: bash + steps: + - name: Download + uses: https://github.com/actions/download-artifact@v4 + with: + name: windows-release + path: release + + # The release for the tag, made if it is not there yet (a pre-release for a version with + # a "-"), and its assets, replacing any of the same name, so a rerun is harmless. + - name: Publish + env: + TOKEN: ${{ secrets.RELEASE_TOKEN }} + API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} + TAG: ${{ github.ref_name }} + SHA: ${{ github.sha }} + run: | + set -euo pipefail + as_root() { if [ "$(id -u)" -eq 0 ]; then "$@"; else sudo "$@"; fi; } + if ! command -v jq >/dev/null 2>&1; then + as_root apt-get update -qq + as_root apt-get install -y -qq jq + fi + [ -n "$TOKEN" ] || { echo "::error::the RELEASE_TOKEN secret is not set"; exit 1; } + api() { curl -sS --fail-with-body -H "Authorization: token $TOKEN" "$@"; } + version=${TAG#windows-v} + + code=$(curl -sS -o found.json -w '%{http_code}' -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG") + case $code in + 200) id=$(jq -r .id found.json) ;; + 404) + pre=false + [[ "$version" == *-* ]] && pre=true + id=$(jq -n --arg tag "$TAG" --arg sha "$SHA" --arg name "Proxy Suite for Windows $version" \ + --rawfile body release/notes.md --argjson pre "$pre" \ + '{tag_name: $tag, target_commitish: $sha, name: $name, body: $body, prerelease: $pre, draft: false}' | + api -H 'Content-Type: application/json' --data-binary @- "$API/releases" | jq -r .id) + echo "made the release for $TAG" ;; + *) echo "::error::looking up the release for $TAG: HTTP $code: $(cat found.json)"; exit 1 ;; + esac + + for f in release/*.zip release/*.sha256; do + name=$(basename "$f") + for old in $(api "$API/releases/$id/assets" | jq -r --arg n "$name" '.[] | select(.name == $n) | .id'); do + api -X DELETE "$API/releases/$id/assets/$old" >/dev/null + done + api -F "attachment=@$f" "$API/releases/$id/assets?name=$name" >/dev/null + echo "uploaded $name" + done + echo "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$TAG" diff --git a/windows/README.md b/windows/README.md index 1268cb5..edb3661 100644 --- a/windows/README.md +++ b/windows/README.md @@ -146,5 +146,10 @@ tools/package.sh # the release zip, in dist/ nix shell nixpkgs#wineWow64Packages.stable -c tools/winws-dry-run.sh dist/ProxySuite-*/components ``` -The Windows programs are cross-compiled with `cargo xwin` (MSVC target). Design notes: -[`DESIGN.md`](DESIGN.md). +The Windows programs are cross-compiled with `cargo xwin` (MSVC target), with the toolchain +in `rust-toolchain.toml`. Design notes: [`DESIGN.md`](DESIGN.md). + +Releases are built by Gitea Actions (`.gitea/workflows/windows-release.yml`): bump `version` +in `Cargo.toml`, add `release-notes/.md`, push a tag `windows-v`. The +workflow tests, packages and publishes the zip and its `.sha256` with the `RELEASE_TOKEN` +secret (a token with `write:repository`). Run by hand, it only builds. diff --git a/windows/release-notes/0.1.0-pre.2.md b/windows/release-notes/0.1.0-pre.2.md new file mode 100644 index 0000000..2bce7ca --- /dev/null +++ b/windows/release-notes/0.1.0-pre.2.md @@ -0,0 +1,29 @@ +First pre-release of the native Windows port of proxy-suite-flake: a Windows service with `proxy-ctl`, no GUI yet. It replaces 0.1.0-pre.1, which never had a build, and fixes a local privilege escalation found in it: the service could go on with a state folder it had failed to secure. + +**This build has never run on real Windows.** It was built and tested on Linux and under Wine. See "What has been verified" in the README, and please report what happens on yours. + +### In this release +- **Local proxy:** SOCKS5/HTTP on `127.0.0.1:1080` through sing-box 1.14.4, or the hybrid sing-box + XRay 26.10.21 backend. +- **Outbounds:** + - Links of every kind upstream parses, plus raw JSON and subscriptions. + - Groups (failover, urltest, selector), chains, pins and route modes. + - Routing rules by site, address, geodata, rule set or **program**. +- **zapret:** Flowseal's zapret-discord-youtube 1.10.4 (`winws.exe` with WinDivert), with any `general*.bat` preset, your lists and the game filter. +- **zapret2:** `winws2.exe` from bol-van's zapret-win-bundle, with nfqws2-keenetic's strategies and nfqws2's own learning of blocked sites. +- **tg-ws-proxy:** Flowseal's tg-ws-proxy 1.11.2 on a bundled Python 3.12. +- **TUN:** sing-box's TUN (wintun). Don't use it together with zapret yet. + +Every bundled program is pinned by version and hash, and checked before it runs. + +### Install +Download `ProxySuite-0.1.0-pre.2-windows-x64.zip`; its SHA-256 is in the `.sha256` file next to it. + +1. Unzip. +2. Run `install.cmd` as administrator. It copies to `C:\Program Files\ProxySuite`, registers the **ProxySuite** service and adds `proxy-ctl` to PATH. +3. In a new terminal, run `proxy-ctl status`. + +### Not yet +The desktop app (GPUI, tray), AmneziaWG, WARP, Tor, the SSH tunnel, whitelist-bypass, the kill switch, server inbounds, the XRay-only backend, zapret2's extended detection and the z2k strategies. + +### Note +Unlike upstream, the signed-in user may change every setting by default (`userControl`), except the ones that could run programs or read files as SYSTEM: those always need an administrator. On a shared computer, restrict `userControl.scopes`. diff --git a/windows/rust-toolchain.toml b/windows/rust-toolchain.toml new file mode 100644 index 0000000..cc5a88e --- /dev/null +++ b/windows/rust-toolchain.toml @@ -0,0 +1,6 @@ +# The toolchain the releases are built with, here and in .gitea/workflows/windows-release.yml. +[toolchain] +channel = "1.99.1" +profile = "minimal" +components = ["clippy", "rustfmt"] +targets = ["x86_64-pc-windows-msvc"]