1.1 --- a/config/global/download_extract.in Fri Apr 18 08:41:30 2008 +0000
1.2 +++ b/config/global/download_extract.in Fri Apr 18 22:16:28 2008 +0000
1.3 @@ -74,7 +74,8 @@
1.4
1.5 config PROXY_TYPE_SOCKS
1.6 bool
1.7 - prompt "SOCKS 4/5 proxy"
1.8 + prompt "SOCKS 4/5 proxy (EXPERIMENTAL)"
1.9 + depends on EXPERIMENTAL
1.10 help
1.11 Use a Socks 4/5 proxy to connect to the internet.
1.12 All protocols can get tunneled through this kind of proxy (depending
1.13 @@ -100,17 +101,35 @@
1.14 choice
1.15 bool
1.16 prompt "type"
1.17 - default PROXY_TYPE_SOCKS_5
1.18 + default PROXY_TYPE_SOCKS_SYS
1.19 +
1.20 +config PROXY_TYPE_SOCKS_SYS
1.21 + bool
1.22 + prompt "Use system settings"
1.23 + help
1.24 + Use that if your system is already configured to
1.25 + connect to SOCKS 4/5 proxies.
1.26 +
1.27 +config PROXY_TYPE_SOCKS_AUTO
1.28 + bool
1.29 + prompt "Auto"
1.30 + help
1.31 + crosstool-NG will attempt to guess what type of
1.32 + SOCKS version the proxy speaks.
1.33 +
1.34 +config PROXY_TYPE_SOCKS_4
1.35 + bool
1.36 + prompt "SOCKS 4"
1.37
1.38 config PROXY_TYPE_SOCKS_5
1.39 bool
1.40 prompt "SOCKS 5"
1.41
1.42 -config PROXY_TYPE_SOCKS_4
1.43 - bool
1.44 - prompt "SOCKS 4"
1.45 +endchoice
1.46
1.47 -endchoice
1.48 +if ! PROXY_TYPE_SOCKS_SYS
1.49 +
1.50 +comment "THIS IS HIGHLY EXPERIMENTAL!!!"
1.51
1.52 config PROXY_HOST
1.53 string
1.54 @@ -129,16 +148,20 @@
1.55 string
1.56 prompt "password"
1.57
1.58 +endif # ! PROXY_TYPE_SOCKS_SYS
1.59 +
1.60 endif # USE_SOCKS_PROXY
1.61
1.62 endchoice
1.63
1.64 config PROXY_TYPE
1.65 string
1.66 - default "none" if PROXY_TYPE_NONE
1.67 - default "http" if PROXY_TYPE_HTTP
1.68 - default "socks5" if PROXY_TYPE_SOCKS_5
1.69 - default "socks4" if PROXY_TYPE_SOCKS_4
1.70 + default "none" if PROXY_TYPE_NONE
1.71 + default "http" if PROXY_TYPE_HTTP
1.72 + default "sockssys" if PROXY_TYPE_SOCKS_SYS
1.73 + default "socksauto" if PROXY_TYPE_SOCKS_AUTO
1.74 + default "socks4" if PROXY_TYPE_SOCKS_4
1.75 + default "socks5" if PROXY_TYPE_SOCKS_5
1.76
1.77 # Force restore indentation
1.78 config BREAK_INDENT
2.1 --- a/scripts/crosstool.sh Fri Apr 18 08:41:30 2008 +0000
2.2 +++ b/scripts/crosstool.sh Fri Apr 18 22:16:28 2008 +0000
2.3 @@ -224,15 +224,55 @@
2.4 export ftp_proxy="${http_proxy}"
2.5 CT_DoLog DEBUG "http_proxy='${http_proxy}'"
2.6 ;;
2.7 - socks?)
2.8 - # Re;ove any lingering config file from any previous run
2.9 + sockssys)
2.10 + CT_HasOrAbort tsocks
2.11 + . tsocks -on
2.12 + ;;
2.13 + socks*)
2.14 + CT_HasOrAbort tsocks
2.15 + # Remove any lingering config file from any previous run
2.16 rm -f "${CT_BUILD_DIR}/tsocks.conf"
2.17 - ( echo "server=${CT_PROXY_HOST}";
2.18 - echo "server_port=${CT_PROXY_PORT}";
2.19 - echo "server_type=${CT_PROXY_TYPE#socks}";
2.20 + # Find all interfaces and build locally accessible networks
2.21 + /sbin/ifconfig |gawk '
2.22 + $0 ~ /inet addr:/ {
2.23 + split( $2, ip, ":|\\." );
2.24 + ip_num = ip[2]*2^24 + ip[3]*2^16 + ip[4]*2^8 + ip[5]*2^0;
2.25 + # Skip 127.0.0.1
2.26 + if( ip_num == 2130706433 ) {
2.27 + next;
2.28 + }
2.29 + split( $(NF), mask, ":|\\." );
2.30 + mask_num = mask[2]*2^24 + mask[3]*2^16 + mask[4]*2^8 + mask[5]*2^0;
2.31 + ip_num = and( ip_num, mask_num );
2.32 + printf( "local = %d.%d.%d.%d/%d.%d.%d.%d\n",
2.33 + and( 0xFF, rshift( ip_num, 24 ) ),
2.34 + and( 0xFF, rshift( ip_num, 16 ) ),
2.35 + and( 0xFF, rshift( ip_num, 8 ) ),
2.36 + and( 0xFF, rshift( ip_num, 0 ) ),
2.37 + and( 0xFF, rshift( mask_num, 24 ) ),
2.38 + and( 0xFF, rshift( mask_num, 16 ) ),
2.39 + and( 0xFF, rshift( mask_num, 8 ) ),
2.40 + and( 0xFF, rshift( mask_num, 0 ) ) );
2.41 + }
2.42 + ' >"${CT_BUILD_DIR}/tsocks.conf"
2.43 + ( echo "server = ${CT_PROXY_HOST}";
2.44 + echo "server_port = ${CT_PROXY_PORT}";
2.45 [ -n "${CT_PROXY_USER}" ] && echo "default_user=${CT_PROXY_USER}";
2.46 [ -n "${CT_PROXY_PASS}" ] && echo "default_pass=${CT_PROXY_PASS}";
2.47 - ) >"${CT_BUILD_DIR}/tsocks.conf"
2.48 + ) >>"${CT_BUILD_DIR}/tsocks.conf"
2.49 + case "${CT_PROXY_TYPE/socks}" in
2.50 + 4|5) proxy_type="${CT_PROXY_TYPE/socks}";;
2.51 + auto)
2.52 + reply=$(inspectsocks "${CT_PROXY_HOST}" "${CT_PROXY_PORT}" 2>&1 || true)
2.53 + case "${reply}" in
2.54 + *"server is a version 4 socks server"*) proxy_type=4;;
2.55 + *"server is a version 5 socks server"*) proxy_type=5;;
2.56 + *) CT_Abort "Unable to determine SOCKS proxy type for '${CT_PROXY_HOST}:${CT_PROXY_PORT}'"
2.57 + esac
2.58 + ;;
2.59 + esac
2.60 + echo "server_type = ${proxy_type}" >> "${CT_BUILD_DIR}/tsocks.conf"
2.61 + validateconf -f "${CT_BUILD_DIR}/tsocks.conf" 2>&1 |CT_DoLog DEBUG
2.62 export TSOCKS_CONF_FILE="${CT_BUILD_DIR}/tsocks.conf"
2.63 . tsocks -on
2.64 ;;