diff options
Diffstat (limited to 'scripts/oe-git-proxy')
| -rwxr-xr-x | scripts/oe-git-proxy | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/scripts/oe-git-proxy b/scripts/oe-git-proxy index 38ce7b66fd..1247902406 100755 --- a/scripts/oe-git-proxy +++ b/scripts/oe-git-proxy | |||
| @@ -116,14 +116,27 @@ for H in ${NO_PROXY//,/ }; do | |||
| 116 | done | 116 | done |
| 117 | 117 | ||
| 118 | # Proxy is necessary, determine protocol, server, and port | 118 | # Proxy is necessary, determine protocol, server, and port |
| 119 | PROTO=$(echo $ALL_PROXY | sed -e 's/\([^:]*\):\/\/.*/\1/') | 119 | # extract protocol |
| 120 | PROXY=$(echo $ALL_PROXY | sed -e 's/.*:\/\/\([^:]*\).*/\1/') | 120 | PROTO=${ALL_PROXY%://*} |
| 121 | # For backwards compatibility, this allows the port number to be followed by /? | 121 | # strip protocol:// from string |
| 122 | # in addition to the customary optional / | 122 | ALL_PROXY=${ALL_PROXY#*://} |
| 123 | PORT=$(echo $ALL_PROXY | sed -e 's/.*:\([0-9]*\)\(\/?\?\)\?$/\1/') | 123 | # extract host & port parts: |
| 124 | if [ "$PORT" = "$ALL_PROXY" ]; then | 124 | # 1) drop username/password |
| 125 | PROXY=${ALL_PROXY##*@} | ||
| 126 | # 2) remove optional trailing /? | ||
| 127 | PROXY=${PROXY%%/*} | ||
| 128 | # 3) extract optional port | ||
| 129 | PORT=${PROXY##*:} | ||
| 130 | if [ "$PORT" = "$PROXY" ]; then | ||
| 125 | PORT="" | 131 | PORT="" |
| 126 | fi | 132 | fi |
| 133 | # 4) remove port | ||
| 134 | PROXY=${PROXY%%:*} | ||
| 135 | |||
| 136 | # extract username & password | ||
| 137 | PROXYAUTH="${ALL_PROXY%@*}" | ||
| 138 | [ "$PROXYAUTH" = "$ALL_PROXY" ] && PROXYAUTH= | ||
| 139 | [ -n "${PROXYAUTH}" ] && PROXYAUTH=",proxyauth=${PROXYAUTH}" | ||
| 127 | 140 | ||
| 128 | if [ "$PROTO" = "socks" ] || [ "$PROTO" = "socks4a" ]; then | 141 | if [ "$PROTO" = "socks" ] || [ "$PROTO" = "socks4a" ]; then |
| 129 | if [ -z "$PORT" ]; then | 142 | if [ -z "$PORT" ]; then |
| @@ -140,7 +153,7 @@ else | |||
| 140 | if [ -z "$PORT" ]; then | 153 | if [ -z "$PORT" ]; then |
| 141 | PORT="8080" | 154 | PORT="8080" |
| 142 | fi | 155 | fi |
| 143 | METHOD="PROXY:$PROXY:$1:$2,proxyport=$PORT" | 156 | METHOD="PROXY:$PROXY:$1:$2,proxyport=${PORT}${PROXYAUTH}" |
| 144 | fi | 157 | fi |
| 145 | 158 | ||
| 146 | exec $SOCAT STDIO $METHOD | 159 | exec $SOCAT STDIO "$METHOD" |
