~为meta内核的providers本地生成文件添加了自动跳过证书验证功能

~优化singbox内核providers生成时的ua标识
~使用systemd启动时,优化启动前逻辑,优化报错信息
~增加内核切换时自动切换dns模式的逻辑
~增加在本地没有配置文件启动时,自动使用providers生成配置的功能
~修复热更新订阅时找不到内核的bug
This commit is contained in:
juewuy
2024-02-17 19:06:42 +08:00
parent 48103e8b09
commit 2fba0f58ed
3 changed files with 26 additions and 8 deletions

View File

@@ -348,7 +348,15 @@ gen_clash_providers(){ #生成clash的providers配置文件
url: "https://www.gstatic.com/generate_204"
interval: 600
EOF
}
[ "$crashcore" = 'meta' ] && {
[ "$skip_cert" = "已开启" ] && skip_cert_verify='skip-cert-verify: true'
cat >> $TMPDIR/providers/providers.yaml <<EOF
override:
udp: true
$skip_cert_verify
EOF
}
}
if [ -z "$(grep "provider_temp_${coretype}" ${CRASHDIR}/configs/ShellCrash.cfg)" ];then
provider_temp_file=$(sed -n "1 p" ${CRASHDIR}/configs/${coretype}_providers.list | awk '{print $2}')
else
@@ -417,7 +425,7 @@ gen_singbox_providers(){ #生成singbox的providers配置文件
"healthcheck_interval": "10m",
"download_url": "${2}",
"path": "./providers/${1}.yaml",
"download_ua": "clash",
"download_ua": "clash.meta",
"download_interval": "24h",
"download_detour": "DIRECT"
},
@@ -1164,6 +1172,8 @@ setcoretype(){ #手动指定内核类型
switch_core(){ #clash与singbox内核切换
#singbox和clash内核切换时提示是否保留文件
[ "$core_new" != "$core_old" ] && {
[ "$dns_mod" = "redir_host" ] && [ "$core_old" = "clash" ] && setconfig dns_mod mix #singbox自动切换dns
[ "$dns_mod" = "mix" ] && [ "$core_old" = "singbox" ] && setconfig dns_mod fake-ip #singbox自动切换dns
echo -e "\033[33m已从$core_old内核切换至$core_new内核\033[0m"
echo -e "\033[33m二者Geo数据库及yaml/json配置文件不通用\033[0m"
read -p "是否保留相关数据库文件?(1/0) > " res

View File

@@ -175,7 +175,12 @@ start_core(){
core_config=${CRASHDIR}/yamls/config.yaml
fi
echo -----------------------------------------------
if [ -s $core_config -o -n "$Url" -o -n "$Https" ];then
if [ ! -s $core_config -a -s $CRASHDIR/configs/providers.cfg ];then
echo -e "\033[33m没有找到${crashcore}配置文件尝试生成providers配置文件\033[0m"
[ "$crashcore" = singboxp ] && coretype=singbox
[ "$crashcore" = meta -o "$crashcore" = clashpre ] && coretype=clash
source ${CRASHDIR}/getdate.sh && gen_${coretype}_providers
elif [ -s $core_config -o -n "$Url" -o -n "$Https" ];then
${CRASHDIR}/start.sh start
#设置循环检测以判定服务启动是否成功
i=1
@@ -1207,7 +1212,6 @@ normal_set(){ #基础设置
}
set_dns_mod(){
[ "$dns_mod" = mix ] && [ "$crashcore" != singbox -o "$crashcore" != singboxp ] && dns_mod=redir_host
echo -----------------------------------------------
echo -e "当前DNS运行模式为\033[47;30m $dns_mod \033[0m"
echo -e "\033[33m切换模式后需要手动重启服务以生效\033[0m"

View File

@@ -1776,8 +1776,10 @@ update_config(){ #更新订阅并重启
hotupdate(){ #热更新订阅
getconfig
get_core_config
core_check
modify_$format && \
put_save http://127.0.0.1:${db_port}/configs "{\"path\":\"${CRASHDIR}/config.$format\"}"
rm -rf ${TMPDIR}/CrashCore
}
set_proxy(){ #设置环境变量
getconfig
@@ -1807,10 +1809,12 @@ start)
elif [ -f /etc/rc.common -a "$(cat /proc/1/comm)" = "procd" ];then
/etc/init.d/shellcrash start
elif [ "$USER" = "root" -a "$(cat /proc/1/comm)" = "systemd" ];then
FragmentPath=$(systemctl show -p FragmentPath shellcrash | sed 's/FragmentPath=//')
[ -f $FragmentPath ] && setconfig ExecStart "$COMMAND >/dev/null" "$FragmentPath"
systemctl daemon-reload
systemctl start shellcrash.service || start_error
bfstart && {
FragmentPath=$(systemctl show -p FragmentPath shellcrash | sed 's/FragmentPath=//')
[ -f $FragmentPath ] && setconfig ExecStart "$COMMAND >/dev/null" "$FragmentPath"
systemctl daemon-reload
systemctl start shellcrash.service || start_error
}
else
bfstart && start_old
fi