mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-15 03:51:51 +00:00
Move MPTCP check in MPTCP interface
This commit is contained in:
parent
47e9fd8827
commit
d380a6a6eb
3 changed files with 102 additions and 4 deletions
|
@ -11,6 +11,8 @@ function index()
|
||||||
entry({"admin", "network", "mptcp", "bandwidth"}, template("mptcp/multipath"), _("Bandwidth"), 3).leaf = true
|
entry({"admin", "network", "mptcp", "bandwidth"}, template("mptcp/multipath"), _("Bandwidth"), 3).leaf = true
|
||||||
entry({"admin", "network", "mptcp", "multipath_bandwidth"}, call("multipath_bandwidth")).leaf = true
|
entry({"admin", "network", "mptcp", "multipath_bandwidth"}, call("multipath_bandwidth")).leaf = true
|
||||||
entry({"admin", "network", "mptcp", "interface_bandwidth"}, call("interface_bandwidth")).leaf = true
|
entry({"admin", "network", "mptcp", "interface_bandwidth"}, call("interface_bandwidth")).leaf = true
|
||||||
|
entry({"admin", "network", "mptcp", "mptcp_check"}, template("mptcp/mptcp_check"), _("MPTCP Support Check"), 4).leaf = true
|
||||||
|
entry({"admin", "network", "mptcp", "mptcp_check_trace"}, post("mptcp_check_trace")).leaf = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function interface_bandwidth(iface)
|
function interface_bandwidth(iface)
|
||||||
|
@ -50,3 +52,26 @@ function multipath_bandwidth()
|
||||||
luci.http.prepare_content("application/json")
|
luci.http.prepare_content("application/json")
|
||||||
luci.http.write_json(result)
|
luci.http.write_json(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mptcp_check_trace(iface)
|
||||||
|
luci.http.prepare_content("text/plain")
|
||||||
|
local tracebox
|
||||||
|
local uci = require "luci.model.uci".cursor()
|
||||||
|
local interface = get_device(iface)
|
||||||
|
local server = uci:get("shadowsocks-libev", "sss0", "server") or ""
|
||||||
|
if server == "" then return end
|
||||||
|
if interface == "" then
|
||||||
|
tracebox = io.popen("tracebox -s /usr/share/tracebox/omr-mptcp-trace.lua " .. server)
|
||||||
|
else
|
||||||
|
tracebox = io.popen("tracebox -s /usr/share/tracebox/omr-mptcp-trace.lua -i " .. interface .. " " .. server)
|
||||||
|
end
|
||||||
|
if tracebox then
|
||||||
|
while true do
|
||||||
|
local ln = tracebox:read("*l")
|
||||||
|
if not ln then break end
|
||||||
|
luci.http.write(ln)
|
||||||
|
luci.http.write("\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
73
luci-app-mptcp/luasrc/view/mptcp/mptcp_check.htm
Normal file
73
luci-app-mptcp/luasrc/view/mptcp/mptcp_check.htm
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
<%+header%>
|
||||||
|
|
||||||
|
<%
|
||||||
|
local uci = require("luci.model.uci").cursor()
|
||||||
|
local sys = require "luci.sys"
|
||||||
|
local ifaces = sys.net:devices()
|
||||||
|
local net = require "luci.model.network".init()
|
||||||
|
%>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="<%=resource%>/cbi.js?v=git-18.193.28471-ee087a1"></script>
|
||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
var stxhr = new XHR();
|
||||||
|
|
||||||
|
function update_mptcp(interface)
|
||||||
|
{
|
||||||
|
var trace = document.getElementById('tracebox');
|
||||||
|
|
||||||
|
if (trace)
|
||||||
|
{
|
||||||
|
trace.innerHTML =
|
||||||
|
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' + '<%:Waiting for command to complete...%>'
|
||||||
|
;
|
||||||
|
|
||||||
|
stxhr.post('<%=url('admin/system/openmptcprouter')%>/mptcp_check_trace/' + interface, { token: '<%=token%>' },
|
||||||
|
function(x)
|
||||||
|
{
|
||||||
|
if (x.responseText)
|
||||||
|
{
|
||||||
|
trace.innerHTML = String.format('<pre>%s</pre>', x.responseText );
|
||||||
|
} else {
|
||||||
|
trace.innerHTML = '<pre><%:Error%></pre>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//]]></script>
|
||||||
|
|
||||||
|
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
|
||||||
|
<form class="inline" method="post" action="<%=url('admin/system/openmptcprouter/mptcp_check_trace')%>">
|
||||||
|
<div class="cbi-map">
|
||||||
|
<h2 name="content"><%:MPTCP Support Check%></h2>
|
||||||
|
<div class="cbi-map-descr"><%:Check if MPTCP between interface and server is working.%></div>
|
||||||
|
<fieldset class="cbi-section" id="networks">
|
||||||
|
<legend><%:Settings%></legend>
|
||||||
|
<div class="cbi-section-descr"></div>
|
||||||
|
<div class="cbi-value">
|
||||||
|
<label class="cbi-value-title"><%:Interface%></label>
|
||||||
|
<div class="cbi-value-field">
|
||||||
|
<select class="cbi-input-select" name="interface" size="1">
|
||||||
|
<%
|
||||||
|
for _, iface in ipairs(net:get_networks()) do
|
||||||
|
local ifname = iface:name()
|
||||||
|
local multipath = uci:get("network",ifname,"multipath")
|
||||||
|
if multipath ~= "off" then
|
||||||
|
%>
|
||||||
|
<option value="<%=ifname%>"><%=ifname%></option>
|
||||||
|
<%
|
||||||
|
end
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<input type="button" value="<%:Test%>" class="cbi-button cbi-button-apply" onclick="update_mptcp(this.form.interface.value)" />
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div class="cbi-section">
|
||||||
|
<span id="tracebox"></span>
|
||||||
|
</div>
|
||||||
|
<%+footer%>
|
|
@ -50,7 +50,7 @@
|
||||||
if(str == "wan1")
|
if(str == "wan1")
|
||||||
return "DeepSkyBlue";
|
return "DeepSkyBlue";
|
||||||
if(str == "wan2")
|
if(str == "wan2")
|
||||||
return "LightGreen";
|
return "SeaGreen";
|
||||||
if(str == "wan3")
|
if(str == "wan3")
|
||||||
return "PaleGreen";
|
return "PaleGreen";
|
||||||
if(str == "wan4")
|
if(str == "wan4")
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
if(str == "wan5")
|
if(str == "wan5")
|
||||||
return "Salmon";
|
return "Salmon";
|
||||||
if(str == "wan6")
|
if(str == "wan6")
|
||||||
return "SeaGreen";
|
return "LightGreen";
|
||||||
if(str == "wan7")
|
if(str == "wan7")
|
||||||
return "PaleTurquoise";
|
return "PaleTurquoise";
|
||||||
// Generate a color folowing the name
|
// Generate a color folowing the name
|
||||||
|
@ -513,7 +513,7 @@
|
||||||
);
|
);
|
||||||
XHR.run();
|
XHR.run();
|
||||||
}
|
}
|
||||||
}, 1000
|
}, 2000
|
||||||
<% else %>
|
<% else %>
|
||||||
var bwxhr = new XHR();
|
var bwxhr = new XHR();
|
||||||
|
|
||||||
|
@ -754,7 +754,7 @@
|
||||||
);
|
);
|
||||||
XHR.run();
|
XHR.run();
|
||||||
}
|
}
|
||||||
}, 1000
|
}, 2000
|
||||||
<% end %>
|
<% end %>
|
||||||
);
|
);
|
||||||
//]]></script>
|
//]]></script>
|
||||||
|
|
Loading…
Reference in a new issue