* [PATCH 0/2] oe-git-proxy updates
@ 2016-03-23 9:47 André Draszik
2016-03-23 9:47 ` [PATCH 1/2] oe-git-proxy: also check all_proxy and http_proxy env variables André Draszik
2016-03-23 9:47 ` [PATCH 2/2] oe-git-proxy: support username / password in http proxy André Draszik
0 siblings, 2 replies; 3+ messages in thread
From: André Draszik @ 2016-03-23 9:47 UTC (permalink / raw)
To: openembedded-core; +Cc: André Draszik
From: André Draszik <adraszik@tycoint.com>
Hi,
These two patches update oe-git-proxy to:
1) support username + password authentication when using an (http) proxy
(care has been taken to support spaces in either)
2) also check the 'other' standard env variables all_proxy and http_proxy
as fallback
Cheers,
André
André Draszik (2):
oe-git-proxy: also check all_proxy and http_proxy env variables
oe-git-proxy: support username / password in http proxy
scripts/oe-git-proxy | 42 ++++++++++++++++++++++++++++++------------
1 file changed, 30 insertions(+), 12 deletions(-)
--
2.8.0.rc3
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] oe-git-proxy: also check all_proxy and http_proxy env variables
2016-03-23 9:47 [PATCH 0/2] oe-git-proxy updates André Draszik
@ 2016-03-23 9:47 ` André Draszik
2016-03-23 9:47 ` [PATCH 2/2] oe-git-proxy: support username / password in http proxy André Draszik
1 sibling, 0 replies; 3+ messages in thread
From: André Draszik @ 2016-03-23 9:47 UTC (permalink / raw)
To: openembedded-core; +Cc: André Draszik
From: André Draszik <adraszik@tycoint.com>
Signed-off-by: André Draszik <adraszik@tycoint.com>
---
scripts/oe-git-proxy | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/scripts/oe-git-proxy b/scripts/oe-git-proxy
index d2e9f92..38ce7b6 100755
--- a/scripts/oe-git-proxy
+++ b/scripts/oe-git-proxy
@@ -1,10 +1,12 @@
#!/bin/bash
# oe-git-proxy is a simple tool to be via GIT_PROXY_COMMAND. It uses socat
-# to make SOCKS5 or HTTPS proxy connections. It uses ALL_PROXY to determine the
-# proxy server, protocol, and port. It uses NO_PROXY to skip using the proxy for
-# a comma delimited list of hosts, host globs (*.example.com), IPs, or CIDR
-# masks (192.168.1.0/24). It is known to work with both bash and dash shells.
+# to make SOCKS5 or HTTPS proxy connections.
+# It uses ALL_PROXY or all_proxy or http_proxy to determine the proxy server,
+# protocol, and port.
+# It uses NO_PROXY to skip using the proxy for a comma delimited list of
+# hosts, host globs (*.example.com), IPs, or CIDR masks (192.168.1.0/24). It
+# is known to work with both bash and dash shells.
#
# Example ALL_PROXY values:
# ALL_PROXY=socks://socks.example.com:1080
@@ -99,6 +101,9 @@ match_host() {
# If no proxy is set or needed, just connect directly
METHOD="TCP:$1:$2"
+[ -z "${ALL_PROXY}" ] && ALL_PROXY=$all_proxy
+[ -z "${ALL_PROXY}" ] && ALL_PROXY=$http_proxy
+
if [ -z "$ALL_PROXY" ]; then
exec $SOCAT STDIO $METHOD
fi
--
2.8.0.rc3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] oe-git-proxy: support username / password in http proxy
2016-03-23 9:47 [PATCH 0/2] oe-git-proxy updates André Draszik
2016-03-23 9:47 ` [PATCH 1/2] oe-git-proxy: also check all_proxy and http_proxy env variables André Draszik
@ 2016-03-23 9:47 ` André Draszik
1 sibling, 0 replies; 3+ messages in thread
From: André Draszik @ 2016-03-23 9:47 UTC (permalink / raw)
To: openembedded-core; +Cc: André Draszik
From: André Draszik <adraszik@tycoint.com>
We also make sure to correctly support usernames that contain spaces.
For simplicity sed + regex has been replaced with shell parameter expansion,
which works in both, bash and dash.
Signed-off-by: André Draszik <adraszik@tycoint.com>
---
scripts/oe-git-proxy | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/scripts/oe-git-proxy b/scripts/oe-git-proxy
index 38ce7b6..1247902 100755
--- a/scripts/oe-git-proxy
+++ b/scripts/oe-git-proxy
@@ -116,14 +116,27 @@ for H in ${NO_PROXY//,/ }; do
done
# Proxy is necessary, determine protocol, server, and port
-PROTO=$(echo $ALL_PROXY | sed -e 's/\([^:]*\):\/\/.*/\1/')
-PROXY=$(echo $ALL_PROXY | sed -e 's/.*:\/\/\([^:]*\).*/\1/')
-# For backwards compatibility, this allows the port number to be followed by /?
-# in addition to the customary optional /
-PORT=$(echo $ALL_PROXY | sed -e 's/.*:\([0-9]*\)\(\/?\?\)\?$/\1/')
-if [ "$PORT" = "$ALL_PROXY" ]; then
+# extract protocol
+PROTO=${ALL_PROXY%://*}
+# strip protocol:// from string
+ALL_PROXY=${ALL_PROXY#*://}
+# extract host & port parts:
+# 1) drop username/password
+PROXY=${ALL_PROXY##*@}
+# 2) remove optional trailing /?
+PROXY=${PROXY%%/*}
+# 3) extract optional port
+PORT=${PROXY##*:}
+if [ "$PORT" = "$PROXY" ]; then
PORT=""
fi
+# 4) remove port
+PROXY=${PROXY%%:*}
+
+# extract username & password
+PROXYAUTH="${ALL_PROXY%@*}"
+[ "$PROXYAUTH" = "$ALL_PROXY" ] && PROXYAUTH=
+[ -n "${PROXYAUTH}" ] && PROXYAUTH=",proxyauth=${PROXYAUTH}"
if [ "$PROTO" = "socks" ] || [ "$PROTO" = "socks4a" ]; then
if [ -z "$PORT" ]; then
@@ -140,7 +153,7 @@ else
if [ -z "$PORT" ]; then
PORT="8080"
fi
- METHOD="PROXY:$PROXY:$1:$2,proxyport=$PORT"
+ METHOD="PROXY:$PROXY:$1:$2,proxyport=${PORT}${PROXYAUTH}"
fi
-exec $SOCAT STDIO $METHOD
+exec $SOCAT STDIO "$METHOD"
--
2.8.0.rc3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-23 9:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-23 9:47 [PATCH 0/2] oe-git-proxy updates André Draszik
2016-03-23 9:47 ` [PATCH 1/2] oe-git-proxy: also check all_proxy and http_proxy env variables André Draszik
2016-03-23 9:47 ` [PATCH 2/2] oe-git-proxy: support username / password in http proxy André Draszik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox