Merge branch 'juewuy:dev' into dev

This commit is contained in:
wangweitung
2025-12-02 13:33:52 +08:00
committed by GitHub
50 changed files with 320 additions and 320 deletions

View File

@@ -95,7 +95,7 @@ ckstatus() {
#检测系统端口占用
checkport
fi
corename=$(echo $crashcore | sed 's/singbox/SingBox/' | sed 's/clash/Clash/' | sed 's/meta/Mihomo/')
corename=$(echo $crashcore | sed 's/singboxr/SingBoxR/' | sed 's/singbox/SingBox/' | sed 's/clash/Clash/' | sed 's/meta/Mihomo/')
[ "$firewall_area" = 5 ] && corename='转发'
[ -f ${TMPDIR}/debug.log -o -f ${CRASHDIR}/debug.log -a -n "$PID" ] && auto="\033[33m并处于debug状态\033[0m"
#输出状态
@@ -180,7 +180,7 @@ startover() {
return 0
}
start_core() {
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ]; then
if echo "$crashcore" | grep -q 'singbox'; then
core_config=${CRASHDIR}/jsons/config.json
else
core_config=${CRASHDIR}/yamls/config.yaml
@@ -188,7 +188,7 @@ start_core() {
echo -----------------------------------------------
if [ ! -s $core_config -a -s $CRASHDIR/configs/providers.cfg ]; then
echo -e "\033[33m没有找到${crashcore}配置文件尝试生成providers配置文件\033[0m"
[ "$crashcore" = singboxp ] && coretype=singbox
[ "$crashcore" = singboxr ] && coretype=singbox
[ "$crashcore" = meta -o "$crashcore" = clashpre ] && coretype=clash
source ${CRASHDIR}/webget.sh && gen_${coretype}_providers
elif [ -s $core_config -o -n "$Url" -o -n "$Https" ]; then
@@ -1523,7 +1523,7 @@ set_dns_mod() { #DNS模式设置
echo -e " 不支持CN-IP绕过功能"
echo -e " 2 redir_host模式\033[32m兼容性更好\033[0m"
echo -e " 需搭配加密DNS使用"
if [ "$crashcore" = singbox ] || [ "$crashcore" = singboxp ] || [ "$crashcore" = meta ]; then
if echo "$crashcore" | grep -q 'singbox' || [ "$crashcore" = meta ]; then
echo -e " 3 mix混合模式 \033[32m内部realip外部fakeip\033[0m"
echo -e " 依赖geosite.dat/geosite-cn.srs数据库"
fi
@@ -1545,7 +1545,7 @@ set_dns_mod() { #DNS模式设置
echo -e "\033[36m已设为 $dns_mod 模式!!\033[0m"
;;
3)
if [ "$crashcore" = singbox ] || [ "$crashcore" = singboxp ] || [ "$crashcore" = meta ]; then
if echo "$crashcore" | grep -q 'singbox' || [ "$crashcore" = meta ]; then
dns_mod=mix
setconfig dns_mod $dns_mod
echo -----------------------------------------------

View File

@@ -37,7 +37,7 @@ getconfig() { #读取配置及全局变量
[ -z "$multiport" ] && multiport='22,80,143,194,443,465,587,853,993,995,5222,8080,8443'
[ "$common_ports" = "已开启" ] && ports="-m multiport --dports $multiport"
#内核配置文件
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ]; then
if echo "$crashcore" | grep -q 'singbox'; then
target=singbox
format=json
core_config="$CRASHDIR"/jsons/config.json
@@ -60,7 +60,7 @@ getconfig() { #读取配置及全局变量
[ -z "$dns_fallback" ] && dns_fallback='1.0.0.1, 8.8.4.4'
#自动生成ua
[ -z "$user_agent" -o "$user_agent" = "auto" ] && {
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then
if echo "$crashcore" | grep -q 'singbox';then
user_agent="sing-box/singbox/$core_v"
elif [ "$crashcore" = meta ];then
user_agent="clash.meta/mihomo/$core_v"
@@ -288,26 +288,31 @@ check_clash_config() { #检查clash配置文件
}
check_singbox_config() { #检查singbox配置文件
#检测节点或providers
if ! grep -qE '"(socks|http|shadowsocks(r)?|vmess|trojan|wireguard|hysteria(2)?|vless|shadowtls|tuic|ssh|tor|outbound_providers)"' "$core_config_new"; then
if ! grep -qE '"(socks|http|shadowsocks(r)?|vmess|trojan|wireguard|hysteria(2)?|vless|shadowtls|tuic|ssh|tor|providers|anytls|soduku)"' "$core_config_new"; then
echo -----------------------------------------------
logger "获取到了配置文件【$core_config_new】,但似乎并不包含正确的节点信息!" 31
echo "请尝试使用6-2或者6-3的方式生成配置文件"
exit 1
fi
#删除不兼容的旧版内容
[ "$(wc -l < "$core_config_new")" -lt 3 ] && {
sed -i 's/^.*"inbounds":/{"inbounds":/' "$core_config_new"
sed -i 's/{[^{}]*"dns-out"[^{}]*}//g' "$core_config_new"
}
#检测并去除无效策略组
[ -n "$url_type" ] && {
#获得无效策略组名称
grep -oE '\{"type":"[^"]*","tag":"[^"]*","outbounds":\["DIRECT"\]' $core_config_new | sed -n 's/.*"tag":"\([^"]*\)".*/\1/p' >"$TMPDIR"/singbox_tags
grep -oE '\{"type":"urltest","tag":"[^"]*","outbounds":\["DIRECT"\]' "$core_config_new" | sed -n 's/.*"tag":"\([^"]*\)".*/\1/p' >"$TMPDIR"/singbox_tags
#删除策略组
sed -i 's/{"type":"[^"]*","tag":"[^"]*","outbounds":\["DIRECT"\]}//g; s/{"type":"[^"]*","tag":"[^"]*","outbounds":\["DIRECT"\],"url":"[^"]*","interval":"[^"]*","tolerance":[^}]*}//g' $core_config_new
sed -i 's/{"type":"urltest","tag":"[^"]*","outbounds":\["DIRECT"\]}//g; s/{"type":"[^"]*","tag":"[^"]*","outbounds":\["DIRECT"\],"url":"[^"]*","interval":"[^"]*","tolerance":[^}]*}//g' "$core_config_new"
#删除全部包含策略组名称的规则
while read line; do
sed -i "s/\"$line\"//g" $core_config_new
sed -i "s/\"$line\"//g" "$core_config_new"
done <"$TMPDIR"/singbox_tags
rm -rf "$TMPDIR"/singbox_tags
#删除多余逗号
sed -i 's/,\+/,/g; s/\[,/\[/g; s/,]/]/g' $core_config_new
}
#清理多余逗号
sed -i 's/,\+/,/g; s/\[,/\[/g; s/,]/]/g' "$core_config_new"
}
get_core_config() { #下载内核配置文件
[ -z "$rule_link" ] && rule_link=1
@@ -359,7 +364,7 @@ get_core_config() { #下载内核配置文件
fi
else
Https=""
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ]; then
if echo "$crashcore" | grep -q 'singbox'; then
check_singbox_config
else
check_clash_config
@@ -459,6 +464,7 @@ EOF
hosts:
'time.android.com': 203.107.6.88
'time.facebook.com': 203.107.6.88
'services.googleapis.cn': services.googleapis.com
EOF
#加载本机hosts
sys_hosts=/etc/hosts
@@ -595,7 +601,7 @@ EOF
rm -f "$TMPDIR"/${char}.yaml
done
}
modify_json() { #修饰singbox配置文件
modify_json() { #修饰singbox1.13配置文件
#生成log.json
cat >"$TMPDIR"/jsons/log.json <<EOF
{ "log": { "level": "info", "timestamp": true } }
@@ -605,29 +611,35 @@ EOF
sys_hosts=/etc/hosts
[ -s /data/etc/custom_hosts ] && sys_hosts=/data/etc/custom_hosts
#NTP劫持
[ -s $sys_hosts ] && {
sed -i '/203.107.6.88/d' $sys_hosts
cat >>$sys_hosts <<EOF
203.107.6.88 time.android.com
203.107.6.88 time.facebook.com
EOF
hosts_domain=$(cat $sys_hosts | grep -E "^([0-9]{1,3}[\.]){3}" | awk '{printf "\"%s\", ", $2}' | sed 's/, $//')
cat >"$TMPDIR"/jsons/add_hosts.json <<EOF
cat >"$TMPDIR"/jsons/add_hosts.json <<EOF
{
"dns": {
"servers": [
{ "tag": "hosts_local", "address": "local", "detour": "DIRECT" }
],
{
"type": "hosts",
"tag": "hosts",
"path": [
"$sys_hosts",
"$HOME/.hosts"
],
"predefined": {
"localhost": [
"127.0.0.1",
"::1"
],
"time.android.com": "203.107.6.88",
"time.facebook.com": "203.107.6.88"
}
}
],
"rules": [
{
"domain": [$hosts_domain],
"server": "hosts_local"
"ip_accept_any": true,
"server": "hosts"
}
]
}
]}
}
EOF
}
fi
#生成dns.json
dns_direct=$(echo $dns_nameserver | awk -F ',' '{print $1}')
@@ -683,47 +695,73 @@ EOF
"servers": [
{
"tag": "dns_proxy",
"address": "$dns_proxy",
"strategy": "$strategy",
"address_resolver": "dns_resolver"
"type": "udp",
"server": "$dns_proxy",
"domain_resolver": "dns_resolver"
},
{
"tag": "dns_direct",
"address": "$dns_direct",
"strategy": "$strategy",
"address_resolver": "dns_resolver",
"detour": "DIRECT"
"type": "udp",
"server": "$dns_direct",
"domain_resolver": "dns_resolver"
},
{ "tag": "dns_fakeip", "address": "fakeip" },
{ "tag": "dns_resolver", "address": "223.5.5.5", "detour": "DIRECT" },
{ "tag": "block", "address": "rcode://success" },
{ "tag": "local", "address": "local", "detour": "DIRECT" }
{
"tag": "dns_fakeip",
"type": "fakeip",
"inet4_range": "198.18.0.0/15",
"inet6_range": "fc00::/18"
},
{
"tag": "dns_resolver",
"type": "udp",
"server": "223.5.5.5"
},
{
"tag": "local",
"type": "local",
}
],
"rules": [
{ "outbound": ["any"], "server": "dns_direct" },
{ "clash_mode": "Global", "server": "$global_dns", "rewrite_ttl": 1 },
{ "clash_mode": "Direct", "server": "dns_direct" },
{ "clash_mode": "Global", "server": "$global_dns", "strategy": "$strategy", "disable_cache": true },
{ "clash_mode": "Direct", "server": "dns_direct", "strategy": "$strategy", "disable_cache": true },
{ "domain_suffix": ["services.googleapis.cn"], "server": "dns_fakeip" },
$fake_ip_filter_domain
$fake_ip_filter_suffix
$fake_ip_filter_regex
$direct_dns
{ "query_type": [ "A", "AAAA" ], "server": "dns_fakeip", "rewrite_ttl": 1 }
{ "query_type": ["A", "AAAA"], "server": "dns_fakeip", "strategy": "$strategy", "disable_cache": true, "rewrite_ttl": 1 }
],
"strategy": "$strategy",
"final": "dns_proxy",
"independent_cache": true,
"reverse_mapping": true,
"fakeip": { "enabled": true, "inet4_range": "28.0.0.1/8", "inet6_range": "fc00::/16" }
"reverse_mapping": true
}
}
EOF
#生成add_route.json
#域名嗅探配置
[ "$sniffer" = "已启用" ] && sniffer_set='{ "inbound": [ "redirect-in", "tproxy-in", "tun-in" ], "action": "sniff", "timeout": "500ms" },'
cat >"$TMPDIR"/jsons/add_route.json <<EOF
{
"route": {
"rules": [
{ "inbound": "dns-in", "outbound": "dns-out" }
],
"default_mark": $routing_mark
"default_domain_resolver": {
"server": "dns_direct",
"strategy": "prefer_ipv4"
},
"default_mark": $routing_mark,
"rules": [
{ "inbound": [ "dns-in" ], "action": "hijack-dns" },
$sniffer_set
{ "protocol": "dns", "action": "hijack-dns" },
{ "clash_mode": [ "Direct" ], "outbound": "DIRECT" },
{ "clash_mode": [ "Global" ], "outbound": "GLOBAL" }
]
}
}
EOF
@@ -739,14 +777,20 @@ EOF
# }
# }
# EOF
#生成certificate.json
cat >"$TMPDIR"/jsons/certificate.json <<EOF
{
"certificate": {
"store": "mozilla"
}
}
EOF
#生成inbounds.json
[ -n "$authentication" ] && {
username=$(echo $authentication | awk -F ':' '{print $1}') #混合端口账号密码
password=$(echo $authentication | awk -F ':' '{print $2}')
userpass='"users": [{ "username": "'$username'", "password": "'$password'" }], '
}
[ "$sniffer" = "已启用" ] && sniffer=true || sniffer=false #域名嗅探配置
#[ "$crashcore" = singboxp ] && always_resolve_udp='"always_resolve_udp": true,'
cat >"$TMPDIR"/jsons/inbounds.json <<EOF
{
"inbounds": [
@@ -754,9 +798,8 @@ EOF
"type": "mixed",
"tag": "mixed-in",
"listen": "::",
"listen_port": $mix_port,
$userpass
"sniff": false
"listen_port": $mix_port
},
{
"type": "direct",
@@ -768,17 +811,13 @@ EOF
"type": "redirect",
"tag": "redirect-in",
"listen": "::",
"listen_port": $redir_port,
"sniff": true,
"sniff_override_destination": $sniffer
"listen_port": $redir_port
},
{
"type": "tproxy",
"tag": "tproxy-in",
"listen": "::",
"listen_port": $tproxy_port,
"sniff": true,
"sniff_override_destination": $sniffer
"listen_port": $tproxy_port
}
]
}
@@ -797,9 +836,7 @@ EOF
"172.18.0.1/30"
],
"auto_route": false,
"stack": "system",
"sniff": true,
"sniff_override_destination": $sniffer
"stack": "system"
}
]
}
@@ -808,15 +845,12 @@ EOF
#生成add_outbounds.json
[ -z "$(cat "$CRASHDIR"/jsons/*.json | grep -oE '"tag" *: *"DIRECT"')" ] && add_direct='{ "tag": "DIRECT", "type": "direct" }'
[ -z "$(cat "$CRASHDIR"/jsons/*.json | grep -oE '"tag" *: *"REJECT"')" ] && add_reject='{ "tag": "REJECT", "type": "block" }'
[ -z "$(cat "$CRASHDIR"/jsons/*.json | grep -oE '"tag" *: *"dns-out"')" ] && add_dnsout='{ "tag": "dns-out", "type": "dns" }'
[ -n "$add_direct" -a -n "$add_reject" ] && add_direct="${add_direct},"
[ -n "$add_reject" -a -n "$add_dnsout" ] && add_reject="${add_reject},"
[ -n "$add_direct" -o -n "$add_reject" -o -n "$add_dnsout" ] && cat >"$TMPDIR"/jsons/add_outbounds.json <<EOF
[ -n "$add_direct" -o -n "$add_reject" ] && cat >"$TMPDIR"/jsons/add_outbounds.json <<EOF
{
"outbounds": [
$add_direct
$add_reject
$add_dnsout
]
}
EOF
@@ -856,14 +890,14 @@ EOF
sed '$s/,$/ ] } }/' >"$TMPDIR"/jsons/cust_add_rules.json
[ ! -s "$TMPDIR"/jsons/cust_add_rules.json ] && rm -rf "$TMPDIR"/jsons/cust_add_rules.json
}
#提取配置文件以获得outbounds.json,outbound_providers.json及route.json
#提取配置文件以获得outbounds.json,providers.json及route.json
"$TMPDIR"/CrashCore format -c $core_config >"$TMPDIR"/format.json
echo '{' >"$TMPDIR"/jsons/outbounds.json
echo '{' >"$TMPDIR"/jsons/route.json
cat "$TMPDIR"/format.json | sed -n '/"outbounds":/,/^ "[a-z]/p' | sed '$d' >>"$TMPDIR"/jsons/outbounds.json
[ "$crashcore" = "singboxp" ] && {
echo '{' >"$TMPDIR"/jsons/outbound_providers.json
cat "$TMPDIR"/format.json | sed -n '/"outbound_providers":/,/^ "[a-z]/p' | sed '$d' >>"$TMPDIR"/jsons/outbound_providers.json
[ "$crashcore" = "singboxr" ] && {
echo '{' >"$TMPDIR"/jsons/providers.json
cat "$TMPDIR"/format.json | sed -n '/^ "providers":/,/^ "[a-z]/p' | sed '$d' >>"$TMPDIR"/jsons/providers.json
}
cat "$TMPDIR"/format.json | sed -n '/"route":/,/^\( "[a-z]\|}\)/p' | sed '$d' >>"$TMPDIR"/jsons/route.json
#清理route.json中的process_name规则以及"auto_detect_interface"
@@ -872,12 +906,12 @@ EOF
sed -i 's/"auto_detect_interface": true/"auto_detect_interface": false/g' "$TMPDIR"/jsons/route.json
#跳过本地tls证书验证
if [ -z "$skip_cert" -o "$skip_cert" = "已开启" ]; then
sed -i 's/"insecure": false/"insecure": true/' "$TMPDIR"/jsons/outbounds.json
sed -i 's/"insecure": false/"insecure": true/' "$TMPDIR"/jsons/outbounds.json "$TMPDIR"/jsons/providers.json
else
sed -i 's/"insecure": true/"insecure": false/' "$TMPDIR"/jsons/outbounds.json
sed -i 's/"insecure": true/"insecure": false/' "$TMPDIR"/jsons/outbounds.json "$TMPDIR"/jsons/providers.json
fi
#判断可用并修饰outbounds&outbound_providers&route.json结尾
for file in outbounds outbound_providers route; do
#判断可用并修饰outbounds&providers&route.json结尾
for file in outbounds providers route; do
if [ -n "$(grep ${file} "$TMPDIR"/jsons/${file}.json 2>/dev/null)" ]; then
sed -i 's/^ },$/ }/; s/^ ],$/ ]/' "$TMPDIR"/jsons/${file}.json
echo '}' >>"$TMPDIR"/jsons/${file}.json
@@ -893,7 +927,7 @@ EOF
mv -f "$TMPDIR"/jsons/${char}.json "$TMPDIR"/jsons_base #如果重复则临时备份
}
done
for char in others inbounds outbounds outbound_providers route rule-set; do
for char in others inbounds outbounds providers route rule-set; do
[ -s "$CRASHDIR"/jsons/${char}.json ] && {
ln -sf "$CRASHDIR"/jsons/${char}.json "$TMPDIR"/jsons/cust_${char}.json
}
@@ -1734,7 +1768,7 @@ core_check() { #检查及下载内核文件
#校验内核
tar_core "$TMPDIR"/CrashCore.tar.gz core_new
chmod +x "$TMPDIR"/core_new
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ]; then
if echo "$crashcore" | grep -q 'singbox'; then
core_v=$("$TMPDIR"/core_new version 2>/dev/null | grep version | awk '{print $3}')
COMMAND='"$TMPDIR/CrashCore run -D $BINDIR -C $TMPDIR/jsons"'
else
@@ -1788,8 +1822,8 @@ clash_check() { #clash启动前检查
return 0
}
singbox_check() { #singbox启动前检查
#检测PuerNya专属功能
[ "$crashcore" != "singboxp" ] && [ -n "$(cat "$CRASHDIR"/jsons/*.json | grep -oE '"shadowsocksr"|"outbound_providers"')" ] && core_exchange singboxp 'PuerNya内核专属功能'
#检测singboxr专属功能
[ "$crashcore" != "singboxr" ] && [ -n "$(cat "$CRASHDIR"/jsons/*.json | grep -oE '"shadowsocksr"|"providers"')" ] && core_exchange singboxr 'singboxr内核专属功能'
core_check
#预下载geoip-cn.srs数据库
[ -n "$(cat "$CRASHDIR"/jsons/*.json | grep -oEi '"rule_set" *: *"geoip-cn"')" ] && ckgeo geoip-cn.srs srs_geoip_cn.srs
@@ -1834,7 +1868,7 @@ bfstart() { #启动前
[ ! -s "$BINDIR"/ui/index.html ] && makehtml #如没有面板则创建跳转界面
catpac #生成pac文件
#内核及内核配置文件检查
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ]; then
if echo "$crashcore" | grep -q 'singbox'; then
singbox_check
[ -d "$TMPDIR"/jsons ] && rm -rf "$TMPDIR"/jsons/* || mkdir -p "$TMPDIR"/jsons #准备目录
[ "$disoverride" != "1" ] && modify_json || ln -sf $core_config "$TMPDIR"/jsons/config.json
@@ -2012,6 +2046,9 @@ stop)
unset_proxy #禁用本机代理
fi
PID=$(pidof CrashCore) && [ -n "$PID" ] && kill -9 $PID >/dev/null 2>&1
#清理缓存目录
rm -rf "$TMPDIR"/crash_start_time
rm -rf "$TMPDIR"/CrashCore.tar.gz
;;
restart)
$0 stop
@@ -2029,7 +2066,7 @@ debug)
stop_firewall >/dev/null #清理路由策略
bfstart
if [ -n "$2" ]; then
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ]; then
if echo "$crashcore" | grep -q 'singbox'; then
sed -i "s/\"level\": \"info\"/\"level\": \"$2\"/" "$TMPDIR"/jsons/log.json 2>/dev/null
else
sed -i "s/log-level: info/log-level: $2/" "$TMPDIR"/config.yaml

View File

@@ -32,7 +32,7 @@ update_core(){ #自动更新内核
logger "任务【自动更新内核】中止-未检测到版本更新"
exit 1
else
[ "$crashcore" = singbox -o "$crashcore" = singboxp ] && core_new=singbox || core_new=clash
echo "$crashcore" | grep -q 'singbox' && core_new=singbox || core_new=clash
if [ -n "$custcorelink" ];then
zip_type=$(echo $custcorelink | grep -oE 'tar.gz$')
[ -z "$zip_type" ] && zip_type=$(echo $custcorelink | grep -oE 'gz$')
@@ -60,7 +60,7 @@ update_core(){ #自动更新内核
[ -f ${TMPDIR}/core_new.gz ] && gunzip ${TMPDIR}/core_new.gz >/dev/null && rm -rf ${TMPDIR}/core_new.gz
chmod +x ${TMPDIR}/core_new
[ "$crashcore" = unknow ] && setcoretype
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then
if echo "$crashcore" | grep -q 'singbox';then
core_v=$(${TMPDIR}/core_new version 2>/dev/null | grep version | awk '{print $3}')
else
core_v=$(${TMPDIR}/core_new -v 2>/dev/null | head -n 1 | sed 's/ linux.*//;s/.* //')

View File

@@ -96,7 +96,7 @@ setrules(){ #自定义规则
echo -e " 1 新增自定义规则"
echo -e " 2 移除自定义规则"
echo -e " 3 清空规则列表"
[ "$crashcore" = singbox -o "$crashcore" = singboxp ] || echo -e " 4 配置节点绕过: \033[36m$proxies_bypass\033[0m"
echo "$crashcore" | grep -q 'singbox' || echo -e " 4 配置节点绕过: \033[36m$proxies_bypass\033[0m"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case $num in
@@ -441,27 +441,34 @@ gen_singbox_providers(){ #生成singbox的providers配置文件
{
"tag": "${1}",
"type": "local",
"healthcheck_url": "https://www.gstatic.com/generate_204",
"healthcheck_interval": "10m",
"path": "${2}"
},
"path": "${2}",
EOF
else
cat >> ${TMPDIR}/providers/providers.json <<EOF
{
"tag": "${1}",
"type": "remote",
"healthcheck_url": "https://www.gstatic.com/generate_204",
"healthcheck_interval": "10m",
"download_url": "${2}",
"url": "${2}",
"path": "./providers/${1}.yaml",
"download_ua": "clash.meta",
"download_interval": "24h",
"download_detour": "DIRECT"
},
"user_agent": "clash.meta;mihomo",
"update_interval": "24h",
EOF
fi
#通用部分生成
[ "$skip_cert" != "未开启" ] && override_tls='true' || override_tls='false'
cat >> ${TMPDIR}/providers/providers.json <<EOF
"health_check": {
"enabled": true,
"url": "https://www.gstatic.com/generate_204",
"interval": "10m",
"timeout": "3s"
},
"override_tls": {
"enabled": true,
"insecure": $override_tls
}
},
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}')
@@ -485,7 +492,7 @@ EOF
#预创建文件并写入对应文件头
cat > ${TMPDIR}/providers/providers.json <<EOF
{
"outbound_providers": [
"providers": [
EOF
cat > ${TMPDIR}/providers/outbounds_add.json <<EOF
{
@@ -495,7 +502,7 @@ EOF
if [ -n "$2" ];then
gen_singbox_providers_txt $1 $2
providers_tags=\"$1\"
echo '{ "tag": "'${1}'", "type": "urltest", "tolerance": 100, "providers": "'${1}'", "includes": ".*" },' >> ${TMPDIR}/providers/outbounds_add.json
echo '{ "tag": "'${1}'", "type": "urltest", "tolerance": 100, "providers": ["'${1}'"], "include": ".*" },' >> ${TMPDIR}/providers/outbounds_add.json
else
providers_tags=''
while read line;do
@@ -503,14 +510,14 @@ EOF
url=$(echo $line | awk '{print $2}')
providers_tags=$(echo "$providers_tags, \"$tag\"" | sed 's/^, //')
gen_singbox_providers_txt $tag $url
echo '{ "tag": "'${tag}'", "type": "urltest", "tolerance": 100, "providers": "'${tag}'", "includes": ".*" },' >> ${TMPDIR}/providers/outbounds_add.json
echo '{ "tag": "'${tag}'", "type": "urltest", "tolerance": 100, "providers": ["'${tag}'"], "include": ".*" },' >> ${TMPDIR}/providers/outbounds_add.json
done < ${CRASHDIR}/configs/providers.cfg
fi
#修复文件格式
sed -i '$s/},/}]}/' ${TMPDIR}/providers/outbounds_add.json
sed -i '$s/},/}]}/' ${TMPDIR}/providers/providers.json
#使用模版生成outbounds和rules模块
cat ${TMPDIR}/provider_temp_file | sed "s/{providers_tags}/$providers_tags/g" >> ${TMPDIR}/providers/outbounds.json
cat ${TMPDIR}/provider_temp_file | sed "s/{providers_tags}/$providers_tags/g" > ${TMPDIR}/providers/outbounds.json
rm -rf ${TMPDIR}/provider_temp_file
#调用内核测试
${CRASHDIR}/start.sh core_check && ${TMPDIR}/CrashCore merge ${TMPDIR}/config.json -C ${TMPDIR}/providers
@@ -541,7 +548,6 @@ setproviders(){ #自定义providers
echo -----------------------------------------------
echo -e "\033[33m你可以在这里快捷管理与生成自定义的providers服务商\033[0m"
echo -e "\033[33m支持在线及本地的Yaml格式配置导入\033[0m"
echo -e "\033[36msingboxp内核暂不支持跳过证书验证功能\033[0m"
[ -s $CRASHDIR/configs/providers.cfg ] && {
echo -----------------------------------------------
echo -e "\033[36m输入对应数字可管理providers服务商\033[0m"
@@ -634,7 +640,7 @@ setproviders(){ #自定义providers
c)
echo -----------------------------------------------
if [ -s $CRASHDIR/configs/providers.cfg ];then
echo -e "\033[33msingboxp与mihomo内核的providers配置文件不互通\033[0m"
echo -e "\033[33msingboxr与mihomo内核的providers配置文件不互通\033[0m"
echo -----------------------------------------------
read -p "确认生成${coretype}配置文件?(1/0) > " res
[ "$res" = "1" ] && {
@@ -743,7 +749,7 @@ override(){ #配置文件覆写
echo -----------------------------------------------
echo -e " 1 自定义\033[32m端口及秘钥\033[0m"
echo -e " 2 管理\033[36m自定义规则\033[0m"
[ "$crashcore" = singbox -o "$crashcore" = singboxp ] || {
echo "$crashcore" | grep -q 'singbox' || {
echo -e " 3 管理\033[33m自定义节点\033[0m"
echo -e " 4 管理\033[36m自定义策略组\033[0m"
}
@@ -782,7 +788,7 @@ override(){ #配置文件覆写
override
;;
5)
[ "$crashcore" = singbox -o "$crashcore" = singboxp ] && set_singbox_adv || set_clash_adv
echo "$crashcore" | grep -q 'singbox' && set_singbox_adv || set_clash_adv
sleep 3
override
;;
@@ -980,6 +986,7 @@ set_core_config_link(){ #直接导入配置
echo -----------------------------------------------
echo -e "注意:\033[31m此功能不兼容“跳过证书验证”功能部分老旧\n设备可能出现x509报错导致节点不通\033[0m"
echo -e "你也可以搭配在线订阅转换网站或者自建SubStore使用"
echo "$crashcore" | grep -q 'singbox' &&echo -e "singbox内核建议使用\033[32;4mhttps://subv.jwsc.eu.org/\033[0m转换"
echo -----------------------------------------------
echo -e "\033[33m0 返回上级菜单\033[0m"
echo -----------------------------------------------
@@ -1015,7 +1022,7 @@ set_core_config_link(){ #直接导入配置
set_core_config(){ #配置文件功能
[ -z "$rule_link" ] && rule_link=1
[ -z "$server_link" ] && server_link=1
[ "$crashcore" = singbox -o "$crashcore" = singboxp ] && config_path=${JSONSDIR}/config.json || config_path=${YAMLSDIR}/config.yaml
echo "$crashcore" | grep -q 'singbox' && config_path=${JSONSDIR}/config.json || config_path=${YAMLSDIR}/config.yaml
echo -----------------------------------------------
echo -e "\033[30;47m ShellCrash配置文件管理\033[0m"
echo -----------------------------------------------
@@ -1069,7 +1076,7 @@ set_core_config(){ #配置文件功能
if [ "$crashcore" = meta -o "$crashcore" = clashpre ];then
coretype=clash
setproviders
elif [ "$crashcore" = singboxp ];then
elif [ "$crashcore" = singboxr ];then
coretype=singbox
setproviders
else
@@ -1247,22 +1254,22 @@ setcpucore(){ #手动设置内核架构
fi
}
setcoretype(){ #手动指定内核类型
[ "$crashcore" = singbox -o "$crashcore" = singboxp ] && core_old=singbox || core_old=clash
echo "$crashcore" | grep -q 'singbox' && core_old=singbox || core_old=clash
echo -e "\033[33m请确认该自定义内核的类型\033[0m"
echo -e " 1 Clash基础内核"
echo -e " 2 Clash-Premium内核"
echo -e " 3 Clash-Meta内核"
echo -e " 4 Sing-Box内核"
echo -e " 5 Sing-Box-Puer内核"
echo -e " 5 Sing-Box-reF1nd内核"
read -p "请输入对应数字 > " num
case "$num" in
2) crashcore=clashpre ;;
3) crashcore=meta ;;
4) crashcore=singbox ;;
5) crashcore=singboxp ;;
5) crashcore=singboxr ;;
*) crashcore=clash ;;
esac
[ "$crashcore" = singbox -o "$crashcore" = singboxp ] && core_new=singbox || core_new=clash
echo "$crashcore" | grep -q 'singbox' && core_new=singbox || core_new=clash
}
switch_core(){ #clash与singbox内核切换
#singbox和clash内核切换时提示是否保留文件
@@ -1289,7 +1296,7 @@ switch_core(){ #clash与singbox内核切换
done
}
}
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then
if echo "$crashcore" | grep -q 'singbox';then
COMMAND='"$TMPDIR/CrashCore run -D $BINDIR -C $TMPDIR/jsons"'
else
COMMAND='"$TMPDIR/CrashCore -d $BINDIR -f $TMPDIR/config.yaml"'
@@ -1297,9 +1304,9 @@ switch_core(){ #clash与singbox内核切换
setconfig COMMAND "$COMMAND" ${CRASHDIR}/configs/command.env && source ${CRASHDIR}/configs/command.env
}
getcore(){ #下载内核文件
[ -z "$crashcore" ] && crashcore=singbox
[ -z "$crashcore" ] && crashcore=meta
[ -z "$cpucore" ] && getcpucore
[ "$crashcore" = singbox -o "$crashcore" = singboxp ] && core_new=singbox || core_new=clash
echo "$crashcore" | grep -q 'singbox' && core_new=singbox || core_new=clash
#获取在线内核文件
echo -----------------------------------------------
echo 正在在线获取$crashcore核心文件……
@@ -1333,7 +1340,7 @@ getcore(){ #下载内核文件
[ -f ${TMPDIR}/core_new.gz ] && gunzip ${TMPDIR}/core_new.gz && rm -rf ${TMPDIR}/core_new.gz
chmod +x ${TMPDIR}/core_new
[ "$crashcore" = unknow ] && setcoretype
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then
if echo "$crashcore" | grep -q 'singbox';then
core_v=$(${TMPDIR}/core_new version 2>/dev/null | grep version | awk '{print $3}')
else
core_v=$(${TMPDIR}/core_new -v 2>/dev/null | head -n 1 | sed 's/ linux.*//;s/.* //')
@@ -1422,10 +1429,9 @@ setcustcore(){ #自定义内核
echo -e "\033[33m请选择需要使用的核心\033[0m"
echo -e "1 \033[36mMetaCubeX/mihomo\033[32m@release\033[0m版本内核"
echo -e "2 \033[36mMetaCubeX/mihomo\033[32m@alpha\033[0m版本内核"
echo -e "3 \033[36myaling888/clash\033[32m@release\033[0m版本内核"
echo -e "4 \033[36mSagerNet/sing-box\033[32m@release\033[0m版本内核"
echo -e "5 \033[36mPuerNya/sing-box\033[0m内核(with_gvisor,with_wireguard)"
echo -e "6 \033[36mSagerNet/sing-box\033[32m@1.7.8\033[0m版本内核(不支持rule-set)"
echo -e "5 \033[36mreF1nd/sing-box\033[0m内核(with_gvisor,with_wireguard)"
echo -e "6 Clash基础内核(已停止维护)"
echo -e "7 Premium-2023.08.17内核(已停止维护)"
echo -e "a \033[33m自定义内核链接 \033[0m"
echo -----------------------------------------------
@@ -1443,12 +1449,6 @@ setcustcore(){ #自定义内核
crashcore=meta
checkcustcore
;;
3)
project=yaling888/clash
api_tag=latest
crashcore=clashpre
checkcustcore
;;
4)
project=SagerNet/sing-box
api_tag=latest
@@ -1457,14 +1457,14 @@ setcustcore(){ #自定义内核
;;
5)
project=juewuy/ShellCrash
api_tag=singbox_core_PuerNya
crashcore=singboxp
api_tag=singbox_core_reF1nd
crashcore=singboxr
checkcustcore
;;
6)
project=SagerNet/sing-box
api_tag=v1.7.8
crashcore=singbox
project=juewuy/ShellCrash
api_tag=Clash_Dreamacro
crashcore=clash
checkcustcore
;;
7)
@@ -1488,7 +1488,7 @@ setcore(){ #内核选择菜单
#获取核心及版本信息
[ -z "$crashcore" ] && crashcore="unknow"
[ ! -f ${CRASHDIR}/CrashCore.tar.gz ] && crashcore="未安装核心"
[ "$crashcore" = singbox -o "$crashcore" = singboxp ] && core_old=singbox || core_old=clash
echo "$crashcore" | grep -q 'singbox' && core_old=singbox || core_old=clash
[ -n "$custcorelink" ] && custcore="$(echo $custcorelink | sed 's#.*github.com##; s#/releases/download/#@#; s#-linux.*$##')"
###
echo -----------------------------------------------
@@ -1498,15 +1498,12 @@ setcore(){ #内核选择菜单
echo -e "\033[33m请选择需要使用的核心版本\033[0m"
echo -e "\033[36m如需本地上传请将二进制文件上传至 /tmp 目录后重新运行crash命令\033[0m"
echo -----------------------------------------------
echo -e "1 \033[43;30m Clash \033[0m \033[32m占用低\033[0m"
echo -e " >>\033[32m$clash_v \033[33m不支持Tun、Rule-set等\033[0m"
echo -e " 说明文档: \033[36;4mhttps://lancellc.gitbook.io\033[0m"
#echo -e "2 \033[43;30m SingBox \033[0m \033[32m支持全面占用低\033[0m"
#echo -e " >>\033[32m$singbox_v \033[33m不支持providers\033[0m"
#echo -e " 说明文档: \033[36;4mhttps://sing-box.sagernet.org\033[0m"
echo -e "3 \033[43;30m Mihomo \033[0m \033[32m(原meta内核)支持全面\033[0m"
echo -e "1 \033[43;30m Mihomo \033[0m \033[32m(原meta内核)支持全面\033[0m"
echo -e " >>\033[32m$meta_v \033[33m占用略高GeoSite可能不兼容华硕固件\033[0m"
echo -e " 说明文档: \033[36;4mhttps://wiki.metacubex.one\033[0m"
echo -e "2 \033[43;30m SingBoxR \033[0m \033[32m支持全面\033[0m"
echo -e " >>\033[32m$singboxr_v \033[33m使用reF1nd增强分支\033[0m"
echo -e " 说明文档: \033[36;4mhttps://sing-boxr.dustinwin.us.kg\033[0m"
#echo -e "4 \033[43;30m SingBoxP \033[0m \033[32m支持ssr、providers、dns并发……\033[0m"
#echo -e " >>\033[32m$singboxp_v \033[33mPuerNya分支版本\033[0m"
#echo -e " 说明文档: \033[36;4mhttps://sing-boxp.dustinwin.top\033[0m"
@@ -1521,16 +1518,6 @@ setcore(){ #内核选择菜单
0)
;;
1)
crashcore=clash
custcorelink=''
getcore
;;
2)
crashcore=singbox
custcorelink=''
getcore
;;
3)
[ -d "/jffs" ] && {
echo -e "\033[31mMeta内核使用的GeoSite.dat数据库在华硕设备存在被系统误删的问题可能无法使用!\033[0m"
sleep 3
@@ -1539,6 +1526,11 @@ setcore(){ #内核选择菜单
custcorelink=''
getcore
;;
2)
crashcore=singboxr
custcorelink=''
getcore
;;
4)
crashcore=singboxp
custcorelink=''
@@ -2226,8 +2218,10 @@ update(){
echo -e "感谢:\033[32msing-box项目 \033[0m作者\033[36m SagerNet\033[0m 项目地址:\033[32mhttps://github.com/SagerNet/sing-box\033[0m"
echo -e "感谢:\033[32mMetaCubeX项目 \033[0m作者\033[36m MetaCubeX\033[0m 项目地址:\033[32mhttps://github.com/MetaCubeX\033[0m"
echo -e "感谢:\033[32mYACD面板项目 \033[0m作者\033[36m haishanh\033[0m 项目地址:\033[32mhttps://github.com/haishanh/yacd\033[0m"
echo -e "感谢:\033[32mzashboard项目 \033[0m作者\033[36m Zephyruso\033[0m 项目地址:\033[32mhttps://github.com/Zephyruso/zashboard\033[0m"
echo -e "感谢:\033[32mSubconverter \033[0m作者\033[36m tindy2013\033[0m 项目地址:\033[32mhttps://github.com/tindy2013/subconverter\033[0m"
echo -e "感谢:\033[32msing-box分支项目 \033[0m作者\033[36m PuerNya\033[0m 项目地址:\033[32mhttps://github.com/PuerNya/sing-box\033[0m"
echo -e "感谢:\033[32msing-box分支项目 \033[0m作者\033[36m reF1nd\033[0m 项目地址:\033[32mhttps://github.com/reF1nd/sing-box\033[0m"
echo -e "感谢:\033[32mDustinWin相关项目 \033[0m作者\033[36m DustinWin\033[0m 作者地址:\033[32mhttps://github.com/DustinWin\033[0m"
echo -----------------------------------------------
echo -e "特别感谢:\033[36m所有帮助及赞助过此项目的同仁们\033[0m"
@@ -2410,7 +2404,7 @@ userguide(){
}
#测试菜单
debug(){
[ "$crashcore" = singbox -o "$crashcore" = singboxp ] && config_tmp=$TMPDIR/jsons || config_tmp=$TMPDIR/config.yaml
echo "$crashcore" | grep -q 'singbox' && config_tmp=$TMPDIR/jsons || config_tmp=$TMPDIR/config.yaml
echo -----------------------------------------------
echo -e "\033[36m注意Debug运行均会停止原本的内核服务\033[0m"
echo -e "后台运行日志地址:\033[32m$TMPDIR/debug.log\033[0m"
@@ -2434,7 +2428,7 @@ debug(){
1)
$CRASHDIR/start.sh stop
$CRASHDIR/start.sh bfstart
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ] ;then
if echo "$crashcore" | grep -q 'singbox' ;then
$TMPDIR/CrashCore run -D $BINDIR -C $TMPDIR/jsons &
{ sleep 4 ; kill $! >/dev/null 2>&1 & }
wait
@@ -2486,7 +2480,7 @@ debug(){
esac
}
testcommand(){
[ "$crashcore" = singbox -o "$crashcore" = singboxp ] && config_path=${JSONSDIR}/config.json || config_path=${YAMLSDIR}/config.yaml
echo "$crashcore" | grep -q 'singbox' && config_path=${JSONSDIR}/config.json || config_path=${YAMLSDIR}/config.yaml
echo -----------------------------------------------
echo -e "\033[30;47m这里是测试命令菜单\033[0m"
echo -e "\033[33m如遇问题尽量运行相应命令后截图提交issue或TG讨论组\033[0m"