mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-12 10:31:51 +00:00
Update iperf interface
This commit is contained in:
parent
a95c150d8f
commit
18d4ac663d
2 changed files with 52 additions and 18 deletions
|
@ -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
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
<script type="text/javascript">//<![CDATA[
|
||||
var stxhr = new XHR();
|
||||
|
||||
function update_speed(field, proto, mode)
|
||||
function update_speed(field, proto, mode,omit,parallel,transmit,bitrate)
|
||||
{
|
||||
update_upload(field,proto,mode);
|
||||
update_upload(field,proto,mode,omit,parallel,transmit,bitrate);
|
||||
}
|
||||
|
||||
function update_upload(field, proto, mode)
|
||||
function update_upload(field, proto, mode,omit,parallel,transmit,bitrate)
|
||||
{
|
||||
var tool = field.name;
|
||||
var addr = field.value;
|
||||
|
@ -27,7 +27,7 @@
|
|||
'<%:Waiting for command to complete...%>'
|
||||
;
|
||||
|
||||
stxhr.post('<%=url('admin/services/iperf')%>/run_test' + '/' + addr + '/' + proto + '/' + mode + '/upload', { token: '<%=token%>' },
|
||||
stxhr.post('<%=url('admin/services/iperf')%>/run_test' + '/' + addr + '/' + proto + '/' + mode + '/upload' + '/' + omit + '/' + parallel + '/' + transmit + '/' + bitrate, { token: '<%=token%>' },
|
||||
function(x)
|
||||
{
|
||||
if (x.responseText)
|
||||
|
@ -47,13 +47,13 @@
|
|||
{
|
||||
upload.innerHTML = '<%:Upload%> - <span class="error"><%:Bad address specified!%></span>';
|
||||
}
|
||||
update_download(field,proto,mode);
|
||||
update_download(field,proto,mode,omit,parallel,transmit,bitrate);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function update_download(field, proto, mode)
|
||||
function update_download(field, proto, mode,omit,parallel,transmit,bitrate)
|
||||
{
|
||||
var tool = field.name;
|
||||
var addr = field.value;
|
||||
|
@ -67,7 +67,7 @@
|
|||
'<%:Waiting for command to complete...%>'
|
||||
;
|
||||
|
||||
stxhr.post('<%=url('admin/services/iperf')%>/run_test' + '/' + addr + '/' + proto + '/' + mode + '/download', { token: '<%=token%>' },
|
||||
stxhr.post('<%=url('admin/services/iperf')%>/run_test' + '/' + addr + '/' + proto + '/' + mode + '/download' + '/' + omit + '/' + parallel + '/' + transmit + '/' + bitrate, { token: '<%=token%>' },
|
||||
function(x)
|
||||
{
|
||||
if (x.responseText)
|
||||
|
@ -96,8 +96,8 @@
|
|||
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
|
||||
<form class="inline" method="post" action="<%=url('admin/services/iperf/run_test')%>">
|
||||
<div class="cbi-map">
|
||||
<h2 name="content"><%:iperf Speed tests%></h2>
|
||||
<div class="cbi-map-descr"><%:This iperf interface is in bêta. No support for this.%></div>
|
||||
<h2 name="content"><%:iPerf speed tests%></h2>
|
||||
<div class="cbi-map-descr"><%:This iPerf interface is in bêta. No support for this.%></div>
|
||||
<fieldset class="cbi-section" id="networks">
|
||||
<legend><%:Settings%></legend>
|
||||
<div class="cbi-section-descr"></div>
|
||||
|
@ -106,7 +106,7 @@
|
|||
<div class="cbi-value-field">
|
||||
<select class="cbi-input-select" name="mode">
|
||||
<option value="tcp">TCP</option>
|
||||
<!-- <option value="udp">UDP</option> -->
|
||||
<option value="udp">UDP</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -119,6 +119,34 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Target bitrate (Mbits/s)%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input name="bitrate" data-type="uinteger" type="text" class="cbi-input-text" value="0"/>
|
||||
</div>
|
||||
<br />
|
||||
<div class="cbi-value-description">
|
||||
<%:0 for unlimited. Need to be limited for UDP test%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Number of parallel client streams to run%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input name="parallel" data-type="uinteger" type="text" class="cbi-input-text" value="1"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Omit the first n seconds%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input name="omit" data-type="uinteger" type="text" class="cbi-input-text" value="3"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Time to transmit for (s)%></label>
|
||||
<div class="cbi-value-field">
|
||||
<input name="transmit" data-type="uinteger" type="text" class="cbi-input-text" value="5"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:Server%></label>
|
||||
<div class="cbi-value-field">
|
||||
|
@ -134,7 +162,7 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<input type="button" value="<%:Test%>" class="cbi-button cbi-button-apply" onclick="update_speed(this.form.addr,this.form.proto.value,this.form.mode.value)" />
|
||||
<input type="button" value="<%:Test%>" class="cbi-button cbi-button-apply" onclick="update_speed(this.form.addr,this.form.proto.value,this.form.mode.value,this.form.omit.value,this.form.parallel.value,this.form.transmit.value,this.form.bitrate.value)" />
|
||||
</fieldset>
|
||||
</div>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue