Files
source-stack/debian13/entrypoint.sh
T

35 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# Start ws2tcp-local (logging to a file so it does not garble the claude TUI), point the proxy variables at it, then run claude.
set -eu
GATEWAY="wss://wangguofang.net/tunnel"
LISTEN_HOST=127.0.0.1
LISTEN_PORT=3128
LOG_FILE="${WS2TCP_LOCAL_LOG:-/tmp/ws2tcp-local.log}"
# The credentials come from WS2TCP_LOCAL_BASIC_AUTH (user:pass), set at image build time.
ws2tcp-local --gateway "$GATEWAY" --listen "$LISTEN_HOST:$LISTEN_PORT" >"$LOG_FILE" 2>&1 &
proxy_pid=$!
for _ in $(seq 1 50); do
if (exec 3<>"/dev/tcp/$LISTEN_HOST/$LISTEN_PORT") 2>/dev/null; then
break
fi
if ! kill -0 "$proxy_pid" 2>/dev/null; then
echo "Error: ws2tcp-local exited during startup. Log ($LOG_FILE):" >&2
cat "$LOG_FILE" >&2
exit 1
fi
sleep 0.2
done
export http_proxy="http://$LISTEN_HOST:$LISTEN_PORT"
export https_proxy="$http_proxy"
export HTTP_PROXY="$http_proxy"
export HTTPS_PROXY="$http_proxy"
export no_proxy="localhost,127.0.0.1"
export NO_PROXY="$no_proxy"
trap 'kill "$proxy_pid" 2>/dev/null || true' EXIT
claude "$@"