1.1 --- a/scripts/crosstool.sh Fri Apr 18 08:41:30 2008 +0000
1.2 +++ b/scripts/crosstool.sh Fri Apr 18 22:16:28 2008 +0000
1.3 @@ -224,15 +224,55 @@
1.4 export ftp_proxy="${http_proxy}"
1.5 CT_DoLog DEBUG "http_proxy='${http_proxy}'"
1.6 ;;
1.7 - socks?)
1.8 - # Re;ove any lingering config file from any previous run
1.9 + sockssys)
1.10 + CT_HasOrAbort tsocks
1.11 + . tsocks -on
1.12 + ;;
1.13 + socks*)
1.14 + CT_HasOrAbort tsocks
1.15 + # Remove any lingering config file from any previous run
1.16 rm -f "${CT_BUILD_DIR}/tsocks.conf"
1.17 - ( echo "server=${CT_PROXY_HOST}";
1.18 - echo "server_port=${CT_PROXY_PORT}";
1.19 - echo "server_type=${CT_PROXY_TYPE#socks}";
1.20 + # Find all interfaces and build locally accessible networks
1.21 + /sbin/ifconfig |gawk '
1.22 + $0 ~ /inet addr:/ {
1.23 + split( $2, ip, ":|\\." );
1.24 + ip_num = ip[2]*2^24 + ip[3]*2^16 + ip[4]*2^8 + ip[5]*2^0;
1.25 + # Skip 127.0.0.1
1.26 + if( ip_num == 2130706433 ) {
1.27 + next;
1.28 + }
1.29 + split( $(NF), mask, ":|\\." );
1.30 + mask_num = mask[2]*2^24 + mask[3]*2^16 + mask[4]*2^8 + mask[5]*2^0;
1.31 + ip_num = and( ip_num, mask_num );
1.32 + printf( "local = %d.%d.%d.%d/%d.%d.%d.%d\n",
1.33 + and( 0xFF, rshift( ip_num, 24 ) ),
1.34 + and( 0xFF, rshift( ip_num, 16 ) ),
1.35 + and( 0xFF, rshift( ip_num, 8 ) ),
1.36 + and( 0xFF, rshift( ip_num, 0 ) ),
1.37 + and( 0xFF, rshift( mask_num, 24 ) ),
1.38 + and( 0xFF, rshift( mask_num, 16 ) ),
1.39 + and( 0xFF, rshift( mask_num, 8 ) ),
1.40 + and( 0xFF, rshift( mask_num, 0 ) ) );
1.41 + }
1.42 + ' >"${CT_BUILD_DIR}/tsocks.conf"
1.43 + ( echo "server = ${CT_PROXY_HOST}";
1.44 + echo "server_port = ${CT_PROXY_PORT}";
1.45 [ -n "${CT_PROXY_USER}" ] && echo "default_user=${CT_PROXY_USER}";
1.46 [ -n "${CT_PROXY_PASS}" ] && echo "default_pass=${CT_PROXY_PASS}";
1.47 - ) >"${CT_BUILD_DIR}/tsocks.conf"
1.48 + ) >>"${CT_BUILD_DIR}/tsocks.conf"
1.49 + case "${CT_PROXY_TYPE/socks}" in
1.50 + 4|5) proxy_type="${CT_PROXY_TYPE/socks}";;
1.51 + auto)
1.52 + reply=$(inspectsocks "${CT_PROXY_HOST}" "${CT_PROXY_PORT}" 2>&1 || true)
1.53 + case "${reply}" in
1.54 + *"server is a version 4 socks server"*) proxy_type=4;;
1.55 + *"server is a version 5 socks server"*) proxy_type=5;;
1.56 + *) CT_Abort "Unable to determine SOCKS proxy type for '${CT_PROXY_HOST}:${CT_PROXY_PORT}'"
1.57 + esac
1.58 + ;;
1.59 + esac
1.60 + echo "server_type = ${proxy_type}" >> "${CT_BUILD_DIR}/tsocks.conf"
1.61 + validateconf -f "${CT_BUILD_DIR}/tsocks.conf" 2>&1 |CT_DoLog DEBUG
1.62 export TSOCKS_CONF_FILE="${CT_BUILD_DIR}/tsocks.conf"
1.63 . tsocks -on
1.64 ;;