diff --git a/bin/ShellCrash.tar.gz b/bin/ShellCrash.tar.gz index 2e86583..5deaa40 100644 Binary files a/bin/ShellCrash.tar.gz and b/bin/ShellCrash.tar.gz differ diff --git a/bin/clashfm.tar.gz b/bin/clashfm.tar.gz index bff3264..7cd0390 100644 Binary files a/bin/clashfm.tar.gz and b/bin/clashfm.tar.gz differ diff --git a/bin/public.tar.gz b/bin/public.tar.gz index b5716a5..40091c6 100644 Binary files a/bin/public.tar.gz and b/bin/public.tar.gz differ diff --git a/bin/version b/bin/version index 8956faa..00ef505 100644 --- a/bin/version +++ b/bin/version @@ -4,5 +4,5 @@ clash_v=v1.7.1 meta_v=v1.18.1 singboxp_v=1.8.5-73d97226 singbox_v=1.8.8 -versionsh=1.9.1alpha8 +versionsh=1.9.1alpha9 GeoIP_v=20240315 diff --git a/scripts/init.sh b/scripts/init.sh index c06c627..76891c9 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -1,7 +1,7 @@ #!/bin/sh # Copyright (C) Juewuy -version=1.9.1alpha8 +version=1.9.1alpha9 setdir(){ dir_avail(){ @@ -297,7 +297,6 @@ done for file in cron task.sh task.list;do mv -f ${CRASHDIR}/$file ${CRASHDIR}/task/$file 2>/dev/null done -chmod 755 ${CRASHDIR}/task/task.sh #旧版文件清理 userdel shellclash >/dev/null 2>&1 sed -i '/shellclash/d' /etc/passwd diff --git a/scripts/menu.sh b/scripts/menu.sh index e698f58..9ec9d12 100644 --- a/scripts/menu.sh +++ b/scripts/menu.sh @@ -228,6 +228,7 @@ log_pusher(){ #日志菜单 [ -n "$push_Deer" ] && stat_Deer=32m已启用 || stat_Deer=33m未启用 [ -n "$push_bark" ] && stat_bark=32m已启用 || stat_bark=33m未启用 [ -n "$push_Po" ] && stat_Po=32m已启用 || stat_Po=33m未启用 + [ -n "$push_PP" ] && stat_PP=32m已启用 || stat_PP=33m未启用 [ "$task_push" = 1 ] && stat_task=32m已启用 || stat_task=33m未启用 [ -n "$device_name" ] && device_s=32m$device_name || device_s=33m未设置 echo ----------------------------------------------- @@ -236,7 +237,8 @@ log_pusher(){ #日志菜单 echo -e " 3 PushDeer推送 ——\033[$stat_Deer\033[0m" echo -e " 4 Bark推送-IOS ——\033[$stat_bark\033[0m" echo -e " 5 Passover推送 ——\033[$stat_Po\033[0m" - echo -e " 6 推送任务日志 ——\033[$stat_task\033[0m" + echo -e " 6 PushPlus推送 ——\033[$stat_PP\033[0m" + echo -e " 7 推送任务日志 ——\033[$stat_task\033[0m" echo -e " 8 设置设备名称 ——\033[$device_s\033[0m" echo -e " 9 清空日志文件" echo ----------------------------------------------- @@ -366,7 +368,7 @@ log_pusher(){ #日志菜单 setconfig push_Po setconfig push_Po_key } - elif curl --version >/dev/null 2>&1;then + else #echo -e "\033[33m详细设置指南请参考 https://juewuy.github.io/ \033[0m" echo -e "请先通过 \033[32;4mhttps://pushover.net/\033[0m 注册账号并获取\033[36mUser Key\033[0m" echo ----------------------------------------------- @@ -391,13 +393,35 @@ log_pusher(){ #日志菜单 else echo -e "\033[31m输入错误,请重新输入!\033[0m" fi - else - echo -e "\033[33mPashover不支持使用wget命令推送,请尝试其他推送方式!\033[0m" fi sleep 1 log_pusher ;; - 6) + 6) + echo ----------------------------------------------- + if [ -n "$push_PP" ];then + read -p "确认关闭PushPlus日志推送?(1/0) > " res + [ "$res" = 1 ] && { + push_PP= + setconfig push_PP + } + else + #echo -e "\033[33m详细设置指南请参考 https://juewuy.github.io/ \033[0m" + echo -e "请先通过 \033[32;4mhttps://www.pushplus.plus/push1.html\033[0m 注册账号并获取\033[36mtoken\033[0m" + echo ----------------------------------------------- + read -p "请输入你的token > " Token + if [ -n "$Token" ];then + push_PP=$Token + setconfig push_PP $Token + ${CRASHDIR}/start.sh logger "已完成PushPlus日志推送设置!" 32 + else + echo -e "\033[31m输入错误,请重新输入!\033[0m" + fi + fi + sleep 1 + log_pusher + ;; + 7) [ "$task_push" = 1 ] && task_push='' || task_push=1 setconfig task_push $task_push sleep 1 @@ -1170,7 +1194,11 @@ set_redir_mod(){ #代理模式设置 if [ "$firewall_mod" = "iptables" ] ;then if [ -f /etc/init.d/qca-nss-ecm -a "$systype" = "mi_snapshot" ] ;then read -p "xiaomi设备的QOS服务与本模式冲突,是否禁用相关功能?(1/0) > " res - [ "$res" = '1' ] && ${CRASHDIR}/misnap_init.sh tproxyfix && redir_mod=Tproxy模式 + [ "$res" = '1' ] && { + ${CRASHDIR}/misnap_init.sh tproxyfix + redir_mod=Tproxy模式 + set_redir_config + } elif [ -n "$(grep -E '^TPROXY$' /proc/net/ip_tables_targets)" ] ;then redir_mod=Tproxy模式 set_redir_config diff --git a/scripts/misnap_init.sh b/scripts/misnap_init.sh index 359334b..b4ca8ec 100644 --- a/scripts/misnap_init.sh +++ b/scripts/misnap_init.sh @@ -34,7 +34,7 @@ tunfix(){ mkdir -p /tmp/overlay/work mount -o noatime,lowerdir=${ko_dir},upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/work -t overlay "overlay_mods_only" ${ko_dir} #将tun.ko链接到lib - ln -sf $CRASHDIR/tools/tun.ko ${ko_dir}/tun.ko + ln -sf $CRASHDIR/tools/tun.ko ${ko_dir}/tun.ko || $CRASHDIR/start.sh loggger "小米Tun模块修复失败!" } tproxyfix(){ sed -i 's/sysctl -w net.bridge.bridge-nf-call-ip/#sysctl -w net.bridge.bridge-nf-call-ip/g' /etc/init.d/qca-nss-ecm @@ -44,10 +44,8 @@ tproxyfix(){ init(){ #等待启动完成 log_file=$(uci get system.@system[0].log_file) - local i=0 - while [ "$i" -lt 20 ]; do - sleep 3 - [ -n "$(grep 'init complete' $log_file)" ] && i=20 || i=$((i + 1)) + while ! /sbin/ip a| grep -q lan; do + sleep 10 done #初始化环境变量 sed -i "/alias crash/d" $profile @@ -68,7 +66,7 @@ init(){ #小米7000/小米万兆修复tproxy [ -f /etc/init.d/qca-nss-ecm ] && [ -n "$(grep 'redir_mod=Tproxy' $CRASHDIR/configs/ShellCrash.cfg )" ] && tproxyfix #启动服务 - /etc/init.d/shellcrash start + $CRASHDIR/start.sh start /etc/init.d/shellcrash enable fi } diff --git a/scripts/start.sh b/scripts/start.sh index 927f66e..bc2979d 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -87,7 +87,7 @@ logger(){ #日志工具 export https_proxy="http://${auth}127.0.0.1:$mix_port" } [ -n "$push_TG" ] && { - url=https://api.telegram.org/bot${push_TG}/sendMessage + url="https://api.telegram.org/bot${push_TG}/sendMessage" curl_data="-d chat_id=$chat_ID&text=$log_text" wget_data="--post-data=$chat_ID&text=$log_text" if curl --version >/dev/null 2>&1;then @@ -97,7 +97,7 @@ logger(){ #日志工具 fi } [ -n "$push_bark" ] && { - url=${push_bark}/${log_text}${bark_param} + url="${push_bark}/${log_text}${bark_param}" if curl --version >/dev/null 2>&1;then curl -kfsSl --connect-timeout 3 "$url" >/dev/null 2>&1 else @@ -105,7 +105,7 @@ logger(){ #日志工具 fi } [ -n "$push_Deer" ] && { - url=https://api2.pushdeer.com/message/push?pushkey=${push_Deer} + url="https://api2.pushdeer.com/message/push?pushkey=${push_Deer}" if curl --version >/dev/null 2>&1;then curl -kfsSl --connect-timeout 3 "$url"\&text="$log_text" >/dev/null 2>&1 else @@ -113,9 +113,23 @@ logger(){ #日志工具 fi } [ -n "$push_Po" ] && { - url=https://api.pushover.net/1/messages.json - curl -kfsSl --connect-timeout 3 --form-string "token=$push_Po" --form-string "user=$push_Po_key" --form-string "message=$log_text" "$url" >/dev/null 2>&1 - } + url="https://api.pushover.net/1/messages.json" + content="{\"token\":\"${push_Po}\",\"user\":\"${push_Po_key}\",\"title\":\"ShellCrash日志推送\",\"message\":\"$log_text\"}" + if curl --version >/dev/null 2>&1;then + curl -kfsSl -X POST --connect-timeout 3 -H "Content-Type: application/json" "$url" -d "$content" >/dev/null 2>&1 + else + wget -Y on -q --timeout=3 -t 1 --method=POST --header="Content-Type: application/json" --body-data="$content" "$url" + fi + } + [ -n "$push_PP" ] && { + url="http://www.pushplus.plus/send" + content="{\"token\":\"${push_PP}\",\"title\":\"ShellCrash日志推送\",\"content\":\"$log_text\"}" + if curl --version >/dev/null 2>&1;then + curl -sS -X POST --connect-timeout 3 -H "Content-Type: application/json" "$url" -d "$content" >/dev/null 2>&1 + else + wget -Y on -q --timeout=3 -t 1 --method=POST --header="Content-Type: application/json" --body-data="$content" "$url" + fi + } } & } croncmd(){ #定时任务工具 @@ -848,7 +862,7 @@ cn_ip_route(){ #CN-IP绕过 # see https://raw.githubusercontent.com/Hackl0us/GeoIP2-CN/release/CN-ip-cidr.txt echo "create cn_ip hash:net family inet hashsize 10240 maxelem 10240" > ${TMPDIR}/cn_ip.ipset awk '!/^$/&&!/^#/{printf("add cn_ip %s'" "'\n",$0)}' ${BINDIR}/cn_ip.txt >> ${TMPDIR}/cn_ip.ipset - ipset -! flush cn_ip 2>/dev/null + ipset destroy cn_ip >/dev/null 2>&1 ipset -! restore < ${TMPDIR}/cn_ip.ipset rm -rf ${TMPDIR}/cn_ip.ipset } @@ -860,7 +874,7 @@ cn_ipv6_route(){ #CN-IPV6绕过 #see https://ispip.clang.cn/all_cn_ipv6.txt echo "create cn_ip6 hash:net family inet6 hashsize 5120 maxelem 5120" > ${TMPDIR}/cn_ipv6.ipset awk '!/^$/&&!/^#/{printf("add cn_ip6 %s'" "'\n",$0)}' ${BINDIR}/cn_ipv6.txt >> ${TMPDIR}/cn_ipv6.ipset - ipset -! flush cn_ip6 2>/dev/null + ipset destroy cn_ip6 >/dev/null 2>&1 ipset -! restore < ${TMPDIR}/cn_ipv6.ipset rm -rf ${TMPDIR}/cn_ipv6.ipset } @@ -936,12 +950,12 @@ start_ipt_dns(){ #iptables-dns通用工具 } if [ "$3" = 'PREROUTING' ] && [ "$macfilter_type" = "白名单" ] && [ -n "$(cat ${CRASHDIR}/configs/mac)" ];then for mac in $(cat ${CRASHDIR}/configs/mac); do - $1 -t nat -A $3 -p tcp -m mac --mac-source $mac -j REDIRECT --to $dns_port - $1 -t nat -A $3 -p udp -m mac --mac-source $mac -j REDIRECT --to $dns_port + $1 -t nat -A $3 -p tcp -m mac --mac-source $mac -j REDIRECT --to-ports $dns_port + $1 -t nat -A $3 -p udp -m mac --mac-source $mac -j REDIRECT --to-ports $dns_port done else - $1 -t nat -A $3 -p tcp -j REDIRECT --to $dns_port - $1 -t nat -A $3 -p udp -j REDIRECT --to $dns_port + $1 -t nat -A $3 -p tcp -j REDIRECT --to-ports $dns_port + $1 -t nat -A $3 -p udp -j REDIRECT --to-ports $dns_port fi $1 -t nat -I $2 -p tcp --dport 53 -j $3 $1 -t nat -I $2 -p udp --dport 53 -j $3 @@ -1785,13 +1799,12 @@ debug) afstart ;; init) - profile=/etc/profile if [ -d "/etc/storage/clash" -o -d "/etc/storage/ShellCrash" ];then i=1 while [ ! -w /etc/profile -a "$i" -lt 10 ];do - sleep 5 && i=$((i+1)) + sleep 3 && i=$((i+1)) done - profile=/etc/profile + [ -w /etc/profile ] && profile=/etc/profile || profile=/etc_ro/profile mount -t tmpfs -o remount,rw,size=45M tmpfs /tmp #增加/tmp空间以适配新的内核压缩方式 sed -i '' $profile #将软链接转化为一般文件 elif [ -d "/jffs" ];then diff --git a/scripts/update.sh b/scripts/update.sh index 9cd947d..c51ba35 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -372,10 +372,12 @@ EOF provider_temp_file=$(grep "provider_temp_${coretype}" ${CRASHDIR}/configs/ShellCrash.cfg | awk -F '=' '{print $2}') fi echo ----------------------------------------------- - if [ ! -s ${TMPDIR}/${provider_temp_file} ];then + if [ -s ${provider_temp_file} ];then + ln -sf ${provider_temp_file} ${TMPDIR}/provider_temp_file + else echo -e "\033[33m正在获取在线模版!\033[0m" - ${CRASHDIR}/start.sh get_bin ${TMPDIR}/${provider_temp_file} rules/${coretype}_providers/${provider_temp_file} - [ -z "$(grep -o 'rules' ${TMPDIR}/${provider_temp_file})" ] && { + ${CRASHDIR}/start.sh get_bin ${TMPDIR}/provider_temp_file rules/${coretype}_providers/${provider_temp_file} + [ -z "$(grep -o 'rules' ${TMPDIR}/provider_temp_file)" ] && { echo -e "\033[31m下载失败,请尝试更换安装源!\033[0m" setserver setproviders @@ -386,9 +388,9 @@ EOF #预创建文件并写入对应文件头 echo 'proxy-providers:' > ${TMPDIR}/providers/providers.yaml #切割模版文件 - sed -n '/^proxy-groups:/,/^[a-z]/ { /^rule/d; p; }' ${TMPDIR}/${provider_temp_file} > ${TMPDIR}/providers/proxy-groups.yaml - sed -n '/^rule/,$p' ${TMPDIR}/${provider_temp_file} > ${TMPDIR}/providers/rules.yaml - rm -rf ${TMPDIR}/${provider_temp_file} + sed -n '/^proxy-groups:/,/^[a-z]/ { /^rule/d; p; }' ${TMPDIR}/provider_temp_file > ${TMPDIR}/providers/proxy-groups.yaml + sed -n '/^rule/,$p' ${TMPDIR}/provider_temp_file > ${TMPDIR}/providers/rules.yaml + rm -rf ${TMPDIR}/provider_temp_file #生成providers模块 if [ -n "$2" ];then gen_clash_providers_txt $1 $2 @@ -459,10 +461,12 @@ EOF provider_temp_file=$(grep "provider_temp_${coretype}" ${CRASHDIR}/configs/ShellCrash.cfg | awk -F '=' '{print $2}') fi echo ----------------------------------------------- - if [ ! -s ${TMPDIR}/${provider_temp_file} ];then + if [ -s ${provider_temp_file} ];then + ln -sf ${provider_temp_file} ${TMPDIR}/provider_temp_file + else echo -e "\033[33m正在获取在线模版!\033[0m" - ${CRASHDIR}/start.sh get_bin ${TMPDIR}/${provider_temp_file} rules/${coretype}_providers/${provider_temp_file} - [ -z "$(grep -o 'route' ${TMPDIR}/${provider_temp_file})" ] && { + ${CRASHDIR}/start.sh get_bin ${TMPDIR}/provider_temp_file rules/${coretype}_providers/${provider_temp_file} + [ -z "$(grep -o 'route' ${TMPDIR}/provider_temp_file)" ] && { echo -e "\033[31m下载失败,请尝试更换安装源!\033[0m" setserver setproviders @@ -495,8 +499,8 @@ EOF fi 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 - rm -rf ${TMPDIR}/${provider_temp_file} + 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 if [ "$?" = 0 ];then @@ -515,6 +519,14 @@ EOF fi } setproviders(){ #自定义providers + #获取模版名称 + if [ -z "$(grep "provider_temp_${coretype}" ${CRASHDIR}/configs/ShellCrash.cfg)" ];then + provider_temp_des=$(sed -n "1 p" ${CRASHDIR}/configs/${coretype}_providers.list | awk '{print $1}') + else + provider_temp_file=$(grep "provider_temp_${coretype}" ${CRASHDIR}/configs/ShellCrash.cfg | awk -F '=' '{print $2}') + provider_temp_des=$(grep "$provider_temp_file" ${CRASHDIR}/configs/${coretype}_providers.list | awk '{print $1}') + [ -z "$provider_temp_des" ] && provider_temp_des=$provider_temp_file + fi echo ----------------------------------------------- echo -e "\033[33m你可以在这里快捷管理与生成自定义的providers提供者\033[0m" echo -e "\033[36m支持在线及本地的Yaml格式配置导入\033[0m" @@ -527,7 +539,7 @@ setproviders(){ #自定义providers echo ----------------------------------------------- echo -e " a \033[36m添加\033[0mproviders提供者" echo -e " b \033[32m生成\033[0m基于providers的配置文件" - echo -e " c 选择\033[33m规则模版\033[0m" + echo -e " c 选择\033[33m规则模版\033[0m \033[32m$provider_temp_des\033[0m" echo -e " d \033[31m清空\033[0mproviders列表" echo -e " e \033[33m清理\033[0mproviders目录" echo -e " 0 返回上级菜单" @@ -622,25 +634,38 @@ setproviders(){ #自定义providers setproviders ;; c) - if [ -z "$(grep "provider_temp_${coretype}" ${CRASHDIR}/configs/ShellCrash.cfg)" ];then - provider_temp_des=$(sed -n "1 p" ${CRASHDIR}/configs/${coretype}_providers.list | awk '{print $1}') - else - provider_temp_file=$(grep "provider_temp_${coretype}" ${CRASHDIR}/configs/ShellCrash.cfg | awk -F '=' '{print $2}') - provider_temp_des=$(grep "$provider_temp_file" ${CRASHDIR}/configs/${coretype}_providers.list | awk '{print $1}') - fi echo ----------------------------------------------- echo -e "当前规则模版为:\033[32m$provider_temp_des\033[0m" echo -e "\033[33m请选择在线模版:\033[0m" echo ----------------------------------------------- cat ${CRASHDIR}/configs/${coretype}_providers.list | awk '{print " "NR" "$1}' echo ----------------------------------------------- - read -p "请输入对应数字 > " num - provider_temp_file=$(sed -n "$num p" ${CRASHDIR}/configs/${coretype}_providers.list | awk '{print $2}') - if [ -z "$provider_temp_file" ];then - errornum - else - setconfig provider_temp_${coretype} $provider_temp_file - fi + echo -e " a 使用\033[36m本地模版\033[0m" + echo ----------------------------------------------- + read -p "请输入对应字母或数字 > " num + case $num in + 0) + ;; + a) + read -p "请输入模版的路径(绝对路径) > " dir + if [ -s $dir ];then + provider_temp_file=$dir + setconfig provider_temp_${coretype} $provider_temp_file + echo -e "\033[32m设置成功!\033[0m" + else + echo -e "\033[31m输入错误,找不到对应模版文件!\033[0m" + fi + sleep 1 + ;; + *) + provider_temp_file=$(sed -n "$num p" ${CRASHDIR}/configs/${coretype}_providers.list 2>/dev/null | awk '{print $2}') + if [ -z "$provider_temp_file" ];then + errornum + else + setconfig provider_temp_${coretype} $provider_temp_file + fi + ;; + esac setproviders ;; d)