Skip to content

Commit

Permalink
v3.1.0
Browse files Browse the repository at this point in the history
1. 增加新的辅助获取设备列表功能-定时扫描局域网 IP 段
2. 修复 bug
  • Loading branch information
tty228 committed Jun 4, 2023
1 parent 739ed9f commit dac6b0f
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 77 deletions.
48 changes: 24 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-wechatpush
PKG_VERSION:=3.0.1
PKG_RELEASE:=11

PKG_MAINTAINER:=tty228 <tty228@yeah.net>

LUCI_TITLE:=LuCI support for wechatpush
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+iputils-arping +curl +jq

define Package/$(PKG_NAME)/conffiles
/etc/config/wechatpush
/usr/share/wechatpush/api/diy.json
/usr/share/wechatpush/api/logo.jpg
/usr/share/wechatpush/api/ipv4.list
/usr/share/wechatpush/api/ipv6.list
/usr/share/wechatpush/api/device_aliases.list
endef

include $(TOPDIR)/feeds/luci/luci.mk

# call BuildPackage - OpenWrt buildroot signature
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-wechatpush
PKG_VERSION:=3.1.0
PKG_RELEASE:=11

PKG_MAINTAINER:=tty228 <tty228@yeah.net>

LUCI_TITLE:=LuCI support for wechatpush
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+iputils-arping +curl +jq

define Package/$(PKG_NAME)/conffiles
/etc/config/wechatpush
/usr/share/wechatpush/api/diy.json
/usr/share/wechatpush/api/logo.jpg
/usr/share/wechatpush/api/ipv4.list
/usr/share/wechatpush/api/ipv6.list
/usr/share/wechatpush/api/device_aliases.list
endef

include $(TOPDIR)/feeds/luci/luci.mk

# call BuildPackage - OpenWrt buildroot signature
33 changes: 20 additions & 13 deletions htdocs/luci-static/resources/view/wechatpush/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,55 +79,62 @@ return view.extend({
});
};

o = s.option(form.Flag, "gateway_info_enable", _("Get host information from the optical modem"));
o.default = 0;
o.rmempty = true;
o.description = _("Suitable for OpenWrt used as a bypass gateway when unable to obtain device hostnames and complete LAN device lists.<br/>Tested only on HG5143F/HN8145V China Telecom optical modems, universality is not guaranteed.");
o = s.option(form.MultiValue, 'device_info_helper', _('Assist in obtaining device information'));
o.value('gateway_info', _('Retrieve hostname list from modem'));
o.value('scan_local_ip', _('Scan local IP'));
o.modalonly = true;
o.description = _('When OpenWrt is used as a bypass gateway and cannot obtain device hostnames or a complete list of local network devices.<br/>the \"Retrieve hostname list from modem\" option has only been tested with HG5143F/HN8145V China Telecom gateways and may not be universally applicable.<br/>The \"Scan local IP\" option may not retrieve hostnames, so please use device name annotations in conjunction with it.');

o = s.option(form.Value, "gateway_host_url", _('Optical modem login URL'));
o.rmempty = true;
o.default = "http://192.168.1.1/cgi-bin/luci";
o.depends('gateway_info_enable', '1');
o.depends({ device_info_helper: "gateway_info", '!contains': true });

o = s.option(form.Value, "gateway_info_url", _('Device list JSON URL'));
o.rmempty = true;
o.default = "http://192.168.1.1/cgi-bin/luci/admin/allInfo";
o.description = _('Use F12 console to capture<br/>ip, devName, model are mandatory fields. Example JSON file information:<br/>{\"pc1\":{\"devName\":\"RouterOS\",\"model\":\"\",\"type\":\"pc\",\"ip\":\"192.168.1.7\"}}');
o.depends('gateway_info_enable', '1');
o.depends({ device_info_helper: "gateway_info", '!contains': true });

o = s.option(form.Value, "gateway_logout_url", _('Optical modem logout URL'))
o.rmempty = true
o.default = "http://192.168.1.1/cgi-bin/luci/admin/logout"
o.description = _("Not a mandatory field, but it may affect other users logging into the web management page, e.g., HG5143F")
o.depends('gateway_info_enable', '1');
o.depends({ device_info_helper: "gateway_info", '!contains': true });

o = s.option(form.Value, "gateway_username_id", _('Login page account input box ID'))
o.rmempty = true
o.default = "username"
o.depends('gateway_info_enable', '1');
o.depends({ device_info_helper: "gateway_info", '!contains': true });

o = s.option(form.Value, "gateway_password_id", _('Login page password input box ID'))
o.rmempty = true
o.default = "psd"
o.description = _("Right-click in the browser and select 'Inspect Element'")
o.depends('gateway_info_enable', '1');
o.depends({ device_info_helper: "gateway_info", '!contains': true });

o = s.option(form.Value, "gateway_username", _('Optical modem login account'))
o.rmempty = true
o.default = "useradmin"
o.depends('gateway_info_enable', '1');
o.depends({ device_info_helper: "gateway_info", '!contains': true });

o = s.option(form.Value, "gateway_password", _('Optical modem login password'))
o.rmempty = true
o.description = _("Use a regular account, no need for super password")
o.depends('gateway_info_enable', '1');
o.depends({ device_info_helper: "gateway_info", '!contains': true });

o = s.option(form.Value, "scan_ip_range", _('IP range to be scanned'))
o.rmempty = true
o.placeholder = _('192.168.1.1-100');
o.depends({ device_info_helper: "scan_local_ip", '!contains': true });

o = s.option(form.Value, 'gateway_sleeptime', _('Interval for capturing optical modem information'));
o = s.option(form.Value, 'device_info_helper_sleeptime', _('Interval for capturing info'));
o.rmempty = false;
o.placeholder = '600';
o.datatype = 'and(uinteger,min(60))'
o.description = _("Generally, frequent capturing is not necessary. Adjust it as needed.")
o.depends('gateway_info_enable', '1');
o.depends({ device_info_helper: "gateway_info", '!contains': true });
o.depends({ device_info_helper: "scan_local_ip", '!contains': true });

o = s.option(form.Flag, "unattended_enable", _("Unattended tasks"))
o.default = 0
Expand Down
64 changes: 38 additions & 26 deletions po/zh_Hans/wechatpush.po
Original file line number Diff line number Diff line change
Expand Up @@ -804,13 +804,21 @@ msgstr "返回的温度值为空"
msgid "Fetch failed:"
msgstr "获取失败:"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:82
msgid "Assist in obtaining device information"
msgstr "辅助获取设备列表"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:83
msgid "Get host information from the optical modem"
msgid "Retrieve hostname list from modem"
msgstr "从光猫获取主机名等信息"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:84
msgid "Scan local IP"
msgstr "扫描局域网 IP"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:86
msgid "Suitable for OpenWrt used as a bypass gateway when unable to obtain device hostnames and complete LAN device lists.<br/>Tested only on HG5143F/HN8145V China Telecom optical modems, universality is not guaranteed."
msgstr "适用于 OpenWrt 作为旁路网关,无法获取设备主机名及完整的局域网设备列表时<br/>仅测试通过 HG5143F/HN8145V 天翼网关,不保证通用性"
msgid "When OpenWrt is used as a bypass gateway and cannot obtain device hostnames or a complete list of local network devices.<br/>the \"Retrieve hostname list from modem\" option has only been tested with HG5143F/HN8145V China Telecom gateways and may not be universally applicable.<br/>The \"Scan local IP\" option may not retrieve hostnames, so please use device name annotations in conjunction with it."
msgstr "适用于 OpenWrt 作为旁路网关,无法获取设备主机名及完整的局域网设备列表时<br/>\"从光猫获取主机名列表\"选项仅测试通过 HG5143F/HN8145V 天翼网关,不保证通用性<br/>\"定期扫描局域网 IP\"选项可能无法获取主机名,请配合设备名备注使用"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:88
msgid "Optical modem login URL"
Expand Down Expand Up @@ -857,78 +865,82 @@ msgid "Use a regular account, no need for super password"
msgstr "使用普通账号即可,不需要超密"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:126
msgid "Interval for capturing optical modem information"
msgstr "抓取光猫信息时间间隔"
msgid "IP range to be scanned"
msgstr "需要扫描的 IP 段"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:131
msgid "Interval for capturing info"
msgstr "抓取信息时间间隔"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:130
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:135
msgid "Generally, frequent capturing is not necessary. Adjust it as needed."
msgstr "一般不需要频繁抓取,酌情设置"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:133
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:139
msgid "Unattended tasks"
msgstr "无人值守任务"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:136
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:142
msgid "Please make sure the script can run properly, otherwise it may cause frequent restarts and other errors!"
msgstr "请确认脚本可以正常运行,否则可能造成频繁重启等错误!"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:138
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:144
msgid "Restart zerotier after IP change"
msgstr "IP 变化后重启 zerotier"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:139
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:145
msgid "An old issue with zerotier<br/>Cannot reconnect after disconnection, emmm, I don't know if it has been fixed now."
msgstr "zerotier 的陈年老问题<br/>断网后不能重新打洞,emmm,我也不知道修了没有"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:142
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:148
msgid "Redial only during Do-Not-Disturb period"
msgstr "仅在免打扰时段重拨"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:145
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:151
msgid "Avoid redialing network during the day to prevent waiting for DDNS domain resolution. This feature does not affect disconnection detection.<br/>Due to the issue of certain apps consuming excessive data at night, this feature may be unstable."
msgstr "避免在白天重拨网络造成 DDNS 域名等待解析,此功能不影响断网检测<br/>因夜间某些 APP 偷跑流量问题,该功能可能不稳定"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:150
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:156
msgid "Will only be executed when none of the devices in the list are online.<br/>After an hour of Do-Not-Disturb period, if the devices in the focus list have low traffic (around 100kb/m) for five minutes, they will be considered offline."
msgstr "只会在列表中设备都不在线时才会执行<br/>免打扰时段一小时后,关注设备五分钟低流量(约100kb/m)将视为离线"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:154
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:160
msgid "When the network is disconnected"
msgstr "网络断开时"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:156
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:164
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:162
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:170
msgid "No operation"
msgstr "无操作"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:157
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:165
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:163
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:171
msgid "Restart the router"
msgstr "重启路由器"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:158
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:166
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:164
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:172
msgid "Redialing network"
msgstr "重新拨号"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:159
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:165
msgid "Option 1 and Option 2 will not modify settings and will try a maximum of 2 times.<br/>【!!This feature cannot guarantee compatibility!!】"
msgstr "选项 1 选项 2 不会修改设置,并最多尝试 2 次。<br/>【!!此功能无法保证兼容性!!】"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:162
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:168
msgid "Scheduled reboot"
msgstr "定时重启"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:169
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:175
msgid "System uptime greater than"
msgstr "系统运行时间大于"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:173
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:180
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:179
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:186
msgid "Unit: hours"
msgstr "单位为小时"

#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:176
#: applications/luci-app-wechatpush/htdocs/luci-static/resources/view/wechatpush/advanced.js:182
msgid "Network uptime greater than"
msgstr "网络在线时间大于"

Expand Down
32 changes: 22 additions & 10 deletions root/etc/uci-defaults/luci-wechatpush
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#!/bin/sh

function get_config(){
function get_config_wechatpush(){
while [[ "$*" != "" ]]; do
eval ${1}='`uci get wechatpush.config.$1`' 2>/dev/null
uci del wechatpush.config.$1 2>/dev/null
uci commit wechatpush
shift
done
}

function get_config_serverchan(){
while [[ "$*" != "" ]]; do
eval ${1}='`uci get serverchan.serverchan.$1`' 2>/dev/null
uci del serverchan.serverchan.$1 2>/dev/null
Expand Down Expand Up @@ -61,35 +70,39 @@ fi
serverchan_config="/etc/config/serverchan"
if [ -f "$serverchan_config" ]; then
cp "/etc/config/serverchan" "/etc/config/serverchan.bak"
sed -i 's#/usr/share/serverchan/api/telegram.json#/usr/share/wechatpush/api/telegram.json#g' "$serverchan_config" 2>/dev/null
sed -i 's#/root/usr/bin/serverchan/api/telegram.json#/usr/share/wechatpush/api/telegram.json#g' "$serverchan_config" 2>/dev/null
sed -i 's#/usr/share/serverchan/api/#/usr/share/wechatpush/api/#g' "$serverchan_config" 2>/dev/null
sed -i 's#/root/usr/bin/serverchan/api/#/usr/share/wechatpush/api/#g' "$serverchan_config" 2>/dev/null
fi

get_config "serverchan_up" "serverchan_down"
get_config_serverchan "serverchan_up" "serverchan_down"
[ -n "$serverchan_up" ] && [ "$serverchan_up" -eq "1" ] && uci add_list wechatpush.config.device_notification='online'
[ -n "$serverchan_down" ] && [ "$serverchan_down" -eq "1" ] && uci add_list wechatpush.config.device_notification='offline'

get_config "cpuload_enable" "temperature_enable"
get_config_serverchan "cpuload_enable" "temperature_enable"
[ -n "$cpuload_enable" ] && [ "$cpuload_enable" -eq "1" ] && uci add_list wechatpush.config.cpu_notification='load'
[ -n "$temperature_enable" ] && [ "$temperature_enable" -eq "1" ] && uci add_list wechatpush.config.cpu_notification='temp'

get_config "web_logged" "ssh_logged" "web_login_failed" "ssh_login_failed"
get_config_serverchan "web_logged" "ssh_logged" "web_login_failed" "ssh_login_failed"
[ -n "$web_logged" ] && [ "$web_logged" -eq "1" ] && uci add_list wechatpush.config.login_notification='web_logged'
[ -n "$ssh_logged" ] && [ "$ssh_logged" -eq "1" ] && uci add_list wechatpush.config.login_notification='ssh_logged'
[ -n "$web_login_failed" ] && [ "$web_login_failed" -eq "1" ] && uci add_list wechatpush.config.login_notification='web_login_failed'
[ -n "$ssh_login_failed" ] && [ "$ssh_login_failed" -eq "1" ] && uci add_list wechatpush.config.login_notification='ssh_login_failed'

get_config "router_status" "router_temp" "router_wan" "client_list"
get_config_serverchan "router_status" "router_temp" "router_wan" "client_list"
[ -n "$router_status" ] && [ "$router_status" -eq "1" ] && uci add_list wechatpush.config.send_notification='router_status'
[ -n "$router_temp" ] && [ "$router_temp" -eq "1" ] && uci add_list wechatpush.config.send_notification='router_temp'
[ -n "$router_wan" ] && [ "$router_wan" -eq "1" ] && uci add_list wechatpush.config.send_notification='wan_info'
[ -n "$client_list" ] && [ "$client_list" -eq "1" ] && uci add_list wechatpush.config.send_notification='client_list'

get_config "regular_time" "regular_time2" "regular_time3"
get_config_serverchan "regular_time" "regular_time2" "regular_time3"
[ -n "$regular_time" ] && uci add_list wechatpush.config.crontab_regular_time="$regular_time"
[ -n "$regular_time2" ] && uci add_list wechatpush.config.crontab_regular_time="$regular_time2"
[ -n "$regular_time3" ] && uci add_list wechatpush.config.crontab_regular_time="$regular_time3"

get_config_wechatpush "gateway_info_enable" "gateway_sleeptime"
[ -n "$gateway_info_enable" ] && [ "$" -eq "1" ] && uci add_list wechatpush.config.device_info_helper='gateway_info'
[ -n "$gateway_sleeptime" ] && uci set wechatpush.config.device_info_helper_sleeptime="$gateway_sleeptime"

serverchan_to_wechatpush_list "device_notification"
serverchan_to_wechatpush_list "cpu_notification"
serverchan_to_wechatpush_list "login_notification"
Expand All @@ -103,7 +116,7 @@ serverchan_to_wechatpush_list "MAC_online_list" "mac_online_list"
serverchan_to_wechatpush_list "MAC_offline_list" "mac_offline_list"
serverchan_to_wechatpush_list "err_device_aliases" "unattended_device_aliases"

get_config "device_aliases"
get_config_serverchan "device_aliases"
mkdir -p /usr/share/wechatpush/api/
[ -n "$device_aliases" ] && echo "$device_aliases"|sed 's/ /\n/g'|sed 's/-/ /' > /usr/share/wechatpush/api/device_aliases.list
serverchan_device_aliases_path="/usr/share/serverchan/api/device_aliases.list"
Expand Down Expand Up @@ -142,7 +155,6 @@ serverchan_to_wechatpush_change "crontab" "crontab_mode"
serverchan_to_wechatpush_change "macmechanism" "mac_filtering_mode_1"
serverchan_to_wechatpush_change "macmechanism2" "mac_filtering_mode_2"


serverchan_to_wechatpush_get \
"enable" "lite_enable" "device_name" "sleeptime" "oui_data" "reset_regularly" "debuglevel" \
"jsonpath" "sckey" "corpid" "userid" "agentid" "corpsecret" "mediapath" "wxpusher_apptoken" "wxpusher_uids" "wxpusher_topicIds" "pushplus_token" "tg_token" "chat_id" \
Expand Down
Loading

0 comments on commit dac6b0f

Please sign in to comment.