From c6b32715dd458d0271a3406834334de222af5c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LZ=EF=BC=88=E5=A6=99=E5=A6=99=E5=91=9C=EF=BC=89?= <73221087+larsonzh@users.noreply.github.com> Date: Sun, 27 Oct 2024 14:57:11 +0800 Subject: [PATCH] v4.6.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.优化代码。 --- source_codes/install.sh | 4 +-- source_codes/lz/Changelog.txt | 3 ++ source_codes/lz/configs/lz_rule_config.sh | 2 +- .../lz/func/lz_clear_custom_scripts_data.sh | 2 +- .../lz/func/lz_define_global_variables.sh | 7 ++-- source_codes/lz/func/lz_initialize_config.sh | 2 +- source_codes/lz/func/lz_rule_address_query.sh | 21 +++++------- source_codes/lz/func/lz_rule_func.sh | 34 +++++++++---------- source_codes/lz/func/lz_rule_status.sh | 15 ++++---- source_codes/lz/func/lz_vpn_daemon.sh | 4 +-- source_codes/lz/interface/lz_rule_service.sh | 4 +-- source_codes/lz/js/lz_policy_routing.js | 2 +- source_codes/lz/lz_rule.sh | 4 +-- source_codes/lz/uninstall.sh | 4 +-- .../lz/webs/LZ_Policy_Routing_Content.asp | 2 +- 15 files changed, 51 insertions(+), 59 deletions(-) diff --git a/source_codes/install.sh b/source_codes/install.sh index cb6a3966..1dc7ca83 100644 --- a/source_codes/install.sh +++ b/source_codes/install.sh @@ -1,5 +1,5 @@ #!/bin/sh -# install.sh v4.6.4 +# install.sh v4.6.5 # By LZ 妙妙呜 (larsonzhang@gmail.com) # LZ RULE script for Asuswrt-Merlin Router @@ -11,7 +11,7 @@ #BEGIN -LZ_VERSION=v4.6.4 +LZ_VERSION=v4.6.5 TIMEOUT=10 CURRENT_PATH="${0%/*}" [ "${CURRENT_PATH:0:1}" != '/' ] && CURRENT_PATH="$( pwd )${CURRENT_PATH#*.}" diff --git a/source_codes/lz/Changelog.txt b/source_codes/lz/Changelog.txt index 7f1f3a49..2e8ac3d9 100644 --- a/source_codes/lz/Changelog.txt +++ b/source_codes/lz/Changelog.txt @@ -1,3 +1,6 @@ +v4.6.5 (2024/10/27) + 1.优化代码。 + v4.6.4 (2024/10/27) 1.新增 CIDR 网段地址数据校验及错误自动修正机制。 2.完善「在线检测新版本」代码逻辑,适配相关站点网络访 diff --git a/source_codes/lz/configs/lz_rule_config.sh b/source_codes/lz/configs/lz_rule_config.sh index fdb09620..a9ab15d2 100644 --- a/source_codes/lz/configs/lz_rule_config.sh +++ b/source_codes/lz/configs/lz_rule_config.sh @@ -1,5 +1,5 @@ #!/bin/sh -# lz_rule_config.sh v4.6.4 +# lz_rule_config.sh v4.6.5 # By LZ 妙妙呜 (larsonzhang@gmail.com) # 本软件采用CIDR(无类别域间路由,Classless Inter-Domain Routing)技术,是一个在Internet上创建附加地 diff --git a/source_codes/lz/func/lz_clear_custom_scripts_data.sh b/source_codes/lz/func/lz_clear_custom_scripts_data.sh index 11f1f748..c8f66e1d 100644 --- a/source_codes/lz/func/lz_clear_custom_scripts_data.sh +++ b/source_codes/lz/func/lz_clear_custom_scripts_data.sh @@ -1,5 +1,5 @@ #!/bin/sh -# lz_clear_custom_scripts_data.sh v4.6.4 +# lz_clear_custom_scripts_data.sh v4.6.5 # By LZ 妙妙呜 (larsonzhang@gmail.com) ## 清除用户自定义脚本数据 diff --git a/source_codes/lz/func/lz_define_global_variables.sh b/source_codes/lz/func/lz_define_global_variables.sh index f46572b8..187610bc 100644 --- a/source_codes/lz/func/lz_define_global_variables.sh +++ b/source_codes/lz/func/lz_define_global_variables.sh @@ -1,5 +1,5 @@ #!/bin/sh -# lz_define_global_variables.sh v4.6.4 +# lz_define_global_variables.sh v4.6.5 # By LZ 妙妙呜 (larsonzhang@gmail.com) # QnkgTFog5aaZ5aaZ5ZGc77yI6Juk6J+G5aKp5YS/77yJ(首次运行标识,切勿修改) @@ -415,9 +415,7 @@ route_static_subnet="$( ip -o -4 address list | awk '$2 == "br0" {print $4; exit route_local_ip="${route_static_subnet%/*}" ## 路由器本地子网 -route_local_subnet="" -if [ -n "${route_static_subnet}" ]; then - route_local_subnet="$( awk -v ipv="${route_static_subnet}" 'function fix_cidr(ipa) { +route_local_subnet="$( awk -v ipv="${route_static_subnet}" 'function fix_cidr(ipa) { if (ipa ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) { if (split(ipa, arr, /\.|\//) == 5) { pos = int(arr[5] / 8) + 1; @@ -438,7 +436,6 @@ if [ -n "${route_static_subnet}" ]; then return ipa; } \ BEGIN{print fix_cidr(ipv);}' )" -fi ## 静态分流模式整体通道推送命令是否执行(0--未执行;1--已执行) command_from_all_executed="0" diff --git a/source_codes/lz/func/lz_initialize_config.sh b/source_codes/lz/func/lz_initialize_config.sh index 6edaeec6..95c693b5 100644 --- a/source_codes/lz/func/lz_initialize_config.sh +++ b/source_codes/lz/func/lz_initialize_config.sh @@ -1,5 +1,5 @@ #!/bin/sh -# lz_initialize_config.sh v4.6.4 +# lz_initialize_config.sh v4.6.5 # By LZ 妙妙呜 (larsonzhang@gmail.com) ## 初始化脚本配置 diff --git a/source_codes/lz/func/lz_rule_address_query.sh b/source_codes/lz/func/lz_rule_address_query.sh index 75480a8c..a190f787 100644 --- a/source_codes/lz/func/lz_rule_address_query.sh +++ b/source_codes/lz/func/lz_rule_address_query.sh @@ -1,5 +1,5 @@ #!/bin/sh -# lz_rule_address_query.sh v4.6.4 +# lz_rule_address_query.sh v4.6.5 # By LZ 妙妙呜 (larsonzhang@gmail.com) ## 网址信息查询脚本 @@ -94,7 +94,7 @@ lz_aq_print_ipv4_address_list() { -e '/^\([0-9]\{1,3\}[\.]\)\{3\}[0-9]\{1,3\}\([\/][0-9]\{1,2\}\)\?$/!d' \ -e '/[3-9][0-9][0-9]\|[2][6-9][0-9]\|[2][5][6-9]\|[\/][4-9][0-9]\|[\/][3][3-9]/d' \ -e 's/[\/]32//g' \ - -e "/\(^\|[[:space:]]\)\(0\+[\.]0\+[\.]0\+[\.]0\+\|${aq_route_local_ip}\)\([[:space:]]\|$\)/d" "${1}" \ + -e "/\(^\|[[:space:]]\)\(0\([\.]0\)\{3\}\|${aq_route_local_ip}\)\([[:space:]]\|$\)/d" "${1}" \ | awk 'function fix_cidr(ipa) { split(ipa, arr, /\.|\//); if (arr[5] !~ /^[0-9][0-9]?$/) @@ -143,7 +143,7 @@ lz_aq_print_src_to_dst_ipv4_address_list() { -e '/^\([0-9]\{1,3\}[\.]\)\{3\}[0-9]\{1,3\}\([\/][0-9]\{1,2\}\)\?[[:space:]]\([0-9]\{1,3\}[\.]\)\{3\}[0-9]\{1,3\}\([\/][0-9]\{1,2\}\)\?$/!d' \ -e '/[3-9][0-9][0-9]\|[2][6-9][0-9]\|[2][5][6-9]\|[\/][4-9][0-9]\|[\/][3][3-9]/d' \ -e 's/[\/]32//g' \ - -e "/\(^\|[[:space:]]\)\(0\+[\.]0\+[\.]0\+[\.]0\+\|${aq_route_local_ip}\)\([[:space:]]\|$\)/d" "${1}" \ + -e "/\(^\|[[:space:]]\)\(0\([\.]0\)\{3\}\|${aq_route_local_ip}\)\([[:space:]]\|$\)/d" "${1}" \ | awk 'function fix_cidr(ipa) { split(ipa, arr, /\.|\//); if (arr[5] !~ /^[0-9][0-9]?$/) @@ -181,7 +181,7 @@ lz_aq_print_src_to_dst_port_ipv4_address_list() { -e 's/\(^\|[^[:digit:]]\)[0]\+\([[:digit:]]\)/\1\2/g' \ -e '/^\([^[:space:]]\+[[:space:]]\)\?[^[:space:]]*\([3-9][0-9][0-9]\|[2][6-9][0-9]\|[2][5][6-9]\|[\/][4-9][0-9]\|[\/][3][3-9]\)[^[:space:]]*\([[:space:]]\|$\)/d' \ -e 's/[\/]32//g' \ - -e "/\(^\|[[:space:]]\)\(0\+[\.]0\+[\.]0\+[\.]0\+\|${aq_route_local_ip}\)\([[:space:]]\|$\)/d" \ + -e "/\(^\|[[:space:]]\)\(0\([\.]0\)\{3\}\|${aq_route_local_ip}\)\([[:space:]]\|$\)/d" \ | awk 'function fix_cidr(ipa) { split(ipa, arr, /\.|\//); if (arr[5] !~ /^[0-9][0-9]?$/) @@ -696,9 +696,7 @@ lz_aq_get_route_local_address_info() { [ -n "$aq_route_local_ip_cidr_mask" ] && aq_route_local_ip_cidr_mask="$( lz_aq_netmask2cdr "${aq_route_local_ip_cidr_mask}" )" aq_route_static_subnet="$( ip -o -4 address list | awk '$2 == "br0" {print $4; exit;}' | grep -Eo '^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$' )" - aq_route_local_subnet="" - if [ -n "${aq_route_static_subnet}" ]; then - aq_route_local_subnet="$( awk -v ipv="${aq_route_static_subnet}" 'function fix_cidr(ipa) { + aq_route_local_subnet="$( awk -v ipv="${aq_route_static_subnet}" 'function fix_cidr(ipa) { if (ipa ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) { if (split(ipa, arr, /\.|\//) == 5) { pos = int(arr[5] / 8) + 1; @@ -719,7 +717,6 @@ lz_aq_get_route_local_address_info() { return ipa; } \ BEGIN{print fix_cidr(ipv);}' )" - fi } ## 设置网址信息查询用变量函数 @@ -1261,9 +1258,9 @@ lz_query_address() { ipset -q flush lz_aq_ispip_tmp_sets ## 第一WAN口的DNS解析服务器网址 eval "$( nvram get "wan0_dns" | awk 'NF >= "1" { - if ($1 !~ /^0+[\.]0+[\.]0+[\.]0+$/ && $1 !~ /^127[\.]0+[\.]0+[\.]0*1$/ && $1 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) + if ($1 != "0.0.0.0" && $1 != "127.0.0.1" && $1 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) print "ipset -q add lz_aq_ispip_tmp_sets "$1; - if ($2 !~ /^0+[\.]0+[\.]0+[\.]0+$/ && $2 !~ /^127[\.]0+[\.]0+[\.]0*1$/ && $2 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) + if ($2 != "0.0.0.0" && $2 != "127.0.0.1" && $2 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) print "ipset -q add lz_aq_ispip_tmp_sets "$2; exit; }' )" @@ -1284,9 +1281,9 @@ lz_query_address() { ipset -q flush lz_aq_ispip_tmp_sets ## 第二WAN口的DNS解析服务器网址 eval "$( nvram get "wan1_dns" | awk 'NF >= "1" { - if ($1 !~ /^0+[\.]0+[\.]0+[\.]0+$/ && $1 !~ /^127[\.]0+[\.]0+[\.]0*1$/ && $1 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) + if ($1 != "0.0.0.0" && $1 != "127.0.0.1" && $1 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) print "ipset -q add lz_aq_ispip_tmp_sets "$1; - if ($2 !~ /^0+[\.]0+[\.]0+[\.]0+$/ && $2 !~ /^127[\.]0+[\.]0+[\.]0*1$/ && $2 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) + if ($2 != "0.0.0.0" && $2 != "127.0.0.1" && $2 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) print "ipset -q add lz_aq_ispip_tmp_sets "$2; exit; }' )" diff --git a/source_codes/lz/func/lz_rule_func.sh b/source_codes/lz/func/lz_rule_func.sh index 7c3d01cc..5a693235 100644 --- a/source_codes/lz/func/lz_rule_func.sh +++ b/source_codes/lz/func/lz_rule_func.sh @@ -1,5 +1,5 @@ #!/bin/sh -# lz_rule_func.sh v4.6.4 +# lz_rule_func.sh v4.6.5 # By LZ 妙妙呜 (larsonzhang@gmail.com) #BEGIN @@ -64,7 +64,7 @@ lz_print_ipv4_address_list() { -e '/^\([0-9]\{1,3\}[\.]\)\{3\}[0-9]\{1,3\}\([\/][0-9]\{1,2\}\)\?$/!d' \ -e '/[3-9][0-9][0-9]\|[2][6-9][0-9]\|[2][5][6-9]\|[\/][4-9][0-9]\|[\/][3][3-9]/d' \ -e 's/[\/]32//g' \ - -e "/\(^\|[[:space:]]\)\(0\+[\.]0\+[\.]0\+[\.]0\+\|${route_local_ip}\)\([[:space:]]\|$\)/d" "${1}" \ + -e "/\(^\|[[:space:]]\)\(0\([\.]0\)\{3\}\|${route_local_ip}\)\([[:space:]]\|$\)/d" "${1}" \ | awk 'function fix_cidr(ipa) { split(ipa, arr, /\.|\//); if (arr[5] !~ /^[0-9][0-9]?$/) @@ -113,7 +113,7 @@ lz_print_src_to_dst_ipv4_address_list() { -e '/^\([0-9]\{1,3\}[\.]\)\{3\}[0-9]\{1,3\}\([\/][0-9]\{1,2\}\)\?[[:space:]]\([0-9]\{1,3\}[\.]\)\{3\}[0-9]\{1,3\}\([\/][0-9]\{1,2\}\)\?$/!d' \ -e '/[3-9][0-9][0-9]\|[2][6-9][0-9]\|[2][5][6-9]\|[\/][4-9][0-9]\|[\/][3][3-9]/d' \ -e 's/[\/]32//g' \ - -e "/\(^\|[[:space:]]\)\(0\+[\.]0\+[\.]0\+[\.]0\+\|${route_local_ip}\)\([[:space:]]\|$\)/d" "${1}" \ + -e "/\(^\|[[:space:]]\)\(0\([\.]0\)\{3\}\|${route_local_ip}\)\([[:space:]]\|$\)/d" "${1}" \ | awk 'function fix_cidr(ipa) { split(ipa, arr, /\.|\//); if (arr[5] !~ /^[0-9][0-9]?$/) @@ -151,7 +151,7 @@ lz_print_src_to_dst_port_ipv4_address_list() { -e 's/\(^\|[^[:digit:]]\)[0]\+\([[:digit:]]\)/\1\2/g' \ -e '/^\([^[:space:]]\+[[:space:]]\)\?[^[:space:]]*\([3-9][0-9][0-9]\|[2][6-9][0-9]\|[2][5][6-9]\|[\/][4-9][0-9]\|[\/][3][3-9]\)[^[:space:]]*\([[:space:]]\|$\)/d' \ -e 's/[\/]32//g' \ - -e "/\(^\|[[:space:]]\)\(0\+[\.]0\+[\.]0\+[\.]0\+\|${route_local_ip}\)\([[:space:]]\|$\)/d" \ + -e "/\(^\|[[:space:]]\)\(0\([\.]0\)\{3\}\|${route_local_ip}\)\([[:space:]]\|$\)/d" \ | awk 'function fix_cidr(ipa) { split(ipa, arr, /\.|\//); if (arr[5] !~ /^[0-9][0-9]?$/) @@ -233,7 +233,7 @@ lz_get_custom_hosts_list() { -e 's/^\([^[:space:]]\+[[:space:]][^[:space:]]\+\)\([[:space:]].*\|\)$/\1/g' \ -e '/^[[:alnum:]]\([[:alnum:]-]\{0,61\}[[:alnum:]]\)\?\([\.][[:alnum:]]\([[:alnum:]-]\{0,61\}[[:alnum:]]\)\?\)*[[:space:]][[:alnum:]]\([[:alnum:]-]\{0,61\}[[:alnum:]]\)\?\([\.][[:alnum:]]\([[:alnum:]-]\{0,61\}[[:alnum:]]\)\?\)*$/!d' \ -e '/[^[:space:]]\{256,\}\|[-]\{2,\}/d' \ - -e "/^0\+[\.]0\+[\.]0\+[\.]0\+[[:space:]]/d" "${1}" 2> /dev/null | tr '[:A-Z:]' '[:a-z:]' + -e "/^0\+\([\.]0\+\)\{3\}[[:space:]]/d" "${1}" 2> /dev/null | tr '[:A-Z:]' '[:a-z:]' } ## 获取自定义域名地址解析条目列表数据文件总有效条目数函数 @@ -3358,16 +3358,16 @@ lz_initialize_ip_data_policy() { ## 获取WAN口的DNS解析服务器网址 local local_ifip_wan0_dns1="" local_ifip_wan0_dns2="" local_ifip_wan1_dns1="" local_ifip_wan1_dns2="" eval "$( nvram get "wan0_dns" | awk 'NF >= "1" { - if ($1 !~ /^0+[\.]0+[\.]0+[\.]0+$/ && $1 !~ /^127[\.]0+[\.]0+[\.]0*1$/ && $1 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) + if ($1 != "0.0.0.0" && $1 != "127.0.0.1" && $1 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) print "local_ifip_wan0_dns1="$1; - if ($2 !~ /^0+[\.]0+[\.]0+[\.]0+$/ && $2 !~ /^127[\.]0+[\.]0+[\.]0*1$/ && $2 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) + if ($2 != "0.0.0.0" && $2 != "127.0.0.1" && $2 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) print "local_ifip_wan0_dns2="$2; exit; }' )" eval "$( nvram get "wan1_dns" | awk 'NF >= "1" { - if ($1 !~ /^0+[\.]0+[\.]0+[\.]0+$/ && $1 !~ /^127[\.]0+[\.]0+[\.]0*1$/ && $1 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) + if ($1 != "0.0.0.0" && $1 != "127.0.0.1" && $1 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) print "local_ifip_wan1_dns1="$1; - if ($2 !~ /^0+[\.]0+[\.]0+[\.]0+$/ && $2 !~ /^127[\.]0+[\.]0+[\.]0*1$/ && $2 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) + if ($2 != "0.0.0.0" && $2 != "127.0.0.1" && $2 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) print "local_ifip_wan1_dns2="$2; exit; }' )" @@ -3682,16 +3682,16 @@ lz_proxy_route_support() { ip rule add from "${line}" to "0.0.0.0" table "${wan_no}" prio "${IP_RULE_PRIO_TOPEST}" > /dev/null 2>&1 else if [ "${dn_pre_resolved}" = "0" ]; then - nslookup "${line}" 2> /dev/null | awk 'NR > 4 && $3 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}$/ && $3 !~ /^0+[\.]0+[\.]0+[\.]0+$/ \ + nslookup "${line}" 2> /dev/null | awk 'NR > 4 && $3 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}$/ && $3 != "0.0.0.0" \ {system("ip rule add from 0.0.0.0 to "$3"'" table ${wan_no} prio ${IP_RULE_PRIO_TOPEST} > /dev/null 2>&1; ip rule add from "'"$3"'" to 0.0.0.0 table ${wan_no} prio ${IP_RULE_PRIO_TOPEST} > /dev/null 2>&1"'")}' elif [ "${dn_pre_resolved}" = "1" ]; then [ "${pre_dns_enable}" = "0" ] \ - && nslookup "${line}" "${pre_dns}" 2> /dev/null | awk 'NR > 4 && $3 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}$/ && $3 !~ /^0+[\.]0+[\.]0+[\.]0+$/ \ + && nslookup "${line}" "${pre_dns}" 2> /dev/null | awk 'NR > 4 && $3 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}$/ && $3 != "0.0.0.0" \ {system("ip rule add from 0.0.0.0 to "$3"'" table ${wan_no} prio ${IP_RULE_PRIO_TOPEST} > /dev/null 2>&1; ip rule add from "'"$3"'" to 0.0.0.0 table ${wan_no} prio ${IP_RULE_PRIO_TOPEST} > /dev/null 2>&1"'")}' elif [ "${dn_pre_resolved}" = "2" ]; then - node_list="$( nslookup "${line}" 2> /dev/null | awk 'NR > 4 && $3 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}$/ && $3 !~ /^0+[\.]0+[\.]0+[\.]0+$/ {print $3}' )" + node_list="$( nslookup "${line}" 2> /dev/null | awk 'NR > 4 && $3 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}$/ && $3 != "0.0.0.0" {print $3}' )" [ "${pre_dns_enable}" = "0" ] \ - && eval "$( nslookup "${line}" "${pre_dns}" 2> /dev/null | awk 'NR > 4 && $3 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}$/ && $3 !~ /^0+[\.]0+[\.]0+[\.]0+$/ \ + && eval "$( nslookup "${line}" "${pre_dns}" 2> /dev/null | awk 'NR > 4 && $3 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}$/ && $3 != "0.0.0.0" \ {printf "node_list=\"\$\( echo \"\${node_list}\" \| sed -e \"\\\$a %s\" -e \"\/\^[[:space:]]\*\$\/d\" \)\"\n", $3}' )" echo "${node_list}" | awk '$1 ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}$/ && !i[$1]++ \ {system("ip rule add from 0.0.0.0 to "$1"'" table ${wan_no} prio ${IP_RULE_PRIO_TOPEST} > /dev/null 2>&1; ip rule add from "'"$1"'" to 0.0.0.0 table ${wan_no} prio ${IP_RULE_PRIO_TOPEST} > /dev/null 2>&1"'")}' @@ -4989,7 +4989,7 @@ lz_output_dport_policy_info_to_system_records() { if ip rule show | grep -q "^[[:space:]]*${1}:[[:space:]]*from[[:space:]]*all[[:space:]]*fwmark[[:space:]]*${2}[[:space:]]*lookup"; then iptables -t mangle -L "${CUSTOM_PREROUTING_CONNMARK_CHAIN}" -n 2> /dev/null \ | sed -n "/CONNMARK[[:space:]]*set[[:space:]]*${2}$/p" \ - | sed -e 's/^.*[[:space:]]\(tcp\|udp\|udplite\|sctp\|dccp\)[^[:alpha:]].*[[:space:]]0\+[\.]0\+[\.]0\+[\.]0\+[\/]0\+[[:space:]]\+0\+[\.]0\+[\.]0\+[\.]0\+[\/]0\+[[:space:]].*dports[[:space:]]\+\([^[:space:]]\+\)[[:space:]].*$/\1 \2/g' \ + | sed -e 's/^.*[[:space:]]\(tcp\|udp\|udplite\|sctp\|dccp\)[^[:alpha:]].*[[:space:]]0\([\.]0\)\{3\}[\/]0[[:space:]]\+0\([\.]0\)\{3\}[\/]0[[:space:]].*dports[[:space:]]\+\([^[:space:]]\+\)[[:space:]].*$/\1 \4/g' \ -e '/CONNMARK/d' \ | tr '[:a-z:]' '[:A-Z:]' \ | awk -v count="0" -v wan_name="${wan_name}" 'NF == "2" {print "'"$(lzdate) [${$}]: "'"wan_name" "$1": "$2; count++;} \ @@ -5069,8 +5069,7 @@ lz_add_dual_ip_rules() { ## 返回值:无 lz_add_src_to_dst_sets_ip_rules() { if [ -z "${1}" ] || [ ! -s "${2}" ]; then return; fi; - { echo "${1}" | grep -qEw '0+[\.]0+[\.]0+[\.]0+[\/]0+' || echo "${1}" | grep -qEw '0+[\.]0+[\.]0+[\.]0+' \ - || [ "${1}" = "${route_local_ip}" ]; } && return + { [ "${1}" = "0.0.0.0/0" ] || [ "${1}" = "0.0.0.0" ] || [ "${1}" = "${route_local_ip}" ]; } && return lz_print_valid_ipv4_address_list "${2}" | awk 'NF >= "1" && $1 != "'"${1}"'" \ {system("'"ip rule add from ${1} to "'"$1"'" table ${3} prio ${4} > /dev/null 2>&1"'");}' } @@ -5084,8 +5083,7 @@ lz_add_src_to_dst_sets_ip_rules() { ## 返回值:无 lz_add_src_sets_to_dst_ip_rules() { if [ ! -s "${1}" ] || [ -z "${2}" ]; then return; fi; - { echo "${2}" | grep -qEw '0+[\.]0+[\.]0+[\.]0+[\/]0+' || echo "${2}" | grep -qEw '0+[\.]0+[\.]0+[\.]0+' \ - || [ "${2}" = "${route_local_ip}" ]; } && return + { [ "${2}" = "0.0.0.0/0" ] || [ "${2}" = "0.0.0.0" ] || [ "${2}" = "${route_local_ip}" ]; } && return lz_print_valid_ipv4_address_list "${1}" | awk 'NF >= "1" && $1 != "'"${2}"'" \ {system("ip rule add from "$1"'" to ${2} table ${3} prio ${4} > /dev/null 2>&1"'");}' } diff --git a/source_codes/lz/func/lz_rule_status.sh b/source_codes/lz/func/lz_rule_status.sh index c626d987..18d1c3fb 100644 --- a/source_codes/lz/func/lz_rule_status.sh +++ b/source_codes/lz/func/lz_rule_status.sh @@ -1,5 +1,5 @@ #!/bin/sh -# lz_rule_status.sh v4.6.4 +# lz_rule_status.sh v4.6.5 # By LZ 妙妙呜 (larsonzhang@gmail.com) ## 显示脚本运行状态脚本 @@ -172,7 +172,7 @@ lz_print_ipv4_address_list_status() { -e '/^\([0-9]\{1,3\}[\.]\)\{3\}[0-9]\{1,3\}\([\/][0-9]\{1,2\}\)\?$/!d' \ -e '/[3-9][0-9][0-9]\|[2][6-9][0-9]\|[2][5][6-9]\|[\/][4-9][0-9]\|[\/][3][3-9]/d' \ -e 's/[\/]32//g' \ - -e "/\(^\|[[:space:]]\)\(0\+[\.]0\+[\.]0\+[\.]0\+\|${status_route_local_ip}\)\([[:space:]]\|$\)/d" "${1}" \ + -e "/\(^\|[[:space:]]\)\(0\([\.]0\)\{3\}\|${status_route_local_ip}\)\([[:space:]]\|$\)/d" "${1}" \ | awk 'function fix_cidr(ipa) { split(ipa, arr, /\.|\//); if (arr[5] !~ /^[0-9][0-9]?$/) @@ -221,7 +221,7 @@ lz_print_src_to_dst_ipv4_address_list_status() { -e '/^\([0-9]\{1,3\}[\.]\)\{3\}[0-9]\{1,3\}\([\/][0-9]\{1,2\}\)\?[[:space:]]\([0-9]\{1,3\}[\.]\)\{3\}[0-9]\{1,3\}\([\/][0-9]\{1,2\}\)\?$/!d' \ -e '/[3-9][0-9][0-9]\|[2][6-9][0-9]\|[2][5][6-9]\|[\/][4-9][0-9]\|[\/][3][3-9]/d' \ -e 's/[\/]32//g' \ - -e "/\(^\|[[:space:]]\)\(0\+[\.]0\+[\.]0\+[\.]0\+\|${status_route_local_ip}\)\([[:space:]]\|$\)/d" "${1}" \ + -e "/\(^\|[[:space:]]\)\(0\([\.]0\)\{3\}\|${status_route_local_ip}\)\([[:space:]]\|$\)/d" "${1}" \ | awk 'function fix_cidr(ipa) { split(ipa, arr, /\.|\//); if (arr[5] !~ /^[0-9][0-9]?$/) @@ -259,7 +259,7 @@ lz_print_src_to_dst_port_ipv4_address_list_status() { -e 's/\(^\|[^[:digit:]]\)[0]\+\([[:digit:]]\)/\1\2/g' \ -e '/^\([^[:space:]]\+[[:space:]]\)\?[^[:space:]]*\([3-9][0-9][0-9]\|[2][6-9][0-9]\|[2][5][6-9]\|[\/][4-9][0-9]\|[\/][3][3-9]\)[^[:space:]]*\([[:space:]]\|$\)/d' \ -e 's/[\/]32//g' \ - -e "/\(^\|[[:space:]]\)\(0\+[\.]0\+[\.]0\+[\.]0\+\|${status_route_local_ip}\)\([[:space:]]\|$\)/d" \ + -e "/\(^\|[[:space:]]\)\(0\([\.]0\)\{3\}\|${status_route_local_ip}\)\([[:space:]]\|$\)/d" \ | awk 'function fix_cidr(ipa) { split(ipa, arr, /\.|\//); if (arr[5] !~ /^[0-9][0-9]?$/) @@ -396,9 +396,7 @@ lz_set_parameter_status_variable() { status_route_static_subnet="$( ip -o -4 address list | awk '$2 == "br0" {print $4; exit;}' | grep -Eo '^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$' )" status_route_local_ip="${status_route_static_subnet%/*}" - status_route_local_subnet="" - if [ -n "${status_route_static_subnet}" ]; then - status_route_local_subnet="$( awk -v ipv="${status_route_static_subnet}" 'function fix_cidr(ipa) { + status_route_local_subnet="$( awk -v ipv="${status_route_static_subnet}" 'function fix_cidr(ipa) { if (ipa ~ /^([0-9]{1,3}[\.]){3}[0-9]{1,3}([\/][0-9]{1,2})?$/) { if (split(ipa, arr, /\.|\//) == 5) { pos = int(arr[5] / 8) + 1; @@ -419,7 +417,6 @@ lz_set_parameter_status_variable() { return ipa; } \ BEGIN{print fix_cidr(ipv);}' )" - fi status_ip_rule_exist=0 status_adjust_traffic_policy="5" @@ -2067,7 +2064,7 @@ lz_output_dport_policy_info_status() { if ip rule show | grep -q "^[[:space:]]*${1}:[[:space:]]*from[[:space:]]*all[[:space:]]*fwmark[[:space:]]*${2}[[:space:]]*lookup"; then iptables -t mangle -L "${STATUS_CUSTOM_PREROUTING_CONNMARK_CHAIN}" -n 2> /dev/null \ | sed -n "/CONNMARK[[:space:]]*set[[:space:]]*${2}$/p" \ - | sed -e 's/^.*[[:space:]]\(tcp\|udp\|udplite\|sctp\|dccp\)[^[:alpha:]].*[[:space:]]0\+[\.]0\+[\.]0\+[\.]0\+[\/]0\+[[:space:]]\+0\+[\.]0\+[\.]0\+[\.]0\+[\/]0\+[[:space:]].*dports[[:space:]]\+\([^[:space:]]\+\)[[:space:]].*$/\1 \2/g' \ + | sed -e 's/^.*[[:space:]]\(tcp\|udp\|udplite\|sctp\|dccp\)[^[:alpha:]].*[[:space:]]0\([\.]0\)\{3\}[\/]0[[:space:]]\+0\([\.]0\)\{3\}[\/]0[[:space:]].*dports[[:space:]]\+\([^[:space:]]\+\)[[:space:]].*$/\1 \4/g' \ -e '/CONNMARK/d' \ | tr '[:a-z:]' '[:A-Z:]' \ | awk -v count="0" -v wan_name="${wan_name}" 'NF == "2" {print "'"$(lzdate) [${$}]: "'"wan_name" "$1": "$2; count++;} \ diff --git a/source_codes/lz/func/lz_vpn_daemon.sh b/source_codes/lz/func/lz_vpn_daemon.sh index ad377295..1c91ccf4 100644 --- a/source_codes/lz/func/lz_vpn_daemon.sh +++ b/source_codes/lz/func/lz_vpn_daemon.sh @@ -1,5 +1,5 @@ #!/bin/sh -# lz_vpn_daemon.sh v4.6.4 +# lz_vpn_daemon.sh v4.6.5 # By LZ 妙妙呜 (larsonzhang@gmail.com) ## 虚拟专网客户端路由刷新处理后台守护进程脚本 @@ -10,7 +10,7 @@ #BEGIN ## 版本号 -LZ_VERSION=v4.6.4 +LZ_VERSION=v4.6.5 ## 项目接口文件部署路径 PATH_INTERFACE="${0%/*}" diff --git a/source_codes/lz/interface/lz_rule_service.sh b/source_codes/lz/interface/lz_rule_service.sh index 611b9da5..22316716 100644 --- a/source_codes/lz/interface/lz_rule_service.sh +++ b/source_codes/lz/interface/lz_rule_service.sh @@ -1,5 +1,5 @@ #!/bin/sh -# lz_rule_service.sh v4.6.4 +# lz_rule_service.sh v4.6.5 # By LZ 妙妙呜 (larsonzhang@gmail.com) ## 服务接口脚本 @@ -272,7 +272,7 @@ case "${2}" in -e '/^\([0-9]\{1,3\}[\.]\)\{3\}[0-9]\{1,3\}\([\/][0-9]\{1,2\}\)\?$/!d' \ -e '/[3-9][0-9][0-9]\|[2][6-9][0-9]\|[2][5][6-9]\|[\/][4-9][0-9]\|[\/][3][3-9]/d' \ -e 's/[\/]32//g' \ - -e "/\(^\|[[:space:]]\)\(0[\.]0[\.]0[\.]0\|0[\.]0[\.]0[\.]0[\/]0\|${route_local_ip}\)\([[:space:]]\|$\)/d" "${custom_data_file}" \ + -e "/\(^\|[[:space:]]\)\(0\([\.]0\)\{3\}\([\/]0\)\?\|${route_local_ip}\)\([[:space:]]\|$\)/d" "${custom_data_file}" \ | awk 'function fix_cidr(ipa) { split(ipa, arr, /\.|\//); if (arr[5] !~ /^[0-9][0-9]?$/) diff --git a/source_codes/lz/js/lz_policy_routing.js b/source_codes/lz/js/lz_policy_routing.js index 997fd432..f6db4319 100644 --- a/source_codes/lz/js/lz_policy_routing.js +++ b/source_codes/lz/js/lz_policy_routing.js @@ -1,5 +1,5 @@ /* -# lz_policy_routing.js v4.6.4 +# lz_policy_routing.js v4.6.5 # By LZ 妙妙呜 (larsonzhang@gmail.com) # LZ JavaScript for Asuswrt-Merlin Router diff --git a/source_codes/lz/lz_rule.sh b/source_codes/lz/lz_rule.sh index 48a006ba..210eb8f0 100644 --- a/source_codes/lz/lz_rule.sh +++ b/source_codes/lz/lz_rule.sh @@ -1,5 +1,5 @@ #!/bin/sh -# lz_rule.sh v4.6.4 +# lz_rule.sh v4.6.5 # By LZ 妙妙呜 (larsonzhang@gmail.com) # 本软件采用CIDR(无类别域间路由,Classless Inter-Domain Routing)技术,是一个在Internet上创建附加地 @@ -86,7 +86,7 @@ ## -------------全局数据定义及初始化------------------- ## 版本号 -LZ_VERSION=v4.6.4 +LZ_VERSION=v4.6.5 ## 运行状态查询命令 SHOW_STATUS="status" diff --git a/source_codes/lz/uninstall.sh b/source_codes/lz/uninstall.sh index 158774ff..a09616ef 100644 --- a/source_codes/lz/uninstall.sh +++ b/source_codes/lz/uninstall.sh @@ -1,5 +1,5 @@ #!/bin/sh -# uninstall.sh v4.6.4 +# uninstall.sh v4.6.5 # By LZ (larsonzhang@gmail.com) # LZ RULE script for Asuswrt-Merlin Router @@ -8,7 +8,7 @@ #BEGIN -LZ_VERSION=v4.6.4 +LZ_VERSION=v4.6.5 TIMEOUT=10 CURRENT_PATH="${0%/*}" [ "${CURRENT_PATH:0:1}" != '/' ] && CURRENT_PATH="$( pwd )${CURRENT_PATH#*.}" diff --git a/source_codes/lz/webs/LZ_Policy_Routing_Content.asp b/source_codes/lz/webs/LZ_Policy_Routing_Content.asp index 5578809f..bbc67094 100644 --- a/source_codes/lz/webs/LZ_Policy_Routing_Content.asp +++ b/source_codes/lz/webs/LZ_Policy_Routing_Content.asp @@ -83,7 +83,7 @@ url: '/ext/lzr/LZRGlobal.html', dataType: 'text', success: function(response) { - // v4.6.4 + // v4.6.5 retVal = (response.match(/QnkgTFog5aaZ5aaZ5ZGc77yI6Juk6J[\+]G5aKp5YS[\/]77yJ/m) != null) ? true : false; } });