From f1f8fa43958ceeb84effee72289964ded9080819 Mon Sep 17 00:00:00 2001 From: delichik Date: Fri, 5 Jul 2024 15:45:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(firewall/set=5Fcust=5Fhost=5Fipv4):=20?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E4=BD=BF=E7=94=A8=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=BD=91=E6=AE=B5=E8=A6=86=E7=9B=96=E9=BB=98=E8=AE=A4=E9=80=8F?= =?UTF-8?q?=E6=98=8E=E8=B7=AF=E7=94=B1=E7=BD=91=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/menu.sh | 21 ++++++++++++++++----- scripts/start.sh | 6 +++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/scripts/menu.sh b/scripts/menu.sh index 79c05318a..e7183c8d1 100644 --- a/scripts/menu.sh +++ b/scripts/menu.sh @@ -723,16 +723,27 @@ setipv6(){ #ipv6设置 esac } setfirewall(){ #防火墙设置 - set_cust_host_ipv4(){ + set_cust_host_ipv4(){ + [ -z "$replace_default_host_ipv4" ] && replace_default_host_ipv4="未开启" + echo ----------------------------------------------- - echo -e "当前已自动设置透明路由的网段为: \033[32m$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep 'br' | grep -v 'iot' | grep -E ' 1(92|0|72)\.' | sed 's/.*inet.//g' | sed 's/br.*$//g' | sed 's/metric.*$//g' | tr '\n' ' ' && echo ) \033[0m" + echo -e "当前默认透明路由的网段为: \033[32m$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep 'br' | grep -v 'iot' | grep -E ' 1(92|0|72)\.' | sed 's/.*inet.//g' | sed 's/br.*$//g' | sed 's/metric.*$//g' | tr '\n' ' ' && echo ) \033[0m" echo -e "当前已添加的自定义网段为:\033[36m$cust_host_ipv4\033[0m" - echo ----------------------------------------------- - echo -e "\033[33m自定义网段不会覆盖自动获取的网段地址,无需重复添加\033[0m" + echo ----------------------------------------------- echo -e " 1 移除所有自定义网段" + echo -e " 2 使用自定义网段覆盖默认网段 \033[36m$replace_default_host_ipv4\033[0m" echo -e " 0 返回上级菜单" - read -p "请输入需要额外添加的网段 > " text + read -p "请输入对应的序号或需要额外添加的网段 > " text case $text in + 2) + if [ "$replace_default_host_ipv4" == "未禁用" ]; then + replace_default_host_ipv4="已禁用" + else + replace_default_host_ipv4="未禁用" + fi + setconfig replace_default_host_ipv4 "$replace_default_host_ipv4" + set_cust_host_ipv4 + ;; 1) unset cust_host_ipv4 setconfig cust_host_ipv4 diff --git a/scripts/start.sh b/scripts/start.sh index 5669843c1..ae33c2b94 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -194,7 +194,11 @@ getlanip() { #获取局域网host地址 sleep 1 && i=$((i + 1)) done #添加自定义ipv4局域网网段 - host_ipv4="$host_ipv4$cust_host_ipv4" + if [ "$replace_default_host_ipv4" == "未禁用" ]; then + host_ipv4="$cust_host_ipv4" + else + host_ipv4="$host_ipv4$cust_host_ipv4" + fi #缺省配置 [ -z "$host_ipv4" ] && host_ipv4='192.168.0.0/16 10.0.0.0/12 172.16.0.0/12' host_ipv6="fe80::/10 fd00::/8 $host_ipv6"