ERM excuse me? wheres tor at? =vanguard probably
This commit is contained in:
parent
2182220c52
commit
f2f80cfa03
1 changed files with 31 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue