- Every request is authorized before it is handled, including `logs -f`, which skipped the check. - The state root is checked once per process: a second check under Wine moved the live root (and its log) aside. - uninstall removes Program Files after it exits: cmd got a garbled quoted command line; it now runs raw, outside the folder, windowless. - install no longer fails when the first start does; it says how to start. - `proxy-ctl proxy tun on` also turns on proxy.tun.enable. - build-tg-ws-proxy.sh resolves its output path before changing directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.9 KiB
Bash
Executable File
37 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# tg-ws-proxy for Windows: Flowseal's source (the headless proxy, not the tray app) on the
|
|
# official embeddable CPython, with its dependencies as pinned win_amd64 wheels. Everything is
|
|
# verified: the Python archive and every wheel by hash, the source by its commit.
|
|
#
|
|
# tools/build-tg-ws-proxy.sh OUT_DIR (needs curl, git, unzip, pip)
|
|
set -euo pipefail
|
|
OUT=$(realpath -m "${1:?output directory}")
|
|
cd "$(dirname "$0")"
|
|
PY_VERSION=3.12.10
|
|
PY_URL=https://www.python.org/ftp/python/$PY_VERSION/python-$PY_VERSION-embed-amd64.zip
|
|
PY_SHA256=4acbed6dd1c744b0376e3b1cf57ce906f9dc9e95e68824584c8099a63025a3c3
|
|
TG_TAG=v1.11.2
|
|
TG_COMMIT=307a384ab7f522e34bb1a045884d0bd90f40bee5
|
|
WORK=$(mktemp -d)
|
|
trap 'rm -rf "$WORK"' EXIT
|
|
|
|
rm -rf "$OUT" && mkdir -p "$OUT/python" "$OUT/app"
|
|
curl -sSfL -o "$WORK/python.zip" "$PY_URL"
|
|
echo "$PY_SHA256 $WORK/python.zip" | sha256sum -c --quiet
|
|
unzip -q "$WORK/python.zip" -d "$OUT/python"
|
|
|
|
pip download -q --require-hashes --no-deps --only-binary=:all: --platform win_amd64 \
|
|
--python-version 3.12 --implementation cp --dest "$WORK/wheels" -r tg-ws-proxy-requirements.txt
|
|
mkdir -p "$OUT/python/Lib/site-packages"
|
|
for w in "$WORK"/wheels/*.whl; do unzip -q -o "$w" -d "$OUT/python/Lib/site-packages"; done
|
|
|
|
git -c advice.detachedHead=false clone -q --depth 1 --branch "$TG_TAG" https://github.com/Flowseal/tg-ws-proxy "$WORK/src"
|
|
[ "$(git -C "$WORK/src" rev-parse HEAD)" = "$TG_COMMIT" ] || { echo "tag $TG_TAG moved off $TG_COMMIT"; exit 1; }
|
|
cp -r "$WORK/src/proxy" "$WORK/src/utils" "$WORK/src/LICENSE" "$OUT/app/"
|
|
|
|
# The embeddable Python reads its path from this file alone: the standard library, the
|
|
# wheels, and the source.
|
|
printf 'python312.zip\n.\nLib\\site-packages\n..\\app\nimport site\n' > "$OUT/python/python312._pth"
|
|
echo "${TG_TAG#v}+py$PY_VERSION" > "$OUT/.version"
|
|
echo "tg-ws-proxy ${TG_TAG#v} on Python $PY_VERSION in $OUT"
|