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

Add VPN choice in wizard

This commit is contained in:
Ycarus 2018-06-11 10:21:48 +02:00
parent bca0dc47de
commit 26a5a7bf55
2 changed files with 33 additions and 7 deletions

View file

@ -94,15 +94,26 @@ function wizard_add()
ucic:commit("shadowsocks-libev") ucic:commit("shadowsocks-libev")
end end
-- Get VPN set by default
local default_vpn = luci.http.formvalue("default") or "glorytun_tcp"
-- Set Glorytun TCP settings -- Set Glorytun TCP settings
local glorytun_key = luci.http.formvalue("glorytun_key") local glorytun_key = luci.http.formvalue("glorytun_key")
if glorytun_key ~= "" then if glorytun_key ~= "" then
ucic:set("glorytun","vpn","port","65001") ucic:set("glorytun","vpn","port","65001")
ucic:set("glorytun","vpn","key",glorytun_key) 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","mptcp",1)
ucic:set("glorytun","vpn","chacha20",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:save("glorytun")
ucic:commit("glorytun") ucic:commit("glorytun")
else else
@ -116,10 +127,10 @@ function wizard_add()
-- Set MLVPN settings -- Set MLVPN settings
local mlvpn_password = luci.http.formvalue("mlvpn_password") local mlvpn_password = luci.http.formvalue("mlvpn_password")
if mlvpn_password ~= "" then if mlvpn_password ~= "" then
if glorytun_key ~= "" then if default_vpn == "mlvpn" then
ucic:set("mlvpn","general","enable",0)
else
ucic:set("mlvpn","general","enable",1) ucic:set("mlvpn","general","enable",1)
else
ucic:set("mlvpn","general","enable",0)
end end
ucic:set("mlvpn","general","password",mlvpn_password) ucic:set("mlvpn","general","password",mlvpn_password)
ucic:set("mlvpn","general","firstport","65201") ucic:set("mlvpn","general","firstport","65201")

View file

@ -43,7 +43,7 @@
<br /> <br />
<div class="cbi-value-description"> <div class="cbi-value-description">
<span class="cbi-value-helpicon"><img src="/luci-static/resources/cbi/help.gif" alt="help" /></span> <span class="cbi-value-helpicon"><img src="/luci-static/resources/cbi/help.gif" alt="help" /></span>
<%:Glorytun is used for UDP and ICMP%> <%:Glorytun TCP is used by default for UDP and ICMP%>
</div> </div>
</div> </div>
</div> </div>
@ -54,7 +54,22 @@
<br /> <br />
<div class="cbi-value-description"> <div class="cbi-value-description">
<span class="cbi-value-helpicon"><img src="/luci-static/resources/cbi/help.gif" alt="help" /></span> <span class="cbi-value-helpicon"><img src="/luci-static/resources/cbi/help.gif" alt="help" /></span>
<%:MLVPN can replace Glorytun with connection with same latency%> <%:MLVPN can replace Glorytun with connections with same latency%>
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Default VPN%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" name="default_vpn" size="1">
<option value="glorytun_tcp" <% if uci:get("glorytun","vpn","enable") == "1" and uci:get("glorytun","vpn","proto") == "tcp" then %>selected="selected"<% end %>>Glorytun TCP</option>
<option value="glorytun_udp" <% if uci:get("glorytun","vpn","enable") == "1" and uci:get("glorytun","vpn","proto") == "udp" then %>selected="selected"<% end %>>Glorytun UDP</option>
<option value="mlvpn" <% if uci:get("mlvpn","general","enable") == "1" then %>selected="selected"<% end %>>MLVPN</option>
</select>
<br />
<div class="cbi-value-description">
<span class="cbi-value-helpicon"><img src="/luci-static/resources/cbi/help.gif" alt="help" /></span>
<%:Set the default VPN used for UDP and ICMP when ShadowSocks is enabled, for all traffic if ShadowSocks is disabled.%>
</div> </div>
</div> </div>
</div> </div>