ERM excuse me? wheres tor at? =vanguard probably

This commit is contained in:
wander 2026-02-06 21:03:29 -05:00
parent 2182220c52
commit f2f80cfa03

View file

@ -2,12 +2,41 @@
set -e
# --- Configuration ---
# Check if command is passed
# If the first argument is 'vanguards', skip Tor setup and just run vanguards
if [ "$1" = "vanguards" ]; then
echo "Starting Vanguards Sidecar Mode..."
shift # remove 'vanguards' from the arguments
exec vanguards "$@"
# Extract the hostname from the arguments?
# For now, we assume 'tor-service' as per the standard docker-compose setup
TARGET_HOST="tor-service"
TARGET_PORT=9051
echo "Waiting for Tor Control Port at $TARGET_HOST:$TARGET_PORT..."
while ! nc -z "$TARGET_HOST" "$TARGET_PORT"; do
sleep 1
done
echo "Tor is awake! Resolving IP..."
# Fix for ValueError: Invalid IP address
# stem/vanguards requires a valid IP, not a hostname
TARGET_IP=$(python3 -c "import socket; print(socket.gethostbyname('$TARGET_HOST'))")
echo "Resolved $TARGET_HOST to $TARGET_IP"
# Replace hostname with IP in arguments
# Note: This crude replacement assumes 'tor-service' is passed as an arg
args=""
for arg in "$@"; do
if [ "$arg" = "$TARGET_HOST" ]; then
args="$args $TARGET_IP"
else
args="$args $arg"
fi
done
# Execute with new args (unquoted expansion nicely splits args here,
# safe enough for this specific use case of rigid flags)
exec vanguards $args
fi
# If other arguments are passed, exec them (fallback)