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

Add available VPN choice

This commit is contained in:
Ycarus 2018-12-04 16:56:02 +01:00
parent 994a39c1b8
commit 11765c65cf
2 changed files with 34 additions and 21 deletions

View file

@ -102,6 +102,7 @@ function wizard_add()
ucic:commit("sqm")
luci.sys.call("uci -q add_list vnstat.@vnstat[-1].interface=wan" .. i)
luci.sys.call("uci -q commit vnstat")
-- Dirty way to add new interface to firewall...
luci.sys.call("uci -q add_list firewall.@zone[1].network=wan" .. i)
@ -285,12 +286,8 @@ function wizard_add()
-- Set Glorytun settings
if default_vpn:match("^glorytun.*") then
ucic:set("glorytun","vpn","enable",1)
ucic:save("glorytun")
ucic:commit("glorytun")
else
ucic:set("glorytun","vpn","enable",0)
ucic:save("glorytun")
ucic:commit("glorytun")
end
local glorytun_key = luci.http.formvalue("glorytun_key")
@ -304,25 +301,19 @@ function wizard_add()
else
ucic:set("glorytun","vpn","proto","tcp")
end
ucic:save("glorytun")
ucic:commit("glorytun")
else
ucic:set("glorytun","vpn","key","")
ucic:set("glorytun","vpn","enable",0)
ucic:set("glorytun","vpn","proto","tcp")
ucic:save("glorytun")
ucic:commit("glorytun")
end
ucic:save("glorytun")
ucic:commit("glorytun")
-- Set MLVPN settings
if default_vpn == "mlvpn" then
ucic:set("mlvpn","general","enable",1)
ucic:save("mlvpn")
ucic:commit("mlvpn")
else
ucic:set("mlvpn","general","enable",0)
ucic:save("mlvpn")
ucic:commit("mlvpn")
end
local mlvpn_password = luci.http.formvalue("mlvpn_password")
@ -330,14 +321,12 @@ function wizard_add()
ucic:set("mlvpn","general","password",mlvpn_password)
ucic:set("mlvpn","general","firstport","65201")
ucic:set("mlvpn","general","interface_name","mlvpn0")
ucic:save("mlvpn")
ucic:commit("mlvpn")
else
--ucic:set("mlvpn","general","enable",0)
ucic:set("mlvpn","general","password","")
ucic:save("mlvpn")
ucic:commit("mlvpn")
end
ucic:save("mlvpn")
ucic:commit("mlvpn")
-- Set OpenVPN settings
local openvpn_key = luci.http.formvalue("openvpn_key")
@ -357,18 +346,15 @@ function wizard_add()
end
end)
ucic:set("openvpn","omr","secret",openvpn_key_path)
ucic:commit("openvpn")
end
if default_vpn == "openvpn" then
ucic:set("openvpn","omr","enabled",1)
ucic:save("openvpn")
ucic:commit("openvpn")
else
ucic:set("openvpn","omr","enabled",0)
ucic:save("openvpn")
ucic:commit("openvpn")
end
ucic:save("openvpn")
ucic:commit("openvpn")
-- OpenMPTCProuter VPS
local openmptcprouter_vps_key = luci.http.formvalue("openmptcprouter_vps_key") or ""

View file

@ -168,11 +168,38 @@ end
<label class="cbi-value-title"><%:Default VPN%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" name="default_vpn" size="1">
<%
local available_vpns = uci:get("openmptcprouter","vps","available_vpn") or ""
if available_vpns ~= "" then
if (type(available_vpns) ~= "table") then
available_vpns = {available_vpns}
end
for _, vpn in pairs(available_vpns) do
if vpn == "glorytun-tcp" then
%>
<% if nixio.fs.access("/usr/sbin/glorytun") then %><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><% end %>
<% elseif vpn == "glorytun-udp" then %>
<% if nixio.fs.access("/usr/sbin/glorytun-udp") then %><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><% end %>
<% elseif vpn == "mlvpn" then %>
<% if nixio.fs.access("/usr/sbin/mlvpn") then %><option value="mlvpn" <% if uci:get("mlvpn","general","enable") == "1" then %>selected="selected"<% end %>>MLVPN</option><% end %>
<% elseif vpn == "openvpn" then %>
<% if nixio.fs.access("/usr/sbin/openvpn") then %><option value="openvpn" <% if uci:get("openvpn","omr","enabled") == "1" then %>selected="selected"<% end %>>OpenVPN</option><% end %>
<%
end
end
%>
<option value="none" <% if uci:get("openmptcprouter","settings","vpn") == "none" then %>selected="selected"<% end %>>None</option>
<%
else
%>
<% if nixio.fs.access("/usr/sbin/glorytun") then %><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><% end %>
<% if nixio.fs.access("/usr/sbin/glorytun-udp") then %><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><% end %>
<% if nixio.fs.access("/usr/sbin/mlvpn") then %><option value="mlvpn" <% if uci:get("mlvpn","general","enable") == "1" then %>selected="selected"<% end %>>MLVPN</option><% end %>
<% if nixio.fs.access("/usr/sbin/openvpn") then %><option value="openvpn" <% if uci:get("openvpn","omr","enabled") == "1" then %>selected="selected"<% end %>>OpenVPN</option><% end %>
<option value="none" <% if uci:get("openmptcprouter","settings","vpn") == "none" then %>selected="selected"<% end %>>None</option>
<%
end
%>
</select>
<br />
<div class="cbi-value-description">