mirror of
https://github.com/juewuy/ShellCrash.git
synced 2024-11-16 03:32:34 +08:00
v0.8.1
~修改了修饰config的方式,增强了兼容性 ~调整http和sock5代理端口统一为7890 ~增加了是否使用内置配置修饰config.yaml的开关 ~界面UI优化
This commit is contained in:
parent
f2e8bc4d89
commit
e81df087b1
Binary file not shown.
110
scripts/clash.sh
110
scripts/clash.sh
|
@ -8,9 +8,8 @@ echo "** by Juewuy **"
|
||||||
echo "***********************************************"
|
echo "***********************************************"
|
||||||
|
|
||||||
getconfig(){
|
getconfig(){
|
||||||
clashdir=/etc/clash
|
|
||||||
#版本号
|
#版本号
|
||||||
clashfm=0.8.0
|
clashfm=0.8.1
|
||||||
#更新服务器地址
|
#更新服务器地址
|
||||||
update_url="https://juewuy.xyz/clash"
|
update_url="https://juewuy.xyz/clash"
|
||||||
#文件路径
|
#文件路径
|
||||||
|
@ -28,10 +27,10 @@ source $ccfg
|
||||||
#if [ $auto_start = true ] > /dev/null 2>&1; then
|
#if [ $auto_start = true ] > /dev/null 2>&1; then
|
||||||
if [ -f /etc/rc.d/*clash ]; then
|
if [ -f /etc/rc.d/*clash ]; then
|
||||||
auto="\033[32m已设置开机启动!\033[0m"
|
auto="\033[32m已设置开机启动!\033[0m"
|
||||||
auto1="禁用clash开机启动"
|
auto1="\033[36m禁用\033[0mclash开机启动"
|
||||||
else
|
else
|
||||||
auto="\033[31m未设置开机启动!\033[0m"
|
auto="\033[31m未设置开机启动!\033[0m"
|
||||||
auto1="允许clash开机启动"
|
auto1="\033[36m允许\033[0mclash开机启动"
|
||||||
fi
|
fi
|
||||||
#获取运行模式
|
#获取运行模式
|
||||||
if [ ! -n "$redir_mod" ]; then
|
if [ ! -n "$redir_mod" ]; then
|
||||||
|
@ -103,14 +102,14 @@ fi
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[44m 实验性功能,遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
echo -e "\033[44m 实验性功能,遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
||||||
echo -e "\033[32m 欢迎使用订阅功能!\033[0m"
|
echo -e "\033[32m 欢迎使用订阅功能!\033[0m"
|
||||||
echo -e 1 输入节点/订阅链接
|
echo -e " 1 输入\033[36m节点/订阅\033[0m链接"
|
||||||
echo -e 2 输入完整clash规则链接
|
echo -e " 2 输入完整clash规则链接"
|
||||||
echo -e 3 选取代理规则模版
|
echo -e " 3 选取\033[33m代理规则\033[0m模版"
|
||||||
echo -e 4 选择配置生成服务器
|
echo -e " 4 选择配置生成服务器"
|
||||||
echo -e 5 还原配置文件
|
echo -e " 5 \033[36m还原\033[0m配置文件"
|
||||||
echo -e 6 手动更新订阅
|
echo -e " 6 \033[32m手动更新\033[0m订阅"
|
||||||
echo -e 7 设置自动更新(未完成)
|
echo -e " 7 设置自动更新(未完成)"
|
||||||
echo -e 0 返回上级菜单
|
echo -e " 0 返回上级菜单"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z $num ];then
|
if [ -z $num ];then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
|
@ -244,29 +243,30 @@ else
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
clashadv(){
|
clashadv(){
|
||||||
#获取高级配置
|
#获取设置默认显示
|
||||||
if [ ! -n "$skip_cert" ]; then
|
if [ ! -n "$skip_cert" ]; then
|
||||||
sed -i "2i\skip_cert=已开启" $ccfg
|
|
||||||
skip_cert=已开启
|
skip_cert=已开启
|
||||||
fi
|
fi
|
||||||
if [ ! -n "$common_ports" ]; then
|
if [ ! -n "$common_ports" ]; then
|
||||||
sed -i "2i\common_ports=未开启" $ccfg
|
|
||||||
common_ports=未开启
|
common_ports=未开启
|
||||||
fi
|
fi
|
||||||
if [ ! -n "$dns_mod" ]; then
|
if [ ! -n "$dns_mod" ]; then
|
||||||
sed -i "2i\dns_mod=redir_host" $ccfg
|
|
||||||
dns_mod=redir_host
|
dns_mod=redir_host
|
||||||
fi
|
fi
|
||||||
|
if [ ! -n "$modify_yaml" ]; then
|
||||||
|
modify_yaml=未开启
|
||||||
|
fi
|
||||||
#
|
#
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[33m欢迎使用高级模式菜单:\033[0m"
|
echo -e "\033[33m欢迎使用高级模式菜单:\033[0m"
|
||||||
echo -e "\033[32m修改配置后请手动重启clash服务!\033[0m"
|
echo -e "\033[32m修改配置后请手动重启clash服务!\033[0m"
|
||||||
echo -e "1 切换运行模式: \033[32m$redir_mod\033[0m"
|
echo -e " 1 切换运行模式: \033[36m$redir_mod\033[0m"
|
||||||
echo -e "2 切换DNS运行模式: \033[32m$dns_mod\033[0m"
|
echo -e " 2 切换DNS运行模式: \033[36m$dns_mod\033[0m"
|
||||||
echo -e "3 跳过本地证书验证:\033[32m$skip_cert\033[0m ————解决节点证书验证错误"
|
echo -e " 3 跳过本地证书验证: \033[36m$skip_cert\033[0m ————解决节点证书验证错误"
|
||||||
echo -e "4 只代理常用端口: \033[32m$common_ports\033[0m ————用于屏蔽P2P流量"
|
echo -e " 4 只代理常用端口: \033[36m$common_ports\033[0m ————用于屏蔽P2P流量"
|
||||||
echo -e "9 重启clash服务"
|
echo -e " 5 不修饰config.yaml: \033[36m$modify_yaml\033[0m ————用于使用自定义配置"
|
||||||
echo -e "0 返回上级菜单 \033[0m"
|
echo -e " 9 \033[32m重启\033[0mclash服务"
|
||||||
|
echo -e " 0 返回上级菜单 \033[0m"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [[ $num -le 9 ]] > /dev/null 2>&1; then
|
if [[ $num -le 9 ]] > /dev/null 2>&1; then
|
||||||
if [[ $num == 0 ]]; then
|
if [[ $num == 0 ]]; then
|
||||||
|
@ -276,13 +276,13 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "当前代理模式为:\033[47;30m $redir_mod \033[0m"
|
echo -e "当前代理模式为:\033[47;30m $redir_mod \033[0m"
|
||||||
echo -e "\033[33m切换模式后需要手动重启clash服务以生效!\033[0m"
|
echo -e "\033[33m切换模式后需要手动重启clash服务以生效!\033[0m"
|
||||||
echo "1 Tun模式: 支持UDP转发且延迟低"
|
echo " 1 Tun模式: 支持UDP转发且延迟低"
|
||||||
echo " 但CPU及内存占用更高"
|
echo " 但CPU及内存占用更高"
|
||||||
echo " 适合外服游戏用户"
|
echo " 适合外服游戏用户"
|
||||||
echo "2 Redir模式:CPU以及内存占用较低"
|
echo " 2 Redir模式:CPU以及内存占用较低"
|
||||||
echo " 但不支持UDP流量转发"
|
echo " 但不支持UDP流量转发"
|
||||||
echo " 日常使用推荐此模式"
|
echo " 日常使用推荐此模式"
|
||||||
echo 0 返回上级菜单
|
echo " 0 返回上级菜单"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [[ $num == 0 ]]; then
|
if [[ $num == 0 ]]; then
|
||||||
clashadv
|
clashadv
|
||||||
|
@ -305,11 +305,11 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "当前DNS运行模式为:\033[47;30m $dns_mod \033[0m"
|
echo -e "当前DNS运行模式为:\033[47;30m $dns_mod \033[0m"
|
||||||
echo -e "\033[33m切换模式后需要手动重启clash服务以生效!\033[0m"
|
echo -e "\033[33m切换模式后需要手动重启clash服务以生效!\033[0m"
|
||||||
echo "1 fake-ip模式: 响应速度更快"
|
echo " 1 fake-ip模式: 响应速度更快"
|
||||||
echo " 但可能和部分软件有冲突"
|
echo " 但可能和部分软件有冲突"
|
||||||
echo "2 redir_host模式:使用稳定,兼容性好"
|
echo " 2 redir_host模式:使用稳定,兼容性好"
|
||||||
echo " 响应速度略慢"
|
echo " 响应速度略慢"
|
||||||
echo 0 返回上级菜单
|
echo " 0 返回上级菜单"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [[ $num == 0 ]]; then
|
if [[ $num == 0 ]]; then
|
||||||
clashadv
|
clashadv
|
||||||
|
@ -357,6 +357,24 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
|
||||||
common_ports=未开启
|
common_ports=未开启
|
||||||
fi
|
fi
|
||||||
clashadv
|
clashadv
|
||||||
|
|
||||||
|
elif [[ $num == 5 ]]; then
|
||||||
|
sed -i '/modify_yaml*/'d $ccfg
|
||||||
|
echo -----------------------------------------------
|
||||||
|
if [ "$modify_yaml" = "未开启" ] > /dev/null 2>&1; then
|
||||||
|
sed -i "1i\modify_yaml=已开启" $ccfg
|
||||||
|
echo -e "\033[33m已设为使用用户完成自定义配置文件!!"
|
||||||
|
echo -e "\033[0m不明白原理的用户切勿随意开启此选项"
|
||||||
|
echo -e "\033[33m!!!必然会导致上不了网!!!\033[0m"
|
||||||
|
modify_yaml=已开启
|
||||||
|
else
|
||||||
|
/etc/init.d/clash enable
|
||||||
|
sed -i "1i\modify_yaml=未开启" $ccfg
|
||||||
|
echo -e "\033[32m已设为使用脚本内置规则管理config.yaml配置文件!!\033[0m"
|
||||||
|
modify_yaml=未开启
|
||||||
|
fi
|
||||||
|
clashadv
|
||||||
|
|
||||||
elif [[ $num == 9 ]]; then
|
elif [[ $num == 9 ]]; then
|
||||||
if [ $status -gt 0 ];then
|
if [ $status -gt 0 ];then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
|
@ -384,11 +402,11 @@ echo -e "感谢:\033[32mClashR \033[0m作者\033[36m BROBIRD\033[0m 项目地
|
||||||
echo -e "感谢:\033[32mtun2socks \033[0m作者\033[36m eycorsican\033[0m 项目地址:\033[32mhttps://github.com/eycorsican/go-tun2socks\033[0m"
|
echo -e "感谢:\033[32mtun2socks \033[0m作者\033[36m eycorsican\033[0m 项目地址:\033[32mhttps://github.com/eycorsican/go-tun2socks\033[0m"
|
||||||
echo -e "感谢:\033[32m更多的帮助过我的人!\033[0m"
|
echo -e "感谢:\033[32m更多的帮助过我的人!\033[0m"
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo 1 更新管理脚本
|
echo -e " 1 更新管理脚本"
|
||||||
echo 2 更新\替换clash核心文件
|
echo -e " 2 更新\替换clash核心文件"
|
||||||
echo 3 更新GeoIP数据库(施工中)
|
echo -e " 3 更新GeoIP数据库(施工中)"
|
||||||
echo 9 卸载clash
|
echo -e " 9 卸载clash"
|
||||||
echo 0 返回上级菜单
|
echo -e " 0 返回上级菜单"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [[ $num -le 9 ]] > /dev/null 2>&1; then
|
if [[ $num -le 9 ]] > /dev/null 2>&1; then
|
||||||
if [[ $num == 0 ]]; then
|
if [[ $num == 0 ]]; then
|
||||||
|
@ -441,8 +459,8 @@ echo -e " 4 $auto1"
|
||||||
echo -e " 5 设置定时任务(施工中)"
|
echo -e " 5 设置定时任务(施工中)"
|
||||||
echo -e " 6 导入\033[32m节点/订阅\033[0m链接"
|
echo -e " 6 导入\033[32m节点/订阅\033[0m链接"
|
||||||
echo -e " 8 \033[36m测试菜单\033[0m"
|
echo -e " 8 \033[36m测试菜单\033[0m"
|
||||||
echo -e " 9 \033[32m更新\033[0m脚本及相关文件"
|
echo -e " 9 \033[32m检查更新\033[0m"
|
||||||
echo -e " 0 \033[35m退出\033[0m脚本"
|
echo -e " 0 \033[0m退出脚本\033[0m"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [[ $num -le 9 ]] > /dev/null 2>&1; then
|
if [[ $num -le 9 ]] > /dev/null 2>&1; then
|
||||||
if [[ $num == 0 ]]; then
|
if [[ $num == 0 ]]; then
|
||||||
|
@ -474,12 +492,12 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
|
||||||
|
|
||||||
elif [[ $num == 4 ]]; then
|
elif [[ $num == 4 ]]; then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
if [ "$auto1" = "允许clash开机启动" ]; then
|
if [ -f /etc/rc.d/*clash ]; then
|
||||||
/etc/init.d/clash enable
|
|
||||||
echo -e "\033[32m已设置Clash开机启动!\033[0m"
|
|
||||||
else
|
|
||||||
/etc/init.d/clash disable
|
/etc/init.d/clash disable
|
||||||
echo -e "\033[33m已禁止Clash开机启动!\033[0m"
|
echo -e "\033[33m已禁止Clash开机启动!\033[0m"
|
||||||
|
else
|
||||||
|
/etc/init.d/clash enable
|
||||||
|
echo -e "\033[32m已设置Clash开机启动!\033[0m"
|
||||||
fi
|
fi
|
||||||
clashsh
|
clashsh
|
||||||
|
|
||||||
|
@ -536,7 +554,7 @@ echo -e "\033[36m正在施工中,敬请期待!\033[0m"
|
||||||
exit;
|
exit;
|
||||||
elif [[ $num == 6 ]]; then
|
elif [[ $num == 6 ]]; then
|
||||||
echo 注意:测试结果不保证一定准确!
|
echo 注意:测试结果不保证一定准确!
|
||||||
delay=`curl -kx socks5://127.0.0.1:7891 -o /dev/null -s -w '%{time_starttransfer}' 'https://google.tw' & { sleep 3 ; kill $! & }` > /dev/null 2>&1
|
delay=`curl -kx 127.0.0.1:7890 -o /dev/null -s -w '%{time_starttransfer}' 'https://google.tw' & { sleep 3 ; kill $! & }` > /dev/null 2>&1
|
||||||
delay=`echo |awk "{print $delay*1000}"` > /dev/null 2>&1
|
delay=`echo |awk "{print $delay*1000}"` > /dev/null 2>&1
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
if [ `echo ${#delay}` -gt 1 ];then
|
if [ `echo ${#delay}` -gt 1 ];then
|
||||||
|
|
|
@ -6,16 +6,17 @@ USE_PROCD=1
|
||||||
START=99
|
START=99
|
||||||
|
|
||||||
getconfig(){
|
getconfig(){
|
||||||
clashdir=/etc/clash
|
|
||||||
ccfg=$clashdir/mark
|
ccfg=$clashdir/mark
|
||||||
if [ ! -f "$ccfg" ]; then
|
if [ ! -f "$ccfg" ]; then
|
||||||
echo mark文件不存在,默认以Redir模式运行!
|
echo mark文件不存在,默认以Redir模式运行!
|
||||||
cat >$ccfg<<EOF
|
cat >$ccfg<<EOF
|
||||||
#标识clash运行状态的文件,不明勿动!
|
#标识clash运行状态的文件,不明勿动!
|
||||||
EOF
|
EOF
|
||||||
|
#指定一些默认状态
|
||||||
redir_mod=redir模式
|
redir_mod=redir模式
|
||||||
common_ports=未开启
|
common_ports=未开启
|
||||||
dns_mod=redir-host
|
dns_mod=redir-host
|
||||||
|
modify_yaml=未开启
|
||||||
fi
|
fi
|
||||||
source $ccfg #加载配置文件
|
source $ccfg #加载配置文件
|
||||||
#是否代理常用端口
|
#是否代理常用端口
|
||||||
|
@ -29,7 +30,11 @@ fi
|
||||||
}
|
}
|
||||||
modifyyaml(){
|
modifyyaml(){
|
||||||
##########需要变更的配置###########
|
##########需要变更的配置###########
|
||||||
|
mix='mixed-port: 7890'
|
||||||
redir='redir-port: 7892'
|
redir='redir-port: 7892'
|
||||||
|
lan='allow-lan: true'
|
||||||
|
mode='mode: Rule'
|
||||||
|
log='log-level: info'
|
||||||
ipv6='ipv6: true'
|
ipv6='ipv6: true'
|
||||||
external='external-controller: 0.0.0.0:9999'
|
external='external-controller: 0.0.0.0:9999'
|
||||||
if [ "$dns_mod" = "fake-ip" ];then
|
if [ "$dns_mod" = "fake-ip" ];then
|
||||||
|
@ -45,24 +50,26 @@ fi
|
||||||
exper='experimental: {ignore-resolve-fail: true, interface-name: en0}'
|
exper='experimental: {ignore-resolve-fail: true, interface-name: en0}'
|
||||||
###################################
|
###################################
|
||||||
#预删除需要添加的项目
|
#预删除需要添加的项目
|
||||||
sed -i '/^redir-port:*/'d $clashdir/config.yaml
|
i=$(grep -n "^proxies:" $clashdir/config.yaml | head -1 | cut -d ":" -f 1)
|
||||||
sed -i '/^ipv6: true:*/'d $clashdir/config.yaml
|
i=$(($i-1))
|
||||||
sed -i '/^external-controller:*/'d $clashdir/config.yaml
|
sed -i '1,'$i'd' $clashdir/config.yaml
|
||||||
sed -i '/^dns:*/'d $clashdir/config.yaml
|
|
||||||
sed -i '/^tun:*/'d $clashdir/config.yaml
|
|
||||||
sed -i '/^experimental:*/'d $clashdir/config.yaml
|
|
||||||
#添加配置
|
#添加配置
|
||||||
sed -i "2a$redir" $clashdir/config.yaml
|
sed -i "1i$mix" $clashdir/config.yaml
|
||||||
|
sed -i "1a$redir" $clashdir/config.yaml
|
||||||
|
sed -i "2a$lan" $clashdir/config.yaml
|
||||||
|
sed -i "3a$mode" $clashdir/config.yaml
|
||||||
|
sed -i "4a$log" $clashdir/config.yaml
|
||||||
sed -i "5a$ipv6" $clashdir/config.yaml
|
sed -i "5a$ipv6" $clashdir/config.yaml
|
||||||
sed -i "6a$external" $clashdir/config.yaml
|
sed -i "6a$external" $clashdir/config.yaml
|
||||||
sed -i "7a$dns" $clashdir/config.yaml
|
sed -i "7a$dns" $clashdir/config.yaml
|
||||||
sed -i "8a$tun" $clashdir/config.yaml
|
sed -i "8a$tun" $clashdir/config.yaml
|
||||||
sed -i "9a$exper" $clashdir/config.yaml
|
sed -i "9a$exper" $clashdir/config.yaml
|
||||||
|
#跳过本地tls证书验证
|
||||||
if [ "$skip_cert" != "未开启" ];then
|
if [ "$skip_cert" != "未开启" ];then
|
||||||
sed -i "10,99s/sni: \S*/\1skip-cert-verify: true}/" $clashdir/config.yaml #跳过trojan本地证书验证
|
sed -i "10,99s/sni: \S*/\1skip-cert-verify: true}/" $clashdir/config.yaml #跳过trojan本地证书验证
|
||||||
sed -i '10,99s/}}/}, skip-cert-verify: true}/' $clashdir/config.yaml #跳过v2+ssl本地证书验证
|
sed -i '10,99s/}}/}, skip-cert-verify: true}/' $clashdir/config.yaml #跳过v2+ssl本地证书验证
|
||||||
fi
|
fi
|
||||||
sed -i '/rules:/a \ - DOMAIN-SUFFIX,clash.razord.top,🎯 全球直连' $clashdir/config.yaml
|
#sed -i '/rules:/a \ - DOMAIN-SUFFIX,clash.razord.top,🎯 全球直连' $clashdir/config.yaml
|
||||||
}
|
}
|
||||||
mark_time(){
|
mark_time(){
|
||||||
start_time=`date +%s`
|
start_time=`date +%s`
|
||||||
|
@ -101,7 +108,10 @@ start_tun(){
|
||||||
}
|
}
|
||||||
start_service() {
|
start_service() {
|
||||||
getconfig
|
getconfig
|
||||||
|
#使用内置规则强行覆盖config配置文件
|
||||||
|
if [ "$modify_yaml" = "未开启" ];then
|
||||||
modifyyaml
|
modifyyaml
|
||||||
|
fi
|
||||||
#创建clash后台进程
|
#创建clash后台进程
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
procd_set_param respawn
|
procd_set_param respawn
|
||||||
|
|
Loading…
Reference in New Issue
Block a user