1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Licensed to the public under the Apache License 2.0.
4 local fs = require("nixio.fs")
8 -- Widget, Name, Default(s), Description
12 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 },
13 translate("Set output verbosity") },
17 translate("Change process priority") },
21 translate("TCP/UDP port # for both local and remote") },
25 translate("Type of used device") },
28 "10.200.200.3 10.200.200.1",
29 translate("Set tun/tap adapter parameters") },
32 "10.200.200.0 255.255.255.0",
33 translate("Configure server mode") },
36 "192.168.1.1 255.255.255.0 192.168.1.128 192.168.1.254",
37 translate("Configure server bridge") },
41 translate("Do not bind to local address and port") },
45 translate("Helper directive to simplify the expression of --ping and --ping-restart in server mode configurations") },
48 { "udp", "tcp-client", "tcp-server" },
49 translate("Use protocol") },
53 translate("Configure client mode") },
57 translate("Allow client-to-client traffic") },
60 "vpnserver.example.org",
61 translate("Remote host name or ip address") },
64 "/etc/openvpn/secret.key",
65 translate("Enable Static Key encryption mode (non-TLS)") },
69 translate("The key direction for 'tls-auth' and 'secret' options") },
72 "/etc/easy-rsa/keys/some-client.pk12",
73 translate("PKCS#12 file containing keys") },
76 "/etc/easy-rsa/keys/ca.crt",
77 translate("Certificate authority") },
80 "/etc/easy-rsa/keys/dh1024.pem",
81 translate("Diffie Hellman parameters") },
84 "/etc/easy-rsa/keys/some-client.crt",
85 translate("Local certificate") },
88 "/etc/easy-rsa/keys/some-client.key",
89 translate("Local private key") },
93 local m = Map("openvpn")
94 m.redirect = luci.dispatcher.build_url("admin", "services", "openvpn")
95 m.apply_on_parse = true
97 local p = m:section( SimpleSection )
98 p.template = "openvpn/pageswitch"
103 local s = m:section( NamedSection, arg[1], "openvpn" )
105 for _, option in ipairs(basicParams) do
107 option[1], option[2],
113 if option[1] == DummyValue then
115 elseif option[1] == FileUpload then
117 function o.cfgvalue(self, section)
118 local cfg_val = AbstractValue.cfgvalue(self, section)
125 function o.formvalue(self, section)
126 local sel_val = AbstractValue.formvalue(self, section)
127 local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox")
129 if sel_val and sel_val ~= "" then
133 if txt_val and txt_val ~= "" then
138 function o.remove(self, section)
139 local cfg_val = AbstractValue.cfgvalue(self, section)
140 local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox")
142 if cfg_val and fs.access(cfg_val) and txt_val == "" then
145 return AbstractValue.remove(self, section)
147 elseif option[1] == Flag then
150 if option[1] == DynamicList then
151 function o.cfgvalue(...)
152 local val = AbstractValue.cfgvalue(...)
153 return ( val and type(val) ~= "table" ) and { val } or val
157 if type(option[3]) == "table" then
158 if o.optional then o:value("", "-- remove --") end
159 for _, v in ipairs(option[3]) do
163 o.default = tostring(option[3][1])
165 o.default = tostring(option[3])
170 if type(option[i]) == "table" then