[Tails-dev] Can't connect to HTTP proxy after tor with curl

このメッセージを削除

このメッセージに返信
著者: Kenneth Morris
日付:  
To: The Tails public development discussion list
題目: [Tails-dev] Can't connect to HTTP proxy after tor with curl
Before in older versions I was able to and you can verify that its still
possible but

torsocks -i /usr/bin/curl -x http://192.168.0.1:80 ipinfo.io/ip
192.168.0.1

but if I use the curl wrapper "/usr/local/bin/curl" (curl)


curl -x http://192.168.0.1:80 ipinfo.io/ip
curl: (7) Failed to connect to 192.168.0.1 port 80: Connection refused


(192.168.0.1 is not the real proxy I don't want to list my private proxy)

Proposed fix check with if statement that -x was provided and use
torsocks --isolate :

#!/bin/sh

# This script is a wrapper around curl that forces it to use Tor.
# We do that by setting the ALL_PROXY environment variable instead of
# using torsocks, because torsocks has issues with IPv6 and therefore
# disabled it by default (see
https://forum.torproject.net/t/torsocks-release-2-4-0/3425).

# Similarly to what torsocks does with the --isolate option, we set a
# random username to make Tor use different circuits each time curl is
# called (see IsolateSOCKSAuth).
username=curl-$(head -c 12 /dev/urandom | xxd -p)
ALL_PROXY="socks5://${username}:0@127.0.0.1:9050"
export ALL_PROXY

# Check if the user has provided an -x option
for arg in "$@"; do
     if [ "$arg" = "-x" ]; then
         # If -x is found, use torsocks to execute cURL
         exec /usr/bin/torsocks --isolate /usr/bin/curl "$@"
     fi
done


# If no -x option is provided, just execute cURL with the ALL_PROXY IPv6
support
exec /usr/bin/curl "$@"