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

Set omrvpn interface using wizard

This commit is contained in:
Ycarus 2018-07-02 13:52:36 +02:00
parent 1ad098eb51
commit 1a30dcb48e

View file

@ -80,20 +80,29 @@ function wizard_add()
-- Get VPN set by default -- Get VPN set by default
local default_vpn = luci.http.formvalue("default_vpn") or "glorytun_tcp" local default_vpn = luci.http.formvalue("default_vpn") or "glorytun_tcp"
local vpn_port local vpn_port = ""
local vpn_intf = ""
if default_vpn:match("^glorytun.*") then if default_vpn:match("^glorytun.*") then
vpn_port = 65001 vpn_port = 65001
vpn_intf = "tun0"
elseif default_vpn == "mlvpn" then elseif default_vpn == "mlvpn" then
vpn_port = 65201 vpn_port = 65201
vpn_intf = "mlvpn0"
elseif default_vpn == "openvpn" then elseif default_vpn == "openvpn" then
vpn_port = 65301 vpn_port = 65301
vpn_intf = "tun0"
end
if vpn_intf ~= "" then
ucic:set("network","omrvpn","ifname",vpn_intf)
ucic:save("network")
ucic:commit("network")
end end
ucic:set("openmptcprouter","settings","vpn",default_vpn) ucic:set("openmptcprouter","settings","vpn",default_vpn)
ucic:save("openmptcprouter") ucic:save("openmptcprouter")
ucic:commit("openmptcprouter") ucic:commit("openmptcprouter")
-- Get all servers ips -- Get all servers ips
local server_ip = luci.http.formvalue("server_ip") local server_ip = luci.http.formvalue("server_ip") or ""
-- We have an IP, so set it everywhere -- We have an IP, so set it everywhere
if server_ip ~= "" then if server_ip ~= "" then
local ss_ip local ss_ip
@ -106,14 +115,18 @@ function wizard_add()
if k == 0 then if k == 0 then
ss_ip=ip ss_ip=ip
table.insert(ss_servers,ip .. ":65101 max_fails=3 fail_timeout=30s") table.insert(ss_servers,ip .. ":65101 max_fails=3 fail_timeout=30s")
table.insert(vpn_servers,ip .. ":65001 max_fails=3 fail_timeout=30s") if vpn_port ~= "" then
table.insert(vpn_servers,ip .. ":" .. vpn_port .. " max_fails=3 fail_timeout=30s")
end
ucic:set("qos","serverin","srchost",ip) ucic:set("qos","serverin","srchost",ip)
ucic:set("qos","serverout","dsthost",ip) ucic:set("qos","serverout","dsthost",ip)
ucic:save("qos") ucic:save("qos")
ucic:commit("qos") ucic:commit("qos")
else else
table.insert(ss_servers,ip .. ":65101 backup") table.insert(ss_servers,ip .. ":65101 backup")
table.insert(vpn_servers,ip .. ":65001 backup") if vpn_port ~= "" then
table.insert(vpn_servers,ip .. ":" .. vpn_port .. " backup")
end
end end
k = k + 1 k = k + 1
end end