update 2024-03-07 20:27:54

This commit is contained in:
github-actions[bot] 2024-03-07 20:27:54 +08:00
parent 1a640e100a
commit 22b245b6be
15 changed files with 304 additions and 225 deletions

View File

@ -1,85 +1,57 @@
# SPDX-License-Identifier: GPL-3.0-only
# Copyright (c) 2020-2024 sirpdboy herboy2008@gmail.com
#
include $(TOPDIR)/rules.mk
PKG_NAME:=homebox
PKG_VERSION:=0.0.0-dev.2020062901
PKG_RELEASE:=14
PKG_VERSION:=0.0.0-dev.2023102203
PKG_RELEASE:=3
PKG_SOURCE_URL_FILE:=v$(PKG_VERSION).tar.gz
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/XGHeaven/homebox/archive/refs/tags/
PKG_HASH:=skip
ifeq ($(ARCH),aarch64)
H_ARCH:=arm64y
PKG_BUILD_DEPENDS:=golang/host homebox/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
else ifeq ($(ARCH),arm)
H_ARCH:=arm
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/${PKG_NAME}
else ifeq ($(ARCH),i386)
H_ARCH:=386
else ifeq ($(ARCH),mips)
H_ARCH:=mips
else ifeq ($(ARCH),mipsel)
H_ARCH:=mips
else ifeq ($(ARCH),x86_64)
H_ARCH:=amd64
endif
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
define Package/$(PKG_NAME)
SECTION:=net
CATEGORY:=Network
SUBMENU:=Web Servers/Proxies
TITLE:=A Toolbox for Home Local Networks
URL:=https://github.com/XGHeaven/homebox
DEPENDS:=$(GO_ARCH_DEPENDS)
MENU:=1
DEPENDS:=@(i386||x86_64||arm||aarch64||mipsel||mips)
endef
define Package/$(PKG_NAME)/description
A Toolbox for Home Local Networks Speed Test
endef
GO_PKG_BUILD_VARS += GO111MODULE=auto
TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
define Build/Configure
( \
cd $(PKG_BUILD_DIR)/server; \
$(GO_PKG_VARS) \
go get -d -modcacherw; \
)
( \
cd $(PKG_BUILD_DIR)/server; \
GOPATH=$(PKG_BUILD_DIR)/.go_work/build \
go install -modcacherw github.com/go-bindata/go-bindata/...@latest; \
)
define Build/Prepare
[ ! -f $(PKG_BUILD_DIR)/server_Linux_$(H_ARCH).tar.gz ] && wget https://github.com/XGHeaven/homebox/releases/download/v$(PKG_VERSION)/server-linux-$(H_ARCH).tar.gz -O $(PKG_BUILD_DIR)/server-linux-$(H_ARCH).tar.gz
tar -xzvf $(PKG_BUILD_DIR)/server-linux-$(H_ARCH).tar.gz -C $(PKG_BUILD_DIR)
endef
define Build/Compile
rm -rf $(PKG_BUILD_DIR)/build/static
mkdir -p $(PKG_BUILD_DIR)/build
$(CP) $(HOST_BUILD_DIR)/build/static $(PKG_BUILD_DIR)/build/
( \
cd $(PKG_BUILD_DIR); \
$(GO_PKG_VARS) PATH=$(PKG_BUILD_DIR)/.go_work/build/bin:$$$$PATH \
$(MAKE) build-server; \
)
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/build/server $(1)/usr/bin/homebox
$(INSTALL_BIN) $(PKG_BUILD_DIR)/server-linux-$(H_ARCH) $(1)/usr/bin/homebox
endef
define Host/Configure
cd $(HOST_BUILD_DIR)/web && rm -f package-lock.json && npm --cache-min 1440 install
endef
define Host/Compile
cd $(HOST_BUILD_DIR) && $(MAKE) build-web
endef
define Host/Install
endef
define Host/Clean
rm -f $(HOST_BUILD_DIR)/build/static
endef
$(eval $(call HostBuild))
$(eval $(call BuildPackage,homebox))
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@ -1,4 +1,4 @@
#
# Copyright (C) 2020-2021 sirpdboy <herboy2008@gmail.com>
#
# This is free software, licensed under the GNU General Public License v3.
@ -8,13 +8,24 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-netspeedtest
PKG_VERSION:=2.2.1
PKG_RELEASE:=20240307
LUCI_TITLE:=LuCI Support for netspeedtest
LUCI_DEPENDS:=+python3 +iperf3-ssl +homebox
LUCI_DEPENDS:=+python3 +iperf3-ssl +homebox +ca-bundle
LUCI_PKGARCH:=all
PKG_VERSION:=2.1.6
PKG_RELEASE:=20240301
PKG_MAINTAINER:=<https://github.com/sirpdboy/netspeedtest>
define Package/$(PKG_NAME)/conffiles
/etc/config/netspeedtest
endef
define Package/$(PKG_NAME)/postinst
endef
define Package/$(PKG_NAME)/prerm
endef
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -3,42 +3,46 @@
module("luci.controller.netspeedtest", package.seeall)
local fs=require"nixio.fs"
local sys=require "luci.sys"
local uci = luci.model.uci.cursor()
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", "homebox"),_("Net Speedtest"), 90)
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","homebox"},cbi("netspeedtest/homebox"),_("Lan homebox 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}),_("Wan Speedtest"), 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", "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}),_("Wan Speedtest"), 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", "test_port"}, call("test_port"))
entry({"admin", "network", "netspeedtest", "checknet"}, call("check_net"))
entry({"admin", "network", "iperf3_status"}, call("iperf3_status"))
entry({"admin", "network","test_iperf0"}, post("test_iperf0"), nil)
entry({"admin", "network","test_iperf1"}, post("test_iperf1"), nil)
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", "speedtestrun"}, call("speedtestrun"))
entry({"admin","network","netspeedtest", "netperfrun"}, call("netperfrun"))
entry({"admin", "network", "netspeedtest", "realtime_log"}, call("get_log"))
entry({"admin", "network", "netspeedtest", "dellog"},call("dellog"))
end
function test_port()
local e = {}
local domain = luci.http.formvalue('domain')
local port = luci.http.formvalue('port')
local domain = luci.http.formvalue('sdomain')
local port = luci.http.formvalue('sport')
local ip=sys.exec("echo "..domain.." | grep -E ^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ || nslookup "..domain.." 2>/dev/null | grep Address | awk -F' ' '{print$NF}' | grep -E ^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ | sed -n 1p")
ip=sys.exec("echo -n "..ip)
e.ping = luci.sys.exec(string.format("echo -n $(tcping -q -c 1 -i 1 -t 2 -p %s %s 2>&1 | grep -o 'time=[0-9]*.[0-9]*' | awk -F '=' '{print $2}') 2>/dev/null", port, ip))
e.type = "tcping"
if r=="" then
if e.ping=="" then
e.ping=sys.call("echo -n $(ping -c 1 -W 1 %q 2>&1 | grep -o 'time=[0-9]*.[0-9]*' | awk -F '=' '{print $2}') 2>/dev/null" % ip)
e.type = "ping"
end
if e.ping=="" then e.ping="0" end
sys.call(string.format("echo -ne '\n$(date +%Y-%m-%d' '%H:%M:%S) server%s -- port%s -- TCP%s Ms' >> /var/log/netspeedtest.log",domain,port,e.ping))
sys.exec(string.format('echo -ne "\n 【$(date)】 服务器:%s -- 端口:%s -- TCP延时%s ms \n">> /var/log/netspeedtest.log',domain,port,e.ping))
uci:set(name, 'speedtestport', 'sdomain', domain)
uci:set(name, 'speedtestport', 'sport', port)
uci:set(name, 'speedtestport', 'tcpspeed', e.ping.." Ms")
uci:commit(name)
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
@ -46,7 +50,7 @@ end
function iperf3_status()
local e={}
e.run=sys.call("pgrep iperf3 >/dev/null")==0
e.run=sys.call("busybox ps -w | grep iperf3 | grep -v grep >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
@ -63,7 +67,6 @@ function testout(cmd, addr)
end
util:close()
end
end
function test_iperf0(addr)
@ -80,9 +83,9 @@ function test_iperf1(addr)
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 ""
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
@ -97,6 +100,3 @@ function speedtestrun()
testout("/etc/init.d/netspeedtest nstest ")
end
function netperfrun()
testout("sh /usr/bin/netperftest")
end

View File

@ -6,7 +6,7 @@ local o,s,e
o = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."</font>",translate( "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:") ..translate("<a href=\'https://github.com/sirpdboy/netspeedtest.git' target=\'_blank\'>GitHub @sirpdboy/netspeedtest</a>") )
o:section(SimpleSection).template = "netspeedtest/speedtestiperf3_status"
s = o:section(TypedSection, "speedtestiperf3", translate('Lan Speedtest Iperf3'))
s = o:section(TypedSection, "netspeedtest", translate('Lan Speedtest Iperf3'))
s.addremove=false
s.anonymous=true

View File

@ -3,7 +3,7 @@ local m, s ,o
m = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."</font>",translate( "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:") ..translate("<a href=\'https://github.com/sirpdboy/netspeedtest.git' target=\'_blank\'>GitHub @sirpdboy/netspeedtest</a>") )
s = m:section(TypedSection, "homebox", translate('Lan homebox Web'))
s = m:section(TypedSection, "netspeedtest", translate('Lan Speedtest Web'))
s.anonymous = true
o=s:option(Flag,"enabled",translate("Enable"))
@ -11,11 +11,11 @@ o.default=0
o = s:option(DummyValue, '', '')
o.rawhtml = true
o.template ='netspeedtest/homebox'
o.template ='netspeedtest/speedtestlan'
m.apply_on_parse = true
m.on_after_apply = function(self,map)
io.popen("/etc/init.d/netspeedtest restart")
luci.http.redirect(luci.dispatcher.build_url("admin","network","netspeedtest","homebox"))
luci.http.redirect(luci.dispatcher.build_url("admin","network","netspeedtest","speedtestlan"))
end
return m

View File

@ -8,14 +8,15 @@ t = o:section(TypedSection, "speedtestport", translate('Server Port Latency Test
t.addremove=false
t.anonymous=true
e = t:option(Value, 'domain', translate('Test server address'))
e = t:option(Value, 'sdomain', translate('Test server address'))
e.default = "www.baidu.com"
e.description = translate('Enter the domain name or IP address of the server that needs to be tested')
e = t:option(Value, 'port', translate('Test server port'))
e = t:option(Value, 'sport', translate('Test server port'))
e.default = "443"
e = t:option(Value, 'tcpspeed', translate('Server Port Delay Value'))
e = t:option(DummyValue, '', '')
e.rawhtml = true
e.template ='netspeedtest/speedtestport'

View File

@ -4,7 +4,7 @@ local o,t,e
o = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."</font>",translate( "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:") ..translate("<a href=\'https://github.com/sirpdboy/netspeedtest.git' target=\'_blank\'>GitHub @sirpdboy/netspeedtest</a>") )
t=o:section(TypedSection,"wanspeedtest",translate("Wan Speedtest"))
t=o:section(TypedSection,"speedtestwan",translate("Broadband speed test"))
t.anonymous=true
e = t:option(DummyValue, '', '')

View File

@ -6,10 +6,9 @@
<script type="text/javascript" src="<%=resource%>/cbi.js?v=1.1"></script>
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
<script type="text/javascript">
var stxhr = new XHR();
function update_status(field, proto)
function update_status(btn,field, proto)
{
var tool = field.name;
var addr = field.value;
@ -21,10 +20,10 @@
output.innerHTML =
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
'<%:Waiting for command to complete...%>';
legend.parentNode.style.display = 'block';
legend.style.display = 'inline';
btn.value='<%:Waiting (executing)...%>';
btn.disabled=true;
stxhr.post('<%=url('admin/network')%>/test_' + tool + protocol + '/' + addr, { token: '<%=token%>' },
function(x)
{
@ -38,15 +37,16 @@
legend.style.display = 'none';
output.innerHTML ='</p> <%:Operation execution complete%></p>';
}
btn.disabled=false;
btn.value='<%:Click to execute%>';
}
);
}
}
//]]></script>
</script>
<form method="post" action="<%=url('admin/network/netspeedtest')%>">
<div class="cbi-section-node" >
<form method="post" class="cbi-map" action="<%=url('admin/network/netspeedtest')%>">
<div class="cbi-value" >
<label class="cbi-value-title" ><%:Select function%></label>
<div class="cbi-value-field">
@ -56,19 +56,32 @@
<option value="1"><%:iperfstop%></option>
</select>
<div class="cbi-value-description">
<span class="cbi-value-helpicon"><img src="/luci-static/resources/cbi/help.gif" /></span>
<%:The speed measurement terminal must be in the same LAN as the router that starts the speed measurement%><br />
<%:Operation steps: start router speed measurement service download test client run speed measurement client input IP address of router speed measurement service%>
</div></div></div>
<div class="cbi-value" ><label class="cbi-value-title" ><%:Perform operation%></label>
<div class="cbi-value-field"><input type="button" value="<%:Perform operation%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.iperf,this.form.iperf_to.selectedIndex)" />
<div class="cbi-value" ><label class="cbi-value-title" ><%:Execute selected functions%></label>
<div class="cbi-value-field"><input type="button" value="<%:Click to execute%>" class="cbi-button cbi-button-apply" onclick="return update_status(this,this.form.iperf,this.form.iperf_to.selectedIndex)" />
</div></div>
<div class="cbi-value" >
<label class="cbi-value-title"><%:Iperf3 speed measurement software download%></label>
<div class="cbi-value-field">
<input type="button" class="cbi-button cbi-input-reload" value="<%:Domestic download password:%>cpd6" onclick="javascript:window.open('https://sipdboy.lanzoui.com/b01c3esih','target');" />
<input type="button" class="cbi-button cbi-input-reload" value="<%:Github download iperf3%>" onclick="javascript:window.open('https://github.com/sirpdboy/netspeedtest/releases','target');" />
<input type="button" class="cbi-button cbi-input-reload" value="<%:Download from foreign official websites%>" onclick="javascript:window.open('https://iperf.fr/iperf-download.php','target');" />
</div></div></div>
</div>
</div>
<div class="cbi-value" >
<label class="cbi-value-title"><%:iperf3 commands reference%></label>
<div class="cbi-value-field">
<%:-c, --client <host> ..............run in client mode, connecting to <host>%><br />
<%:-s, --server .....................run in server mode%><br />
<%:-u, --udp ........................use UDP rather than TCP%><br />
<%:-b, --bandwidth ..<number>[KMG]...target bandwidth in bits/sec (0 for unlimited)%><br />
<%:-t, --time .......<number>........time in seconds to transmit for (default 10 secs)%><br />
<%:-i, --interval ...<number>........seconds between periodic bandwidth reports%><br />
<%:-P, --parallel ...<number>........number of parallel client streams to run%><br />
<%:-R, --reverse ....................run in reverse mode (server sends, client receives)%><br />
</div>
</div>
<fieldset class="cbi-section" style="display:none">
<legend id="test-iperf-legend">
<%:Collecting data...%>

View File

@ -4,12 +4,13 @@
Licensed to the public under the Apache License 2.0.
-%>
<%
local running = luci.sys.exec("pidof homebox")
local running = luci.sys.exec("busybox ps -w | grep homebox | grep -v grep >/dev/null && echo -ne '1' ")
%>
<%+cbi/valueheader%>
<div class="cbi-map">
<% if tonumber(running) ~= nil then %>
<% if running == "1" then %>
<iframe id="homebox" style="width: 100%; min-height: 400px; height: 650px;border: none; border-radius: 3px;"></iframe>
<script type="text/javascript">

View File

@ -3,19 +3,14 @@
https://github.com/sirpdboy/netspeedtest
Licensed to the public under the Apache License 2.0.
-%>
<%+cbi/valueheader%>
<div class="cbi-value" ><label class="cbi-value-title"><%= translate("Test server port delay") %></label>
<div class="cbi-value-field">
<input type="button" class="btn cbi-button cbi-button-apply" value='<%:Perform port test%>' onclick="return speedtestportrun(this, 'speedtestport')" />
<span id="speedtestport-status"></span>
</div>
</div>
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
function speedtestportrun(btn) {
function speedtestportrun(btn,sid) {
var sid='speedtestport'
var opt={
base:"cbid.netspeedtest."+sid,
get:function(opt){
@ -39,18 +34,6 @@ function speedtestportrun(btn,sid) {
alert("<%:Fatal on get option,please help in debug%>:"+opt);
}
return ret;
},
query:function(param,src,tval="1",fval="0"){
var ret="&"+param+"=";
var obj=this.get(src);
if (obj){
if (obj.type=="checkbox"){
return ret+(obj.checked==true ? tval:fval);
}else{
return ret+encodeURIComponent(obj.value);
}
}
return ''
}
}
@ -59,33 +42,40 @@ function speedtestportrun(btn,sid) {
var output=document.getElementById("speedtestport-status");
btn.value='<%:Check...%>';
btn.disabled=true;
var xdomain=opt.get("domain").value;
var xport=opt.get("port").value;
console.log(xdomain);
XHR.get(RUN_URL, {
domain:xdomain,
port:xport
},
function(x,rv) {
btn.value='<%:Waiting (executing)...%>';
btn.disabled=true;
var sdomain=opt.get("sdomain").value;
var sport=opt.get("sport").value;
XHR.get('<%=luci.dispatcher.build_url("admin/network/netspeedtest/test_port")%>',{
sdomain: sdomain,
sport: sport
},
(x) =>{
if(x && x.status == 200) {
output.innerHTML="<font style=\'color:green\'>"+"<%:Perform OK%>"+"</font>";
if (output)
{
console.log(x);
if (rv.ping=="0")
output.outerHTML = "<font style='color:red'><%:Test failed%></font>";
else
output.outerHTML = "<font style='color:green'><%:Test server port delay%> :" + rv.ping + " ms" + "</font>";
}
btn.disabled=false;
btn.value='<%:Perform port test%>';
else{
output.innerHTML="<font style=\'color:green\'>"+"<%:Test failed%>"+"</font>";
}
setTimeout(function(){
window.location = S_URL
},1000);
btn.disabled=false;
btn.value='<%:Click to execute%>';
}
);
return false;
}
return false;
}
//]]></script>
<label class="cbi-value-title"><%= translate("Test server port delay") %></label>
<div class="cbi-value-field">
<input type="button" class="btn cbi-button cbi-button-apply" value='<%:Click to execute%>' onclick="return speedtestportrun(this)" />
<span id="speedtestport-status"></span>
</div>
<%+cbi/valuefooter%>

View File

@ -4,31 +4,32 @@
Licensed to the public under the Apache License 2.0.
-%>
<%+cbi/valueheader%>
<label class="cbi-value-title"><%= translate("Net Speedtest") %></label>
<div class="cbi-value-field">
<input class="cbi-button cbi-button-apply" id="update_service" type="button" onclick="run()" value="<%= translate('Perform Wan Speedtest') %>" />
</div>
<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') %>" />
</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">
const RUN_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","speedtestrun")%>';
function run(s) {
var legend = document.getElementById('wanspeedtest-legend');
var output = document.getElementById('wanspeedtest-output');
output.innerHTML =
function run(btn) {
var legend=document.getElementById('wanspeedtest-legend');
var output=document.getElementById('wanspeedtest-output');
btn.value='<%:Waiting (executing)...%>';
btn.disabled=true;
output.innerHTML =
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
'<%:Network speed test, please wait...%>'
;
legend.parentNode.style.display = 'block';
legend.style.display = 'inline';
XHR.get(RUN_URL, null,
legend.parentNode.style.display = 'block';
legend.style.display = 'inline';
XHR.get(RUN_URL,null,
function(x)
{
if (x.responseText)
@ -43,11 +44,13 @@
output.innerHTML ='</p><%:Operation execution complete%></p>';
}
btn.disabled=false;
btn.value='<%:Click to execute%>';
}
);
return false;
}
);
return false;
}
</script>
<%+cbi/valuefooter%>

View File

@ -20,10 +20,10 @@ msgid "Network speed diagnosis test (including intranet and extranet)<br/>For sp
msgstr "网络速度诊断测试(包括内网、外网、特定端口服务器测速)<br/>使用说明见:"
msgid "Lan Speedtest Iperf3"
msgstr "内网iperf3吞吐测速"
msgstr "本地iperf3吞吐测速"
msgid "Lan homebox Web"
msgstr "Homebox内网测速网页版"
msgid "Lan Speedtest Web"
msgstr "本地测速网页版"
msgid "Running state"
msgstr "运行状态"
@ -61,9 +61,17 @@ msgstr "iperf服务停止"
msgid "Select function"
msgstr "选择功能"
msgid "Perform operation"
msgstr "执行操作"
msgid "Execute selected functions"
msgstr "执行选择的功能"
msgid "Test broadband version"
msgstr "测试宽带版本"
msgid "python3-speedtest-cli"
msgstr "python3网络测试客户端"
msgid "ookla-speedtest-cli"
msgstr "ookla网络测试客户端"
msgid "iperf3 instructions"
msgstr "iperf3使用说明"
@ -77,23 +85,18 @@ msgstr "测速终端机必须与启动测速的路由器在同一局域网内"
msgid "Operation steps: start router speed measurement service download test client run speed measurement client input IP address of router speed measurement service"
msgstr "使用步骤A.启动路由器测速服务 B.下载测试客户端 C.运行测速客户端 D.输入路由器测速服务IP地址。 "
msgid "Domestic download password:"
msgstr "国内下密码:"
msgid "Github download iperf3"
msgstr "Github下载iperf3"
msgid "Iperf3 speed measurement software download"
msgstr "iperf3测速软件下载"
msgid "Wan Speedtest"
msgstr "Speedtest宽带测速"
msgid "Broadband speed test"
msgstr "宽带网速测试"
msgid "Perform Wan Speedtest"
msgstr "执行Speedtest宽带测速"
msgid "speedtest.net Broadband speed test"
msgstr "speedtest.net宽带网速测试"
msgid "Netperf Speedtest"
msgstr "Netperf宽带测速"
msgid "Perform Netperf Speedtest"
msgstr "执行Netperf宽带测速"
msgid "Operation execution complete"
msgstr "操作执行完毕"
@ -119,9 +122,45 @@ msgstr "输入需要测试的服务器域名或者IP地址"
msgid "Test server port delay"
msgstr "测试端口延时"
msgid "Perform port test"
msgstr "执行测试"
msgid "Click to execute"
msgstr "点击执行"
msgid "Test failed"
msgstr "测试失败"
msgid "Waiting (executing)..."
msgstr "等待(执行)中"
msgid "Server Port Delay Value"
msgstr "服务器端口延时值"
msgid "iperf3 commands reference"
msgstr "iperf3命令参考"
msgid "-b, --bandwidth ..<number>[KMG]...target bandwidth in bits/sec (0 for unlimited)"
msgstr "-b, --bandwidth ..<number>[KMG]...目标带宽(以位/秒为单位0表示无限制"
msgid "-t, --time .......<number>........time in seconds to transmit for (default 10 secs)"
msgstr "-t, --time .......<number>........传输时间以秒为单位默认为10秒"
msgid "-i, --interval ...<number>........seconds between periodic bandwidth reports"
msgstr "-i, --interval ...<number>........测试报告之间的秒数"
msgid "-P, --parallel ...<number>........number of parallel client streams to run"
msgstr "-P, --parallel ...<number>........多线程运行的数量"
msgid "-R, --reverse ....................run in reverse mode (server sends, client receives)"
msgstr "-R, --reverse ....................反向模式运行(服务器发送,客户端接收)"
msgid "-c, --client <host> ..............run in client mode, connecting to <host>"
msgstr "-c, --client <host> ..............客户端模式下运行,连接到<host>"
msgid "-s, --server .....................run in server mode"
msgstr "-s, --server .....................服务器模式下运行"
msgid "-u, --udp ........................use UDP rather than TCP"
msgstr "-u, --udp ........................测试传输使用UDP而不是TCP"
msgid "Perform OK"
msgstr "执行完成"

View File

@ -20,10 +20,10 @@ msgid "Network speed diagnosis test (including intranet and extranet)<br/>For sp
msgstr "网络速度诊断测试(包括内网、外网、特定端口服务器测速)<br/>使用说明见:"
msgid "Lan Speedtest Iperf3"
msgstr "内网iperf3吞吐测速"
msgstr "本地iperf3吞吐测速"
msgid "Lan homebox Web"
msgstr "Homebox内网测速网页版"
msgid "Lan Speedtest Web"
msgstr "本地测速网页版"
msgid "Running state"
msgstr "运行状态"
@ -61,9 +61,17 @@ msgstr "iperf服务停止"
msgid "Select function"
msgstr "选择功能"
msgid "Perform operation"
msgstr "执行操作"
msgid "Execute selected functions"
msgstr "执行选择的功能"
msgid "Test broadband version"
msgstr "测试宽带版本"
msgid "python3-speedtest-cli"
msgstr "python3网络测试客户端"
msgid "ookla-speedtest-cli"
msgstr "ookla网络测试客户端"
msgid "iperf3 instructions"
msgstr "iperf3使用说明"
@ -77,23 +85,18 @@ msgstr "测速终端机必须与启动测速的路由器在同一局域网内"
msgid "Operation steps: start router speed measurement service download test client run speed measurement client input IP address of router speed measurement service"
msgstr "使用步骤A.启动路由器测速服务 B.下载测试客户端 C.运行测速客户端 D.输入路由器测速服务IP地址。 "
msgid "Domestic download password:"
msgstr "国内下密码:"
msgid "Github download iperf3"
msgstr "Github下载iperf3"
msgid "Iperf3 speed measurement software download"
msgstr "iperf3测速软件下载"
msgid "Wan Speedtest"
msgstr "Speedtest宽带测速"
msgid "Broadband speed test"
msgstr "宽带网速测试"
msgid "Perform Wan Speedtest"
msgstr "执行Speedtest宽带测速"
msgid "speedtest.net Broadband speed test"
msgstr "speedtest.net宽带网速测试"
msgid "Netperf Speedtest"
msgstr "Netperf宽带测速"
msgid "Perform Netperf Speedtest"
msgstr "执行Netperf宽带测速"
msgid "Operation execution complete"
msgstr "操作执行完毕"
@ -119,9 +122,45 @@ msgstr "输入需要测试的服务器域名或者IP地址"
msgid "Test server port delay"
msgstr "测试端口延时"
msgid "Perform port test"
msgstr "执行测试"
msgid "Click to execute"
msgstr "点击执行"
msgid "Test failed"
msgstr "测试失败"
msgid "Waiting (executing)..."
msgstr "等待(执行)中"
msgid "Server Port Delay Value"
msgstr "服务器端口延时值"
msgid "iperf3 commands reference"
msgstr "iperf3命令参考"
msgid "-b, --bandwidth ..<number>[KMG]...target bandwidth in bits/sec (0 for unlimited)"
msgstr "-b, --bandwidth ..<number>[KMG]...目标带宽(以位/秒为单位0表示无限制"
msgid "-t, --time .......<number>........time in seconds to transmit for (default 10 secs)"
msgstr "-t, --time .......<number>........传输时间以秒为单位默认为10秒"
msgid "-i, --interval ...<number>........seconds between periodic bandwidth reports"
msgstr "-i, --interval ...<number>........测试报告之间的秒数"
msgid "-P, --parallel ...<number>........number of parallel client streams to run"
msgstr "-P, --parallel ...<number>........多线程运行的数量"
msgid "-R, --reverse ....................run in reverse mode (server sends, client receives)"
msgstr "-R, --reverse ....................反向模式运行(服务器发送,客户端接收)"
msgid "-c, --client <host> ..............run in client mode, connecting to <host>"
msgstr "-c, --client <host> ..............客户端模式下运行,连接到<host>"
msgid "-s, --server .....................run in server mode"
msgstr "-s, --server .....................服务器模式下运行"
msgid "-u, --udp ........................use UDP rather than TCP"
msgstr "-u, --udp ........................测试传输使用UDP而不是TCP"
msgid "Perform OK"
msgstr "执行完成"

View File

@ -1,14 +1,15 @@
config netspeedtest 'netspeedtest'
option enabled '0'
option port '3300'
config homebox 'homebox'
option enabled '0'
option port '3300'
option logger '1'
config speedtestiperf3 'speedtestiperf3'
option enabled '0'
config speedtestiperf3 'speedtestiperf3'
config wanspeedtest 'wanspeedtest'
option surl ' '
config speedtestwan 'speedtestwan'
config speedtestport 'speedtestport'
option domain ' '
option port ' '
option sport '443'
option sdomain 'www.taobao.com'

View File

@ -9,19 +9,19 @@
START=99
USE_PROCD=1
PROG=/usr/bin/homebox
EXTRA_COMMANDS="nstest"
TMP_T=/var/netspeedtest.tmp
LOCK=/var/lock/netspeedtest.lock
TMP_T=/var/netspeedtest_nstest.tmp
BINSPEEDTEST='/usr/bin/speedtest'
LOCK=/var/lock/netspeedtest_nstest.lock
LOG=/var/log/netspeedtest.log
MAX_LOG=500
limit_log() {
local logf=$1
local max=$2
[ ! -f "$logf" ] && return
local sc=100
[ -n "$2" ] && sc=$2
sc=${max:-$MAX_LOG}
local count=$(grep -c "" $logf)
if [ $count -gt $sc ];then
let count=count-$sc
@ -29,29 +29,38 @@ limit_log() {
fi
}
init_env() {
[ ! -f "$LOG" ] && echo "" > $LOG
echo 1 > $TMP_T
init_log() {
local logf=$1
[ ! -f "$logf" ] && echo "" > $logf
}
echone() {
echo -ne $* >> $LOG
}
nstest() {
[ -f $LOCK ] && exit
limit_log $LOG 200
init_env
limit_log $LOG 500
init_log $LOG
touch $LOCK
echo -ne "\n speedtest测速" >> $LOG
echo -ne "\n ——————————speedtest测速"—————————— >> $LOG
/usr/bin/speedtest --share > $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 测试时间: " >> $LOG
echo $(date +%Y-%m-%d" "%H:%M:%S) >> $LOG
echo -ne " ————————————————————————————\n" >> $LOG
echo -ne $(cat $TMP_T | grep 'results:' | cut -c16- ) || echo -ne $(cat $TMP_T )
echo -ne "\n 测试结果图片链接:$(cat $TMP_T | grep 'results:' | cut -c16- ) \n" >> $LOG
echo -ne "\n 测试时间:`date +%Y-%m-%d" "%H:%M:%S` \n" >> $LOG
echo -ne " ——————————————————————————————\n" >> $LOG
echo -ne $(cat $TMP_T | grep 'results:' | cut -c16- )
rm -f $LOCK
}
tcptest(){
NDATA=`date +%Y-%m-%d' '%H:%M:%S`
echo -ne "\n $NDATA 服务器:$1 ---- 端口:$2 ---- TCP延时$3 Ms \n" >> $LOG
}
get_config() {
config_get_bool enabled $1 enabled 1
config_get_bool logger $1 logger 1
@ -65,7 +74,7 @@ homebox_prepare() {
start_service() {
config_load netspeedtest
config_foreach get_config homebox
config_foreach get_config netspeedtest
[ "x$enabled" != "x1" ] && {
homebox_prepare
exit