update 2022-10-18 20:28:10

This commit is contained in:
github-actions[bot] 2022-10-18 20:28:10 +08:00
parent d1b1b9f06a
commit 1f4919a892
20 changed files with 462 additions and 275 deletions

View File

@ -1,44 +1,21 @@
#
# Copyright (C) 2020-2021 sirpdboy <herboy2008@gmail.com>
# The LuCI Network diagnosis and speed test <https://github.com/sirpdboy/NetSpeedTest>
#
# This is free software, licensed under the GNU General Public License v3.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-netspeedtest
PKG_VERSION:=1.7
PKG_RELEASE:=20220322
PKG_LICENSE:=GPLv2
PKG_MAINTAINER:=sirpdboy
include $(INCLUDE_DIR)/package.mk
LUCI_TITLE:=LuCI Support for netspeedtest
LUCI_DEPENDS:=+python3 +iperf3 +speedtest-web
LUCI_PKGARCH:=all
PKG_VERSION:=2.0.3
PKG_RELEASE:=20221018
PKG_MAINTAINER:=<https://github.com/sirpdboy/netspeedtest>
define Package/$(PKG_NAME)
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=LuCI Support for netspeedtest
DEPENDS:=+python3 +iperf3
PKGARCH:=all
endef
include $(TOPDIR)/feeds/luci/luci.mk
define Build/Compile
endef
define Package/$(PKG_NAME)/conffiles
/etc/config/netspeedtest
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
cp -pR ./luasrc/* $(1)/usr/lib/lua/luci
$(INSTALL_DIR) $(1)/
cp -pR ./root/* $(1)/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
po2lmo ./po/zh-cn/netspeedtest.po $(1)/usr/lib/lua/luci/i18n/netspeedtest.zh-cn.lmo
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
# call BuildPackage - OpenWrt buildroot signature

View File

@ -1,121 +1,151 @@
[![若部分图片无法正常显示,请挂上机场浏览或点这里到末尾看修复教程](https://visitor-badge.glitch.me/badge?page_id=sirpdboy-visitor-badge)](#解决-github-网页上图片显示失败的问题) [![](https://img.shields.io/badge/TG群-点击加入-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ)
<a href="#readme">
<img src="https://img.vim-cn.com/a1/8713845a4aa922ac96619b0d2fb3d6919d37fc.png" alt="图飞了😂" title="NetSpeedTest" align="right" height="180" />
</a>
## luci-app-netspeedtest
欢迎来到sirpdboy的源码仓库
=
Welcome to sirpdboy's git source of packages
-
[luci-app-NetSpeedTest — 网络速度测试1.7完整版](https://github.com/sirpdboy/NetSpeedTest)
======================
### 访问数:[![](https://visitor-badge.glitch.me/badge?page_id=sirpdboy-visitor-badge)] [![](https://img.shields.io/badge/TG群-点击加入-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ)
[![](https://img.shields.io/badge/-目录:-696969.svg)](#readme) [![](https://img.shields.io/badge/-写在前面-F5F5F5.svg)](#写在前面-) [![](https://img.shields.io/badge/-编译说明-F5F5F5.svg)](#编译说明-) [![](https://img.shields.io/badge/-说明-F5F5F5.svg)](#说明-) [![](https://img.shields.io/badge/-捐助-F5F5F5.svg)](#捐助-)
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/说明1.jpg)
luci-app-netspeedtest 网络速度诊断测试包括内网网页版测速、内网iperf3吞吐测速、外网speedtest.net网速测试、特定服务器的端口延迟测速
[luci-app-netspeedtest 网络速度诊断测试](https://github.com/sirpdboy/netspeedtest)
**认真阅读完毕** 本页面,本页面包含注意事项和如何使用。
a new NetSpeedTest luci app bese luci-app-NetSpeedTest
-
## 写在前面
## 写在前面:[![](https://img.shields.io/badge/-写在前面-F5F5F5.svg)](#写在前面-)
- 一直在找OPENWRT上测试速度的插件苦寻不到于是有了它! 此插件可进行内外和外网网络速度测试。
- TG群友说插件2年没更新了花了几天时间结合时下需要将网络测试功能升级到2.0版本。
一直在找OPENWRT上测试速度的插件苦寻不到于是有了它!
此插件可进行内外和外网网络速度测试。
<!-- TOC -->
1.内网测速基于iperf3 插件服务端路由器如果没有安装请先安装此ipk插件。
## [菜单向导](#luci-app-netspeedtest)
- [功能说明](#功能说明)
- [注意事项](#iperf3吞吐测试注意事项)
- [版本说明](#版本说明)
- [使用方法](#使用方法)
- [源码说明](#源码说明)
- [界面](#界面)
- [其它](#其它)
- [感谢](#感谢)
- [捐助](#捐助)
<!-- /TOC -->
2.测速的终端使用机器必须和测速服务器在同一个局域网络中!
## 功能说明
- 内网网页版测速插件 基于speedtest-web网页版启用后再点start进行测速。网页版启动后程序会驻留内存不测速建议不启用服务。
- 内网iperf3吞吐测试 服务端路由器如果没有安装请先安装此iperf3插件。
- 外网测速使用speedtest.net测速内核基于speedtest-cli,需要有python3才能执行。
- 特定服务器的端口延迟测速,是测试指定服务器的端口的延迟情况。
3.客户端使用步骤:
启动测速服务器端-->下载测试客户端-->运行测速客户端-->输入服务端IP地址-->查看结果。
5.客户端运行国内端下载中有“iperf3测速客户端”运行它输入服务器IP即可。
## iperf3吞吐测试注意事项
- 测速的终端使用机器必须和测速服务器在同一个局域网络中!
- 客户端使用步骤:启动测速服务器端-->下载测试客户端-->运行测速客户端-->输入服务端IP地址-->查看结果。
- 客户端运行国内端下载中有“iperf3测速客户端”运行它输入服务器IP即可。
国外原版,需要手动进入 CMD命令模式再输入命令iperf3.exe -c 服务器IP
- 网络测速iperf3客户端下载地址https://sipdboy.lanzoui.com/b01c3esih 密码:cpd6
- 需要依赖: python3 iperf3 speedtest-web
6.网络测速iperf3客户端下载地址https://sipdboy.lanzoui.com/b01c3esih 密码:cpd6
## 版本说明
8.外网测速使用speedtest.net测速内核需要依赖speedtest,另外感谢superspeed和user1121114685因为借用了你们的灵感
### 2022.10.18 网速测试V2.0.2
- 代码基本重写和优化。
- Iperf3可实时体现服务状态。
- 增加内网测试网页版。
- 外网测速,加入更详细测试报告。
### 2021.3.2 网速测试V1.6
- 升级宽带测试带2.13内核。
- 解决1.806以上版本不能编译问题。
## 使用方法
9.外网测速最后测试阶段感谢佐大:佐须之男 测试查问题!
将NetSpeedTest 主题添加至 LEDE/OpenWRT 源码的方法。
10.新插件难免有bug 请不要大惊小怪。欢迎提交bug。
## 编译说明 [![](https://img.shields.io/badge/-编译说明-F5F5F5.svg)](#编译说明-)
将NetSpeedTest 主题添加至 LEDE/OpenWRT 源码的方法。
## 下载源码方法一:
编辑源码文件夹根目录feeds.conf.default并加入如下内容:
### 下载源码方法一:
- 编辑源码文件夹根目录feeds.conf.default并加入如下内容:
```Brach
# feeds获取源码
src-git NetSpeedTest https://github.com/sirpdboy/NetSpeedTest
src-git netspeedtest https://github.com/sirpdboy/netspeedtest
```
```Brach
# 更新feeds并安装主题
scripts/feeds update NetSpeedTest
scripts/feeds install luci-app-NetSpeedTest
scripts/feeds update netspeedtest
scripts/feeds install netspeedtest
```
## 下载源码方法二:
### 下载源码方法二:
```Brach
# 下载源码
git clone https://github.com/sirpdboy/NetSpeedTest package/NetSpeedTest
git clone https://github.com/sirpdboy/netspeedtest.git package/netspeedtest
make menuconfig
```
## 配置菜单
### 配置菜单
```Brach
make menuconfig
# 找到 LuCI -> Applications, 选择 luci-app-NetSpeedTest, 保存后退出。
# 找到 LuCI -> Applications, 选择 luci-app-netspeedtest, 保存后退出。
```
## 编译
### 编译
```Brach
# 编译固件
make package/NetSpeedTest/luci-app-NetSpeedTest/{clean,compile} V=s
```
## 说明 [![](https://img.shields.io/badge/-说明-F5F5F5.svg)](#说明-)
源码来源https://github.com/sirpdboy/NetSpeedTest/luci-app-NetSpeedTest
make package/netspeedtest/luci-app-netspeedtest/compile V=s
```
你可以随意使用其中的源码,但请注明出处。
============================
## 源码说明
# My other project
网络速度测试 https://github.com/sirpdboy/NetSpeedTest
- 源码来源和依赖:
- luci-app-netspeedtesthttps://github.com/sirpdboy/netspeedtest
- speedtest-webhttps://github.com/ZeaKyX/speedtest-web
- speedtest-clhttps://github.com/sivel/speedtest-cli
定时关机重启 : https://github.com/sirpdboy/luci-app-autopoweroff
- 你可以随意使用其中的源码,但请注明出处。
关机功能插件 : https://github.com/sirpdboy/luci-app-poweroffdevice
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/说明2.jpg)
opentopd主题 : https://github.com/sirpdboy/luci-theme-opentopd
## 界面
opentoks 主题: https://github.com/sirpdboy/luci-theme-opentoks [仿KOOLSAHRE主题]
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/netspeedtest1.jpg)
btmob 主题: https://github.com/sirpdboy/luci-theme-btmob
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/netspeedtest2.jpg)
系统高级设置 : https://github.com/sirpdboy/luci-app-advanced
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/netspeedtest3.jpg)
## 捐助 [![](https://img.shields.io/badge/-捐助-F5F5F5.svg)](#捐助-)
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/netspeedtest4.jpg)
**如果你觉得此项目对你有帮助,请捐助我们,以使项目能持续发展,更加完善。··请作者喝杯咖啡~~~**
**你们的支持就是我的动力!**
## 其它
- 我的其它项目:
- 网络速度测试 https://github.com/sirpdboy/NetSpeedTest
- 定时设置插件 : https://github.com/sirpdboy/luci-app-autotimeset
- 关机功能插件 : https://github.com/sirpdboy/luci-app-poweroffdevice
- btmob 主题: https://github.com/sirpdboy/luci-theme-btmob
- 系统高级设置 : https://github.com/sirpdboy/luci-app-advanced
- ddns-go动态域名: https://github.com/sirpdboy/luci-app-ddns-go
- Lucky(大吉): https://github.com/sirpdboy/luci-app-lucky
### 捐助方式
## 感谢
感谢superspeed、user1121114685、ZeaKyX、佐须之男、lean等。因为有你们珠玉在前
## 捐助
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/说明3.jpg)
| <img src="https://img.shields.io/badge/-支付宝-F5F5F5.svg" href="#赞助支持本项目-" height="25" alt="图飞了😂"/> | <img src="https://img.shields.io/badge/-微信-F5F5F5.svg" height="25" alt="图飞了😂" href="#赞助支持本项目-"/> |
| :-----------------: | :-------------: |
|<img src="https://img.vim-cn.com/fd/8e2793362ac3510094961b04407beec569b2b4.png" width="150" height="150" alt="图飞了😂" href="#赞助支持本项目-"/>|<img src="https://img.vim-cn.com/c7/675730a88accebf37a97d9e84e33529322b6e9.png" width="150" height="150" alt="图飞了😂" href="#赞助支持本项目-"/>|
|![xm1](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/支付宝.png) | ![xm1](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/微信.png) |
<a href="#readme">
<img src="https://img.shields.io/badge/-返回顶部-orange.svg" alt="图飞了😂" title="返回顶部" align="right"/>
</a>
###### [解决 Github 网页上图片显示失败的问题](https://blog.csdn.net/qq_38232598/article/details/91346392)
[![](https://img.shields.io/badge/TG群-点击加入-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ)

View File

@ -1,31 +1,42 @@
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
module("luci.controller.netspeedtest", package.seeall)
local fs=require"nixio.fs"
function index()
entry({"admin","network","netspeedtest"},alias("admin", "network", "netspeedtest", "speedtestweb"),_("Net Speedtest"), 90).dependent = true
entry({"admin","network","netspeedtest","speedtestweb"},cbi("netspeedtest/speedtestweb"),_("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"},cbi("netspeedtest/netspeedtest", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Netspeedtest"),90).dependent=true
entry({"admin", "network", "netspeedtest", "checknet"}, call("check_net"))
entry({"admin", "network", "speedtestweb_status"}, call("speedtestweb_status"))
entry({"admin", "network", "iperf3_status"}, call("iperf3_status"))
entry({"admin", "network", "netspeedtest", "status"}, call("act_status")).leaf = true
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", "run"}, call("run"))
--entry({"admin","network","netspeedtest", "wanrun"}, post("wanrun"), nil).leaf = true
entry({"admin","network","netspeedtest", "wanrun"}, call("wanrun"))
entry({"admin", "network", "netspeedtest", "realtime_log"}, call("get_log"))
entry({"admin", "network", "netspeedtest", "dellog"},call("dellog"))
end
function act_status()
function speedtestweb_status()
local e={}
e.status=luci.sys.call("pgrep iperf3 >/dev/null")==0
e.run=luci.sys.call("pgrep speedtest-web >/dev/null")==0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function iperf3_status()
local e={}
e.run=luci.sys.call("pgrep iperf3 >/dev/null")==0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function testlan(cmd, addr)
function testout(cmd, addr)
luci.http.prepare_content("text/plain")
local util = io.popen(cmd)
if util then
@ -40,29 +51,20 @@ function testlan(cmd, addr)
end
function testwan(cmd)
local util = io.popen(cmd)
util:close()
end
function test_iperf0(addr)
local netease
netease= luci.sys.call("ps |grep unblockneteasemusic |grep app.js |grep -v grep >/dev/null") == 0
if netease then
luci.sys.call("/etc/init.d/unblockneteasemusic stop ")
luci.sys.call("/etc/init.d/unblockmusic stop ")
end
testlan("iperf3 -s ", addr)
luci.sys.call("pgrep -f unblockneteasemusic | xargs kill -9 >/dev/null 2>&1 ")
luci.sys.call("/etc/init.d/unblockneteasemusic stop ")
luci.sys.call("/etc/init.d/unblockmusic stop ")
testout("iperf3 -s ", addr)
end
function test_iperf1(addr)
luci.sys.call("killall iperf3")
luci.sys.call("/etc/init.d/unblockneteasemusic restart ")
luci.sys.call("/etc/init.d/unblockmusic restart ")
luci.sys.call("pgrep -f iperf3 | xargs kill -9 >/dev/null 2>&1 ")
luci.sys.call("/etc/init.d/unblockneteasemusic restart")
luci.sys.call("/etc/init.d/unblockmusic restart")
end
function get_log()
local fs = require "nixio.fs"
local e = {}
e.running = luci.sys.call("busybox ps -w | grep netspeedtest | grep -v grep >/dev/null") == 0
e.log = fs.readfile("/var/log/netspeedtest.log") or ""
@ -70,7 +72,13 @@ function get_log()
luci.http.write_json(e)
end
function run()
testwan("/etc/init.d/netspeedtest nstest ")
luci.http.redirect(luci.dispatcher.build_url("admin","network","netspeedtest"))
function dellog()
fs.writefile("/var/log/netspeedtest.log","")
http.prepare_content("application/json")
http.write('')
end
function wanrun()
testout("/etc/init.d/netspeedtest nstest ")
end

View File

@ -1,32 +0,0 @@
-- Copyright 2018 sirpdboy (herboy2008@gmail.com)
require("luci.util")
local o,t,e
if luci.sys.call("pidof iperf3 >/dev/null") == 0 then
status = translate("<strong><font color=\"green\">iperf3 服务端运行中</font></strong>")
else
status = translate("<strong><font color=\"red\">iperf3 服务端未启动</font></strong>")
end
o = Map("netspeedtest", "<font color='green'>" .. translate("Netspeedtest") .."</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 @netspeedtest/luci-app-netspeedtest</a>") )
t = o:section(TypedSection, "netspeedtest", translate('iperf3 lanspeedtest'))
t.anonymous = true
t.description = translate(string.format("%s<br />", status))
e = t:option(DummyValue, '', '')
e.rawhtml = true
e.template ='netspeedtest/netspeedtest'
t=o:section(TypedSection,"netspeedtest",translate("wanspeedtest"))
t.anonymous=true
e = t:option(DummyValue, '', '')
e.rawhtml = true
e.template ='netspeedtest/speedtest'
e =t:option(DummyValue, '', '')
e.rawhtml = true
e.template = 'netspeedtest/log'
return o

View File

@ -0,0 +1,18 @@
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
require("luci.util")
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.addremove=false
s.anonymous=true
e = s:option(DummyValue, '', '')
e.rawhtml = true
e.template ='netspeedtest/speedtestiperf3'
return o

View File

@ -0,0 +1,18 @@
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
require("luci.util")
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.anonymous=true
e = t:option(DummyValue, '', '')
e.rawhtml = true
e.template ='netspeedtest/speedtestwan'
e =t:option(DummyValue, '', '')
e.rawhtml = true
e.template = 'netspeedtest/log'
return o

View File

@ -0,0 +1,24 @@
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
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>") )
-- m:section(SimpleSection).template = "netspeedtest/speedtestweb_status"
s = m:section(TypedSection, "speedtestweb", translate('Lan Speedtest Web'))
s.addremove=false
s.anonymous=true
o=s:option(Flag,"enabled",translate("Enable"))
o.default=0
o = s:option(DummyValue, '', '')
o.rawhtml = true
o.template ='netspeedtest/speedtestweb'
local o=luci.http.formvalue("cbi.apply")
if o then
io.popen("/etc/init.d/netspeedtest start")
end
return m

View File

@ -1,11 +1,11 @@
<%+cbi/valueheader%>
<textarea id="logview" class="cbi-input-textarea" style="width: 100%" rows="10" readonly="readonly"></textarea>
<textarea id="logview.list" class="cbi-input-textarea" style="width: 100%" rows="20" readonly="readonly"></textarea>
<script type="text/javascript">
const LOG_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","realtime_log")%>';
XHR.poll(1, LOG_URL, null, (x, d) => {
let logview = document.getElementById("logview");
let logview = document.getElementById("logview.list");
if (!d.running) {
XHR.halt();
}

View File

@ -1,31 +0,0 @@
<%+cbi/valueheader%>
<label class="cbi-value-title"> </label>
<div class="cbi-value-field">
<input class="cbi-button cbi-button-apply" id="update_service" type="button" size="0" onclick="run()" value="<%= translate('Perform wanspeedtest') %>" />
</div>
<script type="text/javascript">
const RUN_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest","run")%>';
const S_URL = '<%=luci.dispatcher.build_url("admin", "network", "netspeedtest")%>';
function run() {
var legend = document.getElementById('test-rc-legend');
var output = document.getElementById('test-rc-output');
output.innerHTML =
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
'<%:Network speed test, please wait for 1 minutes%>'
;
legend.parentNode.style.display = 'block';
legend.style.display = 'inline';
XHR.get(RUN_URL, null, () => {
setTimeout(() => { window.location = S_URL }, 3000);
});
return false;
}
</script>
<%+cbi/valuefooter%>

View File

@ -1,21 +1,22 @@
<%
local fs = require "nixio.fs"
%>
<%#
Copyright 2020-2022 sirpdboy Wich <sirpdboy@qq.com>
https://github.com/sirpdboy/netspeedtest
Licensed to the public under the Apache License 2.0.
-%>
<script type="text/javascript" src="<%=resource%>/cbi.js?v=1.1"></script>
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
var stxhr = new XHR();
var stxhr = new XHR();
function update_status(field, proto)
{
var tool = field.name;
var addr = field.value;
var protocol = proto ;
var legend = document.getElementById('test-rc-legend');
var output = document.getElementById('test-rc-output');
var legend = document.getElementById('test-iperf-legend');
var output = document.getElementById('test-iperf-output');
if (legend && output)
{
output.innerHTML =
@ -33,13 +34,11 @@ local fs = require "nixio.fs"
{
legend.style.display = 'none';
output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
}
else
{
legend.style.display = 'none';
output.innerHTML ='</p><%:Operation execution complete%></p>';
output.innerHTML ='</p> <%:Operation execution complete%></p>';
}
@ -50,9 +49,7 @@ local fs = require "nixio.fs"
//]]></script>
<form method="post" action="<%=url('admin/network/netspeedtest')%>">
<div style="width:100%; float:left">
<table>
<tr><td class="cbi-value-title" ><input style="margin: 5px 0" type="hidden" value="" name="iperf" />
<select name="iperf_to" style="width:auto">
<option value="0" selected="selected"><%:iperfstart%></option>
@ -70,15 +67,13 @@ local fs = require "nixio.fs"
<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="<%:Download from foreign official websites%>" onclick="javascript:window.open('https://iperf.fr/iperf-download.php','target');" /></td>
</tr>
</table>
<fieldset class="cbi-section" style="display:none">
<legend id="test-rc-legend">
<legend id="test-iperf-legend">
<%:Collecting data...%>
</legend>
<span id="test-rc-output"></span>
<span id="test-iperf-output"></span>
</fieldset>
</div>
</form>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,27 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[network]], [[iperf3_status]])%>', null,
function(x, data) {
var tb = document.getElementById('iperf3_status');
if (data && tb)
{
if (data.run)
{
tb.innerHTML = '<br/><em style=\"color:green\"><%:The Iperf3 service is running.%></em>';
}
else
{
tb.innerHTML = '<br/><em style=\"color:red\"><%:The Iperf3 service is not running.%></em>';
}
}
}
);
//]]></script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<legend><%:Iperf3 Status%></legend>
<p id="iperf3_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -0,0 +1,51 @@
<%#
Copyright 2020-2022 sirpdboy Wich <sirpdboy@qq.com>
https://github.com/sirpdboy/netspeedtest
Licensed to the public under the Apache License 2.0.
-%>
<%+cbi/valueheader%>
<input class="cbi-button cbi-button-apply" id="update_service" type="button" onclick="run()" value="<%= translate('Perform WanSpeedtest') %>" />
<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","wanrun")%>';
function run(s) {
var legend = document.getElementById('wanspeedtest-legend');
var output = document.getElementById('wanspeedtest-output');
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,
function(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>';
}
}
);
return false;
}
</script>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,18 @@
<%#
Copyright 2020-2022 sirpdboy Wich <sirpdboy@qq.com>
https://github.com/sirpdboy/netspeedtest
Licensed to the public under the Apache License 2.0.
-%>
<%+cbi/valueheader%>
<div class="cbi-map">
<iframe id="speedtest-web" style="width: 90%; min-height: 500px; border: none; border-radius: 3px;"></iframe>
</div>
<script type="text/javascript">
document.getElementById("speedtest-web").src = window.location.protocol + "//" + window.location.hostname + ":8989";
document.getElementById("speedtest-web").height = document.documentElement.clientHeight;
window.onresize = function(){
document.getElementById("speedtest-web").height = document.documentElement.clientHeight;
}
</script>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,28 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[network]], [[speedtestweb_status]])%>', null,
function(x, data) {
var tb = document.getElementById('speedtestweb_status');
if (data && tb)
{
if (data.run)
{
tb.innerHTML = '<br/><em style=\"color:green\"><%:The Speedtestweb service is running.%></em>';
}
else
{
tb.innerHTML = '<br/><em style=\"color:red\"><%:The Speedtestweb service is not running.%></em>';
}
}
}
);
//]]></script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<legend><%:Speedtestweb Status%></legend>
<p id="speedtestweb_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2020-2021 sirpdboy herboy2008@gmail.com
# Copyright (C) 2020-2022 sirpdboy herboy2008@gmail.com https://github.com/sirpdboy/netspeedtest
# This is free software, licensed under the GNU General Public License v3.
#
msgid ""
@ -13,18 +13,41 @@ msgstr ""
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Pootle 2.0.6\n"
msgid "Netspeedtest"
msgid "Net Speedtest"
msgstr "网速测试"
msgid "Network speed diagnosis test (including intranet and extranet)"
msgstr "网络速度诊断测试(包括内网和外网)"
msgid "iperf3 lanspeedtest"
msgstr "iperf3 内网测速"
msgid "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:"
msgstr "网络速度诊断测试(包括内网和外网)<br/>具体使用参见:"
msgstr "网络速度诊断测试(包括内网、外网、特定端口服务器测速)<br/>使用说明见:"
msgid "Lan Speedtest Iperf3"
msgstr "内网iperf3吞吐测速"
msgid "Lan Speedtest Web"
msgstr "内网测速网页版"
msgid "Running state"
msgstr "运行状态"
msgid "The Iperf3 service is running."
msgstr "iperf3服务已启动"
msgid "The Iperf3 service is not running."
msgstr "iperf3服务未启动"
msgid "Iperf3 Status"
msgstr "iperf3服务状态"
msgid "The Speedtestweb service is running."
msgstr "网页测速服务已启动"
msgid "The Speedtestweb service is not running."
msgstr "网页测速服务未启动"
msgid "Speedtestweb Status"
msgstr "网页测速服务状态"
msgid "</br>For specific usage, see:"
msgstr "</br>具体使用方法参见:"
msgid "iperfstart"
msgstr "iperf服务启动"
@ -36,7 +59,7 @@ msgid "Perform operation"
msgstr "执行操作"
msgid "iperf3 instructions"
msgstr "iperf3 使用说明"
msgstr "iperf3使用说明"
msgid "Test speed service started"
msgstr "测试速度服务已经启动"
@ -53,18 +76,21 @@ msgstr "国内下密码:"
msgid "Iperf3 speed measurement software download"
msgstr "iperf3测速软件下载"
msgid "wanspeedtest"
msgid "Wan Speedtest"
msgstr "宽带速率测试"
msgid "Perform wanspeedtest"
msgid "Perform WanSpeedtest"
msgstr "执行宽带测速"
msgid "Operation execution complete"
msgstr "操作执行完毕"
msgid "Network speed test, please wait for 1 minutes"
msgstr "网速测试中,请稍等1分钟"
msgid "Network speed test, please wait..."
msgstr "网速测试中,请稍侯..."
msgid "Download from foreign official websites"
msgstr "国外官网"
msgid "Server Port Speedtest"
msgstr "端口延迟测试"

View File

@ -1,8 +1,10 @@
config speedtestweb 'speedtestweb'
option enabled '1'
option port '8989'
option logger '1'
config netspeedtest
option enabled '0'
config wanspeedtest
option enabled '0'
config speedtestiperf3 'speedtestiperf3'
option enabled '0'
config wanspeedtest 'wanspeedtest'
option surl ' '

View File

@ -1,15 +1,23 @@
#!/bin/sh /etc/rc.common
# Copyright 2020 -2021 sirpdboy (herboy2008@gmail.com)
START=95
STOP=10
#
# Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
#
# This file is part of ddns-go .
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
. /lib/functions.sh
START=99
USE_PROCD=1
PROG=/usr/bin/speedtest-web
EXTRA_COMMANDS="nstest"
EXTRA_HELP=" netspeedtest"
NS_FILE=/usr/share/netspeedtest/netspeedtest.txt
TMP_T=/tmp/netspeedtest
LOG="/var/log/netspeedtest.log"
TMP_T=/var/netspeedtest.tmp
LOCK=/var/lock/netspeedtest.lock
LOG=/var/log/netspeedtest.log
limit_log() {
local logf=$1
@ -24,32 +32,58 @@ limit_log() {
}
init_env() {
[ ! -f "$LOG" ] && echo " " > $LOG
echo 1 > $NS_FILE
[ ! -f "$LOG" ] && echo "" > $LOG
echo 1 > $TMP_T
}
nstest() {
init_env
[ -f "$TMP_T" ] && return
echo 1 > $TMP_T
echo -ne "\n ————————————————————————————" | tee -a $LOG
/etc/init.d/speedtest | tee -a $NS_FILE
ns_server=`cat $NS_FILE | grep 'Hosted by' | cut -c10-`
ns_down=`cat $NS_FILE | grep 'Download:' |awk -F: '{printf $2}' `
ns_up=`cat $NS_FILE | grep 'Upload:' |awk -F: '{printf $2}' `
echo -ne "\n 测服信息:${ns_server} " | tee -a $LOG
echo -ne "\n 下行速率:${ns_down} ---- 上行速率:${ns_up} " | tee -a $LOG
echo -ne "\n 测试时间: " | tee -a $LOG
echo $(date +%Y-%m-%d" "%H:%M:%S) | tee -a $LOG
rm -rf $TMP_T
}
reload(){
start
}
start() {
[ -f $LOCK ] && exit
limit_log $LOG 200
nstest
init_env
touch $LOCK
/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- )
rm -f $LOCK
}
get_config() {
config_get_bool enabled $1 enabled 1
config_get_bool logger $1 logger 1
config_get port $1 port 8989
}
speedtestweb_prepare() {
pgrep -f speedtest-web | xargs kill -9 >/dev/null 2>&1
logger -t netspeedtest -p warn "Netspeedtest speedtest-web is stop."
}
stop_service() {
speedtestweb_prepare
echo "Netspeedtest speedtest-web is stop."
}
start_service() {
speedtestweb_prepare
config_load netspeedtest
config_foreach get_config speedtestweb
[ x$enabled == x1 ] || return 1
logger -t netspeedtest -p warn "Netspeedtest speedtest-web is start."
echo "Netspeedtest speedtest-web is start."
procd_open_instance
procd_set_param command $PROG --listen_port "${port}"
[ "x$logger" == x1 ] && procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
}
service_triggers() {
procd_add_reload_trigger "speedtest-web"
}

View File

@ -1,5 +0,0 @@
#!/bin/sh
chmod 755 /etc/init.d/netspeedtest /etc/init.d/speedtest >/dev/null 2>&1
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
exit 0