sorry i dont know that address = vanguard

This commit is contained in:
wander 2026-02-06 21:09:20 -05:00
parent f2f80cfa03
commit 6e17d8bec4

View file

@ -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."