fix: error log
This commit is contained in:
parent
757efc3ec6
commit
0b7d51be05
2 changed files with 65 additions and 38 deletions
49
.zprofile
49
.zprofile
|
@ -1,31 +1,38 @@
|
|||
# ─< proxy config >───────────────────────────────────────────────────────────────────────
|
||||
proxy() {
|
||||
case "$1" in
|
||||
--show)
|
||||
echo {"http: $http_proxy, $HTTP_PROXY"
|
||||
"https: $https_proxy, $HTTPS_PROXY"}
|
||||
;;
|
||||
*)
|
||||
echo "You entered something wrong!"
|
||||
;;
|
||||
esac
|
||||
|
||||
local ip="172.22.11.69"
|
||||
local port="8080"
|
||||
|
||||
# Check if the IP and port are reachable
|
||||
if nc -z -w5 $ip $port; then
|
||||
# If reachable, set the proxy environment variables
|
||||
export http_proxy="http://$ip:$port"
|
||||
export https_proxy="http://$ip:$port"
|
||||
export HTTP_PROXY="http://$ip:$port"
|
||||
export HTTPS_PROXY="http://$ip:$port"
|
||||
echo_info "Proxy set to: http://$ip:$port" || echo "Proxy set to: http://$ip:$port"
|
||||
else
|
||||
echo_error "IP $ip with port $port is not reachable." || echo "IP $ip with port $port is not reachable."
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: proxy [--show|--set]"
|
||||
echo " --show Show current proxy settings"
|
||||
echo " --set Set proxy to $ip:$port"
|
||||
return 0
|
||||
fi
|
||||
|
||||
alias proxy='echo "http: $HTTP_PROXY"; echo "https: $HTTPS_PROXY"'
|
||||
case "$1" in
|
||||
--show)
|
||||
echo "These are your proxy configurations:"
|
||||
echo "http: $http_proxy, HTTP: $HTTP_PROXY"
|
||||
echo "https: $https_proxy, HTTPS: $HTTPS_PROXY"
|
||||
;;
|
||||
--set)
|
||||
# Check if the IP and port are reachable
|
||||
if nc -z -w5 $ip $port; then
|
||||
# If reachable, set the proxy environment variables
|
||||
export http_proxy="http://$ip:$port"
|
||||
export https_proxy="http://$ip:$port"
|
||||
export HTTP_PROXY="http://$ip:$port"
|
||||
export HTTPS_PROXY="http://$ip:$port"
|
||||
echo_info "Proxy set to: http://$ip:$port" || echo "Proxy set to: http://$ip:$port"
|
||||
else
|
||||
echo_error "IP $ip with port $port is not reachable." || echo "IP $ip with port $port is not reachable."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option! Use --show or --set."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# ─< unset proxy >────────────────────────────────────────────────────────────────────────
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue