1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Add MPTCP connections

This commit is contained in:
Ycarus 2019-01-03 15:56:49 +01:00
parent 18ffe1bb3e
commit 9c6fe0d63a
3 changed files with 69 additions and 3 deletions

View file

@ -1,5 +1,5 @@
# #
# Copyright (C) 2018 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> # Copyright (C) 2018-2019 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
# #
# #

View file

@ -13,8 +13,10 @@ function index()
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"}, template("mptcp/mptcp_check"), _("MPTCP Support Check"), 4).leaf = true
entry({"admin", "network", "mptcp", "mptcp_check_trace"}, post("mptcp_check_trace")).leaf = true entry({"admin", "network", "mptcp", "mptcp_check_trace"}, post("mptcp_check_trace")).leaf = true
entry({"admin", "network", "mptcp", "mptcp_fullmesh"}, template("mptcp/mptcp_fullmesh"), _("MPTCP Fullmesh"), 4).leaf = true entry({"admin", "network", "mptcp", "mptcp_fullmesh"}, template("mptcp/mptcp_fullmesh"), _("MPTCP Fullmesh"), 5).leaf = true
entry({"admin", "network", "mptcp", "mptcp_fullmesh_data"}, post("mptcp_fullmesh_data")).leaf = true entry({"admin", "network", "mptcp", "mptcp_fullmesh_data"}, post("mptcp_fullmesh_data")).leaf = true
entry({"admin", "network", "mptcp", "mptcp_connections"}, template("mptcp/mptcp_connections"), _("Established connections"), 6).leaf = true
entry({"admin", "network", "mptcp", "mptcp_connections_data"}, post("mptcp_connections_data")).leaf = true
end end
function interface_bandwidth(iface) function interface_bandwidth(iface)
@ -85,7 +87,7 @@ end
function mptcp_fullmesh_data() function mptcp_fullmesh_data()
luci.http.prepare_content("text/plain") luci.http.prepare_content("text/plain")
local fullmash local fullmesh
fullmesh = io.popen("multipath -f") fullmesh = io.popen("multipath -f")
if fullmesh then if fullmesh then
while true do while true do
@ -97,3 +99,18 @@ function mptcp_fullmesh_data()
end end
return return
end end
function mptcp_connections_data()
luci.http.prepare_content("text/plain")
local connections
connections = io.popen("multipath -c")
if connections then
while true do
local ln = connections:read("*l")
if not ln then break end
luci.http.write(ln)
luci.http.write("\n")
end
end
return
end

View file

@ -0,0 +1,49 @@
<%+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_connections()
{
var ec = document.getElementById('connections');
if (ec)
{
ec.innerHTML =
'<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' + '<%:Waiting for command to complete...%>'
;
stxhr.post('<%=url('admin/network/mptcp')%>/mptcp_connections_data/', { token: '<%=token%>' },
function(x)
{
if (x.responseText)
{
ec.innerHTML = String.format('<pre>%s</pre>', x.responseText );
} else {
ec.innerHTML = '<pre><%:Error%></pre>';
}
}
);
}
}
setInterval(function () {
update_connections();
}, 10000);
//]]></script>
<% if stderr and #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
<div class="cbi-section">
<span id="connections"></span>
<script type="text/javascript">//<![CDATA[
update_connections();
//]]></script>
</div>
<%+footer%>