mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-07-25 16:29:49 +00:00
Compare commits
8 Commits
bbc0b35b16
...
732d17087e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
732d17087e | ||
|
|
19cc6b70a0 | ||
|
|
433774071a | ||
|
|
55cfa65875 | ||
|
|
edd6936903 | ||
|
|
988c0cde34 | ||
|
|
a85cd5b505 | ||
|
|
b31c824f94 |
@@ -216,7 +216,7 @@ UPG_CORE_V1_SUFFIX=" \033[32m(原meta内核)支持全面\033[0m \033[33m占
|
|||||||
UPG_CORE_V1_DOC="说明文档:\033[36;4mhttps://wiki.metacubex.one\033[0m"
|
UPG_CORE_V1_DOC="说明文档:\033[36;4mhttps://wiki.metacubex.one\033[0m"
|
||||||
UPG_CORE_V2_PREFIX="2) \033[43;30mSingBoxR\033[0m:\033[32m"
|
UPG_CORE_V2_PREFIX="2) \033[43;30mSingBoxR\033[0m:\033[32m"
|
||||||
UPG_CORE_V2_SUFFIX=" \033[32m支持全面\033[0m \033[33m使用reF1nd增强分支\033[0m"
|
UPG_CORE_V2_SUFFIX=" \033[32m支持全面\033[0m \033[33m使用reF1nd增强分支\033[0m"
|
||||||
UPG_CORE_V2_DOC="说明文档:\033[36;4mhttps://sing-boxr.dustinwin.us.kg\033[0m"
|
UPG_CORE_V2_DOC="说明文档:\033[36;4mhttps://sing-boxr.dustinwin.cc.cd\033[0m"
|
||||||
UPG_CORE_V3_PREFIX="3) \033[43;30mSingBox\033[0m:\033[32m"
|
UPG_CORE_V3_PREFIX="3) \033[43;30mSingBox\033[0m:\033[32m"
|
||||||
UPG_CORE_V3_SUFFIX=" \033[32m占用较低\033[0m \033[33m不支持providers\033[0m"
|
UPG_CORE_V3_SUFFIX=" \033[32m占用较低\033[0m \033[33m不支持providers\033[0m"
|
||||||
UPG_CORE_V3_DOC="说明文档:\033[36;4mhttps://sing-box.sagernet.org\033[0m"
|
UPG_CORE_V3_DOC="说明文档:\033[36;4mhttps://sing-box.sagernet.org\033[0m"
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ UPG_CORE_V1_SUFFIX=" \033[32m(full meta core) highly compatible\033[0m \033[33mm
|
|||||||
UPG_CORE_V1_DOC="Docs: \033[36;4mhttps://wiki.metacubex.one\033[0m"
|
UPG_CORE_V1_DOC="Docs: \033[36;4mhttps://wiki.metacubex.one\033[0m"
|
||||||
UPG_CORE_V2_PREFIX="2) \033[43;30mSingBoxR\033[0m: \033[32m"
|
UPG_CORE_V2_PREFIX="2) \033[43;30mSingBoxR\033[0m: \033[32m"
|
||||||
UPG_CORE_V2_SUFFIX=" \033[32mfully featured\033[0m \033[33mreF1nd enhanced branch\033[0m"
|
UPG_CORE_V2_SUFFIX=" \033[32mfully featured\033[0m \033[33mreF1nd enhanced branch\033[0m"
|
||||||
UPG_CORE_V2_DOC="Docs: \033[36;4mhttps://sing-boxr.dustinwin.us.kg\033[0m"
|
UPG_CORE_V2_DOC="Docs: \033[36;4mhttps://sing-boxr.dustinwin.cc.cd\033[0m"
|
||||||
UPG_CORE_V3_PREFIX="3) \033[43;30mSingBox\033[0m: \033[32m"
|
UPG_CORE_V3_PREFIX="3) \033[43;30mSingBox\033[0m: \033[32m"
|
||||||
UPG_CORE_V3_SUFFIX=" \033[32mlower resource usage\033[0m \033[33mproviders are not supported\033[0m"
|
UPG_CORE_V3_SUFFIX=" \033[32mlower resource usage\033[0m \033[33mproviders are not supported\033[0m"
|
||||||
UPG_CORE_V3_DOC="Docs: \033[36;4mhttps://sing-box.sagernet.org\033[0m"
|
UPG_CORE_V3_DOC="Docs: \033[36;4mhttps://sing-box.sagernet.org\033[0m"
|
||||||
|
|||||||
@@ -2,6 +2,20 @@
|
|||||||
|
|
||||||
[ -n "$(find --help 2>&1 | grep -o size)" ] && find_para=' -size +2000' #find命令兼容
|
[ -n "$(find --help 2>&1 | grep -o size)" ] && find_para=' -size +2000' #find命令兼容
|
||||||
|
|
||||||
|
#根据环境权衡决定是否把裸二进制存于$BINDIR(rom)——省RAM,前提是rom装得下
|
||||||
|
#$1=裸二进制字节数。仅当$TMPDIR在内存(tmpfs)时裸存才省RAM;
|
||||||
|
#再按$BINDIR文件系统估算裸二进制落盘体积(透明压缩fs约2:1),需留有余量($raw_margin,默认8M)
|
||||||
|
store_raw_worth_it(){
|
||||||
|
case "$(df -T "$TMPDIR" 2>/dev/null | awk 'END{print $2}')" in tmpfs|ramfs) ;; *) return 1 ;; esac
|
||||||
|
rom_free=$(df -k "$BINDIR" 2>/dev/null | awk 'END{print $4}') #KB
|
||||||
|
[ -z "$rom_free" ] && return 1
|
||||||
|
case "$(df -T "$BINDIR" 2>/dev/null | awk 'END{print $2}')" in
|
||||||
|
squashfs|ubifs|overlay|overlayfs) est=$(( ${1:-0}/1024/2 )) ;; #透明压缩,约2:1
|
||||||
|
*) est=$(( ${1:-0}/1024 )) ;; #无压缩,全量
|
||||||
|
esac
|
||||||
|
[ $(( rom_free - est )) -gt "${raw_margin:-8192}" ] && return 0 || return 1
|
||||||
|
}
|
||||||
|
|
||||||
core_unzip() { #$1:需要解压的文件 $2:目标文件名
|
core_unzip() { #$1:需要解压的文件 $2:目标文件名
|
||||||
if echo "$1" |grep -q 'tar.gz$' ;then
|
if echo "$1" |grep -q 'tar.gz$' ;then
|
||||||
[ "$BINDIR" = "$TMPDIR" ] && rm -rf "$TMPDIR"/CrashCore #小闪存模式防止空间不足
|
[ "$BINDIR" = "$TMPDIR" ] && rm -rf "$TMPDIR"/CrashCore #小闪存模式防止空间不足
|
||||||
@@ -14,6 +28,8 @@ core_unzip() { #$1:需要解压的文件 $2:目标文件名
|
|||||||
rm -rf "$TMPDIR"/core_tmp
|
rm -rf "$TMPDIR"/core_tmp
|
||||||
elif echo "$1" |grep -q '.gz$' ;then
|
elif echo "$1" |grep -q '.gz$' ;then
|
||||||
gunzip -c "$1" > "$TMPDIR"/"$2"
|
gunzip -c "$1" > "$TMPDIR"/"$2"
|
||||||
|
elif echo "$1" |grep -q '.raw$' ;then
|
||||||
|
ln -sf "$1" "$TMPDIR"/"$2"
|
||||||
elif echo "$1" |grep -q '.upx$' ;then
|
elif echo "$1" |grep -q '.upx$' ;then
|
||||||
ln -sf "$1" "$TMPDIR"/"$2"
|
ln -sf "$1" "$TMPDIR"/"$2"
|
||||||
else
|
else
|
||||||
@@ -45,16 +61,20 @@ core_check(){
|
|||||||
rm -rf "$1" "$TMPDIR"/core_new
|
rm -rf "$1" "$TMPDIR"/core_new
|
||||||
return 2
|
return 2
|
||||||
else
|
else
|
||||||
rm -f "$BINDIR"/CrashCore.tar.gz "$BINDIR"/CrashCore.gz "$BINDIR"/CrashCore.upx
|
rm -f "$BINDIR"/CrashCore.tar.gz "$BINDIR"/CrashCore.gz "$BINDIR"/CrashCore.upx "$BINDIR"/CrashCore.raw
|
||||||
if [ -z "$zip_type" ];then
|
if [ "$zip_type" = 'upx' ];then
|
||||||
|
mv -f "$1" "$BINDIR/CrashCore.upx"
|
||||||
|
rm -f "$TMPDIR"/core_new
|
||||||
|
ln -sf "$BINDIR/CrashCore.upx" "$TMPDIR/CrashCore"
|
||||||
|
elif store_raw_worth_it "$(wc -c < "$TMPDIR/core_new")" ;then
|
||||||
|
rm -f "$1"
|
||||||
|
mv -f "$TMPDIR/core_new" "$BINDIR/CrashCore.raw"
|
||||||
|
ln -sf "$BINDIR/CrashCore.raw" "$TMPDIR/CrashCore"
|
||||||
|
elif [ -z "$zip_type" ];then
|
||||||
gzip -c "$TMPDIR/core_new" > "$BINDIR/CrashCore.gz"
|
gzip -c "$TMPDIR/core_new" > "$BINDIR/CrashCore.gz"
|
||||||
|
mv -f "$TMPDIR/core_new" "$TMPDIR/CrashCore"
|
||||||
else
|
else
|
||||||
mv -f "$1" "$BINDIR/CrashCore.$zip_type"
|
mv -f "$1" "$BINDIR/CrashCore.$zip_type"
|
||||||
fi
|
|
||||||
if [ "$zip_type" = 'upx' ];then
|
|
||||||
rm -f "$1" "$TMPDIR"/core_new
|
|
||||||
ln -sf "$TMPDIR/CrashCore.upx" "$TMPDIR/CrashCore"
|
|
||||||
else
|
|
||||||
mv -f "$TMPDIR/core_new" "$TMPDIR/CrashCore"
|
mv -f "$TMPDIR/core_new" "$TMPDIR/CrashCore"
|
||||||
fi
|
fi
|
||||||
core_v="$v"
|
core_v="$v"
|
||||||
@@ -70,6 +90,8 @@ core_webget(){
|
|||||||
. "$CRASHDIR"/libs/check_target.sh
|
. "$CRASHDIR"/libs/check_target.sh
|
||||||
if [ -z "$custcorelink" ];then
|
if [ -z "$custcorelink" ];then
|
||||||
[ -z "$zip_type" ] && zip_type='tar.gz'
|
[ -z "$zip_type" ] && zip_type='tar.gz'
|
||||||
|
#若环境适合裸存(见store_raw_worth_it,按典型核心~45M估算),避免下载upx,改取tar.gz的裸二进制
|
||||||
|
[ "$zip_type" = 'upx' ] && store_raw_worth_it 47185920 && zip_type='tar.gz'
|
||||||
get_bin "$TMPDIR/Coretmp.$zip_type" "bin/$crashcore/${target}-linux-${cpucore}.$zip_type"
|
get_bin "$TMPDIR/Coretmp.$zip_type" "bin/$crashcore/${target}-linux-${cpucore}.$zip_type"
|
||||||
else
|
else
|
||||||
case "$custcorelink" in
|
case "$custcorelink" in
|
||||||
|
|||||||
@@ -540,7 +540,7 @@ EOF
|
|||||||
# s自定义singbox配置文件
|
# s自定义singbox配置文件
|
||||||
set_singbox_adv() {
|
set_singbox_adv() {
|
||||||
comp_box "\033[33m$OVR_SING_TITLE1\033[0m" \
|
comp_box "\033[33m$OVR_SING_TITLE1\033[0m" \
|
||||||
"\033[36mlog dns ntp certificate experimental\033[0m" \
|
"\033[36mlog dns ntp certificate http_clients experimental\033[0m" \
|
||||||
"\033[33m$OVR_SING_TITLE2\033[0m" \
|
"\033[33m$OVR_SING_TITLE2\033[0m" \
|
||||||
"\033[36mendpoints inbounds outbounds providers route services\033[0m" \
|
"\033[36mendpoints inbounds outbounds providers route services\033[0m" \
|
||||||
"$OVR_SING_TITLE3" \
|
"$OVR_SING_TITLE3" \
|
||||||
|
|||||||
@@ -92,10 +92,11 @@ EOF
|
|||||||
],
|
],
|
||||||
"rules": [
|
"rules": [
|
||||||
{
|
{
|
||||||
"ip_accept_any": true,
|
"preferred_by": [ "hosts" ],
|
||||||
"server": "hosts"
|
"server": "hosts"
|
||||||
}
|
}
|
||||||
]}
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
@@ -153,7 +154,7 @@ generate_dns_related_jsons() {
|
|||||||
"format": "binary",
|
"format": "binary",
|
||||||
$srs_path
|
$srs_path
|
||||||
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/cn.srs",
|
"url": "https://testingcf.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box-ruleset/cn.srs",
|
||||||
"download_detour": "DIRECT"
|
"http_client": "detour_direct"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -217,7 +218,8 @@ EOF
|
|||||||
generate_route_and_inbounds_jsons() {
|
generate_route_and_inbounds_jsons() {
|
||||||
#生成add_route.json
|
#生成add_route.json
|
||||||
#域名嗅探配置
|
#域名嗅探配置
|
||||||
[ "$sniffer" != OFF ] && sniffer_set='{ "domain_suffix": [ "push.apple.com" ], "rule_set": [ "telegramip" ], "domain": [ "Mijia Cloud" ], "invert": true, "action": "sniff", "timeout": "500ms" },'
|
grep -q 'telegramip' "$TMPDIR"/jsons/route.json && telegramip_set=' "rule_set": [ "telegramip" ],'
|
||||||
|
[ "$sniffer" != OFF ] && sniffer_set='{ "domain_suffix": [ "push.apple.com" ],'"$telegramip_set"' "domain": [ "Mijia Cloud" ], "invert": true, "action": "sniff", "timeout": "500ms" },'
|
||||||
[ "$ts_service" = ON ] && tailscale_set='{ "inbound": [ "ts-ep" ], "port": 53, "action": "hijack-dns" },'
|
[ "$ts_service" = ON ] && tailscale_set='{ "inbound": [ "ts-ep" ], "port": 53, "action": "hijack-dns" },'
|
||||||
cat >"$TMPDIR"/jsons/add_route.json <<EOF
|
cat >"$TMPDIR"/jsons/add_route.json <<EOF
|
||||||
{
|
{
|
||||||
@@ -225,9 +227,9 @@ generate_route_and_inbounds_jsons() {
|
|||||||
"default_domain_resolver": "dns_resolver",
|
"default_domain_resolver": "dns_resolver",
|
||||||
"default_mark": $routing_mark,
|
"default_mark": $routing_mark,
|
||||||
"rules": [
|
"rules": [
|
||||||
{ "inbound": [ "dns-in" ], "action": "hijack-dns" },
|
|
||||||
$tailscale_set
|
$tailscale_set
|
||||||
$sniffer_set
|
$sniffer_set
|
||||||
|
{ "inbound": [ "dns-in" ], "action": "hijack-dns" },
|
||||||
{ "clash_mode": "Direct" , "outbound": "DIRECT" },
|
{ "clash_mode": "Direct" , "outbound": "DIRECT" },
|
||||||
{ "clash_mode": "Global" , "outbound": "GLOBAL" }
|
{ "clash_mode": "Global" , "outbound": "GLOBAL" }
|
||||||
]
|
]
|
||||||
@@ -324,6 +326,21 @@ generate_outbounds_and_experimental_jsons() {
|
|||||||
$add_global
|
$add_global
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
EOF
|
||||||
|
#生成http_clients.json
|
||||||
|
cat >"$TMPDIR"/jsons/http_clients.json <<EOF
|
||||||
|
{
|
||||||
|
"http_clients": [
|
||||||
|
{
|
||||||
|
"tag": "detour_proxy",
|
||||||
|
"detour": "GLOBAL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "detour_direct",
|
||||||
|
"detour": "DIRECT"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
EOF
|
EOF
|
||||||
#生成experimental.json
|
#生成experimental.json
|
||||||
[ "$crashcore" = "singboxr" ] && urltest_unified_delay=',"urltest_unified_delay": true'
|
[ "$crashcore" = "singboxr" ] && urltest_unified_delay=',"urltest_unified_delay": true'
|
||||||
@@ -394,7 +411,7 @@ link_custom_jsons() {
|
|||||||
#加载自定义配置文件
|
#加载自定义配置文件
|
||||||
mkdir -p "$TMPDIR"/jsons_base
|
mkdir -p "$TMPDIR"/jsons_base
|
||||||
#以下为覆盖脚本的自定义文件
|
#以下为覆盖脚本的自定义文件
|
||||||
for char in log dns ntp certificate experimental; do
|
for char in log dns ntp certificate http_clients experimental; do
|
||||||
[ -s "$CRASHDIR"/jsons/${char}.json ] && {
|
[ -s "$CRASHDIR"/jsons/${char}.json ] && {
|
||||||
ln -sf "$CRASHDIR"/jsons/${char}.json "$TMPDIR"/jsons/cust_${char}.json
|
ln -sf "$CRASHDIR"/jsons/${char}.json "$TMPDIR"/jsons/cust_${char}.json
|
||||||
mv -f "$TMPDIR"/jsons/${char}.json "$TMPDIR"/jsons_base #如果重复则临时备份
|
mv -f "$TMPDIR"/jsons/${char}.json "$TMPDIR"/jsons_base #如果重复则临时备份
|
||||||
|
|||||||
Reference in New Issue
Block a user