diff --git a/luci-app-serverchan/README.md b/luci-app-serverchan/README.md index 4d60e2d0d..1f043aa6e 100644 --- a/luci-app-serverchan/README.md +++ b/luci-app-serverchan/README.md @@ -7,14 +7,13 @@ - 微信推送/推送加 http://www.pushplus.plus/ - Telegram/BotFather https://t.me/BotFather - 精力有限,如需要钉钉推送、飞书推送、Bark推送等请尝试 https://github.com/zzsj0928/luci-app-pushbot -- -- **基于X86 OpenWrt 19.07.8 制作,不同系统不同设备,请自行修改部分代码,无测试条件无法重现的 bug 不考虑修复** +- **基于 x86 OpenWrt 19.07.8 制作,不同系统不同设备,请自行修改部分代码,无测试条件无法重现的 bug 不考虑修复** - 依赖 iputils-arping + curl + jq 命令,安装前请 `opkg update`,小内存路由谨慎安装 -- 使用主动探测设备连接的方式检测设备在线状态,以避免WiFi休眠机制,主动探测较为耗时,**如遇设备休眠频繁,请自行调整超时设置** +- 使用主动探测设备连接的方式检测设备在线状态,以避免 Wi-Fi 休眠机制,主动探测较为耗时,**如遇设备休眠频繁,请自行调整超时设置** - 流量统计功能依赖 wrtbwmon ,自行选装或编译,该插件与 Routing/NAT 、Flow Offloading 冲突,开启无法获取流量,自行选择 #### 主要功能 -- 路由 ip/ipv6 变动推送 +- 路由 IP/IPv6 变动推送 - 设备别名 - 设备上线推送 - 设备离线推送及流量使用情况 @@ -26,7 +25,7 @@ #### 已知问题 - 直接关闭接口时,该接口的离线设备会忽略检测 -- 部分设备无法读取到设备名,脚本使用 `cat /var/dhcp.leases` 命令读取设备名,如果 dhcp 中不存在设备名,则无法读取设备名(如二级路由设备、静态ip设备),请使用设备名备注. +- 部分设备无法读取到设备名,脚本使用 `cat /tmp/dhcp.leases` 命令读取设备名,如果 DHCP 中不存在设备名,则无法读取设备名(如二级路由设备、静态IP设备),请使用设备名备注. - 基于X86 OpenWrt 19.07.8 制作,不同系统不同设备,可能会遇到各种问题 - 潘多拉系统、或不支持 sh 的系统,请将脚本开头 `#!/bin/sh` 改为 `#!/bin/bash`,或手动安装 `sh` @@ -34,9 +33,9 @@ - [luci-app-serverchan](https://github.com/tty228/luci-app-serverchan/releases) - [wrtbwmon](https://github.com/brvphoenix/wrtbwmon) - [luci-app-wrtbwmon](https://github.com/brvphoenix/luci-app-wrtbwmon) -- **L大版本直接编译 luci-app-wrtbwmon ,非原版 luci 如使用以上 wrtbwmon,请注意安装版本号** +- **L大版本直接编译 luci-app-wrtbwmon ,非原版 LuCI 如使用以上 wrtbwmon,请注意安装版本号** -#### ps +#### PS - 新功能看情况开发,忙得头晕眼花 - 欢迎各种代码提交 - 提交bug时请尽量带上设备信息,日志与描述 diff --git a/luci-app-serverchan/luasrc/model/cbi/serverchan/advanced.lua b/luci-app-serverchan/luasrc/model/cbi/serverchan/advanced.lua index 2e3edf339..97f4aa5a7 100644 --- a/luci-app-serverchan/luasrc/model/cbi/serverchan/advanced.lua +++ b/luci-app-serverchan/luasrc/model/cbi/serverchan/advanced.lua @@ -70,7 +70,7 @@ a.description = translate("请确认脚本可以正常运行,否则可能造 a=s:option(Flag,"err_sheep_enable",translate("仅在免打扰时段重拨")) a.default=0 a.rmempty=true -a.description = translate("避免白天重拨 ddns 域名等待解析,此功能不影响断网检测
因夜间跑流量问题,该功能可能不稳定") +a.description = translate("避免白天重拨 DDNS 域名等待解析,此功能不影响断网检测
因夜间跑流量问题,该功能可能不稳定") a:depends({err_enable="1"}) a= s:option(DynamicList, "err_device_aliases", translate("关注列表")) @@ -109,11 +109,11 @@ a.datatype="uinteger" a:depends({system_time_event="2"}) a.description = translate("单位为小时") -a=s:option(Flag,"public_ip_event",translate("重拨尝试获取公网 ip")) +a=s:option(Flag,"public_ip_event",translate("重拨尝试获取公网 IP")) a.default=0 a.rmempty=true a:depends({err_enable="1"}) -a.description = translate("重拨时不会推送 ip 变动通知,并会导致你的域名无法及时更新 ip 地址
请确认你可以通过重拨获取公网 ip,否则这不仅徒劳无功还会引起频繁断网
移动等大内网你就别挣扎了!!") +a.description = translate("重拨时不会推送 IP 变动通知,并会导致你的域名无法及时更新 IP 地址
请确认你可以通过重拨获取公网 IP,否则这不仅徒劳无功还会引起频繁断网
移动等大内网你就别挣扎了!!") a= s:option(Value, "public_ip_retry_count", "当天最大重试次数") a.rmempty = true diff --git a/luci-app-serverchan/luasrc/model/cbi/serverchan/setting.lua b/luci-app-serverchan/luasrc/model/cbi/serverchan/setting.lua index 74ffc7a42..9deb71bd2 100644 --- a/luci-app-serverchan/luasrc/model/cbi/serverchan/setting.lua +++ b/luci-app-serverchan/luasrc/model/cbi/serverchan/setting.lua @@ -9,7 +9,7 @@ local ifaces = sys.net:devices() m=Map("serverchan",translate("ServerChan"), translate("「Server酱」,英文名「ServerChan」,是一款从服务器推送报警信息和日志到微信的工具。

如果你在使用中遇到问题,请到这里提交:") .. [[]] -.. translate("github 项目地址") +.. translate("GitHub 项目地址") .. [[]] ) @@ -132,7 +132,7 @@ a:value("",translate("关闭")) a:value("1",translate("简化版")) a:value("2",translate("完整版")) a:value("3",translate("网络查询")) -a.description = translate("需下载 4.36m 原始数据,处理后完整版约 1.2M,简化版约 250kb
若无梯子,请勿使用网络查询") +a.description = translate("需下载 4.36 MB 原始数据,处理后完整版约 1.2 MB,简化版约 250 kB
若无梯子,请勿使用网络查询") a=s:taboption("basic", Flag,"oui_dir",translate("下载到内存")) a.rmempty = true @@ -151,7 +151,7 @@ a.rmempty = true a.description = translate("
请输入设备 MAC 和设备别名,用“-”隔开,如:
XX:XX:XX:XX:XX:XX-我的手机") --设备状态 -a=s:taboption("content", ListValue,"serverchan_ipv4",translate("ipv4 变动通知")) +a=s:taboption("content", ListValue,"serverchan_ipv4",translate("IPv4 变动通知")) a.rmempty = true a.default="" a:value("",translate("关闭")) @@ -174,7 +174,7 @@ for _, iface in ipairs(ifaces) do end a.description = translate("
一般选择 wan 接口,多拨环境请自行选择") -a=s:taboption("content", TextValue, "ipv4_list", translate("ipv4 api列表")) +a=s:taboption("content", TextValue, "ipv4_list", translate("IPv4 API列表")) a.optional = false a.rows = 8 a.wrap = "soft" @@ -187,7 +187,7 @@ end a.description = translate("
会因服务器稳定性、连接频繁等原因导致获取失败
如接口可以正常获取 IP,不推荐使用
从以上列表中随机地址访问") a:depends({serverchan_ipv4="2"}) -a=s:taboption("content", ListValue,"serverchan_ipv6",translate("ipv6 变动通知")) +a=s:taboption("content", ListValue,"serverchan_ipv6",translate("IPv6 变动通知")) a.rmempty = true a.default="disable" a:value("0",translate("关闭")) @@ -210,7 +210,7 @@ for _, iface in ipairs(ifaces) do end a.description = translate("
一般选择 wan 接口,多拨环境请自行选择") -a=s:taboption("content", TextValue, "ipv6_list", translate("ipv6 api列表")) +a=s:taboption("content", TextValue, "ipv6_list", translate("IPv6 API列表")) a.optional = false a.rows = 8 a.wrap = "soft" diff --git a/luci-app-serverchan/root/usr/bin/serverchan/serverchan b/luci-app-serverchan/root/usr/bin/serverchan/serverchan index 4df857be9..9ad6dcfe9 100755 --- a/luci-app-serverchan/root/usr/bin/serverchan/serverchan +++ b/luci-app-serverchan/root/usr/bin/serverchan/serverchan @@ -176,12 +176,12 @@ function getinterfaceuptime(){ getinterfacelist|grep \"uptime\"|sed $'s/\"uptime": //g'|sed $'s/\,//g' } -# 查询 mac 地址 +# 查询 MAC 地址 function getmac(){ ( echo "$tmp_mac"|grep -q "unknown" ) && unset tmp_mac # 为unknown时重新读取 [ -f "${dir}ipAddress" ] && [ -z "$tmp_mac" ] && local tmp_mac=`cat ${dir}ipAddress|grep -w ${1}|awk '{print $2}'|grep -v "^$"|sort -u|head -n1` [ -f "${dir}tmp_downlist" ] && [ -z "$tmp_mac" ] && local tmp_mac=`cat ${dir}tmp_downlist|grep -w ${1}|awk '{print $2}'|grep -v "^$"|sort -u|head -n1` - [ -f "/var/dhcp.leases" ] && [ -z "$tmp_mac" ] && local tmp_mac=`cat /var/dhcp.leases|grep -w ${1}|awk '{print $2}'|grep -v "^$"|sort -u|head -n1` + [ -f "/tmp/dhcp.leases" ] && [ -z "$tmp_mac" ] && local tmp_mac=`cat /tmp/dhcp.leases|grep -w ${1}|awk '{print $2}'|grep -v "^$"|sort -u|head -n1` [ -z "$tmp_mac" ] && local tmp_mac=`cat /proc/net/arp|grep "0x2\|0x6"|grep -w ${1}|awk '{print $4}'|grep -v "^$"|sort -u|head -n1` [ -z "$tmp_mac" ] && local tmp_mac="unknown" echo "$tmp_mac" @@ -193,7 +193,7 @@ function getname(){ [ -f "${dir}ipAddress" ] && [ -z "$tmp_name" ] && local tmp_name=`cat ${dir}ipAddress|grep -w ${1}|awk '{print $3}'|grep -v "^$"|sort -u|head -n1` [ -f "${dir}tmp_downlist" ] && [ -z "$tmp_name" ] && local tmp_name=`cat ${dir}tmp_downlist|grep -w ${1}|awk '{print $3}'|grep -v "^$"|sort -u|head -n1` ( ! echo "$tmp_name"|grep -q -w "unknown\|*" ) && [ ! -z "$tmp_name" ] && echo "$tmp_name" && return || unset tmp_name # 为unknown时重新读取 - [ -f "/var/dhcp.leases" ] && [ -z "$tmp_name" ] && local tmp_name=`cat /var/dhcp.leases|grep -w ${1}|awk '{print $4}'|grep -v "^$"|sort -u|head -n1` + [ -f "/tmp/dhcp.leases" ] && [ -z "$tmp_name" ] && local tmp_name=`cat /tmp/dhcp.leases|grep -w ${1}|awk '{print $4}'|grep -v "^$"|sort -u|head -n1` ( ! echo "$tmp_name"|grep -q -w "unknown\|*" ) && [ ! -z "$tmp_name" ] && echo "$tmp_name" && return || unset tmp_name # 为unknown时重新读取 [ -z "$dhcp_config" ] && dhcp_config=`uci show dhcp|grep "ip\|mac\|name"` for dhcp_config_str in "host" "domain"; do @@ -506,7 +506,7 @@ function get_client(){ done < ${dir}ipAddress fi cat>/usr/lib/lua/luci/view/serverchan/serverchan_client.htm<<%:在线设备列表%>
<%:客户端名%>
<%:MAC%>
<%:IP%>
<%:总计流量%>
<%: 在线时间%>
+

<%:在线设备列表%>

<%:主机名%>
<%:MAC%>
<%:IP%>
<%:总计流量%>
<%: 在线时间%>
$js_str
EOF @@ -1128,14 +1128,14 @@ function send(){ if [ -z "$1" ] && [ ! -z "$router_wan" ] && [ "$router_wan" -eq "1" ]; then local send_wanIP=`getip wanipv4`;local send_hostIP=`getip hostipv4` - local send_content="${send_content}${str_splitline}${str_title_start} WAN 口信息${str_title_end}${str_linefeed}${str_tab}接口ip:${send_wanIP}" - local send_content="${send_content}${str_linefeed}${str_tab}外网ip:${send_hostIP}" + local send_content="${send_content}${str_splitline}${str_title_start} WAN 口信息${str_title_end}${str_linefeed}${str_tab}接口 IPv4:${send_wanIP}" + local send_content="${send_content}${str_linefeed}${str_tab}外网 IPv4:${send_hostIP}" if [ ! -z "$serverchan_ipv6" ] && [ "$serverchan_ipv6" -ne "0" ]; then local send_wanIPv6=`getip wanipv6`;local send_hostIPv6=`getip hostipv6` - local send_content="${send_content}${str_linefeed}${str_tab}ipv6 :${send_wanIPv6}" - local send_content="${send_content}${str_linefeed}${str_tab}外网v6:${send_hostIPv6}" + local send_content="${send_content}${str_linefeed}${str_tab}接口 IPv6:${send_wanIPv6}" + local send_content="${send_content}${str_linefeed}${str_tab}外网 IPv6:${send_hostIPv6}" fi - ( ! echo "$send_wanIP"|grep -q -w ${send_hostIP} ) && local send_content="${send_content}${str_linefeed}${str_tab}外网 ip 与接口 ip 不一致,你的 ip 不是公网 ip" + ( ! echo "$send_wanIP"|grep -q -w ${send_hostIP} ) && local send_content="${send_content}${str_linefeed}${str_tab}外网 IP 与接口 IP 不一致,你的 IP 可能不是公网 IP" local interfaceuptime=`getinterfaceuptime` [ ! -z "$interfaceuptime" ] && local wanstatustime=`getinterfaceuptime|awk -F. '{run_days=$1 / 86400;run_hour=($1 % 86400)/3600;run_minute=($1 % 3600)/60;run_second=$1 % 60;printf("在线时间:%d天%d时%d分%d秒",run_days,run_hour,run_minute,run_second)}'` && unset run_days run_hour run_minute run_second local send_content="${send_content}${str_linefeed}${str_tab}${wanstatustime}"