1. 修复并发时文件锁失效的 bug
2. 修复带参数启动时,线程限制没有生效的 bug
3. 修复对离线设备进行 NetBIOS 查询的 bug
4. 稍稍调整了推送内容中,设备列表的对齐方式
5. 改为使用 json 存储 IP 和设备信息
(待观察是否需要调整,现在为使用紧凑模式保存,且设备离线后不删除信息以待下次使用,预留了磁盘字段,但怀疑会影响网页加载速度,未并入单文件)
This commit is contained in:
tty228 2024-07-07 07:22:17 +08:00
parent 2cc3596498
commit 172390f666
5 changed files with 496 additions and 463 deletions

View File

@ -48,6 +48,7 @@ v2.06.2 之后的版本不再支持 LuCI 18.06,如需编译,请使用 openwr
- 使用设备名备注
- 在高级设置处配置从光猫获取
- 开启 MAC 设备数据库
- 安装 samba*-server 或 samba*-client使程序可以通过 NetBIOS 查询主机名
**关于设备在线状态:**

View File

@ -42,6 +42,7 @@ For devices that do not declare hostnames, devices connected via optical modem d
- Use device name remarks.
- Configure to obtain the hostname from the optical modem in advanced settings.
- Enable MAC device database.
- Install samba*-server or samba*-client to enable the program to query hostnames via NetBIOS.
**Regarding Device Online Status:**

View File

@ -28,16 +28,14 @@ return view.extend({
},
fetchDevices: function () {
return fs.list('/tmp/wechatpush/client').then(function (files) {
var promises = files.map(function (file) {
return fs.read('/tmp/wechatpush/client/' + file.name).then(function (content) {
return JSON.parse(content);
});
});
return Promise.all(promises).then(function (devices) {
return { devices: devices };
});
return fs.read('/tmp/wechatpush/devices.json').then(function (content) {
try {
var data = JSON.parse(content);
return { devices: data.devices };
} catch (e) {
console.error('Error parsing JSON:', e);
return { devices: [] };
}
});
},
@ -45,7 +43,7 @@ return view.extend({
if (!data || !data.devices || !Array.isArray(data.devices)) {
return document.createElement('div');
}
var devices = data.devices;
var devices = data.devices.filter(device => device.status === 'online');
var totalDevices = devices.length;
var headers = [_('Hostname'), _('IPv4 address'), _('MAC address'), _('Interfaces'), _('Online time'), _('Details')];
var columns = ['name', 'ip', 'mac', 'interface', 'uptime', 'usage'];

View File

@ -1,7 +1,7 @@
#!/bin/sh
logfile="/tmp/wechatpush/wechatpush.log"
dir="/tmp/wechatpush/" && mkdir -p "${dir}" && mkdir -p "${dir}/client"
dir="/tmp/wechatpush/" && mkdir -p "${dir}"
oui_base="${dir}oui_base.txt"
oui_data=$(uci get wechatpush.config.oui_data 2>/dev/null)
oui_url="https://standards-oui.ieee.org/oui/oui.txt"
@ -45,6 +45,6 @@ elif [ "$1" == "update_list" ]; then
echo "$(date "+%Y-%m-%d %H:%M:%S") 【info】${2} API 列表更新成功" >>"${logfile}"
elif [ "$1" == "down_oui" ]; then
# 更新 MAC 信息列表
[ $(file_date "${oui_base}") -lt 86400 ] && echo "$(date "+%Y-%m-%d %H:%M:%S") 【info】MAC 信息文件无需更新" >>"${logfile}" && exit 2
[ $(file_date "$oui_base") -lt 86400 ] && echo "$(date "+%Y-%m-%d %H:%M:%S") 【info】MAC 信息文件无需更新" >>"${logfile}" && exit 2
down_oui >/dev/null 2>&1 &
fi

File diff suppressed because it is too large Load Diff