8 Commits

Author SHA1 Message Date
juewuy
ff7d454432 Merge pull request #1307 from DustinWin/dev
适配 sing-box 内核规则集新特性
2026-07-20 00:06:56 +08:00
DustinWin
cc56656695 适配 sing-box 内核规则集新特性
`route.rule_set.tag` 支持了数组,修改后避免报错“cn 规则集重复”。
2026-07-18 22:47:17 +08:00
juewuy
6ed020a864 ~修复中文括号 2026-07-18 20:36:07 +08:00
juewuy
a6e6907e86 ~1.9.5beta1 pkg 2026-07-18 20:19:51 +08:00
juewuy
c71fcce870 ~给没有 CIDR 前缀的裸 IP 补 /32 2026-07-18 20:16:51 +08:00
juewuy
0f2a0b437c ~修复语法错误 2026-07-18 20:08:06 +08:00
juewuy
8b8d47c633 ~优化文件结构 2026-07-18 19:45:22 +08:00
juewuy
7df1d7aafa ~修复提示 2026-07-18 19:35:13 +08:00
8 changed files with 38 additions and 34 deletions

Binary file not shown.

View File

@@ -1,4 +1,4 @@
meta_v=v1.19.17 meta_v=v1.19.17
singboxr_v=1.13.0-alpha.27 singboxr_v=1.13.0-alpha.27
versionsh=1.9.5alpha15 versionsh=1.9.5beta1
GeoIP_v=20251205 GeoIP_v=20251205

View File

@@ -4,6 +4,8 @@
[ "$ts_service" = ON ] && ! grep -q '"tailscale"' "$CRASHDIR"/jsons/endpoints.json 2>/dev/null && { [ "$ts_service" = ON ] && ! grep -q '"tailscale"' "$CRASHDIR"/jsons/endpoints.json 2>/dev/null && {
[ "$ts_subnet" = true ] && { [ "$ts_subnet" = true ] && {
. "$CRASHDIR"/starts/fw_getlanip.sh && getlanip . "$CRASHDIR"/starts/fw_getlanip.sh && getlanip
# 给没有 CIDR 前缀的裸 IP 补 /32
host_ipv4=$(echo $host_ipv4 | awk '{for(i=1;i<=NF;i++){if($i !~ /\//){$i=$i"/32"}} print}')
advertise_routes=$(echo "$host_ipv4"|sed 's/[[:space:]]\+/", "/g; s/^/"/; s/$/"/') advertise_routes=$(echo "$host_ipv4"|sed 's/[[:space:]]\+/", "/g; s/^/"/; s/$/"/')
} }
[ -z "$ts_exit_node" ] && ts_exit_node=false [ -z "$ts_exit_node" ] && ts_exit_node=false

View File

@@ -118,12 +118,12 @@ ckstatus() {
PID=$(pidof CrashCore | awk '{print $NF}') PID=$(pidof CrashCore | awk '{print $NF}')
if [ -n "$PID" ]; then if [ -n "$PID" ]; then
run="\033[32m$MENU_RUN_ON$redir_mod$MENU_MOD\033[0m" run="\033[32m$MENU_RUN_ON ($redir_mod$MENU_MOD) \033[0m"
running_status running_status
elif [ "$firewall_area" = 5 ] && [ -n "$(ip route list table 100)" ]; then elif [ "$firewall_area" = 5 ] && [ -n "$(ip route list table 100)" ]; then
run="\033[32m$MENU_RUN_SET$redir_mod$MENU_MOD\033[0m" run="\033[32m$MENU_RUN_SET ($redir_mod$MENU_MOD) \033[0m"
else else
run="\033[31m$MENU_RUN_OFF$redir_mod$MENU_MOD\033[0m" run="\033[31m$MENU_RUN_OFF ($redir_mod$MENU_MOD) \033[0m"
# 检测系统端口占用 # 检测系统端口占用
checkport checkport
fi fi

View File

@@ -101,7 +101,7 @@ set_dns_mod() {
common_success common_success
break break
else else
msg_alert msg_alert "\033[33m$DNS_REDIR_NO_SERVICE\033[0m"
fi fi
else else
errornum errornum

View File

@@ -30,7 +30,7 @@ getlanip() { #获取局域网host地址
[ -n "$wg_ipv6" ] && wg_host_ipv6=' $wg_ipv6' [ -n "$wg_ipv6" ] && wg_host_ipv6=' $wg_ipv6'
} }
#添加自定义ipv4局域网网段 #添加自定义ipv4局域网网段
if [ "$replace_default_host_ipv4" == "ON" ]; then if [ "$replace_default_host_ipv4" = "ON" ]; then
host_ipv4="$cust_host_ipv4" host_ipv4="$cust_host_ipv4"
else else
host_ipv4=$(echo "$host_ipv4 $cust_host_ipv4$ts_host_ipv4$wg_host_ipv4" | tr '\n' ' ' | sed 's/ $//') host_ipv4=$(echo "$host_ipv4 $cust_host_ipv4$ts_host_ipv4$wg_host_ipv4" | tr '\n' ' ' | sed 's/ $//')

View File

@@ -2,7 +2,8 @@
# Copyright (C) Juewuy # Copyright (C) Juewuy
#修饰singbox配置文件 #修饰singbox配置文件
parse_singbox_dns() { #dns转换
parse_singbox_dns() { #dns转换工具
first_dns=$(echo "$1" | cut -d',' -f1 | cut -d' ' -f1) first_dns=$(echo "$1" | cut -d',' -f1 | cut -d' ' -f1)
type="" type=""
server="" server=""
@@ -41,8 +42,8 @@ parse_singbox_dns() { #dns转换
# 输出 # 输出
echo '"type": "'"$type"'", "server": "'"$server"'", "server_port": '"$port"',' echo '"type": "'"$type"'", "server": "'"$server"'", "server_port": '"$port"','
} }
extract_base_jsons() {
#提取配置文件以获得outbounds.json,providers.json及route.json extract_base_jsons() { #提取配置文件以获得outbounds.json,providers.json及route.json
"$TMPDIR"/CrashCore format -c $core_config >"$TMPDIR"/format.json "$TMPDIR"/CrashCore format -c $core_config >"$TMPDIR"/format.json
echo '{' >"$TMPDIR"/jsons/outbounds.json echo '{' >"$TMPDIR"/jsons/outbounds.json
echo '{' >"$TMPDIR"/jsons/route.json echo '{' >"$TMPDIR"/jsons/route.json
@@ -127,7 +128,7 @@ EOF
fi fi
} }
prepare_dns_config() { gen_dns() {
#生成dns.json #生成dns.json
[ "$ipv6_dns" != "OFF" ] && strategy='prefer_ipv4' || strategy='ipv4_only' [ "$ipv6_dns" != "OFF" ] && strategy='prefer_ipv4' || strategy='ipv4_only'
#获取detour出口 #获取detour出口
@@ -167,11 +168,8 @@ prepare_dns_config() {
} }
#防泄露设置 #防泄露设置
[ "$dns_protect" = "OFF" ] && sed -i 's/"server": "dns_proxy"/"server": "dns_direct"/g' "$TMPDIR"/jsons/route.json [ "$dns_protect" = "OFF" ] && sed -i 's/"server": "dns_proxy"/"server": "dns_direct"/g' "$TMPDIR"/jsons/route.json
}
generate_dns_related_jsons() {
#生成add_rule_set.json #生成add_rule_set.json
[ "$dns_mod" = "mix" ] || [ "$dns_mod" = "route" ] && ! grep -Eq '"tag" *:[[:space:]]*"cn"' "$CRASHDIR"/jsons/*.json && { [ "$dns_mod" = "mix" ] || [ "$dns_mod" = "route" ] && ! grep -Eq '"tag" *:[[:space:]]*"cn"' "$CRASHDIR"/jsons/*.json && ! grep -Eq '"tag"[[:space:]]*:[[:space:]]*\[[^]]*"cn"' "$CRASHDIR"/jsons/*.json && {
[ "$crashcore" = "singboxr" ] && srs_path='"path": "./ruleset/cn.srs",' [ "$crashcore" = "singboxr" ] && srs_path='"path": "./ruleset/cn.srs",'
cat >"$TMPDIR"/jsons/add_rule_set.json <<EOF cat >"$TMPDIR"/jsons/add_rule_set.json <<EOF
{ {
@@ -243,7 +241,7 @@ EOF
EOF EOF
} }
generate_route_and_inbounds_jsons() { gen_outbounds() {
#生成add_route.json #生成add_route.json
#域名嗅探配置 #域名嗅探配置
grep -q 'telegramip' "$TMPDIR"/jsons/route.json && telegramip_set=' "rule_set": [ "telegramip" ],' grep -q 'telegramip' "$TMPDIR"/jsons/route.json && telegramip_set=' "rule_set": [ "telegramip" ],'
@@ -264,7 +262,9 @@ generate_route_and_inbounds_jsons() {
} }
} }
EOF EOF
#生成certificate.json }
gen_certificate() { #生成certificate.json
cat >"$TMPDIR"/jsons/certificate.json <<EOF cat >"$TMPDIR"/jsons/certificate.json <<EOF
{ {
"certificate": { "certificate": {
@@ -272,7 +272,9 @@ EOF
} }
} }
EOF EOF
#生成inbounds.json }
gen_inbounds() { #生成inbounds.json
[ -n "$authentication" ] && { [ -n "$authentication" ] && {
username=$(echo $authentication | awk -F ':' '{print $1}') #混合端口账号密码 username=$(echo $authentication | awk -F ':' '{print $1}') #混合端口账号密码
password=$(echo $authentication | awk -F ':' '{print $2}') password=$(echo $authentication | awk -F ':' '{print $2}')
@@ -336,8 +338,7 @@ EOF
fi fi
} }
generate_outbounds_and_experimental_jsons() { add_outbounds() { #生成add_outbounds.json
#生成add_outbounds.json
grep -qE '"tag": "DIRECT"' "$TMPDIR"/jsons/outbounds.json || add_direct='{ "tag": "DIRECT", "type": "direct" }' grep -qE '"tag": "DIRECT"' "$TMPDIR"/jsons/outbounds.json || add_direct='{ "tag": "DIRECT", "type": "direct" }'
grep -qE '"tag": "REJECT"' "$TMPDIR"/jsons/outbounds.json || add_reject='{ "tag": "REJECT", "type": "block" }' grep -qE '"tag": "REJECT"' "$TMPDIR"/jsons/outbounds.json || add_reject='{ "tag": "REJECT", "type": "block" }'
grep -qE '"tag": "GLOBAL"' "$TMPDIR"/jsons/outbounds.json || { grep -qE '"tag": "GLOBAL"' "$TMPDIR"/jsons/outbounds.json || {
@@ -355,8 +356,9 @@ generate_outbounds_and_experimental_jsons() {
] ]
} }
EOF EOF
}
#生成experimental.json gen_experimental() { #生成experimental.json
[ "$crashcore" = "singboxr" ] && urltest_unified_delay=',"urltest_unified_delay": true' [ "$crashcore" = "singboxr" ] && urltest_unified_delay=',"urltest_unified_delay": true'
cat >"$TMPDIR"/jsons/experimental.json <<EOF cat >"$TMPDIR"/jsons/experimental.json <<EOF
{ {
@@ -373,8 +375,7 @@ EOF
EOF EOF
} }
generate_custom_rules_json() { generate_custom_rules_json() { #生成自定义规则文件
#生成自定义规则文件
[ -n "$(grep -Ev ^# "$CRASHDIR"/yamls/rules.yaml 2>/dev/null)" ] && { [ -n "$(grep -Ev ^# "$CRASHDIR"/yamls/rules.yaml 2>/dev/null)" ] && {
cat "$CRASHDIR"/yamls/rules.yaml | cat "$CRASHDIR"/yamls/rules.yaml |
sed '/#.*/d' | sed '/#.*/d' |
@@ -399,7 +400,7 @@ generate_custom_rules_json() {
} }
} }
normalize_and_finalize_jsons() { normalize_and_finalize_jsons() { #修饰文件
#清理route.json中的process_name规则以及"auto_detect_interface" #清理route.json中的process_name规则以及"auto_detect_interface"
sed -i '/"process_name": \[/,/],$/d' "$TMPDIR"/jsons/route.json sed -i '/"process_name": \[/,/],$/d' "$TMPDIR"/jsons/route.json
sed -i '/"process_name": "[^"]*",/d' "$TMPDIR"/jsons/route.json sed -i '/"process_name": "[^"]*",/d' "$TMPDIR"/jsons/route.json
@@ -421,7 +422,7 @@ normalize_and_finalize_jsons() {
done done
} }
link_custom_jsons() { link_custom_jsons() { #合并文件
#加载自定义配置文件 #加载自定义配置文件
mkdir -p "$TMPDIR"/jsons_base mkdir -p "$TMPDIR"/jsons_base
#以下为覆盖脚本的自定义文件 #以下为覆盖脚本的自定义文件
@@ -439,8 +440,7 @@ link_custom_jsons() {
done done
} }
validate_and_restore_custom_jsons() { test_json() { #测试自定义配置文件
#测试自定义配置文件
if ! error=$("$TMPDIR"/CrashCore check -D "$BINDIR" -C "$TMPDIR"/jsons 2>&1); then if ! error=$("$TMPDIR"/CrashCore check -D "$BINDIR" -C "$TMPDIR"/jsons 2>&1); then
echo $error echo $error
error_file=$(echo $error | grep -Eo 'cust.*\.json' | sed 's/cust_//g') error_file=$(echo $error | grep -Eo 'cust.*\.json' | sed 's/cust_//g')
@@ -453,17 +453,19 @@ validate_and_restore_custom_jsons() {
fi fi
} }
modify_json() { modify_json() { #入口
extract_base_jsons extract_base_jsons
generate_basic_jsons generate_basic_jsons
prepare_dns_config gen_dns
generate_dns_related_jsons gen_outbounds
generate_route_and_inbounds_jsons gen_certificate
generate_outbounds_and_experimental_jsons gen_inbounds
add_outbounds
gen_experimental
generate_custom_rules_json generate_custom_rules_json
normalize_and_finalize_jsons normalize_and_finalize_jsons
link_custom_jsons link_custom_jsons
validate_and_restore_custom_jsons test_json
#清理缓存 #清理缓存
rm -rf "$TMPDIR"/*.json rm -rf "$TMPDIR"/*.json
rm -rf "$TMPDIR"/jsons_base rm -rf "$TMPDIR"/jsons_base

View File

@@ -1 +1 @@
1.9.5alpha15 1.9.5beta1