v1.0.0beta15.5

~Redir模式增加基于tproxy的udp代理
~修复各种更新检测失败的bug
~增加自动生成pac逻辑
This commit is contained in:
juewuy
2020-10-25 13:48:22 +08:00
parent 1b39b2ebd4
commit 0d65f13af9
4 changed files with 31 additions and 60 deletions

View File

@@ -1,7 +1,7 @@
#! /bin/bash
# Copyright (C) Juewuy
echo='echo -e' && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && echo=echo
echo='echo -e' && [ -n "$(echo -e|grep e)" ] && echo=echo
[ -z "$1" ] && test=0 || test=$1
echo "***********************************************"
@@ -36,7 +36,7 @@ webget(){
#检查更新
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash"
if [ "$test" -gt 0 ];then
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash/master"
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master"
[ "$test" -eq 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi"
[ "$test" -eq 3 ] && url="http://192.168.123.90:8080/clash-for-Miwifi"
else

View File

@@ -96,6 +96,27 @@ echoerrornum(){
echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m"
}
catpac(){
cat > /tmp/pac <<EOF
function FindProxyForURL(url, host) {
if (
isInNet(host, "0.0.0.0", "255.0.0.0")||
isInNet(host, "10.0.0.0", "255.0.0.0")||
isInNet(host, "127.0.0.0", "255.0.0.0")||
isInNet(host, "224.0.0.0", "224.0.0.0")||
isInNet(host, "240.0.0.0", "240.0.0.0")||
isInNet(host, "172.16.0.0", "255.240.0.0")||
isInNet(host, "192.168.0.0", "255.255.0.0")||
isInNet(host, "169.254.0.0", "255.255.0.0")
)
return "DIRECT";
else
return "PROXY $host:$mix_port; DIRECT;"
}
EOF
[ ! -d $clashdir/ui] && mkdir -p $clashdir/ui
[ "$(cat /tmp/pac)" != "$(cat $clashdir/ui/pac 2>&1)" ] && mv -f /tmp/pac $clashdir/ui/pac || rm -rf /tmp/pac
}
start_over(){
[ $? -eq 1 ] && exit
echo -e "\033[32mclash服务已启动\033[0m"
@@ -304,8 +325,9 @@ clashstart(){
if [ -z "$PID" ];then
$clashdir/start.sh stop
echo -e "\033[31mclash启动失败\033[0m"
exit
exit;
fi
catpac #生成pac自动代理文件
start_over
}
macfilter(){
@@ -599,7 +621,8 @@ clashcfg(){
if [ "$local_proxy" = "未开启" ] > /dev/null 2>&1; then
sed -i "1i\local_proxy=已开启" $ccfg
local_proxy=已开启
$clashdir/start.sh set_proxy $mix_port $hostdir
catpac #生成pac自动代理文件
$clashdir/start.sh set_proxy $mix_port
echo -e "\033[32m已经成功配置本机代理~\033[0m"
echo -e "\033[36m如未生效请重新启动终端或重新连接SSH\033[0m"
else

View File

@@ -692,52 +692,6 @@ getdb(){
sleep 1
fi
}
catpac(){
cat > $dbdir/pac <<EOF
function FindProxyForURL(url, host) {
if (
isInNet(host, "0.0.0.0", "255.0.0.0")||
isInNet(host, "10.0.0.0", "255.0.0.0")||
isInNet(host, "127.0.0.0", "255.0.0.0")||
isInNet(host, "224.0.0.0", "224.0.0.0")||
isInNet(host, "240.0.0.0", "240.0.0.0")||
isInNet(host, "172.16.0.0", "255.240.0.0")||
isInNet(host, "192.168.0.0", "255.255.0.0")||
isInNet(host, "169.254.0.0", "255.255.0.0")
)
return "DIRECT";
else
return "PROXY $host:$mix_port; DIRECT;"
}
EOF
}
setpac(){
#检测目录
[ -n "$authentication" ] && echo 检测到已经设置http代理密码pac不支持加密代理请先取消加密 && sleep 1 && clashadv
[ ! -d /www/clash -a ! -d $clashdir/ui ] && echo 未检测到本地Dashboard面板请先安装面板 && sleep 1 && getdb
echo -----------------------------------------------
echo -e "\033[30;47m生成用于设备WIFI或浏览器的自动PAC代理文件\033[0m"
echo -e "\033[33m适用于纯净模式或本机代理配置\033[0m"
[ -f $dbdir/pac ] && echo -e "PAC地址\033[32mhttp://$host$dbdir/pac\033[0m"
echo -----------------------------------------------
echo -e " 1 生成PAC文件"
echo -e " 2 清除PAC文件"
echo -----------------------------------------------
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ "$num" = '1' ]; then
catpac
echo -e "\033[33mPAC文件已生成\033[0m"
echo -e "PAC地址\033[32mhttp://$host$dbdir/pac\033[0m"
echo "使用教程https://baike.baidu.com/item/PAC/16292100"
sleep 2
elif [ "$num" = 2 ]; then
rm -rf $dbdir/pac
echo -----------------------------------------------
echo -e "\033[33mPAC文件已清除\033[0m"
sleep 1
fi
}
setserver(){
echo -----------------------------------------------
@@ -810,7 +764,6 @@ update(){
echo -e " 2 切换\033[33mclash核心 \033[33m$clashv\033[0m > \033[32m$clash_n\033[0m"
echo -e " 3 更新\033[32mGeoIP数据库 \033[33m$Geo_v\033[0m > \033[32m$GeoIP_v\033[0m"
echo -e " 4 安装本地\033[35mDashboard\033[0m面板"
echo -e " 5 生成本地PAC文件(需先安装本地面板)"
echo -----------------------------------------------
echo -e " 7 切换\033[36m安装源\033[0m地址"
echo -e " 8 鸣谢"
@@ -837,10 +790,6 @@ update(){
elif [ "$num" = 4 ]; then
getdb
update
elif [ "$num" = 5 ]; then
setpac
update
elif [ "$num" = 7 ]; then
setserver
@@ -891,7 +840,6 @@ userguide(){
getcore
getgeo
getdb
catpac
clashlink
}
testcommand(){

View File

@@ -382,7 +382,7 @@ afstart(){
#标记启动时间
mark_time
#设置本机代理
[ "$local_proxy" = "已开启" ] && $0 set_proxy $mix_port $hostdir
[ "$local_proxy" = "已开启" ] && $0 set_proxy $mix_port
#还原面板配置
web_save_auto #启用面板配置自动保存
[ -f $clashdir/web_save ] && web_restore & #后台还原面板配置
@@ -448,17 +448,17 @@ web_save)
set_proxy)
#GNOME配置
if gsettings --version >/dev/null 2>&1 ;then
gsettings set org.gnome.system.proxy autoconfig-url "http://127.0.0.1${3}/pac"
gsettings set org.gnome.system.proxy autoconfig-url "http://127.0.0.1:$1/ui/pac"
gsettings set org.gnome.system.proxy mode "auto"
#KDE配置
elif kwriteconfig5 -h >/dev/null 2>&1 ;then
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key "ProxyType" 2
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key "Proxy Config Script" "http://127.0.0.1${3}/pac"
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key "Proxy Config Script" "http://127.0.0.1:$1/ui/pac"
#环境变量方式
else
[ -w ~/.bashrc ] && profile=~/.bashrc
[ -w /etc/profile ] && profile=/etc/profile
echo 'export all_proxy=http://127.0.0.1:'"$2" >> $profile
echo 'export all_proxy=http://127.0.0.1:'"$1" >> $profile
echo 'export ALL_PROXY=$all_proxy' >> $profile
fi
;;