From 7f8c070254ef2edfd7a120c6c132af4a73b39d4a Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 5 May 2020 10:48:28 +0200 Subject: [PATCH] Fixes, low latency option and option to no add default gateway to internet --- .../luasrc/controller/openmptcprouter.lua | 24 ++++++++++++++++++- .../luasrc/view/openmptcprouter/settings.htm | 20 ++++++++++++++++ .../etc/sysctl.d/zzz_openmptcprouter.conf | 3 ++- .../root/etc/uci-defaults/openmptcprouter | 6 +++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua index 7d83993a6..c32da267f 100644 --- a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua +++ b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua @@ -449,12 +449,17 @@ function wizard_add() local encryption = luci.http.formvalue("encryption") if encryption == "none" then ucic:set("shadowsocks-libev","sss0","method","none") + ucic:save("shadowsocks-libev") elseif encryption == "aes-256-gcm" then ucic:set("shadowsocks-libev","sss0","method","aes-256-gcm") ucic:set("glorytun","vpn","chacha20","0") + ucic:save("glorytun") + ucic:save("shadowsocks-libev") elseif encryption == "chacha20-ietf-poly1305" then ucic:set("shadowsocks-libev","sss0","method","chacha20-ietf-poly1305") ucic:set("glorytun","vpn","chacha20","1") + ucic:save("glorytun") + ucic:save("shadowsocks-libev") end -- Set ShadowSocks settings @@ -605,6 +610,7 @@ function wizard_add() -- Restart all if gostatus == true then luci.sys.call("(env -i /bin/ubus call network reload) >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/omr-tracker stop >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/mptcp restart >/dev/null 2>/dev/null") if openmptcprouter_vps_key ~= "" then luci.sys.call("/etc/init.d/openmptcprouter-vps restart >/dev/null 2>/dev/null") @@ -617,7 +623,7 @@ function wizard_add() luci.sys.call("/etc/init.d/ubond restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/openvpn restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/dsvpn restart >/dev/null 2>/dev/null") - luci.sys.call("/etc/init.d/omr-tracker restart >/dev/null 2>/dev/null") + luci.sys.call("/etc/init.d/omr-tracker start >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/omr-6in4 restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/mptcpovervpn restart >/dev/null 2>/dev/null") luci.sys.call("/etc/init.d/vnstat restart >/dev/null 2>/dev/null") @@ -683,6 +689,10 @@ function settings_add() local disablegwping = luci.http.formvalue("disablegwping") or "0" ucic:set("openmptcprouter","settings","disablegwping",disablegwping) + -- Enable/disable default gateway + local disabledefaultgw = luci.http.formvalue("disabledefaultgw") or "1" + ucic:set("openmptcprouter","settings","defaultgw",disabledefaultgw) + -- Enable/disable server ping local disableserverping = luci.http.formvalue("disableserverping") or "0" ucic:set("openmptcprouter","settings","disableserverping",disableserverping) @@ -701,6 +711,18 @@ function settings_add() ucic:set("shadowsocks-libev",section[".name"],"fast_open",fastopen) end) + -- Enable/disable no delay + local nodelay = luci.http.formvalue("enablenodelay") or "1" + ucic:set("openmptcprouter","settings","enable_nodelay",nodelay) + luci.sys.exec("sysctl -w net.ipv4.tcp_low_latency=%s" % nodelay) + luci.sys.exec("sed -i 's:^net.ipv4.tcp_low_latency=[0-9]*:net.ipv4.tcp_low_latency=%s:' /etc/sysctl.d/zzz_openmptcprouter.conf" % nodelay) + ucic:foreach("shadowsocks-libev", "ss_redir", function (section) + ucic:set("shadowsocks-libev",section[".name"],"no_delay",nodelay) + end) + ucic:foreach("shadowsocks-libev", "ss_local", function (section) + ucic:set("shadowsocks-libev",section[".name"],"no_delay",nodelay) + end) + -- Enable/disable obfs local obfs = luci.http.formvalue("obfs") or "0" diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/settings.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/settings.htm index 4edca015c..fbd6fff04 100644 --- a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/settings.htm +++ b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/settings.htm @@ -164,6 +164,16 @@ +
+ +
+ checked<% end %>> +
+
+ <%:Optimize for latency instead of bandwidth%> +
+
+
@@ -184,6 +194,16 @@
+
+ +
+ checked<% end %>> +
+
+ <%:Disable default gateway, no internet if VPS are down%> +
+
+
diff --git a/luci-app-openmptcprouter/root/etc/sysctl.d/zzz_openmptcprouter.conf b/luci-app-openmptcprouter/root/etc/sysctl.d/zzz_openmptcprouter.conf index 474d8b099..96bf976ce 100644 --- a/luci-app-openmptcprouter/root/etc/sysctl.d/zzz_openmptcprouter.conf +++ b/luci-app-openmptcprouter/root/etc/sysctl.d/zzz_openmptcprouter.conf @@ -2,4 +2,5 @@ net.ipv4.tcp_keepalive_time=7200 net.ipv6.conf.all.disable_ipv6=0 net.ipv4.tcp_fin_timeout=60 net.ipv4.tcp_syn_retries=3 -net.ipv4.tcp_fastopen=3 \ No newline at end of file +net.ipv4.tcp_fastopen=3 +net.ipv4.tcp_low_latency=1 diff --git a/luci-app-openmptcprouter/root/etc/uci-defaults/openmptcprouter b/luci-app-openmptcprouter/root/etc/uci-defaults/openmptcprouter index f0f26b242..015737dbd 100755 --- a/luci-app-openmptcprouter/root/etc/uci-defaults/openmptcprouter +++ b/luci-app-openmptcprouter/root/etc/uci-defaults/openmptcprouter @@ -95,4 +95,10 @@ if [ "$(uci -q get openmptcprouter.settings.status_getip_timeout)" = "" ]; then commit openmptcprouter EOF fi +if [ "$(uci -q get openmptcprouter.settings.enable_nodelay)" = "" ]; then + uci -q batch <<-EOF >/dev/null + set openmptcprouter.settings.enable_nodelay=1 + commit openmptcprouter + EOF +fi exit 0