From 26a5a7bf554e9e7968d503dd166349ae391f5984 Mon Sep 17 00:00:00 2001 From: Ycarus Date: Mon, 11 Jun 2018 10:21:48 +0200 Subject: [PATCH] Add VPN choice in wizard --- .../luasrc/controller/openmptcprouter.lua | 21 ++++++++++++++----- .../luasrc/view/openmptcprouter/wizard.htm | 19 +++++++++++++++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua index 3cfca4c30..5c0d156b0 100644 --- a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua +++ b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua @@ -94,15 +94,26 @@ function wizard_add() ucic:commit("shadowsocks-libev") end + -- Get VPN set by default + local default_vpn = luci.http.formvalue("default") or "glorytun_tcp" + -- Set Glorytun TCP settings local glorytun_key = luci.http.formvalue("glorytun_key") if glorytun_key ~= "" then ucic:set("glorytun","vpn","port","65001") ucic:set("glorytun","vpn","key",glorytun_key) - ucic:set("glorytun","vpn","enable",1) + if default_vpn:match("^glorytun.*") then + ucic:set("glorytun","vpn","enable",1) + else + ucic:set("glorytun","vpn","enable",0) + end ucic:set("glorytun","vpn","mptcp",1) ucic:set("glorytun","vpn","chacha20",1) - ucic:set("glorytun","vpn","proto","tcp") + if default_vpn == "glorytun_udp" then + ucic:set("glorytun","vpn","proto","udp") + else + ucic:set("glorytun","vpn","proto","tcp") + end ucic:save("glorytun") ucic:commit("glorytun") else @@ -116,10 +127,10 @@ function wizard_add() -- Set MLVPN settings local mlvpn_password = luci.http.formvalue("mlvpn_password") if mlvpn_password ~= "" then - if glorytun_key ~= "" then - ucic:set("mlvpn","general","enable",0) - else + if default_vpn == "mlvpn" then ucic:set("mlvpn","general","enable",1) + else + ucic:set("mlvpn","general","enable",0) end ucic:set("mlvpn","general","password",mlvpn_password) ucic:set("mlvpn","general","firstport","65201") diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm index b461f416f..bcfd20c6f 100644 --- a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm +++ b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm @@ -43,7 +43,7 @@
help - <%:Glorytun is used for UDP and ICMP%> + <%:Glorytun TCP is used by default for UDP and ICMP%>
@@ -54,7 +54,22 @@
help - <%:MLVPN can replace Glorytun with connection with same latency%> + <%:MLVPN can replace Glorytun with connections with same latency%> +
+ + +
+ +
+ +
+
+ help + <%:Set the default VPN used for UDP and ICMP when ShadowSocks is enabled, for all traffic if ShadowSocks is disabled.%>