From 01fc49a905c080955df38df94ea3986d84de73f4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 25 Jul 2022 23:44:13 +0800 Subject: [PATCH] update 2022-07-25 23:44:13 --- .../model/cbi/gpsysupgrade/sysupgrade.lua | 16 +- luci-app-onliner/Makefile | 32 + .../luasrc/controller/onliner.lua | 17 + .../luasrc/view/onliner/display.htm | 921 ++++++++++++++++++ .../luasrc/view/onliner/onliner.htm | 99 ++ luci-app-onliner/po/zh-cn/onliner.po | 21 + luci-app-onliner/po/zh_Hans | 1 + .../root/usr/share/onliner/setnlbw.sh | 20 + 8 files changed, 1125 insertions(+), 2 deletions(-) create mode 100644 luci-app-onliner/Makefile create mode 100644 luci-app-onliner/luasrc/controller/onliner.lua create mode 100644 luci-app-onliner/luasrc/view/onliner/display.htm create mode 100644 luci-app-onliner/luasrc/view/onliner/onliner.htm create mode 100644 luci-app-onliner/po/zh-cn/onliner.po create mode 120000 luci-app-onliner/po/zh_Hans create mode 100644 luci-app-onliner/root/usr/share/onliner/setnlbw.sh diff --git a/luci-app-gpsysupgrade/luasrc/model/cbi/gpsysupgrade/sysupgrade.lua b/luci-app-gpsysupgrade/luasrc/model/cbi/gpsysupgrade/sysupgrade.lua index 2cc44f5ac..5265830d4 100644 --- a/luci-app-gpsysupgrade/luasrc/model/cbi/gpsysupgrade/sysupgrade.lua +++ b/luci-app-gpsysupgrade/luasrc/model/cbi/gpsysupgrade/sysupgrade.lua @@ -143,8 +143,8 @@ function to_check() model = "ramips_mt7621/xiaomi_mi-router-ac2100" check_update() download_url = "https://op.supes.top/firmware/" ..model.. "/" ..remote_version.. "-openwrt-ramips-mt7621-xiaomi_mi-router-ac2100-squashfs-sysupgrade.bin" - elseif board_name:match("rt%-acrh17") then - model = "ipq40xx_generic/asus_rt-acrh17" + elseif board_name:match("rt%-ac42u") then + model = "ipq40xx_generic/asus_rt-ac42u" check_update() download_url = "https://op.supes.top/firmware/" ..model.. "/" ..remote_version.. "-openwrt-ipq40xx-generic-asus_rt-ac42u-squashfs-sysupgrade.bin" elseif board_name:match("rt%-ac58u") then @@ -287,6 +287,18 @@ function to_check() model = "bcm53xx_generic/asus_rt-ac88u" check_update() download_url = "https://op.supes.top/firmware/" ..model.. "/" ..remote_version.. "-openwrt-bcm53xx-generic-asus_rt-ac88u-squashfs.trx" + elseif board_name:match("edgerouter%-x$") then + model = "bcm53xx_generic/asus_rt-ac88u" + check_update() + download_url = "https://op.supes.top/firmware/" ..model.. "/" ..remote_version.. "-openwrt-ramips-mt7621-ubnt_edgerouter-x-squashfs-sysupgrade.bin" + elseif board_name:match("edgerouter%-x%-sfp") then + model = "bcm53xx_generic/asus_rt-ac88u" + check_update() + download_url = "https://op.supes.top/firmware/" ..model.. "/" ..remote_version.. "-openwrt-ramips-mt7621-ubnt_edgerouter-x-sfp-squashfs-sysupgrade.bin" + elseif board_name:match("wrt1200ac") then + model = "mvebu/cortexa9" + check_update() + download_url = "https://op.supes.top/firmware/" ..model.. "/" ..remote_version.. "-openwrt-mvebu-cortexa9-linksys_wrt1200ac-squashfs-sysupgrade.bin" else local needs_update = false return { diff --git a/luci-app-onliner/Makefile b/luci-app-onliner/Makefile new file mode 100644 index 000000000..11a9647e0 --- /dev/null +++ b/luci-app-onliner/Makefile @@ -0,0 +1,32 @@ +# Copyright (C) 2016 Openwrt.org +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI support arp online +LUCI_DEPENDS:=+luci-app-wrtbwmon +LUCI_PKGARCH:=all +PKG_NAME:=luci-app-onliner +PKG_VERSION:=1.1 +PKG_RELEASE:=5 + +define Package/luci-app-onliner/install + $(INSTALL_DIR) $(1)/usr/lib/lua/luci + cp -pR ./luasrc/* $(1)/usr/lib/lua/luci + $(INSTALL_DIR) $(1)/ + cp -pR ./root/* $(1)/ +endef + +define Package/luci-app-onliner/postinst +#!/bin/sh + rm -f /tmp/luci-indexcache + rm -f /tmp/luci-modulecache/* + chmod -R 755 /usr/share/onliner/* +exit 0 +endef +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature + diff --git a/luci-app-onliner/luasrc/controller/onliner.lua b/luci-app-onliner/luasrc/controller/onliner.lua new file mode 100644 index 000000000..79f5f6f50 --- /dev/null +++ b/luci-app-onliner/luasrc/controller/onliner.lua @@ -0,0 +1,17 @@ +module("luci.controller.onliner",package.seeall) +nixio=require"nixio" +function index() +entry({"admin","status","onliner"},alias("admin","status","onliner","onliner"),_("Connection info")) +entry({"admin","status","onliner","onliner"},template("onliner/onliner"),_("Online User"),1) +entry({"admin", "status","onliner","speed"}, template("onliner/display"), _("Speed monitor"), 2) +entry({"admin", "status","onliner","setnlbw"}, call("set_nlbw")) +end +function set_nlbw() + if nixio.fs.access("/var/run/onsetnlbw") then + nixio.fs.writefile("/var/run/onsetnlbw","1"); + else + io.popen("/usr/share/onliner/setnlbw.sh &") + end + luci.http.prepare_content("application/json") + luci.http.write('') +end diff --git a/luci-app-onliner/luasrc/view/onliner/display.htm b/luci-app-onliner/luasrc/view/onliner/display.htm new file mode 100644 index 000000000..29b738e84 --- /dev/null +++ b/luci-app-onliner/luasrc/view/onliner/display.htm @@ -0,0 +1,921 @@ +<%# + Copyright 2017 Jo-Philipp Wich + Licensed to the public under the Apache License 2.0. +-%> + +<% css = [[ + + #chartjs-tooltip { + opacity: 0; + position: absolute; + background: rgba(0, 0, 0, .7); + color: white; + padding: 3px; + border-radius: 3px; + -webkit-transition: all .1s ease; + transition: all .1s ease; + pointer-events: none; + -webkit-transform: translate(-50%, 0); + transform: translate(-50%, 0); + z-index: 200; + } + + #chartjs-tooltip.above { + -webkit-transform: translate(-50%, -100%); + transform: translate(-50%, -100%); + } + + #chartjs-tooltip.above:before { + border: solid; + border-color: #111 transparent; + border-color: rgba(0, 0, 0, .8) transparent; + border-width: 8px 8px 0 8px; + bottom: 1em; + content: ""; + display: block; + left: 50%; + top: 100%; + position: absolute; + z-index: 99; + -webkit-transform: translate(-50%, 0); + transform: translate(-50%, 0); + } + + table { + border: 1px solid #999; + border-collapse: collapse; + margin: 0 0 2px !important; + } + + th, td, table table td { + border: 1px solid #999; + text-align: right; + padding: 1px 3px !important; + white-space: nowrap; + } + + tbody td { + border-bottom-color: #ccc; + } + tbody td:nth-last-child(4) { + width: 10%; + } + tbody td:nth-last-child(3) { + width: 10%; + } + tbody td:nth-last-child(2) { + width: 10%; + } + tbody td:nth-last-child(1) { + width: 10%; + } + tbody td[rowspan] { + border-bottom-color: #999; + } + + tbody tr:last-child td { + border-bottom-color: #999; + } + + .kpi { + display: inline-block; + vertical-align: top; + } + + .kpi ul { + list-style: none; + } + + .kpi li { + margin: 10px; + display: none; + } + + .kpi big { + font-weight: bold; + } + + #detail-bubble { + position: absolute; + opacity: 0; + visibility: hidden; + } + + #detail-bubble.in { + opacity: 1; + visibility: visible; + transition: opacity 0.5s; + } + + #detail-bubble > div { + border: 1px solid #ccc; + border-radius: 2px; + padding: 5px; + background: #fcfcfc; + } + + #detail-bubble .head { + text-align: center; + white-space: nowrap; + position: relative; + } + + #detail-bubble .head .dismiss { + top: 0; + right: 0; + width: 20px; + line-height: 20px; + text-align: center; + text-decoration: none; + font-weight: bold; + color: #000; + position: absolute; + font-size: 20px; + } + #detail-bubble .kpi { + margin: 40px 5px 5px; + font-size: smaller; + text-align: left; + } + + #detail-bubble .kpi ul { + margin: 0; + } + + #bubble-arrow { + border: 1px solid #ccc; + border-width: 1px 0 0 1px; + background: #fcfcfc; + width: 15px; + height: 15px; + position: absolute; + left: 0; + top: -8px; + transform: rotate(45deg); + margin: 0 0 0 -8px; + } + + tr.active > td { + border-bottom: 2px solid red; + } + + tr.active > td.active { + border: 2px solid red; + border-bottom: none; + } + + td.detail { + border: 2px solid red; + border-top: none; + opacity: 0; + transition: opacity 0.5s; + } + + td.detail.in { + opacity: 1; + } + + th.hostname, + td.hostname { + text-align: left; + } + +]] -%> + +<%+header%> + + + + + +

<%:Netlink Bandwidth Monitor%>

+ +
+ +
+
+ × +
+
    +
  • <%_Hostname: example.org%>
  • +
  • <%_Vendor: Example Corp.%>
  • +
+
+
+
+
+
+ + + +
+
+
+
    +
  • <%_0 hosts%>
  • +
  • <%_0 download%>
  • +
  • <%_0 upload%>
  • +
  • <%_0 connections%>
  • +
+
+
+ + + + + + + + +
<%:Host%><%:MAC%><%:Connections%><%:Download (Bytes / Packets)%><%:Upload (Bytes / Packets)%>
+
+ + + + + + + +<%+footer%> diff --git a/luci-app-onliner/luasrc/view/onliner/onliner.htm b/luci-app-onliner/luasrc/view/onliner/onliner.htm new file mode 100644 index 000000000..b6d9f3d9f --- /dev/null +++ b/luci-app-onliner/luasrc/view/onliner/onliner.htm @@ -0,0 +1,99 @@ +<%# + Copyright 2008 Steven Barth + Copyright 2008-2011 Jo-Philipp Wich + Licensed to the public under the Apache License 2.0. +-%> + +<% +local util = require "luci.util" +local function online_data() + local rv = { } + local fd = util.execi('/usr/bin/awk \'BEGIN{while ((getline < "/tmp/dhcp.leases") > 0){a[$2]=$4;}while ((getline < "/proc/net/arp") > 0){if (!a[$4]){a[$4]="\?";}if (match($3,"0x[26]")){"ping -q -c 1 "$1" &";if (b[$4]){b[$4]=b[$4]"/"$1;}else{b[$4]=$1;}c[$4]=$6;}}while (("ip -6 neighbor show | grep -v fe80" | getline) > 0){if (b[$5]) {"ping -q -c 1 "$1" &";b[$5]=b[$5]"/"$1;}}for (mac in b){print(a[mac],b[mac],mac,c[mac]);}}\' ') + while true do + local ln = fd() + if ln == nil then break end + local name,ip,mac,dev = ln:match("^(%S+) (%S+) (%S+) (%S+)") + if mac and ip and name and dev then + rv[#rv+1] = { + hostname = name, + device = dev, + macaddr = mac, + ipaddr = ip + } + end + end + return rv +end + + +if luci.http.formvalue("status") == "1" then + local rv = { + onlines = online_data() + } + luci.http.prepare_content("application/json") + luci.http.write_json(rv) + return +end +-%> + +<%+header%> + + + + +

<%:Status%>

+ +
+ <%:Online User%> + + + + + + + + + + + +
<%:Hostname%><%:IPv4-Address%><%:MAC-Address%><%:Interface%>

<%:Collecting data...%>
+
+ +<%+footer%> diff --git a/luci-app-onliner/po/zh-cn/onliner.po b/luci-app-onliner/po/zh-cn/onliner.po new file mode 100644 index 000000000..c3df4795f --- /dev/null +++ b/luci-app-onliner/po/zh-cn/onliner.po @@ -0,0 +1,21 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: zh_Hans\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "Connection info" +msgstr "联机用户" + +msgid "Online User" +msgstr "在线用户" + +msgid "Speed monitor" +msgstr "宽带监视" + +msgid "There is no one online now." +msgstr "当前无任何设备在线。" diff --git a/luci-app-onliner/po/zh_Hans b/luci-app-onliner/po/zh_Hans new file mode 120000 index 000000000..41451e4a1 --- /dev/null +++ b/luci-app-onliner/po/zh_Hans @@ -0,0 +1 @@ +zh-cn \ No newline at end of file diff --git a/luci-app-onliner/root/usr/share/onliner/setnlbw.sh b/luci-app-onliner/root/usr/share/onliner/setnlbw.sh new file mode 100644 index 000000000..cd49e40b4 --- /dev/null +++ b/luci-app-onliner/root/usr/share/onliner/setnlbw.sh @@ -0,0 +1,20 @@ +#!/bin/sh +PATH="/usr/sbin:/usr/bin:/sbin:/bin" +echo "1">/var/run/onsetnlbw +interval=$(uci get nlbwmon.@nlbwmon[0].refresh_interval) +uci set nlbwmon.@nlbwmon[0].refresh_interval="2s" +/etc/init.d/nlbwmon reload +while true +do + sleep 12 + watchdog=$(cat /var/run/onsetnlbw) + if [ "$watchdog"x == "0"x ]; then + uci set nlbwmon.@nlbwmon[0].refresh_interval=$interval + uci commit nlbwmon + /etc/init.d/nlbwmon reload + rm -f /var/run/onsetnlbw + exit 0 + else + echo "0">/var/run/onsetnlbw + fi +done