From 78fe9e655459072436d27b750d641a0ad1b901a1 Mon Sep 17 00:00:00 2001 From: Pdboy Sir <63764630+sirpdboy@users.noreply.github.com> Date: Sat, 23 Mar 2024 00:38:54 +0800 Subject: [PATCH] =?UTF-8?q?up=20=E5=8D=87=E7=BA=A7=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luci-app-advancedplus/Makefile | 4 +- .../model/cbi/advancedplus/advancedset.lua | 5 +- .../po/zh-cn/advancedplus.po | 11 ++- .../po/zh_Hans/advancedplus.po | 10 +- .../root/etc/config/advancedplus | 8 +- .../root/etc/init.d/advancedplus | 24 ++++- luci-app-autotimeset/Makefile | 2 +- .../luasrc/model/cbi/autotimeset/base.lua | 10 +- .../root/etc/config/autotimeset | 3 +- .../root/etc/init.d/autotimeset | 10 +- netspeedtest/luci-app-netspeedtest/Makefile | 7 +- .../luasrc/controller/netspeedtest.lua | 61 ++++++++---- .../luasrc/model/cbi/netspeedtest/log.lua | 13 +++ .../model/cbi/netspeedtest/speedtestport.lua | 3 - .../model/cbi/netspeedtest/speedtestwan.lua | 8 +- .../luasrc/view/netspeedtest/log.htm | 61 +++++++++--- .../luasrc/view/netspeedtest/speedtestwan.htm | 97 +++++++++++-------- .../root/etc/init.d/netspeedtest | 58 ++++++----- .../etc/uci-defaults/40_luci-netspeedtest | 9 ++ 19 files changed, 266 insertions(+), 138 deletions(-) create mode 100644 netspeedtest/luci-app-netspeedtest/luasrc/model/cbi/netspeedtest/log.lua diff --git a/luci-app-advancedplus/Makefile b/luci-app-advancedplus/Makefile index 134ba7e..072affa 100644 --- a/luci-app-advancedplus/Makefile +++ b/luci-app-advancedplus/Makefile @@ -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 diff --git a/luci-app-advancedplus/luasrc/model/cbi/advancedplus/advancedset.lua b/luci-app-advancedplus/luasrc/model/cbi/advancedplus/advancedset.lua index bff23f7..74be6e3 100644 --- a/luci-app-advancedplus/luasrc/model/cbi/advancedplus/advancedset.lua +++ b/luci-app-advancedplus/luasrc/model/cbi/advancedplus/advancedset.lua @@ -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.
").. +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.
").. 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("
For specific usage, see:")..translate("GitHub @sirpdboy/luci-app-advancedplus ") @@ -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 diff --git a/luci-app-advancedplus/po/zh-cn/advancedplus.po b/luci-app-advancedplus/po/zh-cn/advancedplus.po index f1e614f..f3277ca 100644 --- a/luci-app-advancedplus/po/zh-cn/advancedplus.po +++ b/luci-app-advancedplus/po/zh-cn/advancedplus.po @@ -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.
" -msgstr "原高级设置的加强版,可以统一设置管理 kucat,Agron,Opentopd三个主题登录壁纸图片,无须分开上传,可以设置kucat,Agron主题的颜色方案
" +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.
" +msgstr "原高级设置的加强版,可以统一设置管理 kucat/Agron/Opentopd三个主题登录壁纸图片,无须分开上传,可以设置kucat/Agron/design主题的颜色方案
" 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参数,改善网络断流" + diff --git a/luci-app-advancedplus/po/zh_Hans/advancedplus.po b/luci-app-advancedplus/po/zh_Hans/advancedplus.po index bf85288..f3277ca 100644 --- a/luci-app-advancedplus/po/zh_Hans/advancedplus.po +++ b/luci-app-advancedplus/po/zh_Hans/advancedplus.po @@ -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.
" -msgstr "原高级设置的加强版,可以统一设置管理 kucat,Agron,Opentopd三个主题登录壁纸图片,无须分开上传,可以设置kucat,Agron主题的颜色方案
" +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.
" +msgstr "原高级设置的加强版,可以统一设置管理 kucat/Agron/Opentopd三个主题登录壁纸图片,无须分开上传,可以设置kucat/Agron/design主题的颜色方案
" 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参数,改善网络断流" + diff --git a/luci-app-advancedplus/root/etc/config/advancedplus b/luci-app-advancedplus/root/etc/config/advancedplus index e7e7133..7ccd659 100644 --- a/luci-app-advancedplus/root/etc/config/advancedplus +++ b/luci-app-advancedplus/root/etc/config/advancedplus @@ -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' diff --git a/luci-app-advancedplus/root/etc/init.d/advancedplus b/luci-app-advancedplus/root/etc/init.d/advancedplus index ce3d400..8db9279 100644 --- a/luci-app-advancedplus/root/etc/init.d/advancedplus +++ b/luci-app-advancedplus/root/etc/init.d/advancedplus @@ -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 diff --git a/luci-app-autotimeset/Makefile b/luci-app-autotimeset/Makefile index d480810..d306189 100644 --- a/luci-app-autotimeset/Makefile +++ b/luci-app-autotimeset/Makefile @@ -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 diff --git a/luci-app-autotimeset/luasrc/model/cbi/autotimeset/base.lua b/luci-app-autotimeset/luasrc/model/cbi/autotimeset/base.lua index babb72e..14fc33d 100644 --- a/luci-app-autotimeset/luasrc/model/cbi/autotimeset/base.lua +++ b/luci-app-autotimeset/luasrc/model/cbi/autotimeset/base.lua @@ -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")) diff --git a/luci-app-autotimeset/root/etc/config/autotimeset b/luci-app-autotimeset/root/etc/config/autotimeset index 27631e5..ef5141b 100644 --- a/luci-app-autotimeset/root/etc/config/autotimeset +++ b/luci-app-autotimeset/root/etc/config/autotimeset @@ -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' diff --git a/luci-app-autotimeset/root/etc/init.d/autotimeset b/luci-app-autotimeset/root/etc/init.d/autotimeset index 5250bf8..4af3b91 100644 --- a/luci-app-autotimeset/root/etc/init.d/autotimeset +++ b/luci-app-autotimeset/root/etc/init.d/autotimeset @@ -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 diff --git a/netspeedtest/luci-app-netspeedtest/Makefile b/netspeedtest/luci-app-netspeedtest/Makefile index 844a5a4..e7181ae 100644 --- a/netspeedtest/luci-app-netspeedtest/Makefile +++ b/netspeedtest/luci-app-netspeedtest/Makefile @@ -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 diff --git a/netspeedtest/luci-app-netspeedtest/luasrc/controller/netspeedtest.lua b/netspeedtest/luci-app-netspeedtest/luasrc/controller/netspeedtest.lua index 9768b8b..d595ec1 100644 --- a/netspeedtest/luci-app-netspeedtest/luasrc/controller/netspeedtest.lua +++ b/netspeedtest/luci-app-netspeedtest/luasrc/controller/netspeedtest.lua @@ -1,6 +1,7 @@ -- Copyright (C) 2020-2022 sirpdboy 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 diff --git a/netspeedtest/luci-app-netspeedtest/luasrc/model/cbi/netspeedtest/log.lua b/netspeedtest/luci-app-netspeedtest/luasrc/model/cbi/netspeedtest/log.lua new file mode 100644 index 0000000..eac9918 --- /dev/null +++ b/netspeedtest/luci-app-netspeedtest/luasrc/model/cbi/netspeedtest/log.lua @@ -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 diff --git a/netspeedtest/luci-app-netspeedtest/luasrc/model/cbi/netspeedtest/speedtestport.lua b/netspeedtest/luci-app-netspeedtest/luasrc/model/cbi/netspeedtest/speedtestport.lua index a1c6bec..ec67a11 100644 --- a/netspeedtest/luci-app-netspeedtest/luasrc/model/cbi/netspeedtest/speedtestport.lua +++ b/netspeedtest/luci-app-netspeedtest/luasrc/model/cbi/netspeedtest/speedtestport.lua @@ -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 diff --git a/netspeedtest/luci-app-netspeedtest/luasrc/model/cbi/netspeedtest/speedtestwan.lua b/netspeedtest/luci-app-netspeedtest/luasrc/model/cbi/netspeedtest/speedtestwan.lua index 34962a9..b06ab50 100644 --- a/netspeedtest/luci-app-netspeedtest/luasrc/model/cbi/netspeedtest/speedtestwan.lua +++ b/netspeedtest/luci-app-netspeedtest/luasrc/model/cbi/netspeedtest/speedtestwan.lua @@ -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 diff --git a/netspeedtest/luci-app-netspeedtest/luasrc/view/netspeedtest/log.htm b/netspeedtest/luci-app-netspeedtest/luasrc/view/netspeedtest/log.htm index 905e2b1..580ec1e 100644 --- a/netspeedtest/luci-app-netspeedtest/luasrc/view/netspeedtest/log.htm +++ b/netspeedtest/luci-app-netspeedtest/luasrc/view/netspeedtest/log.htm @@ -1,16 +1,53 @@ <%+cbi/valueheader%> - + +<%:Reverse%> + - -<%+cbi/valuefooter%> +<%+cbi/valuefooter%> \ No newline at end of file diff --git a/netspeedtest/luci-app-netspeedtest/luasrc/view/netspeedtest/speedtestwan.htm b/netspeedtest/luci-app-netspeedtest/luasrc/view/netspeedtest/speedtestwan.htm index 7da4bb3..872b4ca 100644 --- a/netspeedtest/luci-app-netspeedtest/luasrc/view/netspeedtest/speedtestwan.htm +++ b/netspeedtest/luci-app-netspeedtest/luasrc/view/netspeedtest/speedtestwan.htm @@ -3,24 +3,32 @@ https://github.com/sirpdboy/netspeedtest Licensed to the public under the Apache License 2.0. -%> + <%+cbi/valueheader%> - - - -
- +<%local fs=require"nixio.fs"%> + + - - +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; + } + } + } +);} + +//]]> + <%+cbi/valuefooter%> diff --git a/netspeedtest/luci-app-netspeedtest/root/etc/init.d/netspeedtest b/netspeedtest/luci-app-netspeedtest/root/etc/init.d/netspeedtest index 0fd8a2a..eff8cf2 100644 --- a/netspeedtest/luci-app-netspeedtest/root/etc/init.d/netspeedtest +++ b/netspeedtest/luci-app-netspeedtest/root/etc/init.d/netspeedtest @@ -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|.*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|.*$(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 diff --git a/netspeedtest/luci-app-netspeedtest/root/etc/uci-defaults/40_luci-netspeedtest b/netspeedtest/luci-app-netspeedtest/root/etc/uci-defaults/40_luci-netspeedtest index ef606f4..55efe07 100644 --- a/netspeedtest/luci-app-netspeedtest/root/etc/uci-defaults/40_luci-netspeedtest +++ b/netspeedtest/luci-app-netspeedtest/root/etc/uci-defaults/40_luci-netspeedtest @@ -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