From 966b59692efa774a83effdfb936372b90dff6a26 Mon Sep 17 00:00:00 2001 From: juewuy Date: Sun, 18 Jan 2026 20:52:02 +0800 Subject: [PATCH] ~bug fix --- scripts/libs/get_config.sh | 7 +- scripts/libs/web_get.sh | 2 +- scripts/menus/6_core_config.sh | 2 +- scripts/menus/fw_filter.sh | 150 ++++++++++++++++--------------- scripts/menus/running_status.sh | 4 +- scripts/menus/tui_layout.sh | 29 +----- scripts/starts/singbox_modify.sh | 6 +- 7 files changed, 87 insertions(+), 113 deletions(-) diff --git a/scripts/libs/get_config.sh b/scripts/libs/get_config.sh index 333c85ac..d882287d 100644 --- a/scripts/libs/get_config.sh +++ b/scripts/libs/get_config.sh @@ -13,10 +13,7 @@ routing_mark=$((fwmark + 2)) [ -z "$dns_nameserver" ] && { dns_nameserver='223.5.5.5, 1.2.4.8' - cat /proc/net/udp | grep -q '0035' && dns_nameserver='localhost' + cat /proc/net/udp | grep -q '0035' && dns_nameserver='127.0.0.1' } [ -z "$dns_fallback" ] && dns_fallback="1.1.1.1, 8.8.8.8" -[ -z "$dns_resolver" ] && { - dns_resolver="223.5.5.5, 2400:3200::1" - cat /proc/net/udp | grep -q '0035' && dns_resolver='127.0.0.1' -} \ No newline at end of file +[ -z "$dns_resolver" ] && dns_resolver="223.5.5.5, 2400:3200::1" diff --git a/scripts/libs/web_get.sh b/scripts/libs/web_get.sh index 261a91ee..51ccb5df 100644 --- a/scripts/libs/web_get.sh +++ b/scripts/libs/web_get.sh @@ -43,7 +43,7 @@ webget(){ wget -Y off $progress -O "$1" "$2" return $? else - echo "找不到可用下载工具!!!请安装Curl或Wget!!!" + echo "No Curl or Wget!!!" return 1 fi } \ No newline at end of file diff --git a/scripts/menus/6_core_config.sh b/scripts/menus/6_core_config.sh index 39a3dc73..b6ddacb1 100644 --- a/scripts/menus/6_core_config.sh +++ b/scripts/menus/6_core_config.sh @@ -551,7 +551,7 @@ EOF 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" | sed "s/\"providers_tags\"/$providers_tags/g" > "$TMPDIR"/providers/outbounds.json rm -rf "$TMPDIR"/provider_temp_file #调用内核测试 . "$CRASHDIR"/starts/check_core.sh && check_core && "$TMPDIR"/CrashCore merge "$TMPDIR"/config.json -C "$TMPDIR"/providers diff --git a/scripts/menus/fw_filter.sh b/scripts/menus/fw_filter.sh index 605e587f..40b57bcb 100644 --- a/scripts/menus/fw_filter.sh +++ b/scripts/menus/fw_filter.sh @@ -16,7 +16,7 @@ set_fw_filter() { echo -e " 1 过滤非常用端口: \033[36m$common_ports\033[0m ————用于过滤P2P流量" echo -e " 2 过滤局域网设备: \033[36m$mac_return\033[0m ————使用黑/白名单进行过滤" echo -e " 3 过滤QUIC协议: \033[36m$quic_rj\033[0m ————优化视频性能" - echo -e " 4 过滤CN_IP(6)列表: \033[36m$cn_ip_route\033[0m ————优化性能,不兼容Fake-ip" + echo -e " 4 过滤CN_IP(4/6)列表: \033[36m$cn_ip_route\033[0m ————优化性能" echo -e " 5 自定义透明路由ipv4网段: 适合vlan等复杂网络环境" echo -e " 6 自定义保留地址ipv4网段: 需要以保留地址为访问目标的环境" echo "-----------------------------------------------" @@ -105,80 +105,82 @@ set_fw_filter() { } set_common_ports() { - [ -z "$multiport" ] && multiport='22,80,443,8080,8443' - echo "-----------------------------------------------" - echo -e "\033[31m注意:\033[0mMIX模式下,所有fake-ip来源的非常用端口流量不会被过滤" - [ -n "$common_ports" ] && - echo -e "当前放行端口:\033[36m$multiport\033[0m" - echo "-----------------------------------------------" - echo -e " 1 启用/关闭端口过滤: \033[36m$common_ports\033[0m" - echo -e " 2 添加放行端口" - echo -e " 3 移除指定放行端口" - echo -e " 4 重置默认放行端口" - echo -e " 5 重置为旧版放行端口" - echo -e " 0 返回上级菜单" - echo "-----------------------------------------------" - read -p "请输入对应数字 > " num - case $num in - 1) - if [ "$common_ports" = ON ];then - common_ports=OFF - else - common_ports=ON - fi - setconfig common_ports "$common_ports" - set_common_ports - ;; - 2) - port_count=$(echo "$multiport" | awk -F',' '{print NF}' ) - if [ "$port_count" -ge 15 ];then - echo -e "\033[31m最多支持设置放行15个端口,请先减少一些!\033[0m" - else - read -p "请输入要放行的端口号 > " port - if echo ",$multiport," | grep -q ",$port,";then - echo -e "\033[31m输入错误!请勿重复添加!\033[0m" - elif [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then - echo -e "\033[31m输入错误!请输入正确的数值(1-65535)!\033[0m" - else - multiport=$(echo "$multiport,$port" | sed "s/^,//") - setconfig multiport "$multiport" - fi - fi - sleep 1 - set_common_ports - ;; - 3) - read -p "请输入要移除的端口号 > " port - if echo ",$multiport," | grep -q ",$port,";then - if [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then - echo -e "\033[31m输入错误!请输入正确的数值(1-65535)!\033[0m" - else - multiport=$(echo ",$multiport," | sed "s/,$port//; s/^,//; s/,$//") - setconfig multiport "$multiport" - fi - else - echo -e "\033[31m输入错误!请输入已添加过的端口!\033[0m" - fi - sleep 1 - set_common_ports - ;; - 4) - multiport='' - setconfig multiport - sleep 1 - set_common_ports - ;; - 5) - multiport='22,80,143,194,443,465,587,853,993,995,5222,8080,8443' - setconfig multiport "$multiport" - sleep 1 - set_common_ports - ;; - *) - errornum - ;; - esac + while true; do + [ -z "$multiport" ] && multiport='22,80,443,8080,8443' + echo "-----------------------------------------------" + echo -e "\033[31m注意:\033[0mMIX模式下,所有fake-ip来源的非常用端口流量不会被过滤" + [ -n "$common_ports" ] && + echo -e "当前放行端口:\033[36m$multiport\033[0m" + echo "-----------------------------------------------" + echo -e " 1 启用/关闭端口过滤: \033[36m$common_ports\033[0m" + echo -e " 2 添加放行端口" + echo -e " 3 移除指定放行端口" + echo -e " 4 重置默认放行端口" + echo -e " 5 重置为旧版放行端口" + echo -e " 0 返回上级菜单" + echo "-----------------------------------------------" + read -r -p "请输入对应数字 > " num + case "$num" in + "" | 0) + break + ;; + 1) + if [ "$common_ports" = ON ]; then + common_ports=OFF + else + common_ports=ON + fi + setconfig common_ports "$common_ports" + ;; + 2) + port_count=$(echo "$multiport" | awk -F',' '{print NF}') + if [ "$port_count" -ge 15 ]; then + echo -e "\033[31m最多支持设置放行15个端口,请先减少一些!\033[0m" + else + read -r -p "请输入要放行的端口号 > " port + if echo ",$multiport," | grep -q ",$port,"; then + echo -e "\033[31m输入错误!请勿重复添加!\033[0m" + elif [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then + echo -e "\033[31m输入错误!请输入正确的数值(1-65535)!\033[0m" + else + multiport=$(echo "$multiport,$port" | sed "s/^,//") + setconfig multiport "$multiport" + fi + fi + sleep 1 + ;; + 3) + read -r -p "请输入要移除的端口号 > " port + if echo ",$multiport," | grep -q ",$port,"; then + if [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then + echo -e "\033[31m输入错误!请输入正确的数值(1-65535)!\033[0m" + else + multiport=$(echo ",$multiport," | sed "s/,$port//; s/^,//; s/,$//") + setconfig multiport "$multiport" + fi + else + echo -e "\033[31m输入错误!请输入已添加过的端口!\033[0m" + fi + sleep 1 + ;; + 4) + multiport='' + setconfig multiport + sleep 1 + ;; + 5) + multiport='22,80,143,194,443,465,587,853,993,995,5222,8080,8443' + setconfig multiport "$multiport" + sleep 1 + ;; + *) + errornum + sleep 1 + ;; + esac + done } + set_cust_host_ipv4() { #自定义ipv4透明路由网段 [ -z "$replace_default_host_ipv4" ] && replace_default_host_ipv4="OFF" . "$CRASHDIR"/starts/fw_getlanip.sh && getlanip diff --git a/scripts/menus/running_status.sh b/scripts/menus/running_status.sh index 1e0245a9..e62c8acc 100644 --- a/scripts/menus/running_status.sh +++ b/scripts/menus/running_status.sh @@ -7,7 +7,7 @@ running_status(){ if [ -n "$start_time" ]; then time=$(($(date +%s) - start_time)) day=$((time / 86400)) - [ "$day" = "0" ] && day='' || day="$day天" - time=$(date -u -d @${time} +%H小时%M分%S秒) + [ "$day" = "0" ] && day='' || day="$dayD" + time=$(date -u -d @${time} +%H:%M:%S) fi } diff --git a/scripts/menus/tui_layout.sh b/scripts/menus/tui_layout.sh index 2e6bc65b..7c10ddba 100644 --- a/scripts/menus/tui_layout.sh +++ b/scripts/menus/tui_layout.sh @@ -14,35 +14,10 @@ FULL_EQ="======================================================================= FULL_DASH="- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " # function to print content lines -# (using cursor jump with auto-wrapping and color handling) +# (using cursor jump) content_line() { local param="${1:-}" - - # Calculate Available Text Width - local text_width=$((TABLE_WIDTH - 3)) - - # 1. Extract color codes (if present) - # Use sed to capture the leading ANSI Escape Code (\x1b is the hexadecimal representation of ESC) - # This line extracts \033[33m... from \033[33m and stores it in color_code - local color_code - color_code=$(echo -e "$param" | sed -n 's/^\(\x1b\[[0-9;]*m\).*/\1/p') - - # 2. Generate Clean Text - # Use sed to remove all ANSI color codes, retaining only plain text content - # This allows fold to accurately count characters without premature line breaks - local clean_text - clean_text=$(echo -e "$param" | sed 's/\x1b\[[0-9;]*m//g') - - if [ -z "$clean_text" ]; then - echo -e " \033[${TABLE_WIDTH}G||" - else - # 3. Insert line breaks in plain text - echo "$clean_text" | fold -s -w "$text_width" | while IFS= read -r line; do - # 4. Output Restructuring - # Force the addition of color_code to each line and append \033[0m to reset at the end - echo -e " ${color_code}${line}\033[0m\033[${TABLE_WIDTH}G||" - done - fi + echo -e " ${param}\033[${TABLE_WIDTH}G||" } # function to print sub content lines diff --git a/scripts/starts/singbox_modify.sh b/scripts/starts/singbox_modify.sh index edec27cf..1a04c444 100644 --- a/scripts/starts/singbox_modify.sh +++ b/scripts/starts/singbox_modify.sh @@ -200,7 +200,7 @@ EOF EOF #生成add_route.json #域名嗅探配置 - [ "$sniffer" = ON ] && ! grep -Eq '"action" *:[[:space:]]*"sniff"' "$CRASHDIR"/jsons/*.json && sniffer_set='{ "action": "sniff", "timeout": "500ms" },' + [ "$sniffer" = ON ] && sniffer_set='{ "action": "sniff", "timeout": "500ms" },' [ "$ts_service" = ON ] && tailscale_set='{ "inbound": [ "ts-ep" ], "port": 53, "action": "hijack-dns" },' cat >"$TMPDIR"/jsons/add_route.json <