mirror of
https://github.com/sirpdboy/sirpdboy-package.git
synced 2025-01-05 10:27:11 +08:00
up 升级菜单
This commit is contained in:
parent
6ada837f88
commit
78fe9e6554
@ -10,8 +10,8 @@ LUCI_TITLE:=LuCI support for Kucat theme setting by sirpdboy
|
||||
LUCI_DEPENDS:=+luci-compat +curl +wget +libustream-openssl
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_VERSION:=1.7.9
|
||||
PKG_RELEASE:=20240312
|
||||
PKG_VERSION:=1.7.10
|
||||
PKG_RELEASE:=20240318
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/advancedplus
|
||||
|
@ -4,7 +4,7 @@ local uci=luci.model.uci.cursor()
|
||||
local a, t, e
|
||||
a = Map("advancedplus")
|
||||
a.title = translate("Advanced Setting")
|
||||
a.description = translate("The enhanced version of the original advanced settings allows for unified setting and management of background images for kucat, Agron, and Opentopd themes, without the need to upload them separately. Color schemes for kucat and Agron themes can be set.<br>")..
|
||||
a.description = translate("The enhanced version of the original advanced settings allows for unified setting and management of background images for kucat/Agron/Opentopd themes, without the need to upload them separately. Color schemes for kucat/Agron/design themes can be set.<br>")..
|
||||
translate("At the same time, important plugin parameters can be compiled. At the same time, some system parameters can also be set, such as display and hide settings.")..
|
||||
translate("</br>For specific usage, see:")..translate("<a href=\'https://github.com/sirpdboy/luci-app-advancedplus.git' target=\'_blank\'>GitHub @sirpdboy/luci-app-advancedplus </a>")
|
||||
|
||||
@ -30,5 +30,8 @@ e = t:option(Flag, "wizard",translate('Hide Wizard'), translate('Show or hide th
|
||||
e.default = "0"
|
||||
e.rmempty = false
|
||||
|
||||
e = t:option(Flag, "tsoset",translate('TSO optimization for network card interruption'), translate('Turn off the TSO parameters of the INTEL225 network card to improve network interruption'))
|
||||
e.default = "1"
|
||||
e.rmempty = false
|
||||
|
||||
return a
|
||||
|
@ -14,7 +14,6 @@ msgstr "Argon主题设置"
|
||||
msgid "Design Config"
|
||||
msgstr "Design主题设置"
|
||||
|
||||
|
||||
msgid "Advanced Setting"
|
||||
msgstr "高级设置"
|
||||
|
||||
@ -30,8 +29,8 @@ msgstr "进阶参数编辑"
|
||||
msgid "Built-in"
|
||||
msgstr "内建"
|
||||
|
||||
msgid "The enhanced version of the original advanced settings allows for unified setting and management of background images for kucat, Agron, and Opentopd themes, without the need to upload them separately. Color schemes for kucat and Agron themes can be set.<br>"
|
||||
msgstr "原高级设置的加强版,可以统一设置管理 kucat,Agron,Opentopd三个主题登录壁纸图片,无须分开上传,可以设置kucat,Agron主题的颜色方案<br>"
|
||||
msgid "The enhanced version of the original advanced settings allows for unified setting and management of background images for kucat/Agron/Opentopd themes, without the need to upload them separately. Color schemes for kucat/Agron/design themes can be set.<br>"
|
||||
msgstr "原高级设置的加强版,可以统一设置管理 kucat/Agron/Opentopd三个主题登录壁纸图片,无须分开上传,可以设置kucat/Agron/design主题的颜色方案<br>"
|
||||
|
||||
msgid "At the same time, important plugin parameters can be compiled. At the same time, some system parameters can also be set, such as display and hide settings."
|
||||
msgstr "同时可以编译重要的插件参数。同时还可以设置部分系统参数,如:显示隐藏设置设置等功能。"
|
||||
@ -373,3 +372,9 @@ msgstr "本页是配置"
|
||||
msgid "Document content. Automatic restart takes effect after saving the application"
|
||||
msgstr "文档内容。应用保存后自动重启生效"
|
||||
|
||||
msgid "TSO optimization for network card interruption"
|
||||
msgstr "网卡断流TSO优化"
|
||||
|
||||
msgid "Turn off the TSO parameters of the INTEL225 network card to improve network interruption"
|
||||
msgstr "关闭INTEL225网卡TSO参数,改善网络断流"
|
||||
|
||||
|
@ -29,8 +29,8 @@ msgstr "进阶参数编辑"
|
||||
msgid "Built-in"
|
||||
msgstr "内建"
|
||||
|
||||
msgid "The enhanced version of the original advanced settings allows for unified setting and management of background images for kucat, Agron, and Opentopd themes, without the need to upload them separately. Color schemes for kucat and Agron themes can be set.<br>"
|
||||
msgstr "原高级设置的加强版,可以统一设置管理 kucat,Agron,Opentopd三个主题登录壁纸图片,无须分开上传,可以设置kucat,Agron主题的颜色方案<br>"
|
||||
msgid "The enhanced version of the original advanced settings allows for unified setting and management of background images for kucat/Agron/Opentopd themes, without the need to upload them separately. Color schemes for kucat/Agron/design themes can be set.<br>"
|
||||
msgstr "原高级设置的加强版,可以统一设置管理 kucat/Agron/Opentopd三个主题登录壁纸图片,无须分开上传,可以设置kucat/Agron/design主题的颜色方案<br>"
|
||||
|
||||
msgid "At the same time, important plugin parameters can be compiled. At the same time, some system parameters can also be set, such as display and hide settings."
|
||||
msgstr "同时可以编译重要的插件参数。同时还可以设置部分系统参数,如:显示隐藏设置设置等功能。"
|
||||
@ -372,3 +372,9 @@ msgstr "本页是配置"
|
||||
msgid "Document content. Automatic restart takes effect after saving the application"
|
||||
msgstr "文档内容。应用保存后自动重启生效"
|
||||
|
||||
msgid "TSO optimization for network card interruption"
|
||||
msgstr "网卡断流TSO优化"
|
||||
|
||||
msgid "Turn off the TSO parameters of the INTEL225 network card to improve network interruption"
|
||||
msgstr "关闭INTEL225网卡TSO参数,改善网络断流"
|
||||
|
||||
|
@ -9,7 +9,7 @@ config basic
|
||||
option font_x '0.875rem'
|
||||
option bklock '1'
|
||||
option setbar '1'
|
||||
option dayword '1'
|
||||
option dayword '0'
|
||||
option background '0'
|
||||
option bgqs '1'
|
||||
option mode 'light'
|
||||
@ -19,7 +19,7 @@ config basic
|
||||
option primary_opacity '0'
|
||||
option primary_rgbs_ts '0.1'
|
||||
option primary_rgbs '28,66,188'
|
||||
option bkuse '1'
|
||||
option bkuse '0'
|
||||
|
||||
config theme
|
||||
option primary_rgbbody '33,45,60'
|
||||
@ -31,7 +31,7 @@ config theme
|
||||
option primary_rgbm_ts '0.9'
|
||||
option primary_rgbm 'blue'
|
||||
option use '1'
|
||||
option bkuse '1'
|
||||
option bkuse '0'
|
||||
|
||||
config theme
|
||||
option primary_rgbbody '33,45,60'
|
||||
@ -88,7 +88,7 @@ config theme
|
||||
option remarks '炫灰隔栏模糊'
|
||||
option primary_rgbs_ts '0.5'
|
||||
option primary_opacity '4'
|
||||
option use '0'
|
||||
option use '1'
|
||||
|
||||
config theme
|
||||
option mode 'light'
|
||||
|
@ -23,7 +23,7 @@ config basic
|
||||
option font_x '0.875rem'
|
||||
option bklock '1'
|
||||
option setbar '1'
|
||||
option dayword '1'
|
||||
option dayword '0'
|
||||
option background '0'
|
||||
option bgqs '1'
|
||||
option mode 'light'
|
||||
@ -33,7 +33,7 @@ config basic
|
||||
option primary_opacity '0'
|
||||
option primary_rgbs_ts '0.1'
|
||||
option primary_rgbs '28,66,188'
|
||||
option bkuse '1'
|
||||
option bkuse '0'
|
||||
|
||||
config theme
|
||||
option primary_rgbbody '33,45,60'
|
||||
@ -45,7 +45,7 @@ config theme
|
||||
option primary_rgbm_ts '0.9'
|
||||
option primary_rgbm 'blue'
|
||||
option use '1'
|
||||
option bkuse '1'
|
||||
option bkuse '0'
|
||||
|
||||
config theme
|
||||
option primary_rgbbody '33,45,60'
|
||||
@ -124,6 +124,19 @@ cpumodeset()
|
||||
for i in 0 1 2 3 ;do
|
||||
echo $1 > /sys/devices/system/cpu/cpufreq/policy$i/scaling_governor
|
||||
done
|
||||
}
|
||||
|
||||
tsoset() {
|
||||
tautocore=/etc/init.d/autocore
|
||||
[ -f $tautocore ] || return
|
||||
if [ "x$(uci -q get advancedplus.@basic[0].tsoset)" = "x1" ] ;then
|
||||
sed -i 's/tso on/tso off/g' $tautocore
|
||||
$tautocore restart
|
||||
else
|
||||
sed -i 's/tso off/tso on/g' $tautocore
|
||||
$tautocore restart
|
||||
fi
|
||||
|
||||
}
|
||||
sethttps() {
|
||||
|
||||
@ -166,6 +179,7 @@ dev=`ifconfig | grep "Point-to-Point" | cut -d " " -f1`
|
||||
[ ! $dev ] && dev=br-lan
|
||||
setnetwizard
|
||||
sethttps
|
||||
tsoset
|
||||
[ "x$(uci -q get advancedplus.@basic[0].qos)" = "x1" ] && \usr\bin\qoshome
|
||||
if [ "x$(uci -q get advancedplus.@basic[0].ttl)" = "x1" ] ; then
|
||||
$ipt -t mangle -A PREROUTING -p tcp --tcp-flags RST RST -i $dev -j DROP
|
||||
@ -274,8 +288,8 @@ if [ "x$useset" == "x0" ] ; then
|
||||
uci set advancedplus.@basic[0].primary_rgbs_ts='0.1'
|
||||
uci set advancedplus.@basic[0].primary_rgbs='225,112,88'
|
||||
uci set advancedplus.@basic[0].bkuse='1'
|
||||
uci set advancedplus.@basic[0].primary_rgbm_ts='0.9'
|
||||
uci set advancedplus.@basic[0].primary_opacity='50'
|
||||
uci set advancedplus.@basic[0].primary_rgbm_ts='0.7'
|
||||
uci set advancedplus.@basic[0].primary_opacity='5'
|
||||
[ $mode == dark ] && uci set advancedplus.@basic[0].primary_rgbbody='33,45,60' || uci set advancedplus.@basic[0].primary_rgbbody='248,248,248'
|
||||
fi
|
||||
if [ "x$(uci -q get advancedplus.@basic[0].fontmode)" = "x1" ] ; then
|
||||
|
@ -12,7 +12,7 @@ LUCI_TITLE:=LuCI support for Scheduled Time setting
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_VERSION:=2.1.0
|
||||
PKG_RELEASE:=20240311
|
||||
PKG_RELEASE:=20240318
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
|
@ -13,12 +13,12 @@ s.anonymous=true
|
||||
e=s:option(TextValue, "customscript" ,translate("Edit Custom Script"))
|
||||
e.description = translate("The execution content of the [Scheduled Customscript] in the task name")
|
||||
e.rows = 5
|
||||
e.rmempty = false
|
||||
e.default=" "
|
||||
|
||||
e=s:option(TextValue, "customscript2" ,translate("Edit Custom Script2"))
|
||||
e.description = translate("The execution content of the [Scheduled Customscript2] in the task name")
|
||||
e.rows = 5
|
||||
e.rmempty = false
|
||||
e.default=" "
|
||||
|
||||
s=m:section(TypedSection,"stime","")
|
||||
s.addremove=true
|
||||
@ -38,9 +38,9 @@ e:value(9,translate("Scheduled DisReconn"))
|
||||
e:value(10,translate("Scheduled DisRereboot"))
|
||||
e:value(11,translate("Scheduled Restartmwan3"))
|
||||
e:value(12,translate("Scheduled Customscript"))
|
||||
e:value(13,translate("Scheduled Customscript2"))
|
||||
e:value(14,translate("Scheduled Wifiup"))
|
||||
e:value(15,translate("Scheduled Wifidown"))
|
||||
e:value(13,translate("Scheduled Wifiup"))
|
||||
e:value(14,translate("Scheduled Wifidown"))
|
||||
e:value(15,translate("Scheduled Customscript2"))
|
||||
e.default=2
|
||||
|
||||
e=s:option(Flag,"enable",translate("Enable"))
|
||||
|
@ -1,6 +1,7 @@
|
||||
config global
|
||||
option enabled '0'
|
||||
option customscript '#!/bin/sh'
|
||||
option customscript '# Sh script rules'
|
||||
option customscript2 '# Sh script rules'
|
||||
|
||||
config stime
|
||||
option hour '*/4'
|
||||
|
@ -77,17 +77,17 @@ do
|
||||
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler customscript Startup_task" >>$TT
|
||||
;;
|
||||
13)
|
||||
local cmd="$minute $hour * $month $week /usr/bin/timesethandler customscript2 Scheduled_task"
|
||||
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler customscript2 Startup_task" >>$TT
|
||||
;;
|
||||
14)
|
||||
local cmd="$minute $hour * $month $week /usr/bin/timesethandler upwifi Scheduled_task"
|
||||
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler upwifi Startup_task" >>$TT
|
||||
;;
|
||||
15)
|
||||
14)
|
||||
local cmd="$minute $hour * $month $week /usr/bin/timesethandler downwifi Scheduled_task"
|
||||
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler downwifi Startup_task" >>$TT
|
||||
;;
|
||||
15)
|
||||
local cmd="$minute $hour * $month $week /usr/bin/timesethandler customscript2 Scheduled_task"
|
||||
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler customscript2 Startup_task" >>$TT
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
@ -8,8 +8,8 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-netspeedtest
|
||||
|
||||
PKG_VERSION:=2.2.3
|
||||
PKG_RELEASE:=20240315
|
||||
PKG_VERSION:=2.2.4
|
||||
PKG_RELEASE:=20240319
|
||||
|
||||
LUCI_TITLE:=LuCI Support for netspeedtest
|
||||
LUCI_DEPENDS:=+python3 +iperf3-ssl +homebox
|
||||
@ -24,8 +24,7 @@ endef
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/prerm
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
|
||||
|
||||
module("luci.controller.netspeedtest", package.seeall)
|
||||
local http = require "luci.http"
|
||||
local fs=require"nixio.fs"
|
||||
local sys=require "luci.sys"
|
||||
local uci = luci.model.uci.cursor()
|
||||
@ -8,22 +9,47 @@ name='netspeedtest'
|
||||
function index()
|
||||
|
||||
if not nixio.fs.access("/etc/config/netspeedtest") then return end
|
||||
local e = entry({"admin","network","netspeedtest"},alias("admin", "network", "netspeedtest", "speedtestlan"),_("Net Speedtest"), 90)
|
||||
e.dependent=false
|
||||
e.acl_depends = { "luci-app-netspeedtest" }
|
||||
|
||||
local e = entry({"admin","network","netspeedtest"},alias("admin", "network", "netspeedtest", "speedtestlan"),_("Net Speedtest"),90)
|
||||
e.dependent = false
|
||||
e.acl_depends = { "luci-app-netspeedtest" }
|
||||
|
||||
entry({"admin", "network", "netspeedtest", "speedtestlan"},cbi("netspeedtest/speedtestlan"),_("Lan Speedtest Web"),20).leaf = true
|
||||
entry({"admin", "network", "netspeedtest", "speedtestiperf3"},cbi("netspeedtest/speedtestiperf3", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Lan Speedtest Iperf3"),30).leaf = true
|
||||
entry({"admin", "network", "netspeedtest", "speedtestwan"},cbi("netspeedtest/speedtestwan", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Broadband speed test"), 40).leaf = true
|
||||
entry({"admin", "network", "netspeedtest", "speedtestport"},cbi("netspeedtest/speedtestport", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Server Port Latency Test"), 50).leaf = true
|
||||
entry({"admin", "network", "netspeedtest", "log"}, form("netspeedtest/log"), _("Log"), 60).leaf = true
|
||||
entry({"admin", "network", "netspeedtest", "test_port"}, call("test_port"))
|
||||
entry({"admin", "network", "iperf3_status"}, call("iperf3_status"))
|
||||
entry({"admin", "network", "test_iperf0"}, post("test_iperf0"), nil).leaf = true
|
||||
entry({"admin", "network", "test_iperf1"}, post("test_iperf1"), nil).leaf = true
|
||||
entry({"admin", "network", "netspeedtest", "speedtestwanrun"}, call("speedtestwanrun"))
|
||||
entry({"admin", "network", "netspeedtest", "realtime_log"}, call("get_log"))
|
||||
entry({"admin", "network", "netspeedtest", "netcheck"}, call("netcheck"))
|
||||
entry({"admin", "network", "netspeedtest", "dellog"},call("dellog"))
|
||||
entry({"admin", "network", "netspeedtest", "getlog"},call("getlog"))
|
||||
end
|
||||
|
||||
function netcheck()
|
||||
http.prepare_content("text/plain; charset=utf-8")
|
||||
local f=io.open("/etc/netspeedtest/netspeedtest.log", "r+")
|
||||
local fdp=fs.readfile("/etc/netspeedtest/netspeedtestpos") or 0
|
||||
f:seek("set",fdp)
|
||||
local a=f:read(2048000) or ""
|
||||
fdp=f:seek()
|
||||
fs.writefile("/etc/netspeedtest/netspeedtestpos",tostring(fdp))
|
||||
f:close()
|
||||
http.write(a)
|
||||
end
|
||||
|
||||
function speedtestwanrun()
|
||||
local cli = luci.http.formvalue('cli')
|
||||
uci:set(name, 'speedtestwan', 'speedtest_cli', cli)
|
||||
uci:commit(name)
|
||||
fs.writefile("/etc/netspeedtest/netspeedtestpos","0")
|
||||
http.prepare_content("application/json")
|
||||
http.write('')
|
||||
sys.exec(string.format("/etc/init.d/netspeedtest wantest " ..cli.. " > /etc/netspeedtest/netspeedtest.log 2>&1 &" ))
|
||||
end
|
||||
|
||||
function test_port()
|
||||
local e = {}
|
||||
@ -82,24 +108,25 @@ function test_iperf1(addr)
|
||||
sys.call("/etc/init.d/unblockmusic restart")
|
||||
end
|
||||
|
||||
function get_log()
|
||||
local e = {}
|
||||
e.running = sys.call("busybox ps -w | grep netspeedtest | grep -v grep >/dev/null") == 0
|
||||
e.log = fs.readfile("/var/log/netspeedtest.log") or ""
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function dellog()
|
||||
fs.writefile("/var/log/netspeedtest.log","")
|
||||
http.prepare_content("application/json")
|
||||
http.write('')
|
||||
end
|
||||
|
||||
function speedtestwanrun()
|
||||
local cli = luci.http.formvalue('cli')
|
||||
uci:set(name, 'speedtestwan', 'speedtest_cli', cli)
|
||||
uci:commit(name)
|
||||
testout("/etc/init.d/netspeedtest wantest "..cli)
|
||||
|
||||
|
||||
function getlog()
|
||||
logfile="/var/log/netspeedtest.log"
|
||||
if not fs.access(logfile) then
|
||||
http.write("")
|
||||
return
|
||||
end
|
||||
local f=io.open(logfile,"r")
|
||||
local a=f:read("*a") or ""
|
||||
f:close()
|
||||
a=string.gsub(a,"\n$","")
|
||||
http.prepare_content("text/plain; charset=utf-8")
|
||||
http.write(a)
|
||||
end
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
local fs = require "nixio.fs"
|
||||
local uci = require"luci.model.uci".cursor()
|
||||
local f, t
|
||||
f = SimpleForm("logview")
|
||||
f.reset = false
|
||||
f.submit = false
|
||||
t=f:field(TextValue,"conf")
|
||||
|
||||
t.rmempty=true
|
||||
t.rows=20
|
||||
t.template="netspeedtest/log"
|
||||
t.readonly="readonly"
|
||||
return f
|
@ -21,8 +21,5 @@ e = t:option(DummyValue, '', '')
|
||||
e.rawhtml = true
|
||||
e.template ='netspeedtest/speedtestport'
|
||||
|
||||
e =t:option(DummyValue, '', '')
|
||||
e.rawhtml = true
|
||||
e.template = 'netspeedtest/log'
|
||||
|
||||
return o
|
||||
|
@ -12,12 +12,8 @@ e:value("0",translate("ookla-speedtest-cli"))
|
||||
e:value("1",translate("python3-speedtest-cli"))
|
||||
e.default = "1"
|
||||
|
||||
e = t:option(DummyValue, '', '')
|
||||
e.rawhtml = true
|
||||
e=t:option(Button, "restart", translate("speedtest.net Broadband speed test"))
|
||||
e.inputtitle=translate("Click to execute")
|
||||
e.template ='netspeedtest/speedtestwan'
|
||||
|
||||
e =t:option(DummyValue, '', '')
|
||||
e.rawhtml = true
|
||||
e.template = 'netspeedtest/log'
|
||||
|
||||
return o
|
||||
|
@ -1,16 +1,53 @@
|
||||
<%+cbi/valueheader%>
|
||||
<textarea id="logview.list" class="cbi-input-textarea" style="width: 100%" rows="20" readonly="readonly"></textarea>
|
||||
<input type="button" class="btn cbi-button cbi-button-apply" id="apply_update_button" value="<%:Clear Log%>" onclick="apply_del_log()"/>
|
||||
<input type="checkbox" name="NAME" value="reverse" onclick="reverselog()" style="vertical-align:middle;height:auto;"><%:Reverse%></input>
|
||||
<textarea id="cbid.logview.1.conf" class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="32" cols="60" readonly="readonly" > </textarea>
|
||||
|
||||
<script type="text/javascript">
|
||||
const LOG_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","realtime_log")%>';
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var islogreverse=false;
|
||||
|
||||
XHR.poll(1, LOG_URL, null, (x, d) => {
|
||||
let logview = document.getElementById("logview.list");
|
||||
if (!d.running) {
|
||||
XHR.halt();
|
||||
}
|
||||
logview.value = d.log;
|
||||
logview.scrollTop = logview.scrollHeight;
|
||||
});
|
||||
function createAndDownloadFile(fileName,content){
|
||||
var aTag=document.createElement('a');
|
||||
var blob=new Blob([content]);
|
||||
aTag.download=fileName;
|
||||
aTag.href=URL.createObjectURL(blob);
|
||||
aTag.click();
|
||||
URL.revokeObjectURL(blob);
|
||||
}
|
||||
function apply_del_log(){
|
||||
XHR.get('<%=url([[admin]],[[network]],[[netspeedtest]],[[dellog]])%>',null,function(x,data){
|
||||
var lv=document.getElementById('cbid.logview.1.conf');
|
||||
lv.innerHTML="";
|
||||
}
|
||||
);
|
||||
return
|
||||
}
|
||||
|
||||
function reverselog(){
|
||||
var lv=document.getElementById('cbid.logview.1.conf');
|
||||
lv.innerHTML=lv.innerHTML.split('\n').reverse().join('\n')
|
||||
if (islogreverse){
|
||||
islogreverse=false;
|
||||
}else{
|
||||
islogreverse=true;
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
XHR.poll(3,'<%=url([[admin]],[[network]],[[netspeedtest]],[[getlog]])%>',null,
|
||||
function(x,data){
|
||||
var lv=document.getElementById('cbid.logview.1.conf');
|
||||
lv.innerHTML=""
|
||||
if (x.responseText && lv){
|
||||
if (islogreverse){
|
||||
lv.innerHTML=x.responseText.split('\n').reverse().join('\n')+lv.innerHTML;
|
||||
}else{
|
||||
lv.innerHTML+=x.responseText;
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
<%+cbi/valuefooter%>
|
||||
<%+cbi/valuefooter%>
|
@ -3,24 +3,32 @@
|
||||
https://github.com/sirpdboy/netspeedtest
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<%+cbi/valueheader%>
|
||||
|
||||
|
||||
<label class="cbi-value-title"><%= translate("speedtest.net Broadband speed test") %></label>
|
||||
<div class="cbi-value-field">
|
||||
<input class="cbi-button cbi-button-apply" id="run_service" type="button" onclick="run(this)" value="<%=translate('Click to execute') %>" />
|
||||
<%local fs=require"nixio.fs"%>
|
||||
<input type="button" class="btn cbi-button cbi-button-apply" id="apply_run_button" value="<%:Click to execute%>" onclick=" return apply_run(this) "/>
|
||||
<div id="logview" style="display:none">
|
||||
<input type="checkbox" id="reversetag" value="reverse" onclick=" return reverselog()" style="vertical-align:middle;height: auto;"><%:reverse%></input>
|
||||
<textarea id="cbid.logview.test.conf" class="cbi-input-textarea" style="width: 100%;display:block;" data-update="change" rows="20" cols="80" readonly="readonly" > </textarea>
|
||||
</div>
|
||||
<fieldset class="cbi-section" style="display:none">
|
||||
<legend id="wanspeedtest-legend">
|
||||
<%:Collecting data...%>
|
||||
</legend>
|
||||
<span id="wanspeedtest-output"></span>
|
||||
</fieldset>
|
||||
<script type="text/javascript">
|
||||
function run(btn) {
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
const RUN_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","speedtestwanrun")%>';
|
||||
const S_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","speedtestwan")%>';
|
||||
const S_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","netcheck")%>';
|
||||
var checkbtn = document.getElementById('apply_run_button');
|
||||
|
||||
var islogreverse = false;
|
||||
function reverselog(){
|
||||
var lv = document.getElementById('cbid.logview.test.conf');
|
||||
lv.innerHTML=lv.innerHTML.split('\n').reverse().join('\n')
|
||||
if (islogreverse){
|
||||
islogreverse=false;
|
||||
}else{
|
||||
islogreverse=true;
|
||||
}
|
||||
return
|
||||
}
|
||||
function apply_run(btn) {
|
||||
|
||||
var sid='speedtestwan'
|
||||
var opt={
|
||||
base:"cbid.netspeedtest."+sid,
|
||||
@ -47,40 +55,45 @@ function run(btn) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
var legend=document.getElementById('wanspeedtest-legend');
|
||||
var output=document.getElementById('wanspeedtest-output');
|
||||
btn.value='<%:Waiting (executing)...%>';
|
||||
btn.disabled=true;
|
||||
var cli=opt.get("speedtest_cli").value;
|
||||
console.log(cli);
|
||||
legend.parentNode.style.display = 'block';
|
||||
legend.style.display = 'inline';
|
||||
output.innerHTML =
|
||||
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
|
||||
'<%:Network speed test, please wait...%>'
|
||||
;
|
||||
|
||||
XHR.get(RUN_URL, { cli: cli },
|
||||
(x) =>{
|
||||
if (x.responseText)
|
||||
{
|
||||
legend.style.display = 'none';
|
||||
output.innerHTML = String.format('<img src=%h height="300" style="vertical-align:middle" />', x.responseText);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
legend.style.display = 'none';
|
||||
output.innerHTML ='</p><%:Operation execution complete%></p>';
|
||||
|
||||
}
|
||||
btn.disabled=false;
|
||||
btn.value='<%:Click to execute%>';
|
||||
}
|
||||
(x) =>{}
|
||||
);
|
||||
return false;
|
||||
poll_check();
|
||||
return;
|
||||
}
|
||||
|
||||
</script>
|
||||
function poll_check(){
|
||||
var tag = document.getElementById('logview');
|
||||
tag.style.display="block"
|
||||
XHR.poll(3, '<%=url([[admin]], [[network]], [[netspeedtest]], [[netcheck]])%>', null,
|
||||
function(x, data) {
|
||||
var lv = document.getElementById('cbid.logview.test.conf');
|
||||
|
||||
if (x.responseText && lv) {
|
||||
if (x.responseText=="\u0000"){
|
||||
for(j = 0,len=this.XHR._q.length; j < len; j++) {
|
||||
if (this.XHR._q[j].url == '<%=url([[admin]], [[network]], [[netspeedtest]], [[netcheck]])%>'){
|
||||
this.XHR._q.splice(j,1);
|
||||
checkbtn.disabled = false;
|
||||
checkbtn.value = '<%:Click to execute%>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
if (islogreverse){
|
||||
lv.innerHTML = x.responseText.split('\n').reverse().join('\n')+lv.innerHTML;
|
||||
}else{
|
||||
lv.innerHTML += x.responseText;
|
||||
}
|
||||
}
|
||||
}
|
||||
);}
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
<%+cbi/valuefooter%>
|
||||
|
@ -15,7 +15,15 @@ EXTRA_COMMANDS="wantest"
|
||||
TMP_T=/var/netspeedtest_nstest.tmp
|
||||
BINSPEEDTEST='/usr/bin/speedtest'
|
||||
LOCK=/var/lock/netspeedtest_nstest.lock
|
||||
LOGD=/etc/netspeedtest
|
||||
LOG=/var/log/netspeedtest.log
|
||||
LOGE=$LOGD/netspeedtest.log
|
||||
LOGT=$LOGD/netspeedtestpos
|
||||
[ -d "$LOGD" ] || mkdir -p $LOGD
|
||||
[ -f "$LOGE" ] || echo "start" > $LOG
|
||||
[ -f "$LOGT" ] || echo "start" > $LOGT
|
||||
[ -f "$LOG" ] || echo "start" > $LOG
|
||||
|
||||
MAX_LOG=500
|
||||
limit_log() {
|
||||
local logf=$1
|
||||
@ -29,10 +37,6 @@ limit_log() {
|
||||
fi
|
||||
}
|
||||
|
||||
init_log() {
|
||||
local logf=$1
|
||||
[ ! -f "$logf" ] && echo "" > $logf
|
||||
}
|
||||
|
||||
echone() {
|
||||
echo -ne $* >> $LOG
|
||||
@ -42,46 +46,50 @@ echone() {
|
||||
wantest() {
|
||||
[ -f $LOCK ] && exit
|
||||
limit_log $LOG 500
|
||||
init_log $LOG
|
||||
touch $LOCK
|
||||
TESTMODE=$1
|
||||
BINTEMP=$(git_bin_handle $TESTMODE)
|
||||
# [ -n "$BINTEMP" ] || return
|
||||
# echone "\n BINTEMP: $BINTEMP "
|
||||
case $TESTMODE in
|
||||
0)
|
||||
echo -ne "\n —————ookla-speedtest测速$TESTMODE—————" >> $LOG
|
||||
info=$($BINTEMP > $TMP_T 2>&1 )
|
||||
RESULT=$(echo "$TMP_T" | grep "URL" | awk '{print $NF}')
|
||||
echo -ne "\n —————ookla-speedtest测速—————\n" | tee -a $LOG
|
||||
$BINTEMP | tee $TMP_T
|
||||
RESULT=$(cat $TMP_T | grep 'URL' | cut -c15-)
|
||||
if [ -n "$RESULT" ] ;then
|
||||
echo -ne "\n 测服信息:`cat $TMP_T | grep 'Server'| cut -c10- | awk -F: '{printf $2$3}'` 线路:`cat $TMP_T | grep 'ISP' | awk -F: '{printf $2}' ` 延时:`cat $TMP_T | grep 'Latency' | awk -F: '{printf $2}' | awk -F '(' '{printf $1}'`" >> $LOG
|
||||
echo -ne "\n 下行速率:`cat $TMP_T | grep 'Download' |awk -F: '{printf $2}' | awk -F '(' '{printf $1}'` --" >> $LOG
|
||||
echo -ne "-- 上行速率:`cat $TMP_T | grep 'Upload' |awk -F: '{printf $2}' | awk -F '(' '{printf $1}'`" >> $LOG
|
||||
echo -ne "\n 测速结果图片链接:`cat $TMP_T | grep 'URL' | cut -c15-`" >> $LOG
|
||||
echo -ne "$RESULT"
|
||||
else
|
||||
echo -ne "\n 因客户端在LUCI状态下无法执行,测试失败!" >> $LOG
|
||||
echo -ne "\n 请SSH登陆后输入 :/etc/init.d/netspeedtest wantest 0 然后等完成后,刷新后查看记录!" >> $LOG
|
||||
echo -ne "\n 因客户端在LUCI下运行错误,测试失败!" | tee -a $LOG
|
||||
echo -ne "\n 请SSH运行:/etc/init.d/netspeedtest wantest 0 测试,完成后,在日志中有测试结果!" | tee -a $LOG
|
||||
fi
|
||||
echo -ne "\n 测试时间: `date +%Y-%m-%d' '%H:%M:%S`" >> $LOG
|
||||
echo -ne "\n ————————————————————\n" >> $LOG
|
||||
echo -ne "\n 测试时间: `date +%Y-%m-%d' '%H:%M:%S`" | tee -a $LOG
|
||||
echo -ne "\n ————————————————————\n" | tee -a $LOG
|
||||
;;
|
||||
*)
|
||||
echo -ne "\n —————python3-speedtest测速$TESTMODE—————" >> $LOG
|
||||
info=$($BINTEMP > $TMP_T 2>&1 )
|
||||
*)
|
||||
echo -ne "\n —————python3-speedtest测速—————\n" | tee -a $LOG
|
||||
$BINTEMP | tee $TMP_T
|
||||
echo -ne "\n 测服信息:$(cat $TMP_T | grep 'Hosted by'| cut -c10- | awk -F: '{printf $1}') 延时:$(cat $TMP_T | grep 'Hosted by' | awk -F: '{printf $2}')" >> $LOG
|
||||
echo -ne "\n 下行速率:$(cat $TMP_T | grep 'Download:' |awk -F: '{printf $2}' )" >> $LOG
|
||||
echo -ne " ---- 上行速率:$(cat $TMP_T | grep 'Upload:' |awk -F: '{printf $2}' )" >> $LOG
|
||||
echo -ne "\n 下行速率:$(cat $TMP_T | grep 'Download:' |awk -F: '{printf $2}' ) --" >> $LOG
|
||||
echo -ne "-- 上行速率:$(cat $TMP_T | grep 'Upload:' |awk -F: '{printf $2}' )" >> $LOG
|
||||
echo -ne "\n 测试结果图片链接:$(cat $TMP_T | grep 'results:' | cut -c16- )" >> $LOG
|
||||
echo -ne "\n 测试时间:`date +%Y-%m-%d" "%H:%M:%S`" >> $LOG
|
||||
echo -ne "\n ————————————————————\n" >> $LOG
|
||||
echo -ne $(cat $TMP_T | grep 'results:' | awk '{print $NF}')
|
||||
echo -ne "\n 测试时间:`date +%Y-%m-%d" "%H:%M:%S`" | tee -a $LOG
|
||||
echo -ne "\n ————————————————————\n" | tee -a $LOG
|
||||
|
||||
;;
|
||||
esac
|
||||
rm -f $LOCK
|
||||
}
|
||||
|
||||
getcpucore(){
|
||||
#i386, x86_64, arm32, arm32hf, and arm64.
|
||||
cputype=$(uname -ms | tr ' ' '_' | tr '[A-Z]' '[a-z]')
|
||||
[ -n "$(echo $cputype | grep -E "linux.*armv.*")" ] && cpucore="armel"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*armv7.*")" ] && [ -n "$(cat /proc/cpuinfo | grep vfp)" ] && [ ! -d /jffs/clash ] && cpucore="armhf"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*aarch64.*|linux.*armv8.*")" ] && cpucore="aarch64"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*86.*")" ] && cpucore="i386"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*86_64.*")" ] && cpucore="x86_64"
|
||||
echo $cpucore
|
||||
}
|
||||
|
||||
git_bin_handle()
|
||||
{
|
||||
@ -95,7 +103,7 @@ case $1 in
|
||||
chmod 755 $BINSPEEDTEST >/dev/null 2>&1
|
||||
echo "$BINSPEEDTEST --accept-gdpr --accept-license --progress=no"
|
||||
else
|
||||
ooklaurl=`curl --connect-timeout 5 -m 60 -sSL 'https://www.speedtest.net/apps/cli' | grep 'Download for Linux' | sed 's|<|\n<|g' | sed -n '/Download for Linux/,/<\/div>/p' | sed -En "s|.*<a href=\"([^\"]+)\">x86_64|\1|p" `
|
||||
ooklaurl=`curl --connect-timeout 5 -m 60 -sSL 'https://www.speedtest.net/apps/cli' | grep 'Download for Linux' | sed 's|<|\n<|g' | sed -n '/Download for Linux/,/<\/div>/p' | sed -En "s|.*<a href=\"([^\"]+)\">$(getcpucore)|\1|p" `
|
||||
[ -n "$ooklaurl" ] && curl -sSL $ooklaurl | tar -xvz -C /tmp >/dev/null 2>&1 || return
|
||||
mv /tmp/speedtest $BINSPEEDTEST >/dev/null 2>&1
|
||||
chmod 755 $BINSPEEDTEST >/dev/null 2>&1
|
||||
|
@ -1,9 +1,18 @@
|
||||
#!/bin/sh
|
||||
chmod +x /etc/init.d/netspeedtest >/dev/null 2>&1
|
||||
[ `uci -q get partexp.global` ] && uci set partexp.global=global
|
||||
[ `uci -q get netspeedtest.netspeedtest` ] || uci set netspeedtest.netspeedtest=netspeedtest
|
||||
[ `uci -q get netspeedtest.speedtestiperf3` ] || uci set netspeedtest.speedtestiperf3=speedtestiperf3
|
||||
[ `uci -q get netspeedtest.speedtestport` ] || uci set netspeedtest.speedtestport=speedtestport
|
||||
[ `uci -q get netspeedtest.speedtestwan` ] || uci set netspeedtest.speedtestport=speedtestwan
|
||||
LOGD=/etc/netspeedtest
|
||||
LOG=/var/log/netspeedtest.log
|
||||
LOGE=$LOGD/netspeedtest.log
|
||||
LOGT=$LOGD/netspeedtestpos
|
||||
[ -d "$LOGD" ] || mkdir -p $LOGD
|
||||
[ -f "$LOGE" ] || echo "start" > $LOG
|
||||
[ -f "$LOGT" ] || echo "start" > $LOGT
|
||||
[ -f "$LOG" ] || echo "start" > $LOG
|
||||
|
||||
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user