update 2023-10-31 23:36:29

This commit is contained in:
github-actions[bot] 2023-10-31 23:36:29 +08:00
parent 3a652d7190
commit 8e5ad78957
7 changed files with 244 additions and 194 deletions

View File

@ -543,6 +543,9 @@ msgstr "分流模式下的 DNS 查询模式"
msgid "Anti-pollution DNS Server For Shunt Mode"
msgstr "分流模式下的访问国外域名 DNS 服务器"
msgid "Custom DNS Server for mosdns"
msgstr "MOSDNS 自定义 DNS 服务器"
msgid "Disable IPv6 In MOSDNS Query Mode (Shunt Mode)"
msgstr "禁止 MOSDNS 返回 IPv6 记录 (分流模式)"

View File

@ -66,6 +66,10 @@ v2.06.2 之后的版本不再支持 LuCI 18.06,如需编译,请使用 openwr
流量统计功能依赖 wrtbwmon ,需自行选装或编译,**该插件与 Routing/NAT 、Flow Offloading 、代理上网等插件冲突,开启后将会无法获取流量,请自行选择**
**关于硬盘信息:**
当 OpenWrt 系统或远程主机PVE未安装 lsblk 时,硬盘总容量信息可能与实际不一致
当 OpenWrt 系统或远程主机PVE未安装 smartctl 时,硬盘温度、通电时间、健康度等信息不可用
**关于 bug 提交:**

View File

@ -56,6 +56,11 @@ By default, ping/arping is used to actively detect device online status to count
Traffic statistics functionality depends on `wrtbwmon`. Please install or compile it yourself. **Enabling this plugin will conflict with Routing/NAT, Flow Offloading, proxy internet access, and other plugins, resulting in the inability to obtain traffic statistics. Please choose accordingly.**
**About Hard Drive Information:**
When the OpenWrt system or remote host (PVE) does not have lsblk installed, the total hard drive capacity information may be inconsistent with the actual capacity.
When the OpenWrt system or remote host (PVE) does not have smartctl installed, information such as hard drive temperature, uptime, and health status will not be available.
**Regarding Bug Submissions:**

View File

@ -78,7 +78,7 @@ return view.extend({
var _this = this;
return fs.exec(programPath, ['soc']).then(function (res) {
if (!res.stdout) {
throw new Error(_('Returned temperature value is empty'));
throw new Error(_('Returned value is empty'));
}
_this.description = res.stdout.trim();
return _this.map.reset();

View File

@ -303,6 +303,22 @@ return view.extend({
o.description = _('Please enter the device MAC and device alias separated by a space, such as:<br/> XX:XX:XX:XX:XX:XX My Phone<br/> 192.168.1.2 My PC<br />Please use the 「Save」 button in the text box.');
// 推送内容
o = s.taboption('content', form.Button, '_getip', _('Test IP acquisition command'), _('You may need to save the configuration before sending.'));
o.inputstyle = 'action';
o.onclick = function () {
var _this = this;
return fs.exec(programPath, ['getip']).then(function (res) {
if (!res.stdout) {
throw new Error(_('Returned value is empty'));
}
_this.description = res.stdout.trim();
return _this.map.reset();
}).catch(function (err) {
_this.description = _('Fetch failed') + err.message;
return _this.map.reset();
});
};
o = s.taboption('content', cbiRichListValue, 'get_ipv4_mode', _('IPv4 Dynamic Notification'));
o.value('', _('Close'),
_(' '));

View File

@ -275,6 +275,10 @@ msgstr "设备别名"
msgid "Please enter the device MAC and device alias separated by a space, such as:<br/> XX:XX:XX:XX:XX:XX My Phone<br/> 192.168.1.2 My PC<br />Please use the 「Save」 button in the text box."
msgstr "请输入设备 MAC 和设备别名,用空格隔开,例如:<br/> XX:XX:XX:XX:XX:XX 我的手机<br/> 192.168.1.2 我的电脑<br />文本框请使用「保存」按钮"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js:306
msgid "Test IP acquisition command"
msgstr "测试 IP 获取命令"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js:306
msgid "IPv4 Dynamic Notification"
msgstr "IPv4 变动通知"
@ -806,8 +810,9 @@ msgid "Test temperature command"
msgstr "测试温度命令"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:82
msgid "Returned temperature value is empty"
msgstr "返回的温度值为空"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/config.js:312
msgid "Returned value is empty"
msgstr "返回值为空"
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:87
msgid "Fetch failed"

View File

@ -534,7 +534,7 @@ function cut_str {
[ ! "$2" ] && return
if [ $(length_str "$1") -le "$2" ]; then
echo "$1"
echo -n "$1" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
return
fi
@ -551,7 +551,7 @@ function cut_str {
done
local text=$(echo -n "$1" | cut -d ' ' -f $max_column)
if [ $(length_str "$text") -le "$2" ]; then
echo "$text"
echo "$text" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
return
fi
fi
@ -565,7 +565,7 @@ function cut_str {
done
temp_length=$(expr $temp_length - 1)
echo "$(echo -n "$1" | cut -c -$temp_length)"..
echo "$(echo -n "$1" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | cut -c -$temp_length).."
}
@ -838,6 +838,11 @@ function ip_changes(){
[ "$get_ipv6_mode" -eq "1" ] && local IPv6=`getip wanipv6` && local IPv6_URL="网络接口"
[ "$get_ipv6_mode" -eq "2" ] && local IPv6=`getip hostipv6` && local IPv6_URL=`echo ${IPv6}|jq -r '.URL'` && local IPv6=`echo ${IPv6}|jq -r '.IP'`
if [ "$1" ] && [ $1 == "getip" ]; then
echo "IPv4$IPv4<br/>地址:$(get_ip_attribution $IPv4)<br/>接口:$IPv4_URL<br/>IPv6$IPv6<br/>地址:$(get_ip_attribution $IPv6)<br/>接口:$IPv6_URL"
return
fi
# 存在临时文件
if [ -f ${dir}ip ]; then
local last_IPv4=$(cat "${dir}ip"|grep IPv4|awk '{print $2}'|grep -v "^$"|sort -u|head -n1)
@ -1112,7 +1117,9 @@ function get_disk() {
pve_disk_names=()
# 查询本地硬盘名
local_disk_names=($(lsblk | awk '$NF=="disk" {print $1}' | sort -u))
local_disk_names=($(lsblk 2>/dev/null | awk '$NF=="disk" {print $1}' | sort -u))
# 如未安装 lsblk查找以 /dev/ 开头,但挂载点不是根目录 / 的设备,然后提取硬盘的名称(准确性较低)
[ -z "$local_disk_names" ] && local_disk_names=($(df -h 2>/dev/null | awk '$1 ~ /^\/dev/ {if ($NF ~ /^\/[a-zA-Z0-9]/) { sub("/dev/", "", $1); sub(/[0-9]+$/, "", $1); print $1 }}'))
local_disk_tags=($(for _ in "${local_disk_names[@]}"; do echo "local"; done))
# 查询远程硬盘名
@ -1140,8 +1147,8 @@ function get_disk() {
file_path="${dir}disk_info/${tmp_name}${disk_type}"
# 如果不能获取值,使用分区名重试(因为不清楚是 OpenWrt 的原因还是 smartctl 版本的原因,使用出错重试的方式)
eval ${tmp_command} smartctl -i -n standby "/dev/${tmp_name}" | grep -qE "$error_pattern" && {
tmp_name=$(df -h | awk "/^\\/dev\\/${tmp_name}/ {print \$1}" | awk -F '/' '{print $NF}' | head -n1)
eval ${tmp_command} smartctl -i -n standby "/dev/${tmp_name}" 2>/dev/null | grep -qE "$error_pattern" && {
tmp_name=$(eval ${tmp_command} df -h | awk "/^\\/dev\\/${tmp_name}/ {print \$1}" | awk -F '/' '{print $NF}' | head -n1)
[ -z "$tmp_name" ] && continue
}
@ -1149,18 +1156,18 @@ function get_disk() {
last_disk_time=$(date -r "${file_path}" +%s 2>/dev/null) || last_disk_time=0
if [ $(( $(date +%s) - $last_disk_time )) -gt 86000 ]; then
disk_info=$(eval ${tmp_command} smartctl -i -n standby "/dev/${tmp_name}")
disk_info=$(eval ${tmp_command} smartctl -i -n standby "/dev/${tmp_name}" 2>/dev/null)
echo "$disk_info" | grep -qE "$error_pattern" && {
continue
} || \
echo "$disk_info" | grep -q "STANDBY" && {
echo "$disk_info" > "${file_path}"
} || \
eval ${tmp_command} smartctl -a -j /dev/${tmp_name} > ${file_path}
eval ${tmp_command} smartctl -a -j /dev/${tmp_name} 2>/dev/null> ${file_path}
fi
# 硬盘状态
if [ -f "${file_path}" ] && ( ! cat "${file_path}" | grep -q -v "STANDBY" ); then
if [ -f "${file_path}" ] && [ -s "${file_path}" ] && ( ! cat "${file_path}" | grep -q -v "STANDBY" ); then
disk_name=$(awk '/Device Model/{print $NF}' "$file_path")
[[ -n $disk_name && $disk_name != null && $disk_name != 0 ]] && {
disk_name=$(cut_str "$disk_name" "20")
@ -1170,9 +1177,12 @@ function get_disk() {
elif [ -f "${file_path}" ]; then
# 硬盘名称
disk_name=$(jq -r .model_name ${file_path})
[ -z "$disk_name" ] && disk_name=$(cat /sys/block/"${all_disk_names[i]}"/device/model)
[[ -n $disk_name && $disk_name != null && $disk_name != 0 ]] && {
disk_name=$(cut_str "$disk_name" "20")
disk_name="${disk_name}_$(eval ${tmp_command} lsblk -o NAME,SIZE | awk "/^${all_disk_names[i]}/ {print \$NF}")"
disk_size=$(eval ${tmp_command} lsblk -o NAME,SIZE 2>/dev/null | awk "/^${all_disk_names[i]}/ {print \$NF}")
[ -z "$disk_size" ] && disk_size=$(eval ${tmp_command} df -h 2>/dev/null | awk -v tmp_disk_name="${all_disk_names[i]}" '$1 ~ "^/dev/"tmp_disk_name {print $2}')
disk_name="${disk_name}_${disk_size}"
}
printf "${str_linefeed}${str_title_start} 硬盘名称:${disk_name}${disk_type}${str_title_end}" >> "$output_dir/get_disk"
# 硬盘温度
@ -1182,7 +1192,8 @@ function get_disk() {
disk_time=$(jq -r .power_on_time.hours ${file_path})
[[ -n $disk_time && $disk_time != null ]] && printf "${str_linefeed}${str_tab}通电时间:${disk_time}h" >> "$output_dir/get_disk"
# 空间使用
disk_use=$(eval ${tmp_command} lsblk -o NAME,FSUSE%,TYPE | awk -v part_name="${all_disk_names[i]}" '$NF == "part" && $1 ~ part_name && NF > 2 {sub(".*" part_name, part_name, $1); printf "%s: %s ", $1, $2} END {print ""}')
disk_use=$(eval ${tmp_command} lsblk -o NAME,FSUSE%,TYPE 2>/dev/null | awk -v part_name="${all_disk_names[i]}" '$NF == "part" && $1 ~ part_name && NF > 2 {sub(".*" part_name, part_name, $1); printf "%s: %s ", $1, $2} END {print ""}')
[ -z "$disk_use" ] && disk_use=$(eval ${tmp_command} df -h 2>/dev/null | awk -v part_name="${all_disk_names[i]}" '$1 ~ "^/dev/"part_name && NF > 1 {sub("/dev/", "", $1); sub(/[0-9]+$/, "", $1); printf "%s: %s ", $1, $5} END {print ""}')
[ -n "$disk_use" ] && [ -n "${disk_use// }" ] && echo -e -n "${str_linefeed}${str_tab}空间使用:${disk_use}" >> "$output_dir/get_disk"
# 寿命使用
disk_health=$(jq -r .nvme_smart_health_information_log.percentage_used ${file_path})
@ -1211,10 +1222,10 @@ function get_disk() {
# 查询 IP 归属地
function get_ip_attribution(){
ip="$1"
[ -f ${dir}ipAddress ] && ( cat ${dir}ipAddress|grep -q -w -i "$ip" ) && echo "本地网" && return
[ -f ${dir}ipAddress ] && ( cat ${dir}ipAddress|grep -q -w -i "$ip" ) && echo "本地局域网" && return
ip_attribution_urls=$(cat /usr/share/wechatpush/api/ip_attribution.list)
while IFS= read -r ip_attribution_command; do
login_ip_attribution=$(eval "$ip_attribution_command" 2>/dev/null)
local login_ip_attribution=$(eval "$ip_attribution_command" 2>/dev/null)
[ "$login_ip_attribution" == "null" ] && unset login_ip_attribution
[ -n "$login_ip_attribution" ] && break
done <<< "$ip_attribution_urls"
@ -1249,7 +1260,7 @@ function login_send(){
fi
[ -n "$log_only" ] && echo "`date "+%Y-%m-%d"` ${login_time} 【info】设备 ${login_ip} 通过 Web ${login_mode} 登录了路由器 " >> ${logfile} && continue
login_ip_attribution=$(get_ip_attribution ${login_ip})
local login_ip_attribution=$(get_ip_attribution ${login_ip})
[ -n "$login_ip_attribution" ] && content_attribution="${str_linefeed}${str_tab}IP 归属地: ${str_space}${str_space}${str_space}${str_space}${login_ip_attribution}"
[ -n "$login_mode" ] && content_mode="${str_linefeed}${str_tab}登录方式: ${str_space}${str_space}${str_space}${str_space}${login_mode}"
if { [ -z "$login_disturb" ] || [ "$login_disturb" -ne "1" ]; }; then
@ -1282,7 +1293,7 @@ function login_send(){
fi
[ -n "$log_only" ] && echo "`date "+%Y-%m-%d"` ${login_time} 【info】设备 ${login_ip} 通过 SSH ${login_mode} 登录了路由器 " >> ${logfile} && continue
login_ip_attribution=$(get_ip_attribution ${login_ip})
local login_ip_attribution=$(get_ip_attribution ${login_ip})
[ -n "$login_ip_attribution" ] && content_attribution="${str_linefeed}${str_tab}IP 归属地: ${str_space}${str_space}${str_space}${str_space}${login_ip_attribution}"
[ ! -z "$login_mode" ] && content_mode="${str_linefeed}${str_tab}登录方式: ${str_space}${str_space}${str_space}${str_space}${login_mode}"
if { [ -z "$login_disturb" ] || [ "$login_disturb" -ne "1" ]; }; then
@ -1304,7 +1315,7 @@ function login_send(){
# Web 非法登录
[ -f ${dir}web_failed ] && for login_ip in `cat ${dir}web_failed | sort -u`; do
[ -z "$login_ip" ] && continue
login_ip_attribution=$(get_ip_attribution ${login_ip})
local login_ip_attribution=$(get_ip_attribution ${login_ip})
[ -n "$login_ip_attribution" ] && content_attribution="${str_linefeed}${str_tab}IP 归属地: ${str_space}${str_space}${str_space}${str_space}${login_ip_attribution}" || unset content_attribution
echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】设备 ${login_ip} (${login_ip_attribution}) 通过 Web 频繁尝试登录" >> ${logfile}
[ -n "$login_disturb" ] && [ "$login_disturb" -eq "1" ] && continue
@ -1324,7 +1335,7 @@ function login_send(){
# SSH 非法登录
[ -f ${dir}ssh_failed ] && for login_ip in `cat ${dir}ssh_failed | sort -u`; do
[ -z "$login_ip" ] && continue
login_ip_attribution=$(get_ip_attribution ${login_ip})
local login_ip_attribution=$(get_ip_attribution ${login_ip})
[ -n "$login_ip_attribution" ] && content_attribution="${str_linefeed}${str_tab}IP 归属地: ${str_space}${str_space}${str_space}${str_space}${login_ip_attribution}" || unset content_attribution
echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】设备 ${login_ip} (${login_ip_attribution}) 通过 SSH 频繁尝试登录" >> ${logfile}
[ -n "$login_disturb" ] && [ "$login_disturb" -eq "1" ] && continue
@ -1612,6 +1623,12 @@ function send(){
if [ "$1" ] ;then
[ $1 == "soc" ] && get_config "soc_code" "server_host" "server_port"
[ $1 == "soc" ] && soc_temp && exit $?
[ $1 == "getip" ] && {
get_config "get_ipv4_mode" "ipv4_interface" "get_ipv6_mode" "ipv6_interface"
ipv4_urllist=`cat /usr/share/wechatpush/api/ipv4.list` 2>/dev/null
ipv6_urllist=`cat /usr/share/wechatpush/api/ipv6.list` 2>/dev/null
ip_changes getip && exit $?
}
read_config
[ $1 == "send" ] && send && exit $?
[ $1 == "test" ] && send test && exit $?