diff --git a/package/ctcgfw/luci-app-serverchan/Makefile b/package/ctcgfw/luci-app-serverchan/Makefile
index 1af9b9d8d7..f772ad7c38 100644
--- a/package/ctcgfw/luci-app-serverchan/Makefile
+++ b/package/ctcgfw/luci-app-serverchan/Makefile
@@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-serverchan
-PKG_VERSION:=1.77
+PKG_VERSION:=1.78
PKG_RELEASE:=8
include $(INCLUDE_DIR)/package.mk
diff --git a/package/ctcgfw/luci-app-serverchan/luasrc/controller/serverchan.lua b/package/ctcgfw/luci-app-serverchan/luasrc/controller/serverchan.lua
index 77dc85bc90..9858e374b7 100644
--- a/package/ctcgfw/luci-app-serverchan/luasrc/controller/serverchan.lua
+++ b/package/ctcgfw/luci-app-serverchan/luasrc/controller/serverchan.lua
@@ -9,22 +9,22 @@ function index()
entry({"admin", "services", "serverchan"}, alias("admin", "services", "serverchan", "setting"),_("微信推送"), 30).dependent = true
entry({"admin","services","serverchan","status"},call("act_status")).leaf=true
entry({"admin", "services", "serverchan", "setting"}, cbi("serverchan/setting"),_("配置"), 40).leaf = true
- entry({"admin", "services", "serverchan", "advanced"}, cbi("serverchan/advanced"),_("高级设置"), 90).leaf = true
+ entry({"admin", "services", "serverchan", "advanced"}, cbi("serverchan/advanced"),_("高级设置"), 50).leaf = true
+ entry({"admin", "services", "serverchan", "client"}, form("serverchan/client"), "在线设备", 80)
entry({"admin", "services", "serverchan", "log"}, form("serverchan/log"),_("日志"), 99).leaf = true
-
entry({"admin", "services", "serverchan", "get_log"}, call("get_log")).leaf = true
- entry({"admin", "services", "serverchan", "clear_log"}, call("clear_log")).leaf = true
+ entry({"admin", "services", "serverchan", "clear_log"}, call("clear_log")).leaf = true
end
function act_status()
local e={}
- e.running=luci.sys.call("pgrep -f serverchan/serverchan >/dev/null")==0
- luci.http.prepare_content("application/json")
+ e.running=luci.sys.call("pgrep -f serverchan/serverchan >/dev/null")==0
+ luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function get_log()
- luci.http.write(luci.sys.exec(
+ luci.http.write(luci.sys.exec(
"[ -f '/tmp/serverchan/serverchan.log' ] && cat /tmp/serverchan/serverchan.log"))
end
diff --git a/package/ctcgfw/luci-app-serverchan/luasrc/model/cbi/serverchan/advanced.lua b/package/ctcgfw/luci-app-serverchan/luasrc/model/cbi/serverchan/advanced.lua
index 89bc28e784..e3111b76ca 100644
--- a/package/ctcgfw/luci-app-serverchan/luasrc/model/cbi/serverchan/advanced.lua
+++ b/package/ctcgfw/luci-app-serverchan/luasrc/model/cbi/serverchan/advanced.lua
@@ -63,7 +63,7 @@ a:depends({err_enable="1"})
a= s:option(DynamicList, "err_device_aliases", translate("关注列表"))
a.rmempty = true
-a.description = translate("只会在列表中设备都不在线时才会执行
免打扰时段一小时后,关注设备五分钟低流量(约10kb/m)将视为离线")
+a.description = translate("只会在列表中设备都不在线时才会执行
免打扰时段一小时后,关注设备五分钟低流量(约100kb/m)将视为离线")
nt.mac_hints(function(mac, name) a :value(mac, "%s (%s)" %{ mac, name }) end)
a:depends({err_enable="1"})
diff --git a/package/ctcgfw/luci-app-serverchan/luasrc/model/cbi/serverchan/client.lua b/package/ctcgfw/luci-app-serverchan/luasrc/model/cbi/serverchan/client.lua
new file mode 100644
index 0000000000..9c2dafd4fa
--- /dev/null
+++ b/package/ctcgfw/luci-app-serverchan/luasrc/model/cbi/serverchan/client.lua
@@ -0,0 +1,6 @@
+f = SimpleForm("serverchan")
+luci.sys.call("/usr/bin/serverchan/serverchan client")
+f.reset = false
+f.submit = false
+f:append(Template("serverchan/client"))
+return f
diff --git a/package/ctcgfw/luci-app-serverchan/root/etc/config/serverchan b/package/ctcgfw/luci-app-serverchan/root/etc/config/serverchan
index 836aff6460..a9a53d9be5 100644
--- a/package/ctcgfw/luci-app-serverchan/root/etc/config/serverchan
+++ b/package/ctcgfw/luci-app-serverchan/root/etc/config/serverchan
@@ -2,13 +2,10 @@
config serverchan 'serverchan'
option serverchan_enable '0'
option sleeptime '60'
- option serverchan_ipv4 '0'
option serverchan_ipv6 '0'
- option serverchan_up '0'
- option serverchan_down '0'
- option cpuload_enable '0'
+ option serverchan_up '1'
+ option serverchan_down '1'
+ option cpuload_enable '1'
+ option cpuload '2'
option temperature_enable '0'
- option up_timeout '2'
- option down_timeout '10'
- option serverchan_sheep '0'
diff --git a/package/ctcgfw/luci-app-serverchan/root/etc/init.d/serverchan b/package/ctcgfw/luci-app-serverchan/root/etc/init.d/serverchan
index 1cbd0a9d86..90189e251e 100755
--- a/package/ctcgfw/luci-app-serverchan/root/etc/init.d/serverchan
+++ b/package/ctcgfw/luci-app-serverchan/root/etc/init.d/serverchan
@@ -20,7 +20,7 @@ stop() {
restart(){
stop
- sleep 2
+ sleep 1
start
echo "restarted."
}
\ No newline at end of file
diff --git a/package/ctcgfw/luci-app-serverchan/root/usr/bin/serverchan/serverchan b/package/ctcgfw/luci-app-serverchan/root/usr/bin/serverchan/serverchan
index bfaa8a7e98..135643cf62 100755
--- a/package/ctcgfw/luci-app-serverchan/root/usr/bin/serverchan/serverchan
+++ b/package/ctcgfw/luci-app-serverchan/root/usr/bin/serverchan/serverchan
@@ -1,8 +1,5 @@
#!/bin/sh
-# 等待 3s,确保 luci 设置已保存
-[ ! "$1" ] && sleep 3
-
# 读取设置文件
function get_config(){
while [[ "$*" != "" ]]; do
@@ -13,7 +10,7 @@ function get_config(){
# 初始化设置信息
function read_config(){
- get_config "serverchan_enable" "sckey" "serverchan_ipv4" "ipv4_interface" "ipv4_URL" "serverchan_ipv6" "ipv6_interface" "ipv6_URL" "serverchan_up" "serverchan_down" "serverchan_sheep" "serverchan_whitelist" "serverchan_blacklist" "serverchan_interface" "starttime" "endtime" "cpuload_enable" "cpuload" "temperature_enable" "temperature" "device_name" "err_enable" "network_err_event" "err_sheep_enable" "system_time_event" "autoreboot_time" "network_restart_time" "public_ip_event" "public_ip_retry_count" "soc_code" "sleeptime" "up_timeout" "down_timeout" "device_aliases" "debuglevel" "cpuload" "temperature" "send_mode" "regular_time" "regular_time_2" "regular_time_3" "interval_time" "thread_num" "timeout_retry_count" "send_tg" "tgtoken"
+ get_config "serverchan_enable" "sckey" "serverchan_ipv4" "ipv4_interface" "ipv4_URL" "serverchan_ipv6" "ipv6_interface" "ipv6_URL" "serverchan_up" "serverchan_down" "serverchan_sheep" "serverchan_whitelist" "serverchan_blacklist" "serverchan_interface" "starttime" "endtime" "cpuload_enable" "cpuload" "temperature_enable" "temperature" "device_name" "err_enable" "network_err_event" "err_sheep_enable" "system_time_event" "autoreboot_time" "network_restart_time" "public_ip_event" "public_ip_retry_count" "soc_code" "sleeptime" "up_timeout" "down_timeout" "device_aliases" "debuglevel" "cpuload" "temperature" "send_mode" "regular_time" "regular_time_2" "regular_time_3" "interval_time" "thread_num" "timeout_retry_count" "send_tg" "tgtoken" "err_device_aliases"
for str_version in "wrtbwmon" "iputils-arping" "curl" "iw"; do
eval `echo ${str_version:0:2}"_version"`=`opkg list-installed|grep -w ^${str_version}|awk '{print $3}'` 2>/dev/null
done
@@ -27,7 +24,6 @@ function read_config(){
[ -z "$timeout_retry_count" ] && timeout_retry_count="2";[ "$timeout_retry_count" -eq "0" ] && timeout_retry_count="1"
markdown_splitline="%0D%0A%0D%0A---%0D%0A%0D%0A";markdown_linefeed="%0D%0A%0D%0A";markdown_tab=" ";markdown_space=" "
[ ! -z "$send_tg" ] && [ "$send_tg" -eq "1" ] && markdown_splitline="%0D%0A%0D%0A%0D%0A%0D%0A" && markdown_tab=""
- enable_detection
}
# 初始化
@@ -131,6 +127,8 @@ function getinterface(){
# ping
function getping(){
+ [ "$iw_version" ] && local wlan_online=`iw dev ${ip_interface} station dump|grep -i -w ${ip_mac}|grep Station` >/dev/null 2>&1
+ [ "$wlan_online" ] && return 0
for i in `seq 1 ${3}`; do
( ! echo "$ip_ms"|grep -q "ms" ) && local ip_ms=$( arping -I `cat /proc/net/arp|grep -w ${1}|awk '{print $6}'|grep -v "^$"|sort -u` -c 20 -f -w ${2} $1 ) 2>/dev/null
( ! echo "$ip_ms"|grep -q "ms" ) && local ip_ms=`ping -c 5 -w ${2} ${1}|grep -v '100% packet loss'` 2>/dev/null
@@ -168,7 +166,7 @@ function usage(){
[ -z "$total_n" ] && total_n="6"
[ "$2" ] && local tmptotal=`cat ${dir}usage.db|sed 's/,/ /g'|grep -i -w ${2}|awk "{print "'$'$total_n"}"|grep -v "^$"|sort -u` 2>/dev/null
[ -z "$tmptotal" ] && local tmptotal="0"
- echo `bytes_for_humans ${tmptotal}`
+ [ ! "$3" ] && echo `bytes_for_humans ${tmptotal}` || echo $tmptotal
elif [ $1 == "down" ] ;then
[ "$2" ] && sed -i "/${2}/d" ${dir}usage.db 2>/dev/null
fi
@@ -313,6 +311,29 @@ function blackwhitelist(){
[ ! -z "$serverchan_interface" ] && ( echo `getinterface ${1}`|grep -q -i -w $serverchan_interface ) && return
}
+function get_client(){
+ if [ -f "${dir}ipAddress" ]; then
+ while read line; do
+ local js_str="${js_str}