From a7c5289492a87115fcab7da04dabffd8669d7896 Mon Sep 17 00:00:00 2001 From: juewuy Date: Mon, 8 Dec 2025 20:07:01 +0800 Subject: [PATCH] =?UTF-8?q?~=E4=BC=98=E5=8C=96tg=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=EF=BC=8C=E6=81=A2=E5=A4=8D=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E8=BE=93=E5=85=A5ChatID=E5=8A=9F=E8=83=BD=20~?= =?UTF-8?q?=E4=BC=98=E5=8C=96mihomo=E5=86=85=E6=A0=B8=E5=9F=BA=E7=A1=80dns?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=9B=A0=E4=B8=BA=E8=AF=81=E4=B9=A6=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=E5=AF=BC=E8=87=B4=E7=9A=84=E7=BD=91=E7=BB=9C=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20~=E4=BC=98=E5=8C=96singbox=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E5=90=88=E5=B9=B6?= =?UTF-8?q?=EF=BC=8C=E7=8E=B0=E5=9C=A8=E6=94=AF=E6=8C=81certificate?= =?UTF-8?q?=E3=80=81endpoint=E3=80=81services=E7=AD=89=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E8=87=AA=E5=AE=9A=E4=B9=89=E9=85=8D=E7=BD=AE=E5=90=88?= =?UTF-8?q?=E5=B9=B6=20~=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E7=89=88?= =?UTF-8?q?=E6=9C=ACcurl=E6=97=A0=E6=B3=95=E6=AD=A3=E7=A1=AE=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=9C=AC=E6=9C=BA=E4=BB=A3=E7=90=86=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E8=80=8C=E5=AF=BC=E8=87=B4=E7=9A=84407=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20~=E4=BF=AE=E5=A4=8D=E5=8D=B8=E8=BD=BD?= =?UTF-8?q?=E6=97=B6=E9=80=89=E6=8B=A9=E4=BF=9D=E7=95=99=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=BC=9A=E5=AF=BC=E8=87=B4=E9=87=8D=E6=96=B0=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=90=8E=E5=90=AF=E5=8A=A8=E6=8A=A5=E9=94=99=E7=9A=84bug=20~?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddocker=E8=BF=90=E8=A1=8C=E6=97=B6=E4=BC=9A?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/menu.sh | 25 +++++++++++++---------- scripts/start.sh | 52 ++++++++++++++++++++++++++++------------------- scripts/webget.sh | 12 ++++++----- 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/scripts/menu.sh b/scripts/menu.sh index c0d2305..5c6eae4 100644 --- a/scripts/menu.sh +++ b/scripts/menu.sh @@ -282,7 +282,7 @@ log_pusher() { #日志菜单 echo ----------------------------------------------- read -p "请输入你获取到的API TOKEN > " TOKEN echo ----------------------------------------------- - echo -e "请向\033[32m你申请的机器人\033[31m而不是BotFather\033[0m,发送" + echo -e "请向\033[32m你申请的机器人\033[33m而不是BotFather!\033[0m" url_tg=https://api.telegram.org/bot${TOKEN}/getUpdates } public_bot(){ @@ -304,16 +304,19 @@ log_pusher() { #日志菜单 fi [ -n "$chat" ] && chat_ID=$(echo $chat | sed 's/"update_id":/{\n"update_id":/g' | grep "$public_key" | head -n1 |grep -oE '"id":.*,"is_bot' | sed s'/"id"://' | sed s'/,"is_bot//') [ -z "$chat_ID" ] && { - echo -e "\033[31m无法获取对话ID,请重新输入!\033[0m" - chose_bot + echo -e "\033[31m无法获取对话ID,请返回重新设置或手动输入ChatID!\033[0m" + echo -e "通常访问 \033[32;4m$url_tg\033[0m \n\033[36m即可看到ChatID\033[0m" + read -p "请手动输入ChatID > " chat_ID } - if [ -n "$chat_ID" ]; then + if echo "$chat_ID" | grep -qE '^[0-9]{8,}$'; then push_TG=$TOKEN setconfig push_TG $TOKEN setconfig chat_ID $chat_ID ${CRASHDIR}/start.sh logger "已完成Telegram日志推送设置!" 32 else echo -e "\033[31m无法获取对话ID,请重新配置!\033[0m" + sleep 1 + chose_bot fi fi } @@ -321,7 +324,7 @@ log_pusher() { #日志菜单 public_key=$(cat /proc/sys/kernel/random/boot_id | sed 's/.*-//') echo ----------------------------------------------- echo -e " 1 使用公共机器人 ——不依赖内核服务" - echo -e " 2 使用私人机器人 ——需要额外申请" + echo -e " 2 使用私人机器人 ——需要额外申请" echo ----------------------------------------------- read -p "请输入对应数字 > " num case $num in @@ -1923,13 +1926,13 @@ uninstall() { if [ -n "${CRASHDIR}" ] && [ "${CRASHDIR}" != '/' ];then read -p "是否保留脚本配置及订阅文件?[1/0] > " res if [ "$res" = '1' ]; then - mv -f ${CRASHDIR}/configs /tmp/ShellCrash/ - mv -f ${CRASHDIR}/yamls /tmp/ShellCrash/ - mv -f ${CRASHDIR}/jsons /tmp/ShellCrash/ + mv -f ${CRASHDIR}/configs /tmp/ShellCrash/configs_bak + mv -f ${CRASHDIR}/yamls /tmp/ShellCrash/yamls_bak + mv -f ${CRASHDIR}/jsons /tmp/ShellCrash/jsons_bak rm -rf ${CRASHDIR}/* - mv -f /tmp/ShellCrash/configs "${CRASHDIR}/" - mv -f /tmp/ShellCrash/yamls "${CRASHDIR}/" - mv -f /tmp/ShellCrash/jsons "${CRASHDIR}/" + mv -f /tmp/ShellCrash/configs_bak "${CRASHDIR}/configs" + mv -f /tmp/ShellCrash/yamls_bak "${CRASHDIR}/yamls" + mv -f /tmp/ShellCrash/jsons_bak "${CRASHDIR}/jsons" else rm -rf ${CRASHDIR} fi diff --git a/scripts/start.sh b/scripts/start.sh index b155ae9..95d2895 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -410,16 +410,15 @@ modify_yaml() { #修饰clash配置文件 } #dns配置 [ -z "$(cat "$CRASHDIR"/yamls/user.yaml 2>/dev/null | grep '^dns:')" ] && { - default_nameserver='223.5.5.5' - [ "$crashcore" = 'meta' ] && default_nameserver='https://223.5.5.5/dns-query' + [ "$skip_cert" = "已开启" ] && psdns_skip_cert='#skip-cert-verify' cat >"$TMPDIR"/dns.yaml </dev/null)" ]; then #NTP劫持 cat >"$TMPDIR"/hosts.yaml <>"$TMPDIR"/hosts.yaml - #加载本机hosts - sys_hosts=/etc/hosts - [ -f /data/etc/custom_hosts ] && sys_hosts=/data/etc/custom_hosts - while read line; do - [ -n "$(echo "$line" | grep -oE "([0-9]{1,3}[\.]){3}")" ] && - [ -z "$(echo "$line" | grep -oE '^#')" ] && - hosts_ip=$(echo $line | awk '{print $1}') && - hosts_domain=$(echo $line | awk '{print $2}') && - [ -z "$(cat "$TMPDIR"/hosts.yaml | grep -oE "$hosts_domain")" ] && - echo " '$hosts_domain': $hosts_ip" >>"$TMPDIR"/hosts.yaml - done <$sys_hosts + if [ "$crashcore" = "meta" ];then + echo " 'services.googleapis.cn': services.googleapis.com" >>"$TMPDIR"/hosts.yaml + else + #加载本机hosts + sys_hosts=/etc/hosts + [ -f /data/etc/custom_hosts ] && sys_hosts=/data/etc/custom_hosts + while read line; do + [ -n "$(echo "$line" | grep -oE "([0-9]{1,3}[\.]){3}")" ] && + [ -z "$(echo "$line" | grep -oE '^#')" ] && + hosts_ip=$(echo $line | awk '{print $1}') && + hosts_domain=$(echo $line | awk '{print $2}') && + [ -z "$(cat "$TMPDIR"/hosts.yaml | grep -oE "$hosts_domain")" ] && + echo " '$hosts_domain': $hosts_ip" >>"$TMPDIR"/hosts.yaml + done <$sys_hosts + fi fi #分割配置文件 yaml_char='proxies proxy-groups proxy-providers rules rule-providers' @@ -935,13 +938,15 @@ EOF done #加载自定义配置文件 mkdir -p "$TMPDIR"/jsons_base - for char in log dns ntp experimental; do + #以下为覆盖脚本的自定义文件 + for char in log dns ntp certificate experimental; do [ -s "$CRASHDIR"/jsons/${char}.json ] && { ln -sf "$CRASHDIR"/jsons/${char}.json "$TMPDIR"/jsons/cust_${char}.json mv -f "$TMPDIR"/jsons/${char}.json "$TMPDIR"/jsons_base #如果重复则临时备份 } done - for char in others inbounds outbounds providers route rule-set; do + #以下为增量添加的自定义文件 + for char in others endpoints inbounds outbounds providers route services; do [ -s "$CRASHDIR"/jsons/${char}.json ] && { ln -sf "$CRASHDIR"/jsons/${char}.json "$TMPDIR"/jsons/cust_${char}.json } @@ -1508,9 +1513,9 @@ start_firewall() { #路由规则总入口 [ "$firewall_mod" = 'iptables' ] && start_iptables [ "$firewall_mod" = 'nftables' ] && start_nftables #修复部分虚拟机dns查询失败的问题 - [ "$firewall_area" = 2 -o "$firewall_area" = 3 ] && [ -z "$(grep 'nameserver 127.0.0.1' /etc/resolv.conf 2>/dev/null)" ] && [ -w /etc/resolv.conf ] && { + [ "$firewall_area" = 2 -o "$firewall_area" = 3 ] && [ -z "$(grep '127.0.0.1' /etc/resolv.conf 2>/dev/null)" ] && [ -w /etc/resolv.conf ] && { line=$(grep -n 'nameserver' /etc/resolv.conf | awk -F: 'FNR==1{print $1}') - sed -i "$line i\nameserver 127.0.0.1 #shellcrash-dns-repair" /etc/resolv.conf 2>/dev/null + sed -i "$line i\nameserver 127.0.0.1 #shellcrash-dns-repair" /etc/resolv.conf >/dev/null 2>&1 } #openwrt使用dnsmasq转发DNS if [ "$dns_redir" = "已开启" -a "$firewall_area" -le 3 -a "$dns_no" != "已禁用" ]; then @@ -2137,7 +2142,12 @@ webget) [ "$5" = "rediroff" ] && redirect='' || redirect='-L' [ "$6" = "skipceroff" ] && certificate='' || certificate='-k' [ -n "$7" ] && agent="--user-agent \"$7\"" - result=$(curl $agent -w %{http_code} --connect-timeout 3 $progress $redirect $certificate -o "$2" "$url") + if curl --version | grep -q '^curl 8.' ;then + auth_b64=$(echo -n "$authentication" | base64) + result=$(curl $agent -w %{http_code} --connect-timeout 3 --proxy-header "Proxy-Authorization: Basic $auth_b64" $progress $redirect $certificate -o "$2" "$url") + else + result=$(curl $agent -w %{http_code} --connect-timeout 3 $progress $redirect $certificate -o "$2" "$url") + fi [ "$result" != "200" ] && export all_proxy="" && result=$(curl $agent -w %{http_code} --connect-timeout 5 $progress $redirect $certificate -o "$2" "$3") else if wget --version >/dev/null 2>&1; then diff --git a/scripts/webget.sh b/scripts/webget.sh index 2e2a147..63985df 100644 --- a/scripts/webget.sh +++ b/scripts/webget.sh @@ -620,10 +620,10 @@ setproviders(){ #自定义providers echo -e "本地配置文件请放在\033[32m$CRASHDIR\033[0m目录下,并填写相对路径如【\033[32m./providers/test.yaml\033[0m】" echo ----------------------------------------------- read -p "请输入providers订阅地址或本地相对路径 > " link - link=$(${link// /}) + link="$(echo "$link" | tr -d '[:space:]')" [ -n "$(echo $link | grep -E '.*\..*|^\./')" ] && { read -p "请输入代理服务商的名称或者代号(不可重复) > " name - name=$(${name// /}) + name="$(echo "$name" | tr -d '[:space:]')" [ -n "$name" ] && [ -z "$(grep "name" $CRASHDIR/configs/providers.cfg)" ] && { echo ----------------------------------------------- echo -e "代理服务商:\033[36m$name\033[0m" @@ -737,9 +737,11 @@ EOF } set_singbox_adv(){ #自定义singbox配置文件 echo ----------------------------------------------- - echo -e "singbox配置文件中,支持自定义的模块有:\033[0m" - echo -e "\033[36mlog dns ntp inbounds outbounds outbound_providers route experimental\033[0m" - echo -e "将相应json文件放入\033[33m$JSONSDIR\033[0m目录后即可在启动时加载" + echo -e "支持覆盖脚本设置的模块有:\033[0m" + echo -e "\033[36mlog dns ntp certificate experimental\033[0m" + echo -e "支持与内置功能合并(但不可冲突)的模块有:\033[0m" + echo -e "\033[36mendpoints inbounds outbounds providers route services\033[0m" + echo -e "将相应json文件放入\033[33m$JSONSDIR\033[0m目录后即可在启动时自动加载" echo ----------------------------------------------- echo -e "使用前请务必参考配置教程:\033[32;4m https://juewuy.github.io/nWTjEpkSK \033[0m" }