~增加了singbox内核对ssr协议的检测提醒
~修改了Cloudflare源的地址
~修复了小闪存模式更新内核失败的bug
~修复了自动下载内核失败的bug
~修复了启用本机代理后的若干报错
~修复部分第三方geo数据库下载失败的问题
~修复了升级后小闪存模式会被自动取消的bug
~修复了部分低性能设备无法自动还原面板节点的问题
~修复了热更新订阅失败的bug
This commit is contained in:
juewuy 2024-01-20 16:35:52 +08:00
parent 243c66282f
commit 85547ab863
9 changed files with 152 additions and 143 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -4,5 +4,5 @@ clash_v=v1.7.1
meta_v=v1.18.0
singbox_v=1.7.8
versionsh=1.8.7d
GeoIP_v=20240113
versionsh=1.8.7e

View File

@ -3,7 +3,7 @@
101 Jsdelivr_CDN源 https://fastly.jsdelivr.net/gh/juewuy/ShellCrash
102 Github直连源(请注意网络环境) https://raw.githubusercontent.com/juewuy/ShellCrash
103 ShellClash自建源(请勿滥用!) https://gh.jwsc.eu.org
104 Cloudflare_CDN源 https://gh.shellclash.workers.dev/https://raw.githubusercontent.com/juewuy/ShellCrash
104 Cloudflare_CDN源 https://testingcf.jsdelivr.net/gh/juewuy/ShellCrash
201 wwng2333自建CN源(请勿滥用!) https://mirrors.csgo.ovh/ShellClash 公测版
202 http私人内测源(危险!非必要请勿使用) http://t.jwsc.eu.org 开发版

View File

@ -921,48 +921,38 @@ getcore(){
}
setcustcore(){
[ -z "$cpucore" ] && getcpucore
echo -----------------------------------------------
echo -e "\033[36m自定义内核均未经过适配可能存在部分功能不兼容的问题\033[0m"
echo -e "\033[36m如你不熟悉相关内核的运行机制请使用脚本已经适配过的内核\033[0m"
echo -e "\033[36m自定义内核不兼容小闪存模式且下载可能依赖服务\033[0m"
echo -e "\033[33m继续后如出现任何问题请务必自行解决一切提问恕不受理\033[0m"
echo -----------------------------------------------
sleep 1
read -p "我确认遇到问题可以自行解决[1/0] > " res
[ "$res" = '1' ] && {
echo -e "\033[33m请选择需要使用的核心\033[0m"
echo -e "1 \033[32m 测试版ClashPre内核 \033[0m"
echo -e "2 \033[32m 最新Meta.Alpha内核 \033[0m"
#echo -e "3 \033[32m Sing-Box官方内核 \033[0m"
echo -e "4 \033[33m 自定义内核链接 \033[0m"
read -p "请输入对应数字 > " num
case "$num" in
1)
crashcore=clashpre
custcorelink=https://github.com/juewuy/ShellCrash/releases/download/clash.premium.latest/clash-linux-$cpucore
getcore
;;
2)
crashcore=meta
custcorelink=https://github.com/juewuy/ShellCrash/releases/download/clash.meta.alpha/clash-linux-$cpucore
getcore
;;
3)
crashcore=singbox
custcorelink=https://github.com/juewuy/ShellCrash/releases/download/singbox_core/singbox-linux-$cpucore
getcore
;;
4)
read -p "请输入自定义内核的链接地址(必须是二进制文件) > " link
[ -n "$link" ] && custcorelink="$link"
crashcore=unknow
getcore
;;
*)
errornum
;;
esac
}
echo -e "\033[33m请选择需要使用的核心\033[0m"
echo -e "1 \033[32m 测试版ClashPre内核 \033[0m"
echo -e "2 \033[32m 最新Meta.Alpha内核 \033[0m"
#echo -e "3 \033[32m Sing-Box官方内核 \033[0m"
echo -e "4 \033[33m 自定义内核链接 \033[0m"
read -p "请输入对应数字 > " num
case "$num" in
1)
crashcore=clashpre
custcorelink=https://github.com/juewuy/ShellCrash/releases/download/clash.premium.latest/clash-linux-$cpucore
getcore
;;
2)
crashcore=meta
custcorelink=https://github.com/juewuy/ShellCrash/releases/download/clash.meta.alpha/clash-linux-$cpucore
getcore
;;
3)
crashcore=singbox
custcorelink=https://github.com/juewuy/ShellCrash/releases/download/singbox_core/singbox-linux-$cpucore
getcore
;;
4)
read -p "请输入自定义内核的链接地址(必须是二进制文件) > " link
[ -n "$link" ] && custcorelink="$link"
crashcore=unknow
getcore
;;
*)
errornum
;;
esac
}
setcore(){
#获取核心及版本信息
@ -1020,7 +1010,15 @@ setcore(){
getcore
;;
5)
setcustcore
echo -----------------------------------------------
echo -e "\033[36m自定义内核均未经过适配可能存在部分功能不兼容的问题\033[0m"
echo -e "\033[36m如你不熟悉相关内核的运行机制请使用脚本已经适配过的内核\033[0m"
echo -e "\033[36m自定义内核不兼容小闪存模式且下载可能依赖服务\033[0m"
echo -e "\033[33m继续后如出现任何问题请务必自行解决一切提问恕不受理\033[0m"
echo -----------------------------------------------
sleep 1
read -p "我确认遇到问题可以自行解决[1/0] > " res
[ "$res" = '1' ] && setcustcore
;;
6)
setcpucore
@ -1072,9 +1070,11 @@ setcustgeo(){
sleep 1
}
checkcustgeo(){
[ "$api_tag" = "latest" ] && api_url=latest || api_url="tags/$api_tag"
[ ! -s ${TMPDIR}/geo.list ] && {
echo -e "\033[32m正在查找可更新的数据库文件\033[0m"
${CRASHDIR}/start.sh webget ${TMPDIR}/github_api https://api.github.com/repos/$project/releases/latest
${CRASHDIR}/start.sh webget ${TMPDIR}/github_api https://api.github.com/repos/${project}/releases/${api_url}
release_tag=$(cat ${TMPDIR}/github_api | grep '"tag_name":' | awk -F '"' '{print $4}')
cat ${TMPDIR}/github_api | grep "browser_download_url" | grep -oE 'releases/download.*' | grep -oiE 'geosite.*\.dat"$|country.*\.mmdb"$|geosite.*\.db"$|geoip.*\.db"$' | sed 's/"//' > ${TMPDIR}/geo.list
rm -rf ${TMPDIR}/github_api
}
@ -1095,9 +1095,7 @@ setcustgeo(){
[ -n "$(echo $geotype | grep -oiE 'Country.*mmdb')" ] && geoname=Country.mmdb
[ -n "$(echo $geotype | grep -oiE 'geosite.*db')" ] && geoname=geosite.db
[ -n "$(echo $geotype | grep -oiE 'geoip.*db')" ] && geoname=geoip.db
[ -n "$(pidof CrashCore)" ] && \
custgeolink=https://raw.githubusercontent.com/${project}/release/$geotype || \
custgeolink=https://fastly.jsdelivr.net/gh/${project}@release/$geotype
custgeolink=https://github.com/${project}/releases/download/${release_tag}/${geotype}
getcustgeo
checkcustgeo
else
@ -1115,60 +1113,63 @@ setcustgeo(){
}
rm -rf ${TMPDIR}/geo.list
echo -----------------------------------------------
echo -e "\033[36m自定义数据库需要调用第三方地址请尽量在服务启动后更新\033[0m"
echo -e "\033[36m自定义数据库不兼容小闪存模式也不支持自动更新\033[0m"
echo -e "\033[33m继续后如出现任何问题请务必自行解决一切提问恕不受理\033[0m"
echo -e "\033[36m此处数据库均源自互联网采集此处致谢各位作者\033[0m"
echo -e "\033[32m请点击或复制链接前往项目页面查看具体说明\033[0m"
echo -e "\033[33m如遇到网络错误请先启动ShellCrash服务\033[0m"
echo -e "\033[0m请选择需要更新的数据库项目来源\033[0m"
echo -----------------------------------------------
read -p "我确认遇到问题可以自行解决[1/0] > " res
[ "$res" = '1' ] && {
echo -----------------------------------------------
echo -e "\033[36m此处数据库均源自互联网采集此处致谢各位作者\033[0m"
echo -e "\033[32m请点击或复制链接前往项目页面查看具体说明\033[0m"
echo -e "\033[33m如遇到网络错误请先启动ShellCrash服务\033[0m"
echo -e "\033[0m请选择需要更新的数据库项目来源\033[0m"
echo -----------------------------------------------
echo -e " 1 \033[36;4mhttps://github.com/MetaCubeX/meta-rules-dat\033[0m (Clash及SingBox)"
#echo -e " 2 \033[36;4mhttps://github.com/DustinWin/clash-geosite\033[0m (Clash及SingBox)"
echo -e " 3 \033[36;4mhttps://github.com/lyc8503/sing-box-rules\033[0m (仅限SingBox)"
echo -e " 4 \033[36;4mhttps://github.com/Loyalsoldier/geoip\033[0m (仅限Clash-GeoIP)"
echo -----------------------------------------------
echo -e " 9 \033[33m自定义数据库链接 \033[0m"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
0)
;;
1)
project=MetaCubeX/meta-rules-dat
checkcustgeo
setcustgeo
;;
2)
project=DustinWin/clash-geosite
checkcustgeo
setcustgeo
;;
3)
project=lyc8503/sing-box-rules
checkcustgeo
setcustgeo
;;
4)
project=Loyalsoldier/geoip
checkcustgeo
setcustgeo
;;
9)
read -p "请输入自定义数据库的链接地址 > " link
[ -n "$link" ] && custgeolink="$link"
getgeo
setcustgeo
;;
*)
errornum
;;
esac
}
echo -e " 1 \033[36;4mhttps://github.com/MetaCubeX/meta-rules-dat\033[0m (Clash及SingBox)"
echo -e " 2 \033[36;4mhttps://github.com/DustinWin/ruleset_geodata\033[0m (仅限Clash)"
echo -e " 3 \033[36;4mhttps://github.com/DustinWin/ruleset_geodata\033[0m (仅限SingBox)"
echo -e " 4 \033[36;4mhttps://github.com/lyc8503/sing-box-rules\033[0m (仅限SingBox)"
echo -e " 5 \033[36;4mhttps://github.com/Loyalsoldier/geoip\033[0m (仅限Clash-GeoIP)"
echo -----------------------------------------------
echo -e " 9 \033[33m自定义数据库链接 \033[0m"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
0)
;;
1)
project=MetaCubeX/meta-rules-dat
api_tag=latest
checkcustgeo
setcustgeo
;;
2)
project=DustinWin/ruleset_geodata
api_tag=clash
checkcustgeo
setcustgeo
;;
3)
project=DustinWin/ruleset_geodata
api_tag=sing-box
checkcustgeo
setcustgeo
;;
4)
project=lyc8503/sing-box-rules
api_tag=latest
checkcustgeo
setcustgeo
;;
5)
project=Loyalsoldier/geoip
api_tag=latest
checkcustgeo
setcustgeo
;;
9)
read -p "请输入自定义数据库的链接地址 > " link
[ -n "$link" ] && custgeolink="$link"
getgeo
setcustgeo
;;
*)
errornum
;;
esac
}
setgeo(){
source $CFG_PATH > /dev/null
@ -1186,6 +1187,7 @@ setgeo(){
echo -e " 5 Meta完整版GeoSite数据库(约5mb) \033[33m$geosite_v\033[0m"
echo -e " 6 SingBox精简版GeoIP_cn数据库(约0.3mb) \033[33m$geoip_cn_v\033[0m"
echo -e " 7 SingBox精简版GeoSite数据库(约0.8mb) \033[33m$geosite_cn_v\033[0m"
echo -----------------------------------------------
echo -e " 9 \033[32m自定义数据库\033[0m \033[33m仅限专业用户使用\033[0m"
echo " 0 返回上级菜单"
echo -----------------------------------------------
@ -1278,7 +1280,13 @@ setgeo(){
setgeo
;;
9)
setcustgeo
echo -----------------------------------------------
echo -e "\033[36m自定义数据库需要调用第三方地址请尽量在服务启动后更新\033[0m"
echo -e "\033[36m自定义数据库不兼容小闪存模式也不支持自动更新\033[0m"
echo -e "\033[33m继续后如出现任何问题请务必自行解决一切提问恕不受理\033[0m"
echo -----------------------------------------------
read -p "我确认遇到问题可以自行解决[1/0] > " res
[ "$res" = '1' ] && setcustgeo
;;
*)
errornum
@ -1482,9 +1490,9 @@ setserver(){
echo -----------------------------------------------
grep -E "^1|$release_name" ${CRASHDIR}/configs/servers.list | awk '{print " "NR" "$2}'
echo -----------------------------------------------
echo -e " a 切换至\033[32m稳定版\033[0m"
echo -e " b 切换至\033[36m公测版\033[0m"
echo -e " c 切换至\033[33m开发版\033[0m"
echo -e " a 切换至\033[32m稳定版-stable\033[0m"
echo -e " b 切换至\033[36m公测版-master\033[0m"
echo -e " c 切换至\033[33m开发版-dev\033[0m"
echo -----------------------------------------------
echo -e " d 自定义源地址(用于本地源或自建源)"
echo -e " e \033[31m版本回退\033[0m"
@ -1612,7 +1620,7 @@ update(){
sleep 1
}
echo -----------------------------------------------
echo -e " 1 更新\033[36m管理脚本 \033[33m$versionsh_l\033[0m > \033[32m$version_new\033[0m"
echo -e " 1 更新\033[36m管理脚本 \033[33m$versionsh_l\033[0m > \033[32m$version_new \033[36m$release_type\033[0m"
echo -e " 2 切换\033[33m内核文件 \033[33m$core_v\033[0m > \033[32m$core_v_new\033[0m"
echo -e " 3 更新\033[32m数据库文件\033[0m"
echo -e " 4 安装本地\033[35mDashboard\033[0m面板"

View File

@ -1,7 +1,7 @@
#!/bin/sh
# Copyright (C) Juewuy
version=1.8.7d
version=1.8.7e
setdir(){
dir_avail(){
@ -177,17 +177,19 @@ for file in start.sh task.sh ;do
done
setconfig versionsh_l $version
#生成用于执行systemd及procd服务的变量文件
TMPDIR='/tmp/ShellCrash'
BINDIR=${CRASHDIR}
touch ${CRASHDIR}/configs/command.env
setconfig TMPDIR ${TMPDIR} ${CRASHDIR}/configs/command.env
setconfig BINDIR ${BINDIR} ${CRASHDIR}/configs/command.env
if [ -x ${CRASHDIR}/CrashCore ] && [ -n "$(grep 'crashcore=singbox' ${CRASHDIR}/configs/ShellCrash.cfg)" ];then
COMMAND='"$BINDIR/CrashCore run -D $BINDIR -c $TMPDIR/config.json"'
else
COMMAND='"$BINDIR/CrashCore -d $BINDIR -f $TMPDIR/config.yaml"'
fi
setconfig COMMAND "$COMMAND" ${CRASHDIR}/configs/command.env
[ ! -f ${CRASHDIR}/configs/command.env ] && {
TMPDIR='/tmp/ShellCrash'
BINDIR=${CRASHDIR}
touch ${CRASHDIR}/configs/command.env
setconfig TMPDIR ${TMPDIR} ${CRASHDIR}/configs/command.env
setconfig BINDIR ${BINDIR} ${CRASHDIR}/configs/command.env
if [ -x ${CRASHDIR}/CrashCore ] && [ -n "$(grep 'crashcore=singbox' ${CRASHDIR}/configs/ShellCrash.cfg)" ];then
COMMAND='"$BINDIR/CrashCore run -D $BINDIR -c $TMPDIR/config.json"'
else
COMMAND='"$BINDIR/CrashCore -d $BINDIR -f $TMPDIR/config.yaml"'
fi
setconfig COMMAND "$COMMAND" ${CRASHDIR}/configs/command.env
}
#设置更新地址
[ -n "$url" ] && setconfig update_url $url
#设置环境变量
@ -271,6 +273,7 @@ chmod 755 ${CRASHDIR}/task/task.sh
#旧版文件清理
rm -rf /etc/init.d/clash
rm -rf $CRASHDIR/clashservice
rm -rf $CRASHDIR/core.new
rm -rf $CRASHDIR/shellcrash.rc
rm -rf $CRASHDIR/clash.sh
for file in log shellcrash.service mark? mark.bak;do

View File

@ -1592,7 +1592,7 @@ uninstall(){
rm -rf /usr/lib/systemd/system/shellcrash.service
rm -rf /www/clash
rm -rf /tmp/ShellCrash
sed -Ei s/0:7890/7890:7890/g /etc/passwd
sed -i '/0:7890/d' /etc/passwd
userdel -r shellcrash 2>/dev/null
nvram set script_usbmount="" 2>/dev/null
nvram commit 2>/dev/null

View File

@ -34,8 +34,12 @@ getconfig(){ #获取脚本配置
[ "$common_ports" = "已开启" ] && ports="-m multiport --dports $multiport"
#内核配置文件
if [ "$crashcore" = singbox ];then
target=singbox
format=json
core_config=${CRASHDIR}/jsons/config.json
else
target=clash
format=yaml
core_config=${CRASHDIR}/yamls/config.yaml
fi
}
@ -142,7 +146,8 @@ get_bin(){ #专用于项目内部文件的下载
source ${CRASHDIR}/configs/ShellCrash.cfg >/dev/null
[ -z "$update_url" ] && update_url=https://fastly.jsdelivr.net/gh/juewuy/ShellCrash@master
if [ -n "$url_id" ];then
if [ "$url_id" = 101 ];then
[ -z "$release_type" ] && release_type=master
if [ "$url_id" = 101 -o "$url_id" = 104 ];then
url="$(grep "$url_id" ${CRASHDIR}/configs/servers.list | awk '{print $3}')@$release_type/$2" #jsdelivr特殊处理
else
url="$(grep "$url_id" ${CRASHDIR}/configs/servers.list | awk '{print $3}')/$release_type/$2"
@ -239,13 +244,6 @@ get_core_config(){ #下载内核配置文件
Config=$(grep -aE '^5' ${CRASHDIR}/configs/servers.list | sed -n ""$rule_link"p" | awk '{print $3}')
#如果传来的是Url链接则合成Https链接否则直接使用Https链接
if [ -z "$Https" ];then
if [ "$crashcore" = singbox ];then
target=singbox
format=json
else
target=clash
format=yaml
fi
#Urlencord转码处理保留字符
Url=$(echo $Url | sed 's/;/\%3B/g; s|/|\%2F|g; s/?/\%3F/g; s/:/\%3A/g; s/@/\%4O/g; s/=/\%3D/g; s/&/\%26/g')
Https="${Server}/sub?target=${target}&insert=true&new_name=true&scv=true&udp=true&exclude=${exclude}&include=${include}&url=${Url}&config=${Config}"
@ -1318,7 +1316,7 @@ web_restore(){ #还原面板节点
#设置循环检测clash面板端口
i=1
while [ -z "$test" -a "$i" -lt 20 ];do
sleep 1
sleep 2
if curl --version > /dev/null 2>&1;then
test=$(curl -s http://127.0.0.1:${db_port})
else
@ -1395,9 +1393,9 @@ core_check(){
logger "未找到【$crashcore】核心,正在下载!" 33
[ -z "$cpucore" ] && source ${CRASHDIR}/getdate.sh && getcpucore
[ -z "$cpucore" ] && logger 找不到设备的CPU信息请手动指定处理器架构类型 31 && exit 1
get_bin ${BINDIR}/core.new "bin/$crashcore/clash-linux-$cpucore"
get_bin ${TMPDIR}/core.new "bin/$crashcore/${target}-linux-$cpucore"
#校验内核
chmod +x ${BINDIR}/core.new 2>/dev/null
chmod +x ${TMPDIR}/core.new 2>/dev/null
if [ "$crashcore" = singbox ];then
core_v=$(${TMPDIR}/core.new version 2>/dev/null | grep version | awk '{print $3}')
COMMAND='"$BINDIR/CrashCore run -D $BINDIR -c $TMPDIR/config.json"'
@ -1429,13 +1427,13 @@ clash_check(){ #clash启动前检查
fi
#检测是否存在高级版规则或者tun模式
if [ "$crashcore" = "clash" ];then
[ -n "$(cat $core_config | grep -aE '^script:|proxy-providers|rule-providers|rule-set')" ] || \
[ -n "$(cat $core_config | grep -aiE '^script:|proxy-providers|rule-providers|rule-set')" ] || \
[ "$redir_mod" = "混合模式" ] || \
[ "$redir_mod" = "Tun模式" ] && {
echo -----------------------------------------------
logger "检测到高级功能!将改为使用ClashPre核心启动!" 33
logger "检测到高级功能!将改为使用meta核心启动!" 33
rm -rf ${BINDIR}/CrashCore
crashcore=clashpre
crashcore=meta
echo -----------------------------------------------
}
fi
@ -1464,6 +1462,12 @@ clash_check(){ #clash启动前检查
fi
}
singbox_check(){ #singbox启动前检查
#检测SSR节点
if [ -n "$(cat $core_config | grep -oE '"type": "ssr"')" ];then
echo -----------------------------------------------
logger "singbox以移除对SSR相关协议的支持请使用clash系内核" 33
exit 1
fi
core_check
#预下载GeoIP数据库
if [ ! -f ${BINDIR}/geoip.db ];then
@ -1526,14 +1530,8 @@ bfstart(){ #启动前
if [ "$local_proxy" = "已开启" -a -n "$(echo $local_type | grep '增强模式')" ];then
#添加shellcrash用户
if [ -z "$(id shellcrash 2>/dev/null | grep 'root')" ];then
if ckcmd userdel useradd groupmod; then
userdel shellcrash 2>/dev/null
useradd shellcrash -u 7890
groupmod shellcrash -g 7890
sed -Ei s/7890:7890/0:7890/g /etc/passwd
else
grep -qw shellcrash /etc/passwd || echo "shellcrash:x:0:7890:::" >> /etc/passwd
fi
sed -i '/0:7890/d' /etc/passwd
grep -qw shellcrash /etc/passwd || echo "shellcrash:x:0:7890:::" >> /etc/passwd
fi
#修改启动文件
if [ "$start_old" != "已开启" ];then
@ -1766,7 +1764,7 @@ webget)
getconfig
[ -n "$authentication" ] && auth="$authentication@"
export all_proxy="http://${auth}127.0.0.1:$mix_port"
url=$(echo $3 | sed 's#https://fastly.jsdelivr.net/gh/juewuy/ShellCrash[@|/]#https://raw.githubusercontent.com/juewuy/ShellCrash/#' | sed 's#https://gh.jwsc.eu.org/#https://raw.githubusercontent.com/juewuy/ShellCrash/#')
url=$(echo $3 | sed 's#https://.*jsdelivr.net/gh/juewuy/ShellCrash[@|/]#https://raw.githubusercontent.com/juewuy/ShellCrash/#' | sed 's#https://gh.jwsc.eu.org/#https://raw.githubusercontent.com/juewuy/ShellCrash/#')
else
url=$(echo $3 | sed 's#https://raw.githubusercontent.com/juewuy/ShellCrash/#https://fastly.jsdelivr.net/gh/juewuy/ShellCrash@#')
fi