From 6e17d8bec45b67c2cebf8701f76b6a96d36ba590 Mon Sep 17 00:00:00 2001 From: wander Date: Fri, 6 Feb 2026 21:09:20 -0500 Subject: [PATCH] sorry i dont know that address = vanguard --- assets/entrypoint.sh | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/assets/entrypoint.sh b/assets/entrypoint.sh index 61c4c44..8bf06e4 100755 --- a/assets/entrypoint.sh +++ b/assets/entrypoint.sh @@ -13,9 +13,15 @@ if [ "$1" = "vanguards" ]; then 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 + # Use Python to wait for the port (more reliable than Alpine's nc) + python3 -c "import socket, time; +while True: + try: + with socket.create_connection(('$TARGET_HOST', $TARGET_PORT), timeout=1): + break + except (OSError, ConnectionRefusedError): + time.sleep(1)" + echo "Tor is awake! Resolving IP..." # Fix for ValueError: Invalid IP address @@ -93,11 +99,22 @@ if [ -n "$HIDDEN_SERVICE_HOSTS" ]; then HOST=$(echo "$rule" | cut -d: -f2) INT_PORT=$(echo "$rule" | cut -d: -f3) - # Sanitize HOST (remove carriage returns) + # Sanitize HOST HOST_CLEAN=$(echo "$HOST" | tr -d '\r') - echo "Adding Hidden Service Rule: Onion:$EXT_PORT -> $HOST_CLEAN:$INT_PORT" - echo "HiddenServicePort $EXT_PORT $HOST_CLEAN:$INT_PORT" >> "$TOR_CONFIG" + # RESOLVE HOST TO IP FOR TOR + # Tor is picky about hostnames in HiddenServicePort configs sometimes. + # We pre-resolve it to be safe. + echo "Resolving $HOST_CLEAN..." + if ! HOST_IP=$(python3 -c "import socket; print(socket.gethostbyname('$HOST_CLEAN'))" 2>/dev/null); then + echo "Warning: Could not resolve '$HOST_CLEAN'. Using hostname directly." + HOST_IP=$HOST_CLEAN + else + echo "Resolved $HOST_CLEAN to $HOST_IP" + fi + + echo "Adding Hidden Service Rule: Onion:$EXT_PORT -> $HOST_IP:$INT_PORT" + echo "HiddenServicePort $EXT_PORT $HOST_IP:$INT_PORT" >> "$TOR_CONFIG" done else echo "Warning: HIDDEN_SERVICE_HOSTS is empty. Tor will run but host nothing."