|
|
|
@ -3,9 +3,23 @@ local uci = require("luci.model.uci").cursor()
|
|
|
|
|
local sys = require("luci.sys")
|
|
|
|
|
local util = require("luci.util")
|
|
|
|
|
|
|
|
|
|
-- Function to check if OpenVPN (tun0) is active
|
|
|
|
|
local function is_vpn_connected()
|
|
|
|
|
local status = sys.call("ip link show tun0 >/dev/null 2>&1")
|
|
|
|
|
return (status == 0) and "Connected" or "Disconnected"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Define the model
|
|
|
|
|
m = Map("tgopenvpn_cfg", "TorGuard OpenVPN Setup")
|
|
|
|
|
|
|
|
|
|
-- VPN Status Section
|
|
|
|
|
status_section = m:section(TypedSection, "ovpnconfig", "OpenVPN Status")
|
|
|
|
|
status_section.anonymous = true
|
|
|
|
|
status_section.addremove = false
|
|
|
|
|
|
|
|
|
|
status = status_section:option(DummyValue, "_vpn_status", translate("VPN Status"))
|
|
|
|
|
status.value = is_vpn_connected()
|
|
|
|
|
|
|
|
|
|
-- Define the section for the OpenVPN settings
|
|
|
|
|
s = m:section(TypedSection, "ovpnconfig", "OpenVPN Settings")
|
|
|
|
|
s.anonymous = true
|
|
|
|
@ -71,63 +85,20 @@ svr:value("us-fl.torguard.com", "USA Miami")
|
|
|
|
|
svr:value("us-atl.torguard.com", "USA Atlanta")
|
|
|
|
|
svr:value("us-ny.torguard.com", "USA New York")
|
|
|
|
|
svr:value("us-chi.torguard.com", "USA Chicago")
|
|
|
|
|
svr:value("us-chi-loc2.torguard.com", "USA Chicago 2")
|
|
|
|
|
svr:value("us-dal.torguard.com", "USA Dallas")
|
|
|
|
|
svr:value("us-dal-loc2.torguard.com", "USA Dallas 2")
|
|
|
|
|
svr:value("us-la.torguard.com", "USA LA")
|
|
|
|
|
svr:value("us-lv.torguard.com", "USA Las Vegas")
|
|
|
|
|
svr:value("us-sa.torguard.com", "USA Seattle")
|
|
|
|
|
svr:value("us-sf.torguard.com", "USA San Francisco")
|
|
|
|
|
svr:value("us-nj.torguard.com", "USA New Jersey")
|
|
|
|
|
svr:value("us-nj-loc2.torguard.com", "USA New Jersey 2")
|
|
|
|
|
svr:value("us-slc.torguard.com", "USA Salt Lake City")
|
|
|
|
|
|
|
|
|
|
dedicated = s:option(ListValue, "dedicated", translate("Use Dedicated IP"))
|
|
|
|
|
dedicated:value("YES")
|
|
|
|
|
dedicated:value("NO")
|
|
|
|
|
|
|
|
|
|
dediserver = s:option(Value, "dediserver", translate("Dedicated IP"))
|
|
|
|
|
|
|
|
|
|
protocol = s:option(ListValue, "protocol", translate("VPN Protocol"))
|
|
|
|
|
protocol:value("udp")
|
|
|
|
|
protocol:value("tcp")
|
|
|
|
|
|
|
|
|
|
port = s:option(ListValue, "port", translate("VPN Port"))
|
|
|
|
|
-- Add all ports here
|
|
|
|
|
port:value("1912|SHA256", "1912|SHA256")
|
|
|
|
|
port:value("1195|SHA256", "1195|SHA256")
|
|
|
|
|
port:value("53|SHA256", "53|SHA256")
|
|
|
|
|
port:value("1198|SHA256", "1198|SHA256")
|
|
|
|
|
port:value("9201|SHA256", "9201|SHA256")
|
|
|
|
|
port:value("501|SHA256", "501|SHA256")
|
|
|
|
|
port:value("1194|SHA1", "1194|SHA1")
|
|
|
|
|
port:value("995|SHA1", "995|SHA1")
|
|
|
|
|
port:value("1215|SHA512", "1215|SHA512")
|
|
|
|
|
port:value("389|SHA512", "389|SHA512")
|
|
|
|
|
port:value("80|SHA1", "80|SHA1")
|
|
|
|
|
port:value("443|SHA1", "443|SHA1")
|
|
|
|
|
|
|
|
|
|
cipher = s:option(ListValue, "cipher", translate("VPN Cipher"))
|
|
|
|
|
-- Add all cipher options here
|
|
|
|
|
cipher:value("AES-128-CBC")
|
|
|
|
|
cipher:value("AES-256-CBC")
|
|
|
|
|
cipher:value("AES-128-GCM")
|
|
|
|
|
cipher:value("AES-256-GCM")
|
|
|
|
|
cipher:value("BF-CBC")
|
|
|
|
|
|
|
|
|
|
-- VPN Control: Start/Stop OpenVPN
|
|
|
|
|
ctrl = m:section(TypedSection, "ovpnconfig", "VPN Control: Start/Stop OpenVPN")
|
|
|
|
|
ctrl.anonymous = true
|
|
|
|
|
ctrl.addremove = false
|
|
|
|
|
|
|
|
|
|
btnStop = ctrl:option(Button, "_btn_start", translate("Click to Stop OpenVPN"))
|
|
|
|
|
btnStop = ctrl:option(Button, "_btn_stop", translate("Click to Stop OpenVPN"))
|
|
|
|
|
function btnStop.write()
|
|
|
|
|
io.popen("/etc/init.d/tgopenvpn stop")
|
|
|
|
|
os.execute("/etc/init.d/tgopenvpn stop")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
btnStart = ctrl:option(Button, "_btn_stop", translate("Click to Start OpenVPN"))
|
|
|
|
|
btnStart = ctrl:option(Button, "_btn_start", translate("Click to Start OpenVPN"))
|
|
|
|
|
function btnStart.write()
|
|
|
|
|
io.popen("/etc/init.d/tgopenvpn start")
|
|
|
|
|
os.execute("/etc/init.d/tgopenvpn start")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Return the configuration page
|
|
|
|
|