note/tech/socks_http.sh
2025-11-19 10:16:05 +08:00

25 lines
1013 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
#############
# 脚本说明:
# 选择1是socks代理选择2是http代理
# 先检测1080和1099端口是否正常工作
SOCKS_PORT="1080"
HTTP_PORT="1099"
PAC_URL="https://pac.disbaidu.com/gfw.pac"
PAC2_URL="https://pac.disbaidu.com/gfw2.pac"
if ! lsof -i:"$SOCKS_PORT" | grep -q "LISTEN"; then
echo "socks端口 $SOCKS_PORT 未开启。"
exit 1
fi
if ! lsof -i:"$HTTP_PORT" | grep -q "LISTEN"; then
echo "http端口 $HTTP_PORT 未开启。"
exit 1
fi
read -r -p "选择设置socks代理(y/N) " response
if [[ "$response" =~ ^([yY])$ ]]; then
echo "设置PAC的http代理。。。"
networksetup -setautoproxyurl Wi-Fi "$PAC_URL"
echo "naiveproxy启动成功"
osascript -e 'tell app "System Events" to display dialog "代理启动成功已设置PAC代理。直接打开浏览器就可以自由上网。\n本地代理为http://127.0.0.1:'"$HTTP_PORT"'\n代理测试结果'"$REQUESTS"'" buttons {"OK"}'
exit 0