From 18d4ac663de2f44f5790459482d4fd00cfba99b9 Mon Sep 17 00:00:00 2001 From: Ycarus Date: Fri, 20 Jul 2018 15:04:35 +0200 Subject: [PATCH] Update iperf interface --- luci-app-iperf/luasrc/controller/iperf.lua | 20 ++++++--- luci-app-iperf/luasrc/view/iperf/test.htm | 50 +++++++++++++++++----- 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/luci-app-iperf/luasrc/controller/iperf.lua b/luci-app-iperf/luasrc/controller/iperf.lua index f239833a2..8adbe8c7b 100644 --- a/luci-app-iperf/luasrc/controller/iperf.lua +++ b/luci-app-iperf/luasrc/controller/iperf.lua @@ -5,32 +5,38 @@ module("luci.controller.iperf", package.seeall) function index() --entry({"admin", "openmptcprouter", "iperf"}, cbi("iperf"), _("iperf")) - entry({"admin", "services", "iperf"}, alias("admin", "services", "iperf", "test"), _("iperf"),1) + entry({"admin", "services", "iperf"}, alias("admin", "services", "iperf", "test"), _("iPerf"),8) entry({"admin", "services", "iperf", "test"}, template("iperf/test"), nil,1) entry({"admin", "services", "iperf", "run_test"}, post("run_test")).leaf = true end -function run_test(server,proto,mode,updown) +function run_test(server,proto,mode,updown,omit,parallel,transmit,bitrate) luci.http.prepare_content("text/plain") local iperf local addr = uci:get("iperf",server,"host") local ports = uci:get("iperf",server,"ports") + if proto == "ipv4" then + local ipv = 4 + else + local ipv = 6 + end + local t={} for pt in ports:gmatch("([^,%s]+)") do table.insert(t,pt) end local port = t[ math.random( #t ) ] - if proto == "ipv4" then + if mode == "tcp" then if updown == "upload" then - iperf = io.popen("iperf3 -c %s -P 10 -4 -p %s -O 3 -t 6 -J" % {ut.shellquote(addr),port}) + iperf = io.popen("iperf3 -c %s -P %s -%i -p %s -O %s -t %i -J" % {ut.shellquote(addr),parallel,ipv,port,omit,transmit}) else - iperf = io.popen("iperf3 -c %s -P 10 -4 -p %s -O 3 -R -t 6 -J" % {ut.shellquote(addr),port}) + iperf = io.popen("iperf3 -c %s -P %s -%i -p %s -O %s -R -t %s -J" % {ut.shellquote(addr),parallel,ipv,port,omit,transmit}) end else if updown == "upload" then - iperf = io.popen("iperf3 -c %s -P 10 -6 -p %s -O 3 -t 6 -J" % {ut.shellquote(addr),port}) + iperf = io.popen("iperf3 -c %s -P %s -%i -p %s -O %s -t %s -u -b %s -J" % {ut.shellquote(addr),parallel,ipv,port,omit,transmit,bitrate}) else - iperf = io.popen("iperf3 -c %s -P 10 -6 -p %s -O 3 -R -t 6 -J" % {ut.shellquote(addr),port}) + iperf = io.popen("iperf3 -c %s -P %s -%i -p %s -O %s -R -t %s -u -b %s -J" % {ut.shellquote(addr),parallel,ipv,port,omit,transmit,bitrate}) end end if iperf then diff --git a/luci-app-iperf/luasrc/view/iperf/test.htm b/luci-app-iperf/luasrc/view/iperf/test.htm index 224da8c19..d086e820c 100644 --- a/luci-app-iperf/luasrc/view/iperf/test.htm +++ b/luci-app-iperf/luasrc/view/iperf/test.htm @@ -8,12 +8,12 @@