2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
17 require("luci.model.uci")
22 -- Widget Name Optn. Default(s)
25 { ListValue, "verb", { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 } },
27 { Value, "port", 1194 },
28 { ListValue, "dev_type", { "tun", "tap" } },
29 { Flag, "tun_ipv6", 0 },
31 { Value, "ifconfig", "10.200.200.3 10.200.200.1" },
32 { Value, "server", "10.200.200.0 255.255.255.0" },
33 { Value, "server_bridge", "192.168.1.1 255.255.255.0 192.168.1.128 192.168.1.254" },
34 { Flag, "nobind", 0 },
36 { Flag, "comp_lzo", 0 },
37 { Value, "keepalive", "10 60" },
39 { ListValue, "proto", { "udp", "tcp" } },
41 { Flag, "client", 0 },
42 { Flag, "client_to_client", 0 },
43 { DynamicList, "remote", "vpnserver.example.org" },
45 { Value, "secret", "/etc/openvpn/secret.key 1" },
46 { Value, "ca", "/etc/easy-rsa/keys/ca.crt" },
47 { Value, "dh", "/etc/easy-rsa/keys/dh1024.pem" },
48 { Value, "cert", "/etc/easy-rsa/keys/some-client.crt" },
49 { Value, "key", "/etc/easy-rsa/keys/some-client.key" },
53 local m = Map("openvpn")
54 local p = m:section( SimpleSection )
56 p.template = "openvpn/pageswitch"
61 local s = m:section( NamedSection, arg[1], "openvpn" )
63 for _, option in ipairs(basicParams) do
64 local o = s:option(option[1], option[2])
67 if option[1] == DummyValue then
70 if option[1] == DynamicList then
72 function o.cfgvalue(...)
73 local val = AbstractValue.cfgvalue(...)
74 return ( val and type(val) ~= "table" ) and { val } or val
78 if type(option[3]) == "table" then
79 if o.optional then o:value("", "-- remove --") end
80 for _, v in ipairs(option[3]) do
84 o.default = tostring(option[3][1])
86 o.default = tostring(option[3])
91 if type(option[i]) == "table" then