diff --git a/pyproject.toml b/pyproject.toml index 3b3d5b5..4f3ca5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ voxvera = ["templates/**", "src/**", "resources/**", "locales/**", "resources/bi [project] name = "voxvera" -version = "0.1.9" +version = "0.2.0" description = "VoxVera CLI utilities" readme = "README.md" authors = [{name = "VoxVera"}] diff --git a/scripts/download_tor.sh b/scripts/download_tor.sh index 4cebb51..171fc13 100755 --- a/scripts/download_tor.sh +++ b/scripts/download_tor.sh @@ -4,46 +4,70 @@ set -euo pipefail VERSION="${VERSION:-15.0.7}" BASE_URL="https://dist.torproject.org/torbrowser" -ARCH=$(uname -m) -if [ "$ARCH" == "aarch64" ] || [ "$ARCH" == "arm64" ]; then - TOR_ARCH="aarch64" -else - TOR_ARCH="x86_64" -fi +# ARCH=$(uname -m) # Not needed for multi-platform download if we hardcode/loop targets -case "$(uname -s)" in - Linux*) PLATFORM=linux; ARCHIVE="tor-expert-bundle-linux-${TOR_ARCH}-${VERSION}.tar.gz"; EXE=tor;; - Darwin*) PLATFORM=mac; ARCHIVE="tor-expert-bundle-macos-${TOR_ARCH}-${VERSION}.tar.gz"; EXE=tor;; - MINGW*|MSYS*|CYGWIN*) PLATFORM=win; ARCHIVE="tor-expert-bundle-windows-x86_64-${VERSION}.tar.gz"; EXE=tor.exe;; - *) echo "Unsupported OS" >&2; exit 1;; -esac +download_platform() { + local platform=$1 + local arch=$2 + local archive=$3 + local exe=$4 + + local tmpdir=$(mktemp -d) + # trap 'rm -rf "$tmpdir"' EXIT # We'll clean up manually in the loop -TMPDIR=$(mktemp -d) -trap 'rm -rf "$TMPDIR"' EXIT + local url="$BASE_URL/${VERSION}/${archive}" + local dest="$(dirname "$0")/../voxvera/resources/tor/$platform" + + echo "--- Platform: $platform ($arch) ---" + echo "Downloading $url" + if ! curl -L "$url" -o "$tmpdir/$archive"; then + echo "Failed to download $url" >&2 + rm -rf "$tmpdir" + return 1 + fi -URL="$BASE_URL/${VERSION}/${ARCHIVE}" + echo "Extracting..." + if [[ "$archive" == *.zip ]]; then + unzip -q "$tmpdir/$archive" -d "$tmpdir" + else + tar -xf "$tmpdir/$archive" -C "$tmpdir" + fi -echo "Downloading $URL" -curl -L "$URL" -o "$TMPDIR/$ARCHIVE" + mkdir -p "$dest" -echo "Extracting..." -tar -xf "$TMPDIR/$ARCHIVE" -C "$TMPDIR" + local tor_bin=$(find "$tmpdir" -type f -name "$exe" | head -n 1) + local obfs_bin=$(find "$tmpdir" -type f \( -name "lyrebird*" -o -name "obfs4proxy*" \) | head -n 1) -DEST="$(dirname "$0")/../voxvera/resources/tor/$PLATFORM" -mkdir -p "$DEST" + if [[ -z "$tor_bin" || -z "$obfs_bin" ]]; then + echo "Failed to locate tor or lyrebird/obfs4proxy in archive for $platform" >&2 + rm -rf "$tmpdir" + return 1 + fi -TOR_BIN=$(find "$TMPDIR" -type f -name "$EXE" | head -n 1) -OBFS_BIN=$(find "$TMPDIR" -type f \( -name "lyrebird*" -o -name "obfs4proxy*" \) | head -n 1) + echo "Installing binaries to $dest" + cp "$tor_bin" "$dest/$(basename "$exe")" + cp "$obfs_bin" "$dest/$(basename "$obfs_bin")" -if [[ -z "$TOR_BIN" || -z "$OBFS_BIN" ]]; then - echo "Failed to locate tor or lyrebird/obfs4proxy in archive" >&2 - exit 1 -fi + chmod +x "$dest/$(basename "$exe")" "$dest/$(basename "$obfs_bin")" + + # If it's lyrebird, create a symlink for obfs4proxy for compatibility + if [[ "$(basename "$obfs_bin")" == "lyrebird"* ]]; then + local obfs_name="obfs4proxy" + [[ "$platform" == "win" ]] && obfs_name="obfs4proxy.exe" + echo "Creating symlink $obfs_name -> $(basename "$obfs_bin")" + (cd "$dest" && rm -f "$obfs_name" && ln -s "$(basename "$obfs_bin")" "$obfs_name") + fi -cp "$TOR_BIN" "$DEST/$(basename "$EXE")" -cp "$OBFS_BIN" "$DEST/$(basename "$OBFS_BIN")" + rm -rf "$tmpdir" +} -chmod +x "$DEST/$(basename "$EXE")" "$DEST/$(basename "$OBFS_BIN")" +# Linux x86_64 +download_platform "linux" "x86_64" "tor-expert-bundle-linux-x86_64-${VERSION}.tar.gz" "tor" -echo "Installed binaries to $DEST" +# macOS x86_64 (Intel) - works on M1/M2 via Rosetta if needed, but expert bundle usually has universal or specific +download_platform "mac" "x86_64" "tor-expert-bundle-macos-x86_64-${VERSION}.tar.gz" "tor" +# Windows x86_64 +download_platform "win" "x86_64" "tor-expert-bundle-windows-x86_64-${VERSION}.tar.gz" "tor.exe" + +echo "All platforms updated." diff --git a/voxvera/__init__.py b/voxvera/__init__.py index cd11d05..6f294c3 100644 --- a/voxvera/__init__.py +++ b/voxvera/__init__.py @@ -1,7 +1,7 @@ import sys from pathlib import Path -__version__ = "0.1.9" +__version__ = "0.2.0" # Add the vendor directory to sys.path as a fallback. # For standard installs (pip/pipx), the installed dependencies in the venv diff --git a/voxvera/resources/tor/mac/lyrebird b/voxvera/resources/tor/mac/lyrebird new file mode 100755 index 0000000..d6a47ef Binary files /dev/null and b/voxvera/resources/tor/mac/lyrebird differ diff --git a/voxvera/resources/tor/mac/obfs4proxy b/voxvera/resources/tor/mac/obfs4proxy deleted file mode 100755 index 48cdce8..0000000 --- a/voxvera/resources/tor/mac/obfs4proxy +++ /dev/null @@ -1 +0,0 @@ -placeholder diff --git a/voxvera/resources/tor/mac/obfs4proxy b/voxvera/resources/tor/mac/obfs4proxy new file mode 120000 index 0000000..57c3989 --- /dev/null +++ b/voxvera/resources/tor/mac/obfs4proxy @@ -0,0 +1 @@ +lyrebird \ No newline at end of file diff --git a/voxvera/resources/tor/mac/tor b/voxvera/resources/tor/mac/tor index 48cdce8..afbe3a9 100755 Binary files a/voxvera/resources/tor/mac/tor and b/voxvera/resources/tor/mac/tor differ diff --git a/voxvera/resources/tor/win/lyrebird.exe b/voxvera/resources/tor/win/lyrebird.exe new file mode 100755 index 0000000..477fa3a Binary files /dev/null and b/voxvera/resources/tor/win/lyrebird.exe differ diff --git a/voxvera/resources/tor/win/obfs4proxy.exe b/voxvera/resources/tor/win/obfs4proxy.exe deleted file mode 100755 index 48cdce8..0000000 --- a/voxvera/resources/tor/win/obfs4proxy.exe +++ /dev/null @@ -1 +0,0 @@ -placeholder diff --git a/voxvera/resources/tor/win/obfs4proxy.exe b/voxvera/resources/tor/win/obfs4proxy.exe new file mode 120000 index 0000000..2cd7744 --- /dev/null +++ b/voxvera/resources/tor/win/obfs4proxy.exe @@ -0,0 +1 @@ +lyrebird.exe \ No newline at end of file diff --git a/voxvera/resources/tor/win/tor.exe b/voxvera/resources/tor/win/tor.exe index 48cdce8..f04852f 100755 Binary files a/voxvera/resources/tor/win/tor.exe and b/voxvera/resources/tor/win/tor.exe differ