From d380a6a6eb226e2790a76ef1cc3f9850ea99525e Mon Sep 17 00:00:00 2001 From: Ycarus Date: Tue, 27 Nov 2018 15:18:03 +0100 Subject: [PATCH] Move MPTCP check in MPTCP interface --- luci-app-mptcp/luasrc/controller/mptcp.lua | 25 +++++++ .../luasrc/view/mptcp/mptcp_check.htm | 73 +++++++++++++++++++ .../luasrc/view/mptcp/multipath.htm | 8 +- 3 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 luci-app-mptcp/luasrc/view/mptcp/mptcp_check.htm diff --git a/luci-app-mptcp/luasrc/controller/mptcp.lua b/luci-app-mptcp/luasrc/controller/mptcp.lua index 69ea37d7a..aab837e02 100644 --- a/luci-app-mptcp/luasrc/controller/mptcp.lua +++ b/luci-app-mptcp/luasrc/controller/mptcp.lua @@ -11,6 +11,8 @@ function index() 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", "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 function interface_bandwidth(iface) @@ -50,3 +52,26 @@ function multipath_bandwidth() luci.http.prepare_content("application/json") luci.http.write_json(result) 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 diff --git a/luci-app-mptcp/luasrc/view/mptcp/mptcp_check.htm b/luci-app-mptcp/luasrc/view/mptcp/mptcp_check.htm new file mode 100644 index 000000000..97b560bbb --- /dev/null +++ b/luci-app-mptcp/luasrc/view/mptcp/mptcp_check.htm @@ -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() +%> + + + + +<% if stderr and #stderr > 0 then %>
<%=pcdata(stderr)%>
<% end %> +
+
+

<%:MPTCP Support Check%>

+
<%:Check if MPTCP between interface and server is working.%>
+
+ <%:Settings%> +
+
+ +
+ +
+
+ +
+
+
+ +
+ +
+<%+footer%> diff --git a/luci-app-mptcp/luasrc/view/mptcp/multipath.htm b/luci-app-mptcp/luasrc/view/mptcp/multipath.htm index 27be51b1c..d6d92bb4d 100644 --- a/luci-app-mptcp/luasrc/view/mptcp/multipath.htm +++ b/luci-app-mptcp/luasrc/view/mptcp/multipath.htm @@ -50,7 +50,7 @@ if(str == "wan1") return "DeepSkyBlue"; if(str == "wan2") - return "LightGreen"; + return "SeaGreen"; if(str == "wan3") return "PaleGreen"; if(str == "wan4") @@ -58,7 +58,7 @@ if(str == "wan5") return "Salmon"; if(str == "wan6") - return "SeaGreen"; + return "LightGreen"; if(str == "wan7") return "PaleTurquoise"; // Generate a color folowing the name @@ -513,7 +513,7 @@ ); XHR.run(); } - }, 1000 + }, 2000 <% else %> var bwxhr = new XHR(); @@ -754,7 +754,7 @@ ); XHR.run(); } - }, 1000 + }, 2000 <% end %> ); //]]>