From 368f23be9965c40ce3e06b80099e214f2e22640c Mon Sep 17 00:00:00 2001 From: Ycarus Date: Thu, 9 Aug 2018 16:57:26 +0200 Subject: [PATCH] Test if VPS support MPTCP --- luci-app-openmptcprouter/Makefile | 2 +- .../luasrc/controller/openmptcprouter.lua | 27 +++++++++++++------ .../luasrc/view/openmptcprouter/wanstatus.htm | 4 +++ .../root/bin/omr-tracebox-mptcp | 7 +++++ 4 files changed, 31 insertions(+), 9 deletions(-) create mode 100755 luci-app-openmptcprouter/root/bin/omr-tracebox-mptcp diff --git a/luci-app-openmptcprouter/Makefile b/luci-app-openmptcprouter/Makefile index ca286381b..b562cebcf 100644 --- a/luci-app-openmptcprouter/Makefile +++ b/luci-app-openmptcprouter/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=LuCI Support for OpenMPTCProuter -LUCI_DEPENDS:=+luci-lib-json +rdisc6 +curl +whois +bind-dig +LUCI_DEPENDS:=+luci-lib-json +rdisc6 +curl +whois +bind-dig +tracebox PKG_LICENSE:=GPLv3 include ../luci/luci.mk diff --git a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua index d77993b6f..0d97b273f 100644 --- a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua +++ b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua @@ -442,7 +442,7 @@ function interfaces_status() mArray.openmptcprouter["service_addr"] = uci:get("shadowsocks-libev", "sss0", "server") or "" mArray.openmptcprouter["local_addr"] = uci:get("network", "lan", "ipaddr") - + mArray.openmptcprouter["server_mptcp"] = "" -- dns mArray.openmptcprouter["dns"] = false local dns_test = sys.exec("dig openmptcprouter.com | grep 'ANSWER: 0'") @@ -664,15 +664,26 @@ function interfaces_status() local multipath_available if connectivity ~= "ERROR" and mArray.openmptcprouter["dns"] == true and ifname ~= nil and ifname ~= "" and gateway ~= "" and gw_ping == "UP" then -- Test if multipath can work on the connection - local multipath_available_state = ut.trim(sys.exec("omr-mptcp-intf " .. ifname .. " | grep 'Nay, Nay, Nay'")) - if multipath_available_state == "" then + local multipath_available_state = "" + if mArray.openmptcprouter["service_addr"] ~= "" then + multipath_available_state = ut.trim(sys.exec("omr-tracebox-mptcp " .. mArray.openmptcprouter["service_addr"] .. " " .. ifname .. " | grep 'MPTCP enabled'")) + else + multipath_available_state = ut.trim(sys.exec("omr-mptcp-intf " .. ifname .. " | grep 'you are MPTCP-capable'")) + end + if multipath_available_state ~= "" then multipath_available = 'OK' else - multipath_available = 'ERROR' - if mArray.openmptcprouter["socks_service"] == true and connectivity == "OK" then - connectivity = 'ERROR' - elseif connectivity == "OK" then - connectivity = 'WARNING' + multipath_available_state_wan = ut.trim(sys.exec("omr-mptcp-intf " .. ifname .. " | grep 'Nay, Nay, Nay'")) + if multipath_available_state_wan == "" then + multipath_available = 'OK' + mArray.openmptcprouter["server_mptcp"] = false + else + multipath_available = 'ERROR' + if mArray.openmptcprouter["socks_service"] == true and connectivity == "OK" then + connectivity = 'ERROR' + elseif connectivity == "OK" then + connectivity = 'WARNING' + end end end else diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm index 278b2636d..6f284fee9 100644 --- a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm +++ b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm @@ -110,6 +110,10 @@ { statusMessage += 'ShadowSocks not working
'; } + if (mArray.openmptcprouter.server_mptcp == false) + { + statusMessage += 'MPTCP not enabled on the server
'; + } } if (mArray.openmptcprouter.tun_service == false) { diff --git a/luci-app-openmptcprouter/root/bin/omr-tracebox-mptcp b/luci-app-openmptcprouter/root/bin/omr-tracebox-mptcp new file mode 100755 index 000000000..053b18965 --- /dev/null +++ b/luci-app-openmptcprouter/root/bin/omr-tracebox-mptcp @@ -0,0 +1,7 @@ +#!/bin/sh +INTERFACE=$2 +if [ -z "$INTERFACE" ]; then + tracebox -m 20 -l "pkt = ip{dst=to} / tcp{dst=65101} / MPCAPABLE / MSS / WSCALE if string.find(tostring(tracebox(pkt)),'MPTCP') then print 'MPTCP enabled' else print 'MPTCP disabled' end" $1 +else + tracebox -m 20 -l "pkt = ip{dst=to} / tcp{dst=65101} / MPCAPABLE / MSS / WSCALE if string.find(tostring(tracebox(pkt)),'MPTCP') then print 'MPTCP enabled' else print 'MPTCP disabled' end" -i $INTERFACE $1 +fi \ No newline at end of file