Add an option to use a SOCKS 4/5 proxy to connect to the internet.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Thu Apr 17 18:07:26 2008 +0000 (2008-04-17)
changeset 442ab046c11fbf7
parent 441 f1326505e3e5
child 443 340e4684925b
Add an option to use a SOCKS 4/5 proxy to connect to the internet.
As for the HTTP proxy, this is completetly untested, as I have no such proxy at home.

scripts/crosstool.sh | 45 31 14 0 +++++++++++++++++--------
config/global.in | 95 81 14 0 +++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 112 insertions(+), 28 deletions(-)
config/global.in
scripts/crosstool.sh
     1.1 --- a/config/global.in	Sun Apr 13 22:46:02 2008 +0000
     1.2 +++ b/config/global.in	Thu Apr 17 18:07:26 2008 +0000
     1.3 @@ -251,23 +251,23 @@
     1.4      prompt "Proxy type"
     1.5      default USE_NO_PROXY
     1.6  
     1.7 -config USE_NO_PROXY
     1.8 +config PROXY_TYPE_NONE
     1.9      bool
    1.10      prompt "No proxy"
    1.11      help
    1.12        Select this option if you have a direct connection to the internet,
    1.13        or if you already set the environment adequately.
    1.14  
    1.15 -config USE_HTTP_PROXY
    1.16 +config PROXY_TYPE_HTTP
    1.17      bool
    1.18      prompt "HTTP proxy"
    1.19      help
    1.20        Use an HTTP proxy to connect to to the internet.
    1.21 -      Onlt the http and ftp protocols will be tunneled through this
    1.22 +      Only the http and ftp protocols will be tunneled through this
    1.23        proxy.
    1.24  
    1.25 -      Alternatively to setting this options, you can set and export
    1.26 -      the following variable in your environment:
    1.27 +      Alternatively to setting this option, you can set and export the
    1.28 +      following variables in your environment:
    1.29          ftp_proxy=http://user:passwd@proxy.server:port/
    1.30          http_proxy=http://user:passwd@proxy.server:port/
    1.31          https_proxy=http://user:passwd@proxy.server:port/
    1.32 @@ -277,28 +277,95 @@
    1.33  # choice menu!
    1.34  # To add a third entry in the choice menu, add it after the
    1.35  # if...endif conditional below, and so on for a fourth entry...
    1.36 -if USE_HTTP_PROXY
    1.37 +if PROXY_TYPE_HTTP
    1.38  
    1.39 -config HTTP_PROXY_HOST
    1.40 +config PROXY_HOST
    1.41      string
    1.42 -    prompt "HTTP proxy hostname/IP"
    1.43 +    prompt "hostname/IP"
    1.44  
    1.45 -config HTTP_PROXY_PORT
    1.46 +config PROXY_PORT
    1.47      int
    1.48 -    prompt "HTTP proxy port"
    1.49 +    prompt "port"
    1.50 +    default 0
    1.51      
    1.52 -config HTTP_PROXY_USER
    1.53 +config PROXY_USER
    1.54      string
    1.55 -    prompt "HTTP proxy user name"
    1.56 +    prompt "user name"
    1.57  
    1.58 -config HTTP_PROXY_PASSWD
    1.59 +config PROXY_PASS
    1.60      string
    1.61 -    prompt "HTTP proxy password"
    1.62 +    prompt "password"
    1.63  
    1.64  endif # USE_HTTP_PROXY
    1.65  
    1.66 +config PROXY_TYPE_SOCKS
    1.67 +    bool
    1.68 +    prompt "SOCKS 4/5 proxy"
    1.69 +    help
    1.70 +      Use a Socks 4/5 proxy to connect to the internet.
    1.71 +      All protocols can get tunneled through this kind of proxy (depending
    1.72 +      on your proxy configuration, so;e do not allow all protocols, but
    1.73 +      chances are that protocols needed by crosstool-NG are allowed).
    1.74 +
    1.75 +      Alternatively to setting this option, you can set and export the
    1.76 +      following variable in your environment:
    1.77 +        LD_PRELOAD=/path/to/your/tsocks-library.so
    1.78 +
    1.79 +      In any case, wether you set this option or you export the aforementionned
    1.80 +      variable, you will _have_ to  configure the /etc/tsocks.conf file
    1.81 +      accordingly to your network setup.
    1.82 +
    1.83 +      This option makes use of the tsocks library. You will have to have tsocks
    1.84 +      installed on your system, of course.
    1.85 +
    1.86 +      If you think you do not know what tsocks is, or how to configure it,
    1.87 +      chances are that you do not need to set this option.
    1.88 +
    1.89 +if PROXY_TYPE_SOCKS
    1.90 +
    1.91 +choice
    1.92 +    bool
    1.93 +    prompt "type"
    1.94 +    default PROXY_TYPE_SOCKS_5
    1.95 +
    1.96 +config PROXY_TYPE_SOCKS_5
    1.97 +    bool
    1.98 +    prompt "SOCKS 5"
    1.99 +
   1.100 +config PROXY_TYPE_SOCKS_4
   1.101 +    bool
   1.102 +    prompt "SOCKS 4"
   1.103 +
   1.104  endchoice
   1.105  
   1.106 +config PROXY_HOST
   1.107 +    string
   1.108 +    prompt "hostname/IP"
   1.109 +
   1.110 +config PROXY_PORT
   1.111 +    int
   1.112 +    prompt "port"
   1.113 +    default 0
   1.114 +
   1.115 +config PROXY_USER
   1.116 +    string
   1.117 +    prompt "user name"
   1.118 +
   1.119 +config PROXY_PASS
   1.120 +    string
   1.121 +    prompt "password"
   1.122 +
   1.123 +endif # USE_SOCKS_PROXY
   1.124 +
   1.125 +endchoice
   1.126 +
   1.127 +config PROXY_TYPE
   1.128 +    string
   1.129 +    default "none" if PROXY_TYPE_NONE
   1.130 +    default "HTTP" if PROXY_TYPE_HTTP
   1.131 +    default "socks5" if PROXY_TYPE_SOCKS_5
   1.132 +    default "socks4" if PROXY_TYPE_SOCKS_4
   1.133 +
   1.134  # Force restore indentation
   1.135  config FOOBAR
   1.136  
     2.1 --- a/scripts/crosstool.sh	Sun Apr 13 22:46:02 2008 +0000
     2.2 +++ b/scripts/crosstool.sh	Thu Apr 17 18:07:26 2008 +0000
     2.3 @@ -206,6 +206,37 @@
     2.4          ;;
     2.5  esac
     2.6  
     2.7 +# Set environment for proxy access
     2.8 +# This has to be done even if we are restarting, as they don't get
     2.9 +# saved in the step snapshot.
    2.10 +case "${CT_PROXY_TYPE}" in
    2.11 +  none) ;;
    2.12 +  http)
    2.13 +    http_proxy="http://"
    2.14 +    case  "${CT_PROXY_USER}:${CT_PROXY_PASS}" in
    2.15 +      :)      ;;
    2.16 +      :*)     http_proxy="${http_proxy}:${CT_HTP_PROXY_PASS}@";;
    2.17 +      *:)     http_proxy="${http_proxy}${CT_HTTP_PROXY_USER}@";;
    2.18 +      *:*)    http_proxy="${http_proxy}${CT_HTTP_PROXY_USER}:${CT_HTP_PROXY_PASS}@";;
    2.19 +    esac
    2.20 +    export http_proxy="${http_proxy}${HTTP_PROXY_HOST}:${HTTP_PROXY_PORT}/"
    2.21 +    export https_proxy="${http_proxy}"
    2.22 +    export ftp_proxy="${http_proxy}"
    2.23 +    ;;
    2.24 +  socks?)
    2.25 +    # Re;ove any lingering config file from any previous run
    2.26 +    rm -f "${CT_BUILD_DIR}/tsocks.conf"
    2.27 +    ( echo "server=${CT_PROXY_HOST}";
    2.28 +      echo "server_port=${CT_PROXY_PORT}";
    2.29 +      echo "server_type=${CT_PROXY_TYPE#socks}";
    2.30 +      [ -n "${CT_PROXY_USER}"   ] && echo "default_user=${CT_PROXY_USER}";
    2.31 +      [ -n "${CT_PROXY_PASS}" ] && echo "default_pass=${CT_PROXY_PASS}";
    2.32 +    ) >"${CT_BUILD_DIR}/tsocks.conf"
    2.33 +    export TSOCKS_CONF_FILE="${CT_BUILD_DIR}/tsocks.conf"
    2.34 +    . tsocks -on
    2.35 +    ;;
    2.36 +esac
    2.37 +
    2.38  # Setting up the rest of the environment only if not restarting
    2.39  if [ -z "${CT_RESTART}" ]; then
    2.40      # Determine build system if not set by the user
    2.41 @@ -307,20 +338,6 @@
    2.42      [ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
    2.43      [ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
    2.44  
    2.45 -    # Set environment for proxy access
    2.46 -    if [ "${CT_USE_HTTP_PROXY}" = "y" ]; then
    2.47 -      http_proxy="http://"
    2.48 -      case  "${CT_HTTP_PROXY_USER}:${CT_HTTP_PROXY_PASSWD}" in
    2.49 -        :)      ;;
    2.50 -        :*)     http_proxy="${http_proxy}:${CT_HTP_PROXY_PASSWD}@";;
    2.51 -        *:)     http_proxy="${http_proxy}${CT_HTTP_PROXY_USER}@";;
    2.52 -        *:*)    http_proxy="${http_proxy}${CT_HTTP_PROXY_USER}:${CT_HTP_PROXY_PASSWD}@";;
    2.53 -      esac
    2.54 -      export http_proxy="${http_proxy}${HTTP_PROXY_HOST}:${HTTP_PROXY_PORT}/"
    2.55 -      export https_proxy="${http_proxy}"
    2.56 -      export ftp_proxy="${http_proxy}"
    2.57 -    fi
    2.58 -
    2.59      CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
    2.60      CT_DoLog EXTRA "Building a toolchain for:"
    2.61      CT_DoLog EXTRA "  build  = ${CT_BUILD}"