Skip to content

Commit

Permalink
v4.4.1
Browse files Browse the repository at this point in the history
1.完善参数配置文件数据读写自动纠错机制。
  • Loading branch information
larsonzh authored May 29, 2024
1 parent b04dae0 commit 3457e40
Show file tree
Hide file tree
Showing 14 changed files with 223 additions and 105 deletions.
4 changes: 2 additions & 2 deletions source_codes/install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# install.sh v4.4.0
# install.sh v4.4.1
# By LZ 妙妙呜 ([email protected])

# LZ RULE script for Asuswrt-Merlin Router
Expand All @@ -11,7 +11,7 @@

#BEIGIN

LZ_VERSION=v4.4.0
LZ_VERSION=v4.4.1
TIMEOUT=10
CURRENT_PATH="${0%/*}"
[ "${CURRENT_PATH:0:1}" != '/' ] && CURRENT_PATH="$( pwd )${CURRENT_PATH#*.}"
Expand Down
3 changes: 3 additions & 0 deletions source_codes/lz/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v4.4.1 (2024/5/29)
1.完善参数配置文件数据读写自动纠错机制。

v4.4.0 (2024/5/25)
1.强化参数配置文件数据读取纠错机制。
2.更新运营商 IP 地址数据文件。
Expand Down
5 changes: 2 additions & 3 deletions source_codes/lz/configs/lz_rule_config.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_rule_config.sh v4.4.0
# lz_rule_config.sh v4.4.1
# By LZ 妙妙呜 ([email protected])

# 本软件采用CIDR(无类别域间路由,Classless Inter-Domain Routing)技术,是一个在Internet上创建附加地
Expand Down Expand Up @@ -173,7 +173,6 @@ unicom_cnc_wan_port=0
## 中国移动IPv4目标网段流量出口(网段数据文件:cmcc_cidr.txt)
## 0--第一WAN口;1--第二WAN口;2--均分出口;3--反向均分出口;>3--自动分配出口;取值范围:0~9
## 缺省为第二WAN口(1)。
## 1:表示对中国移动网段的访问使用第二AN口。
cmcc_wan_port=1

## 中国铁通IPv4目标网段流量出口(网段数据文件:crtc_cidr.txt)
Expand Down Expand Up @@ -866,7 +865,7 @@ wan2_udpxy_port=8888
wan2_udpxy_buffer=65536

## 第二WAN口UDPXY代理支持的内网客户端数量
##取值范围:1~5000
## 取值范围:1~5000
## 缺省为10。
wan2_udpxy_client_num=10

Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/func/lz_clear_custom_scripts_data.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_clear_custom_scripts_data.sh v4.4.0
# lz_clear_custom_scripts_data.sh v4.4.1
# By LZ 妙妙呜 ([email protected])

## 清除用户自定义脚本数据
Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/func/lz_define_global_variables.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_define_global_variables.sh v4.4.0
# lz_define_global_variables.sh v4.4.1
# By LZ 妙妙呜 ([email protected])
# QnkgTFog5aaZ5aaZ5ZGc77yI6Juk6J+G5aKp5YS/77yJ(首次运行标识,切勿修改)

Expand Down
239 changes: 177 additions & 62 deletions source_codes/lz/func/lz_initialize_config.sh

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions source_codes/lz/func/lz_rule_address_query.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_rule_address_query.sh v4.4.0
# lz_rule_address_query.sh v4.4.1
# By LZ 妙妙呜 ([email protected])

## 网址信息查询脚本
Expand Down Expand Up @@ -746,7 +746,7 @@ lz_aq_get_box_data() {
i["aq_high_wan_1_src_to_dst_addr_port_file"]=pathd"/high_wan_1_src_to_dst_addr_port.txt";
i["aq_usage_mode"]=0;
total=length(i);
} $1 ~ /^lz_config_[a-zA-Z0-9]+/ {
} $0 ~ /^[[:space:]]*lz_config_[[:alnum:]_]+[=]/ {
flag=0;
if ($1 == "lz_config_all_foreign_wan_port")
key="aq_isp_wan_port_0";
Expand Down Expand Up @@ -775,7 +775,7 @@ lz_aq_get_box_data() {
sub(/^lz_config_/, "aq_", key);
}
value=$2;
gsub(/[ \t#].*$/, "", value);
gsub(/[[:space:]#].*$/, "", value);
invalid=0;
if (key == "aq_version") {
flag=1;
Expand Down Expand Up @@ -855,7 +855,7 @@ lz_aq_get_box_data() {
|| key == "aq_wan_2_src_to_dst_addr_port_file" \
|| key == "aq_high_wan_1_src_to_dst_addr_port_file") {
flag=2;
if ((value !~ /^[\"]([\/][a-zA-Z0-9_\-][a-zA-Z0-9_\.\-]*)+[\"]$/ && value !~ /^([\/][a-zA-Z0-9_\-][a-zA-Z0-9_\.\-]*)+$/) \
if ((value !~ /^[\"]([\/][[:alnum:]_\-][[:alnum:]_\.\-]*)+[\"]$/ && value !~ /^([\/][[:alnum:]_\-][[:alnum:]_\.\-]*)+$/) \
|| value ~ /[\/][\/]/)
invalid=2;
}
Expand Down Expand Up @@ -973,26 +973,26 @@ lz_aq_get_static_policy_wan_port() {
## IPv4网络IP地址^_域名^_DNS服务器地址^_DNS服务器名称
lz_aq_resolve_ip() {
local local_ip="$( echo "${1}" | sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' -e 's/[[:space:]]\+/ /g' \
-e 's/\(^.*[^ ]\)[ ]*$/\1/g' -e '/[3-9][0-9][0-9]/d' -e '/[2][6-9][0-9]/d' \
-e 's/\(^.*[^[:space:]]\)[[:space:]]*$/\1/g' -e '/[3-9][0-9][0-9]/d' -e '/[2][6-9][0-9]/d' \
-e '/[2][5][6-9]/d' -e 's/\/.*$//g' \
| grep -Eo '^([0-9]{1,3}[\.]){3}[0-9]{1,3}$' | sed -n 1p )"
local local_domain_name="$( echo "${1}" | sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' -e 's/[[:space:]]\+/ /g' \
-e 's/\(^.*[^ ]\)[ ]*$/\1/g' -e 's/^.*\:\/\///g' -e 's/^[^ ]\{0,6\}\://g' \
-e 's/\(^.*[^[:space:]]\)[[:space:]]*$/\1/g' -e 's/^.*\:\/\///g' -e 's/^[^[:space:]]\{0,6\}\://g' \
-e 's/\/.*$//g' | sed -n 1p | tr '[:A-Z:]' '[:a-z:]' )"
local local_dns_server_ip=""
local local_dns_server_name=""
if [ "${local_ip}" = "${local_domain_name}" ]; then
local_domain_name=""
[ -z "${local_ip}" ] && local_ip="$( echo "${1}" | sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' -e 's/[[:space:]]\+/ /g' \
-e 's/\(^.*[^ ]\)[ ]*$/\1/g' | sed -n 1p | tr '[:A-Z:]' '[:a-z:]' )"
-e 's/\(^.*[^[:space:]]\)[[:space:]]*$/\1/g' | sed -n 1p | tr '[:A-Z:]' '[:a-z:]' )"
else
local local_dnslookup_server="$( echo "${2}" | sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' \
-e 's/[[:space:]]\+/ /g' \
-e 's/\(^.*[^ ]\)[ ]*$/\1/g' \
-e 's/\(^.*[^[:space:]]\)[[:space:]]*$/\1/g' \
-e '/[3-9][0-9][0-9]/d' -e '/[2][6-9][0-9]/d' \
-e '/[2][5][6-9]/d' -e 's/\/.*$//g' \
| grep -Eo '^([0-9]{1,3}[\.]){3}[0-9]{1,3}$' | sed -n 1p )"
if ! echo "${local_domain_name}" | grep -qEo "[ ]"; then
if ! echo "${local_domain_name}" | grep -qEo "[[:space:]]"; then
local local_info=
if [ -z "${local_dnslookup_server}" ]; then
local_info="$( nslookup "${local_domain_name}" 2> /dev/null )"
Expand All @@ -1005,21 +1005,21 @@ lz_aq_resolve_ip() {
[ -z "${local_domain_name}" ] && local_domain_name="$( echo "${1}" \
| sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' \
-e 's/[[:space:]]\+/ /g' \
-e 's/\(^.*[^ ]\)[ ]*$/\1/g' \
-e 's/\(^.*[^[:space:]]\)[[:space:]]*$/\1/g' \
-e 's/^.*\:\/\///g' \
-e 's/^[^ ]\{0,6\}\://g' \
-e 's/^[^[:space:]]\{0,6\}\://g' \
-e 's/\/.*$//g' \
| tr '[:A-Z:]' '[:a-z:]' )"
local_dns_server_ip="$( echo "${local_info}" | sed -n 2p | awk '{print $3}' | tr '[:A-Z:]' '[:a-z:]' )"
local_dns_server_name="$( echo "${local_info}" | sed -n 2p | awk '{print $4}' \
| sed 's/[\.]$//g' | tr '[:A-Z:]' '[:a-z:]' )"
[ -z "${local_ip}" ] && {
local_ip="$( echo "${1}" | sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' -e 's/[[:space:]]\+/ /g' -e 's/\(^.*[^ ]\)[ ]*$/\1/g' \
local_ip="$( echo "${1}" | sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' -e 's/[[:space:]]\+/ /g' -e 's/\(^.*[^[:space:]]\)[[:space:]]*$/\1/g' \
| sed -n 1p | tr '[:A-Z:]' '[:a-z:]' )"
local_domain_name=""
}
else
local_ip="$( echo "${1}" | sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' -e 's/[[:space:]]\+/ /g' -e 's/\(^.*[^ ]\)[ ]*$/\1/g' \
local_ip="$( echo "${1}" | sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' -e 's/[[:space:]]\+/ /g' -e 's/\(^.*[^[:space:]]\)[[:space:]]*$/\1/g' \
| sed -n 1p | tr '[:A-Z:]' '[:a-z:]' )"
local_domain_name=""
fi
Expand Down Expand Up @@ -1072,7 +1072,7 @@ lz_show_address_info() {
fi
elif [ "${3}" = "$(( AQ_ISP_TOTAL + 4 ))" ]; then
echo "$(lzdate)" [$$]: " Private network address" | tee -ai "${ADDRESS_LOG}" 2> /dev/null
elif echo "${1}" | sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' -e 's/[[:space:]]\+/ /g' -e 's/\(^.*[^ ]\)[ ]*$/\1/g' \
elif echo "${1}" | sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' -e 's/[[:space:]]\+/ /g' -e 's/\(^.*[^[:space:]]\)[[:space:]]*$/\1/g' \
-e '/[3-9][0-9][0-9]/d' -e '/[2][6-9][0-9]/d' -e '/[2][5][6-9]/d' -e 's/\/.*$//g' \
| grep -qEo '^([0-9]{1,3}[\.]){3}[0-9]{1,3}$'; then
if [ "${2}" = "0" ]; then
Expand Down Expand Up @@ -1164,7 +1164,7 @@ lz_query_address() {
local local_ip_item_total="$( echo "${local_net_ip}" | wc -l )"

if [ "${local_ip_item_total}" -le "1" ]; then
if echo "${local_net_ip}" | sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' -e 's/[[:space:]]\+/ /g' -e 's/\(^.*[^ ]\)[ ]*$/\1/g' \
if echo "${local_net_ip}" | sed -e 's/^[[:space:]]*\([^[:space:]].*$\)/\1/g' -e 's/[[:space:]]\+/ /g' -e 's/\(^.*[^[:space:]]\)[[:space:]]*$/\1/g' \
-e '/[3-9][0-9][0-9]/d' -e '/[2][6-9][0-9]/d' -e '/[2][5][6-9]/d' -e 's/\/.*$//g' \
| grep -qEo '^([0-9]{1,3}[\.]){3}[0-9]{1,3}$'; then
ipset -q flush lz_aq_ispip_tmp_sets && ipset -q destroy lz_aq_ispip_tmp_sets
Expand Down
9 changes: 5 additions & 4 deletions source_codes/lz/func/lz_rule_func.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/sh
# lz_rule_func.sh v4.4.0
# lz_rule_func.sh v4.4.1
# By LZ 妙妙呜 ([email protected])

#BEIGIN

# shellcheck source=/dev/null
# shellcheck disable=SC2034 # Unused variables left for readability
# shellcheck disable=SC2153
# shellcheck disable=SC2154
# shellcheck disable=SC3051

Expand Down Expand Up @@ -115,9 +116,9 @@ lz_get_custom_hosts_file_item_total() {
## 返回值:
## 域名地址条目列表
lz_get_domain_list() {
sed -e "s/\'//g" -e 's/\"//g' -e 's/[[:space:]]\+/ /g' -e 's/^[ ]*//g' -e '/^[#]/d' -e 's/[#].*$//g' -e 's/^\([^ ]*\).*$/\1/g' \
-e 's/^[^ ]*[\:][\/][\/]//g' -e 's/^[^ ]\{0,6\}[\:]//g' -e 's/[\/].*$//g' -e 's/[ ].*$//g' -e '/^[\.]/d' \
-e '/^[ ]*$/d' "${1}" 2> /dev/null | tr '[:A-Z:]' '[:a-z:]'
sed -e "s/\'//g" -e 's/\"//g' -e 's/[[:space:]]\+/ /g' -e 's/^[[:space:]]*//g' -e '/^[#]/d' -e 's/[#].*$//g' -e 's/^\([^[:space:]]*\).*$/\1/g' \
-e 's/^[^[:space:]]*[\:][\/][\/]//g' -e 's/^[^[:space:]]\{0,6\}[\:]//g' -e 's/[\/].*$//g' -e 's/[[:space:]].*$//g' -e '/^[\.]/d' \
-e '/^[[:space:]]*$/d' "${1}" 2> /dev/null | tr '[:A-Z:]' '[:a-z:]'
}

## 获取WAN口域名地址条目列表数据文件总有效条目数函数
Expand Down
14 changes: 7 additions & 7 deletions source_codes/lz/func/lz_rule_status.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_rule_status.sh v4.4.0
# lz_rule_status.sh v4.4.1
# By LZ 妙妙呜 ([email protected])

## 显示脚本运行状态脚本
Expand Down Expand Up @@ -211,9 +211,9 @@ lz_get_custom_hosts_file_item_total_status() {
lz_get_domain_data_file_item_total_status() {
local retval="0"
[ -f "${1}" ] && {
retval="$( sed -e "s/\'//g" -e 's/\"//g' -e 's/[[:space:]]\+/ /g' -e 's/^[ ]*//g' -e '/^[#]/d' -e 's/[#].*$//g' -e 's/^\([^ ]*\).*$/\1/g' \
-e 's/^[^ ]*[\:][\/][\/]//g' -e 's/^[^ ]\{0,6\}[\:]//g' -e 's/[\/].*$//g' -e 's/[ ].*$//g' -e '/^[\.]/d' \
-e '/^[ ]*$/d' "${1}" 2> /dev/null | tr '[:A-Z:]' '[:a-z:]' | awk -v count="0" 'NF >= "1" && !i[$1]++ {count++} END{print count}' )"
retval="$( sed -e "s/\'//g" -e 's/\"//g' -e 's/[[:space:]]\+/ /g' -e 's/^[[:space:]]*//g' -e '/^[#]/d' -e 's/[#].*$//g' -e 's/^\([^[:space:]]*\).*$/\1/g' \
-e 's/^[^[:space:]]*[\:][\/][\/]//g' -e 's/^[^[:space:]]\{0,6\}[\:]//g' -e 's/[\/].*$//g' -e 's/[[:space:]].*$//g' -e '/^[\.]/d' \
-e '/^[[:space:]]*$/d' "${1}" 2> /dev/null | tr '[:A-Z:]' '[:a-z:]' | awk -v count="0" 'NF >= "1" && !i[$1]++ {count++} END{print count}' )"
}
echo "${retval}"
}
Expand Down Expand Up @@ -601,7 +601,7 @@ lz_get_box_data_status() {
i["status_custom_dualwan_scripts"]=5;
i["status_custom_dualwan_scripts_filename"]=pathd"/custom_dualwan_scripts.sh";
total=length(i);
} $1 ~ /^lz_config_[a-zA-Z0-9]+/ {
} $0 ~ /^[[:space:]]*lz_config_[[:alnum:]_]+[=]/ {
flag=0;
if ($1 == "lz_config_all_foreign_wan_port")
key="status_isp_wan_port_0";
Expand Down Expand Up @@ -630,7 +630,7 @@ lz_get_box_data_status() {
sub(/^lz_config_/, "status_", key);
}
value=$2;
gsub(/[ \t#].*$/, "", value);
gsub(/[[:space:]#].*$/, "", value);
invalid=0;
if (key == "status_version") {
flag=1;
Expand Down Expand Up @@ -758,7 +758,7 @@ lz_get_box_data_status() {
|| key == "status_custom_config_scripts_filename" \
|| key == "status_custom_dualwan_scripts_filename") {
flag=2;
if ((value !~ /^[\"]([\/][a-zA-Z0-9_\-][a-zA-Z0-9_\.\-]*)+[\"]$/ && value !~ /^([\/][a-zA-Z0-9_\-][a-zA-Z0-9_\.\-]*)+$/) \
if ((value !~ /^[\"]([\/][[:alnum:]_\-][[:alnum:]_\.\-]*)+[\"]$/ && value !~ /^([\/][[:alnum:]_\-][[:alnum:]_\.\-]*)+$/) \
|| value ~ /[\/][\/]/)
invalid=2;
}
Expand Down
4 changes: 2 additions & 2 deletions source_codes/lz/func/lz_vpn_daemon.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_vpn_daemon.sh v4.4.0
# lz_vpn_daemon.sh v4.4.1
# By LZ 妙妙呜 ([email protected])

## 虚拟专网客户端路由刷新处理后台守护进程脚本
Expand All @@ -9,7 +9,7 @@

#BEIGIN
## 版本号
LZ_VERSION=v4.4.0
LZ_VERSION=v4.4.1

## 项目接口文件部署路径
PATH_INTERFACE="${0%/*}"
Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/interface/lz_rule_service.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_rule_service.sh v4.4.0
# lz_rule_service.sh v4.4.1
# By LZ 妙妙呜 ([email protected])

## 服务接口脚本
Expand Down
2 changes: 1 addition & 1 deletion source_codes/lz/js/lz_policy_routing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
# lz_policy_routing.js v4.4.0
# lz_policy_routing.js v4.4.1
# By LZ 妙妙呜 ([email protected])
# LZ JavaScript for Asuswrt-Merlin Router
Expand Down
8 changes: 4 additions & 4 deletions source_codes/lz/lz_rule.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# lz_rule.sh v4.4.0
# lz_rule.sh v4.4.1
# By LZ 妙妙呜 ([email protected])

# 本软件采用CIDR(无类别域间路由,Classless Inter-Domain Routing)技术,是一个在Internet上创建附加地
Expand Down Expand Up @@ -80,7 +80,7 @@
## -------------全局数据定义及初始化-------------------

## 版本号
LZ_VERSION=v4.4.0
LZ_VERSION=v4.4.1

## 运行状态查询命令
SHOW_STATUS="status"
Expand Down Expand Up @@ -1228,11 +1228,11 @@ __lz_main() {

drop_sys_caches=0
if [ -f "${PATH_CONFIGS}/lz_rule_config.box" ]; then
eval "$( awk -F "=" '$1 == "lz_config_drop_sys_caches" {
eval "$( awk -F "=" '$0 ~ /^[[:space:]]*lz_config_[[:alnum:]_]+[=]/ && $1 == "lz_config_drop_sys_caches" {
key=$1;
sub(/^lz_config_/, "", key);
value=$2;
gsub(/[ \t#].*$/, "", value);
gsub(/[[:space:]#].*$/, "", value);
if (value !~ /^[0-9]$/)
value=0
print key"="value;
Expand Down
4 changes: 2 additions & 2 deletions source_codes/lz/uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# uninstall.sh v4.4.0
# uninstall.sh v4.4.1
# By LZ ([email protected])

# LZ RULE script for Asuswrt-Merlin Router
Expand All @@ -8,7 +8,7 @@

# BEIGIN

LZ_VERSION=v4.4.0
LZ_VERSION=v4.4.1
TIMEOUT=10
CURRENT_PATH="${0%/*}"
[ "${CURRENT_PATH:0:1}" != '/' ] && CURRENT_PATH="$( pwd )${CURRENT_PATH#*.}"
Expand Down

0 comments on commit 3457e40

Please sign in to comment.