mac启动代理是啥
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mac启动代理是啥相关的知识,希望对你有一定的参考价值。
参考技术A
开启代理。使用shadowsocks软件开启代理,只支持浏览器开启代理,其他软件是不能够开启代理的,因为这个问题,自己一直无法用本地终端gitclone一些库。
sh 适用于Mac OS 10.11.5的代理自动启动/自动配置shell脚本
#!/bin/sh
# Proxy Autostart/auto-configure for Mac OS 10.11.5
# written by Kyle Falconer <Kyle.Falconer@vta.org> June 2016
#
# cntlm was setup using the instructions found at:
# http://blog.hoachuck.biz/blog/2013/03/21/howto-set-cntlm-on-mac-os-x/
#
# cntlm autostarts using launchctl
# see the plist at
# ~/Library/LaunchAgents/org.vta.cntlm.daemon.plist
WIFI_INTERFACE="en0"
ETHERNET_INTERFACE="en4"
INTRANET_ADDR="thehub.vta.org"
INTERNET_ADDR="google.com"
COLOR_RED="\033[91m"
COLOR_GREEN="\033[92m"
COLOR_RESET="\033[0m"
ifactive () {
if [ "`ifconfig | sed -n '/^'$1'/,/^[a-z]/ s/.*status: \(.*\)$/\1/p'`" = "active" ]; then
echo "true"
else
echo "false"
fi
}
boolping () {
ping -oc 2 $1 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "true"
else
echo "false"
fi
}
ETHERNET_UP=$(ifactive $ETHERNET_INTERFACE)
WIFI_UP=$(ifactive $WIFI_INTERFACE)
INTERNET_UP=$(boolping $INTERNET_ADDR)
INTRANET_UP=$(boolping $INTRANET_ADDR)
# The proxy should be enabled if on the intranet over ethernet
if [ $INTRANET_UP = "true" -a $ETHERNET_UP = "true" ]; then
# echo "setting up proxy settings"
# standard env vars
export http_proxy=http://localhost:3128
export https_proxy=https://localhost:3128
export all_proxy=http://localhost:3128
# application-specific
alias curl="curl -x ${http_proxy}"
npm config set proxy ${http_proxy}
npm config set registry http://registry.npmjs.org/
git config --global http.proxy ${http_proxy} > /dev/null 2>&1
PROXY_STATUS="true"
else
# echo "turning off proxy settings"
# standard env vars
unset http_proxy
unset https_proxy
unset all_proxy
# application-specific
npm config set registry https://registry.npmjs.org/
npm config delete proxy
npm config delete https-proxy
git config --global --unset http.proxy > /dev/null 2>&1
PROXY_STATUS="false"
fi
ETHERNET_STATUS=$([ $ETHERNET_UP = "true" ] && echo $COLOR_GREEN"up"$COLOR_RESET || echo $COLOR_RED"down"$COLOR_RESET )
WIFI_STATUS=$([ $WIFI_UP = "true" ] && echo $COLOR_GREEN"up"$COLOR_RESET || echo $COLOR_RED"down"$COLOR_RESET )
INTRANET_STATUS=$([ $INTRANET_UP = "true" ] && echo $COLOR_GREEN"up"$COLOR_RESET || echo $COLOR_RED"down"$COLOR_RESET )
INTERNET_STATUS=$([ $INTERNET_UP = "true" ] && echo $COLOR_GREEN"up"$COLOR_RESET || echo $COLOR_RED"down"$COLOR_RESET )
PROXY_STATUS=$([ $PROXY_STATUS = "true" ] && echo $COLOR_GREEN"enabled"$COLOR_RESET || echo $COLOR_RED"disabled"$COLOR_RESET )
printf 'Ethernet: %s, WiFi: %s, intranet: %s, internet: %s, proxy: %s\n' "$ETHERNET_STATUS" "$WIFI_STATUS" "$INTRANET_STATUS" "$INTERNET_STATUS" "$PROXY_STATUS"
以上是关于mac启动代理是啥的主要内容,如果未能解决你的问题,请参考以下文章
安卓手机wlan 设置有个启用代理的作用是啥
Mac 设置命令行代理
在 Mac 上的“终端”中使用 launchd 管理脚本
英特尔ME FW恢复代理是啥意思
ip代理是啥意思?有啥作用与好处?
从 Visual Studio 2019 Xamarin.iOS 连接到 Mac 的代理问题