2015-07-12 18:29:52 +02:00
|
|
|
|
|
|
|
# Proxy
|
|
|
|
function proxy_set {
|
|
|
|
export http_proxy=$1
|
|
|
|
export https_proxy=$1
|
|
|
|
export ftp_proxy=$1
|
|
|
|
export rsync_proxy=$1
|
|
|
|
export HTTP_PROXY=$1
|
|
|
|
export HTTPS_PROXY=$1
|
|
|
|
export FTP_PROXY=$1
|
|
|
|
export RSYNC_PROXY=$1
|
|
|
|
echo "Proxy changed"
|
|
|
|
}
|
|
|
|
|
|
|
|
function proxy_on {
|
|
|
|
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
|
|
|
|
|
|
|
|
if (( $# > 0 )); then
|
|
|
|
valid=$(echo $@ | sed -n 's/\([0-9]\{1,3\}.\)\{4\}:\([0-9]\+\)/&/p')
|
|
|
|
if [[ $valid != $@ ]]; then
|
|
|
|
>&2 echo "Invalid address"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
proxy_set "http://$1/"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -n "User: "; read username
|
|
|
|
if [[ $username != "" ]]; then
|
|
|
|
echo -n "Password: "
|
|
|
|
read -es password
|
|
|
|
local pre="$username:$password@"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -n "Server: "; read server
|
|
|
|
echo -n "Port: "; read port
|
|
|
|
proxy_set "http://$pre$server:$port/"
|
|
|
|
}
|
|
|
|
|
|
|
|
function proxy_off {
|
|
|
|
unset http_proxy
|
|
|
|
unset https_proxy
|
|
|
|
unset ftp_proxy
|
|
|
|
unset rsync_proxy
|
2016-02-19 13:46:26 +01:00
|
|
|
unset HTTP_PROXY
|
|
|
|
unset HTTPS_PROXY
|
|
|
|
unset FTP_PROXY
|
|
|
|
unset RSYNC_PROXY
|
2015-07-12 18:29:52 +02:00
|
|
|
echo -e "Proxy removed"
|
|
|
|
}
|
|
|
|
|